summaryrefslogtreecommitdiff
path: root/tests/spirv/discard.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-01 19:26:14 -0700
committerGitHub <noreply@github.com>2024-06-01 19:26:14 -0700
commitc5a453e56985022deb820cbbb2ff5cd6a8347e34 (patch)
tree019c81e8bfcc099f2ff17c1a58f625cf6a527d47 /tests/spirv/discard.slang
parent5799281bda2f9a174b825de4058c5e8c9aa5b27f (diff)
Support different SPIRV versions. (#4254)
Diffstat (limited to 'tests/spirv/discard.slang')
-rw-r--r--tests/spirv/discard.slang22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/spirv/discard.slang b/tests/spirv/discard.slang
new file mode 100644
index 000000000..e0859371e
--- /dev/null
+++ b/tests/spirv/discard.slang
@@ -0,0 +1,22 @@
+//TEST:SIMPLE(filecheck=SPV16): -target spirv -profile spirv_1_6
+//TEST:SIMPLE(filecheck=SPV15): -target spirv -profile spirv_1_5
+//TEST:SIMPLE(filecheck=SPV14): -target spirv -profile spirv_1_4+SPV_EXT_demote_to_helper_invocation
+
+uniform int a;
+
+// Test that we translate `discard` to OpDemoateToHelperInvocation
+// when targeting SPIRV 1.6, and to OpKill when targeting SPIRV 1.5.
+// If the user explicitly specified SPV_EXT_demote_to_helper_invocation
+// in the profile, we will also emit OpDemoteToHelperInvocation.
+
+//SPV16: OpDemoteToHelperInvocation
+//SPV15: OpKill
+//SPV14: OpDemoteToHelperInvocation
+
+[shader("fragment")]
+float4 frag() : SV_Target
+{
+ if (a == 0)
+ discard;
+ return 0;
+} \ No newline at end of file