From aa3cc1e79315592e9b22fccd77fc27fef0c09762 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Jul 2025 11:02:58 -0700 Subject: Fix SV_VertexID and SV_InstanceID crash with -preserve-params in SPIR-V emitter (#7691) * Initial plan * Fix SV_VertexID and SV_InstanceID crash with -preserve-params in SPIR-V emitter Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix transformation layer to handle unused builtin params properly This ensures that builtin decorations are correctly transformed for unused parameters with -preserve-params, preventing the SPIR-V emitter from seeing un-translated builtins like sv_vertexid. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Format code according to project style Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --- tests/spirv/sv-vertex-id-preserve-params.slang | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/spirv/sv-vertex-id-preserve-params.slang (limited to 'tests') diff --git a/tests/spirv/sv-vertex-id-preserve-params.slang b/tests/spirv/sv-vertex-id-preserve-params.slang new file mode 100644 index 000000000..6bf4bfb89 --- /dev/null +++ b/tests/spirv/sv-vertex-id-preserve-params.slang @@ -0,0 +1,13 @@ +//TEST:SIMPLE(filecheck=SPIRV): -entry VertexMain -stage vertex -target spirv -preserve-params +//TEST:SIMPLE(filecheck=SPIRV): -entry VertexMain -stage vertex -target spirv -emit-spirv-directly -preserve-params + +// Test for https://github.com/shader-slang/slang/issues/7689 +// SV_VertexID combined with -preserve-params should not crash + +// SPIRV: OpEntryPoint + +[shader("vertex")] +float4 VertexMain(uint vertexId: SV_VertexID, uint instanceId: SV_InstanceID) : SV_Position +{ + return float4(0.0); +} \ No newline at end of file -- cgit v1.2.3