From bd971b4a653f2f2681a66e8ce1aa2650da0c8a70 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 6 Dec 2024 13:05:27 -0800 Subject: [PATCH] Add Sampler*Shadow declarations. --- source/slang/hlsl.meta.slang | 14 ++++++++++++++ tests/spirv/sampler-shadow.slang | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/spirv/sampler-shadow.slang diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 412d5b6a0e..31500f028f 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -4052,6 +4052,20 @@ ${{{{ } }}}} +// Declare Sampler*Shadow type aliases. +${{{{ + for (int shape = 0; shape < 4; shape++) + for (int isArray = 0; isArray<=1; isArray++) + { +}}}} +/// Represents a handle to a $(shapeTypeNames[shape]) combined texture-sampler for shadow comparison. +/// @param format The storage format of the texture. +/// @see Please refer to `_Texture` for more information about texture types. +/// @category texture_types +typealias Sampler$(shapeTypeNames[shape])$(arrayPostFix[isArray])Shadow = _Texture; +${{{{ + } +}}}} // Atomic intrinsic insts. diff --git a/tests/spirv/sampler-shadow.slang b/tests/spirv/sampler-shadow.slang new file mode 100644 index 0000000000..89bdbc405a --- /dev/null +++ b/tests/spirv/sampler-shadow.slang @@ -0,0 +1,13 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +// CHECK: OpImageSampleDrefExplicitLod + +Sampler2DShadow ss; + +RWStructuredBuffer output; + +[numthreads(1,1,1)] +void computeMain() +{ + output[0] = ss.SampleCmpLevelZero(float2(0.0), 0.5); +} \ No newline at end of file