yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2020a102e
master
1//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage compute -g2 -emit-spirv-directly 2 3// Test for debug variable handling with generic parameters and structs containing resources 4// This test ensures that structs containing StructuredBuffer fields don't get invalid DebugVar instructions 5 6StructuredBuffer<uint4> gData; 7 8interface IGeometryReader 9{ 10 float4 read(uint attributeIndex); 11} 12 13struct PositionReader : IGeometryReader 14{ 15 float4 read(uint vertexIndex) 16 { 17 return m_geometryBuffer[vertexIndex]; 18 } 19 20 __init(StructuredBuffer<uint4> geometryBuffer) 21 { 22 m_geometryBuffer = geometryBuffer; 23 } 24 25 StructuredBuffer<uint4> m_geometryBuffer; 26} 27 28float4 test<Reader: IGeometryReader>(Reader reader) 29{ 30 float4 pos = reader.read(0); 31 return pos; 32} 33 34RWStructuredBuffer<float4> result; 35 36[numthreads(1,1,1)] 37void main() 38{ 39 let reader = PositionReader(gData); 40 float4 pos = test(reader); 41 42 result[0] = pos; 43} 44 45// Verify that debug info is generated but no invalid DebugVar for struct with StructuredBuffer 46// CHECK: OpExtInst %void {{.*}} DebugExpression 47 48// Ensure we have the expected legitimate debug variables 49// CHECK: pos{{.*}}DebugLocalVariable{{.*}} 50// CHECK: vertexIndex{{.*}}DebugLocalVariable{{.*}} 51 52// After legitimate debug vars, ensure we don't create debug vars for non-debuggable types 53// Specifically check that we don't create debug vars for variables containing StructuredBuffer: 54// - No debug var for 'reader' (PositionReader struct instance) 55// - No debug var for 'm_geometryBuffer' (StructuredBuffer field) 56// The absence of these variables in the output proves the fix is working 57// CHECK-NOT: reader{{.*}}DebugLocalVariable{{.*}} 58// CHECK-NOT: m_geometryBuffer{{.*}}DebugLocalVariable{{.*}} 59// CHECK-NOT: geometryBuffer{{.*}}DebugLocalVariable{{.*}} 60 61// Verify the function ends properly 62// CHECK: OpFunctionEnd