yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeAdd checking for hlsl register semantic. (#7118)0d6312f3b

master
1.9 KiB55 linesraw
1// binding-spv-storage-class.slang
2
3//TEST:SIMPLE(filecheck=GL-SPIRV): -stage anyhit -entry main -target spirv-assembly -emit-spirv-via-glsl
4//TEST:SIMPLE(filecheck=SPIRV): -stage anyhit -entry main -target spirv
5
6// This test checks that the only the resource with Uniform, Storage or UniformConstant storage class can be decorated by binding or descriptor set.
7struct MyStruct
8{
9    float3 org;
10    float3 dir;
11};
12
13// ShaderRecordKHR storage class
14layout(shaderRecordNV) ConstantBuffer<MyStruct> myStruct : register(b0, space1);
15
16// Uniform buffer
17ConstantBuffer<MyStruct> myStruct1 : register(b1, space1);
18
19// Storage buffer
20RWStructuredBuffer<MyStruct> myStruct2 : register(u2, space1);
21
22// UniformConstant
23Texture2D<float>    texture: register(t3, space1);
24SamplerState        sampler: register(s4, space1);
25
26[shader("anyhit")]
27void main(out float3 pos)
28{
29    pos = myStruct.org + myStruct.dir +
30          myStruct1.org + myStruct1.dir +
31          myStruct2[0].org + myStruct2[0].dir;
32
33    pos.x = texture.SampleLevel(
34            sampler,
35            pos.xy, 0);
36}
37
38// SPIRV-DAG: OpDecorate %myStruct1{{.*}} Binding 1
39// SPIRV-DAG: OpDecorate %myStruct1{{.*}} DescriptorSet 1
40// SPIRV-DAG: OpDecorate %myStruct2{{.*}} Binding 2
41// SPIRV-DAG: OpDecorate %myStruct2{{.*}} DescriptorSet 1
42// SPIRV-DAG: OpDecorate %texture{{.*}} Binding 3
43// SPIRV-DAG: OpDecorate %texture{{.*}} DescriptorSet 1
44// SPIRV-DAG: OpDecorate %sampler{{.*}} Binding 4
45// SPIRV-DAG: OpDecorate %sampler{{.*}} DescriptorSet 1
46//
47//
48// GL-SPIRV-DAG: OpDecorate %myStruct1{{.*}} DescriptorSet 1
49// GL-SPIRV-DAG: OpDecorate %myStruct1{{.*}} Binding 1
50// GL-SPIRV-DAG: OpDecorate %myStruct2{{.*}} DescriptorSet 1
51// GL-SPIRV-DAG: OpDecorate %myStruct2{{.*}} Binding 2
52// GL-SPIRV-DAG: OpDecorate %texture{{.*}} DescriptorSet 1
53// GL-SPIRV-DAG: OpDecorate %texture{{.*}} Binding 3
54// GL-SPIRV-DAG: OpDecorate %sampler{{.*}} DescriptorSet 1
55// GL-SPIRV-DAG: OpDecorate %sampler{{.*}} Binding 4