From fdc17a974970559d8ff76d52c3ce40aaa056d441 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 19 Jan 2024 18:02:40 -0800 Subject: Add `-fspv-reflect` support. (#3464) * Add `-fspv-reflect` support. Closes #3462. * Fix. * Fix. * Remove use of `SPV_GOOGLE_hlsl_functionality1`. * Fix spirv validation error. * Fix test. * Update typename hints. * Update commandline options doc. * Remove superfluous empty lines. --------- Co-authored-by: Yong He --- tests/spirv/spirv-reflection.slang | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/spirv/spirv-reflection.slang (limited to 'tests/spirv') diff --git a/tests/spirv/spirv-reflection.slang b/tests/spirv/spirv-reflection.slang new file mode 100644 index 000000000..90414eb59 --- /dev/null +++ b/tests/spirv/spirv-reflection.slang @@ -0,0 +1,33 @@ +//TEST:SIMPLE(filecheck=SPIRV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -fspv-reflect + +// Test ability to directly output SPIR-V reflection info on parameters. + +Texture2D mTexture : MY_HLSL_SEMANTIC; +struct MyElement +{ + float x; +} +StructuredBuffer myBuffer : MY_HLSL_SEMANTIC1; +AppendStructuredBuffer myAppendBuffer : MY_HLSL_SEMANTIC2; + +[numthreads(8, 8, 1)] +void computeMain() +{ + float4 color = mTexture.Load(int3(0, 0, 0)); + myAppendBuffer.Append(color.x + myBuffer[0].x); +} + +// SPIRV-DAG: OpExtension "SPV_GOOGLE_user_type" + +// SPIRV-DAG: OpDecorate %mTexture UserTypeGOOGLE "Texture2D" +// SPIRV-DAG: OpDecorate %mTexture UserSemantic "MY_HLSL_SEMANTIC" + +// SPIRV-DAG: OpDecorate %myBuffer UserTypeGOOGLE "StructuredBuffer" +// SPIRV-DAG: OpDecorate %myBuffer UserSemantic "MY_HLSL_SEMANTIC1" + +// SPIRV-DAG: OpDecorate %myAppendBuffer_counter UserTypeGOOGLE "RWStructuredBuffer" +// SPIRV-DAG: OpDecorate %myAppendBuffer_counter UserSemantic "MY_HLSL_SEMANTIC2" + +// SPIRV-DAG: OpDecorate %myAppendBuffer_elements UserTypeGOOGLE "RWStructuredBuffer" +// SPIRV-DAG: OpDecorate %myAppendBuffer_elements UserSemantic "MY_HLSL_SEMANTIC2" +// SPIRV-DAG: OpDecorateId %myAppendBuffer_elements CounterBuffer %myAppendBuffer_counter -- cgit v1.2.3