From 044b52c3195edf3282a0b530a21ad54b87135cd9 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Mon, 25 Nov 2024 15:40:47 +0200 Subject: Fix issue where inter-stage parameters without semantics don't get location attributes (#5670) * wgsl: Make sure each shader input field has a semantic This closes #5633. * Add test for inter-stage variables without semantics This verifies the fix of the second issue identified in https://github.com/shader-slang/slang/issues/5633 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- ...stage-io-locations-without-user-semantics.slang | 77 +++++++++++++++++++++ ...locations-without-user-semantics.slang.expected | 5 ++ ...tions-without-user-semantics.slang.expected.png | Bin 0 -> 36676 bytes 3 files changed, 82 insertions(+) create mode 100644 tests/render/multiple-stage-io-locations-without-user-semantics.slang create mode 100644 tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected create mode 100644 tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png (limited to 'tests/render') diff --git a/tests/render/multiple-stage-io-locations-without-user-semantics.slang b/tests/render/multiple-stage-io-locations-without-user-semantics.slang new file mode 100644 index 000000000..af0e3e39f --- /dev/null +++ b/tests/render/multiple-stage-io-locations-without-user-semantics.slang @@ -0,0 +1,77 @@ +// TODO: Investigate failures on non-WebGPU backends +//TEST(smoke,render):COMPARE_HLSL_RENDER: -wgpu + +cbuffer Uniforms +{ + float4x4 modelViewProjection; +} + +struct AssembledVertex +{ + float3 position; + float3 color; +}; + +struct Fragment +{ + float4 color; +}; + +// Vertex Shader + +struct VertexStageInput +{ + AssembledVertex assembledVertex : A; +}; + +struct VertexStageOutput +{ + float3 color; + float3 localPosition; + float4 sv_position : SV_Position; +}; + +VertexStageOutput vertexMain(VertexStageInput input) +{ + VertexStageOutput output; + + float3 position = input.assembledVertex.position; + float3 color = input.assembledVertex.color; + + output.color = color; + output.sv_position = mul(modelViewProjection, float4(position, 1.0)); + output.localPosition = position; + + return output; +} + +// Fragment Shader + +struct FragmentStageInput +{ + float3 color; + float3 localPosition; +}; + +struct FragmentStageOutput +{ + Fragment fragment : SV_Target; +}; + +FragmentStageOutput fragmentMain(FragmentStageInput input) +{ + FragmentStageOutput output; + + float3 color = input.color; + + if (input.color.y < input.color.z) + { + output.fragment.color = float4(input.localPosition, 1.0); + } + else + { + output.fragment.color = float4(input.color, 1.0); + } + + return output; +} diff --git a/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected new file mode 100644 index 000000000..4c32e2510 --- /dev/null +++ b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected @@ -0,0 +1,5 @@ +result code = 0 +standard error = { +} +standard output = { +} diff --git a/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png new file mode 100644 index 000000000..3333a12d7 Binary files /dev/null and b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png differ -- cgit v1.2.3