summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/types/conditional-varying.slang23
-rw-r--r--tests/spirv/spec-constant-generic.slang10
2 files changed, 26 insertions, 7 deletions
diff --git a/tests/language-feature/types/conditional-varying.slang b/tests/language-feature/types/conditional-varying.slang
new file mode 100644
index 000000000..674ae96e7
--- /dev/null
+++ b/tests/language-feature/types/conditional-varying.slang
@@ -0,0 +1,23 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+//TEST:SIMPLE(filecheck=HLSL): -target hlsl -entry fragMain -profile ps_6_0
+
+// CHECK: OpEntryPoint
+// HLSL: float4 fragMain() : SV_TARGET
+
+extern static const bool enableConditional = false;
+
+struct Vertex
+{
+ Conditional<float3, enableConditional> color : COLOR;
+}
+
+[shader("fragment")]
+float4 fragMain(Vertex v) : SV_Target
+{
+ if (let c = v.color.get())
+ {
+ // This block should not be executed.
+ return float4(c, 1.0f);
+ }
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+} \ No newline at end of file
diff --git a/tests/spirv/spec-constant-generic.slang b/tests/spirv/spec-constant-generic.slang
index 9a9f7006f..1d7e3c1fe 100644
--- a/tests/spirv/spec-constant-generic.slang
+++ b/tests/spirv/spec-constant-generic.slang
@@ -1,14 +1,13 @@
//TEST:SIMPLE(filecheck=CHECK): -target spirv
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -output-using-type -emit-spirv-directly
-// CHECK: %[[C0:[0-9A-Za-z_]+]] = OpSpecConstant %int 32
+// CHECK: %[[C0:[0-9A-Za-z_]+]] = OpConstant %int 32
// CHECK: %[[C1:[0-9A-Za-z_]+]] = OpSpecConstant %int 2
// CHECK: %[[COP0:[0-9A-Za-z_]+]] = OpSpecConstantOp %int SDiv %[[C0]] %[[C1]]
// CHECK: %[[ARR_TYPE:[0-9A-Za-z_]+]] = OpTypeArray %float %[[COP0]]
// CHECK: %[[PT_TYPE:[0-9A-Za-z_]+]] = OpTypePointer Function %[[ARR_TYPE]]
-[SpecializationConstant]
-const int constValue0 = 32;
+static const int constValue0 = 32;
[SpecializationConstant]
const int constValue1 = 2;
@@ -33,11 +32,8 @@ struct MyStruct<let N: int>
[numthreads(1, 1, 1)]
void computeMain()
{
- // This test checks we can use spec constants for generic arguments, and also
- // we can show that the array size is computed correctly.
- // The function call shows that the two arrays are the same type.
+ // This test checks we can use spec constants for array sizes.
MyStruct<constValue0> s;
- // CHECK: OpVariable %[[PT_TYPE]] Function
func(s.buffer);