diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2025-08-13 08:37:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-13 08:37:22 -0700 |
| commit | d7e2bac2df176af4cd3955e6df02e2ddcbc059d8 (patch) | |
| tree | 130f6932650d81f1f0d11bfbb2ca851579cbac30 /tests/wgsl | |
| parent | 047b8af4881e1fc90aa1004d17e32bdffd53bdcf (diff) | |
Remove the semantic decoration from the original entry struct (#8146)
When we legalize the entry point param, there are cases where we need to
reconstruct a struct for the parameter and the original struct wouldn't
be used. But if the user tries to use the origianl struct as a type for
a function parameter, we will end up using both the original struct and
the synthesized struct at the same time.
On Metal and WGSL, it causes an error when an identical semtaic is used
on more than one variable.
This commit removes the semantics from the original struct after cloning
the type.
Fixes https://github.com/shader-slang/slang/issues/8141
Related to https://github.com/shader-slang/slang/issues/7693
---------
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
Diffstat (limited to 'tests/wgsl')
| -rw-r--r-- | tests/wgsl/entry-point-legalization.slang | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/wgsl/entry-point-legalization.slang b/tests/wgsl/entry-point-legalization.slang new file mode 100644 index 000000000..454d3a775 --- /dev/null +++ b/tests/wgsl/entry-point-legalization.slang @@ -0,0 +1,40 @@ +// tests/wgsl/entry-point-legalization.slang +//TEST:SIMPLE(filecheck=CHK):-target wgsl-spirv-asm -stage vertex -entry vertexMain +//TEST:SIMPLE(filecheck=CHK):-target wgsl-spirv-asm -stage vertex -entry vertexMain -DREPRODUCE + +//CHK: %vertexMain = OpFunction + +struct AssembledVertex +{ + float3 position; +}; + +struct VertexStageInput +{ + AssembledVertex assembledVertex : A; +}; + +struct VertexStageOutput +{ + float4 sv_position : SV_Position; +}; + +float3 GetPosition(VertexStageInput i) +{ + return i.assembledVertex.position; +} + +[shader("vertex")] +VertexStageOutput vertexMain(VertexStageInput input) +{ + VertexStageOutput output; + +#if defined(REPRODUCE) + float3 position = GetPosition(input); +#else + float3 position = input.assembledVertex.position; +#endif + + output.sv_position = float4(position, 1.0); + return output; +} |
