From 9d47a352960efd71494c7dfa0918debd5b405077 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 21 Jul 2025 21:35:44 -0700 Subject: Fix Conditioanl fields with a semantic. (#7855) * Fix Conditioanl fields with a semantic. * Add unit test. * Fix test. --- .../types/conditional-varying.slang | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/language-feature/types/conditional-varying.slang (limited to 'tests/language-feature') 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 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 -- cgit v1.2.3