summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorNils Hasenbanck <hasenbanck@users.noreply.github.com>2025-10-04 14:50:56 +0200
committerGitHub <noreply@github.com>2025-10-04 12:50:56 +0000
commit3375cde1add65894b8f2e2780cc91ab4ccf6d8fb (patch)
tree0b7bb910f096c7ec5b83b08b6b656729cadc754e /tests/spirv
parent2491ac5f42d78d082d4afa6416906fad9b32ea80 (diff)
Respect isShadow() flag when setting depth type in SPIR-V backend (#8604)
This is important for SPIR-V targets that need to know if a texture is designated as a depth texture or not (for example WebGPU). I didn't change the default behavior for when isShadow() is not set, since I didn't want to make the change too invasive.
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/depth-texture.slang38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/spirv/depth-texture.slang b/tests/spirv/depth-texture.slang
new file mode 100644
index 000000000..17204249e
--- /dev/null
+++ b/tests/spirv/depth-texture.slang
@@ -0,0 +1,38 @@
+//TEST:SIMPLE(filecheck=SPIRV): -target spirv
+//TEST:SIMPLE(filecheck=SPIRV): -target spirv -entry psMain -stage pixel
+
+// SPIRV: OpTypeImage %{{.*}} 2D 1 0 0 1 Unknown
+
+__generic<let sampleCount : int = 0, let format : int = 0>
+typealias DepthTexture2D = _Texture<
+ float,
+ __Shape2D,
+ 0, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 0, // isCombined
+ format
+>;
+
+[[vk::binding(0, 0)]] DepthTexture2D depthTexture : register(t0);
+[[vk::binding(1, 0)]] SamplerComparisonState comparisonSampler : register(s0);
+
+[[shader("pixel")]]
+float4 psMain(
+ float4 position : SV_POSITION,
+ float2 texCoord : TEXCOORD0
+) : SV_TARGET {
+ float comparison = depthTexture.SampleCmp(
+ comparisonSampler,
+ texCoord,
+ 0.5
+ );
+
+ if (comparison != 0.0) {
+ return float4(1.0, 1.0, 1.0, 1.0);
+ } else {
+ return float4(0.0, 0.0, 0.0, 1.0);
+ }
+}