From 2302b5fac6b0409ab8902091dac78a5ae42c0ca1 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 22 Oct 2024 09:29:00 -0400 Subject: [PATCH] test: add regr. cvg. for conflicting idents. in shader I/O and locals --- naga/tests/in/6438-conflicting-idents.wgsl | 16 +++++ .../6438-conflicting-idents.fs.Fragment.glsl | 16 +++++ .../6438-conflicting-idents.vs.Vertex.glsl | 23 +++++++ .../out/hlsl/6438-conflicting-idents.hlsl | 25 ++++++++ .../out/hlsl/6438-conflicting-idents.ron | 16 +++++ .../tests/out/msl/6438-conflicting-idents.msl | 37 ++++++++++++ .../out/spv/6438-conflicting-idents.spvasm | 60 +++++++++++++++++++ .../out/wgsl/6438-conflicting-idents.wgsl | 18 ++++++ naga/tests/snapshots.rs | 4 ++ 9 files changed, 215 insertions(+) create mode 100644 naga/tests/in/6438-conflicting-idents.wgsl create mode 100644 naga/tests/out/glsl/6438-conflicting-idents.fs.Fragment.glsl create mode 100644 naga/tests/out/glsl/6438-conflicting-idents.vs.Vertex.glsl create mode 100644 naga/tests/out/hlsl/6438-conflicting-idents.hlsl create mode 100644 naga/tests/out/hlsl/6438-conflicting-idents.ron create mode 100644 naga/tests/out/msl/6438-conflicting-idents.msl create mode 100644 naga/tests/out/spv/6438-conflicting-idents.spvasm create mode 100644 naga/tests/out/wgsl/6438-conflicting-idents.wgsl diff --git a/naga/tests/in/6438-conflicting-idents.wgsl b/naga/tests/in/6438-conflicting-idents.wgsl new file mode 100644 index 000000000..2e4598be2 --- /dev/null +++ b/naga/tests/in/6438-conflicting-idents.wgsl @@ -0,0 +1,16 @@ +struct OurVertexShaderOutput { + @builtin(position) position: vec4f, + @location(0) texcoord: vec2f, +}; + +@vertex fn vs( + @location(0) xy: vec2f +) -> OurVertexShaderOutput { + var vsOutput: OurVertexShaderOutput; + vsOutput.position = vec4f(xy, 0.0, 1.0); + return vsOutput; +} + +@fragment fn fs() -> @location(0) vec4f { + return vec4f(1.0, 0.0, 0.0, 1.0); +} diff --git a/naga/tests/out/glsl/6438-conflicting-idents.fs.Fragment.glsl b/naga/tests/out/glsl/6438-conflicting-idents.fs.Fragment.glsl new file mode 100644 index 000000000..d5d8fc7b5 --- /dev/null +++ b/naga/tests/out/glsl/6438-conflicting-idents.fs.Fragment.glsl @@ -0,0 +1,16 @@ +#version 310 es + +precision highp float; +precision highp int; + +struct OurVertexShaderOutput { + vec4 position; + vec2 texcoord; +}; +layout(location = 0) out vec4 _fs2p_location0; + +void main() { + _fs2p_location0 = vec4(1.0, 0.0, 0.0, 1.0); + return; +} + diff --git a/naga/tests/out/glsl/6438-conflicting-idents.vs.Vertex.glsl b/naga/tests/out/glsl/6438-conflicting-idents.vs.Vertex.glsl new file mode 100644 index 000000000..7937cba42 --- /dev/null +++ b/naga/tests/out/glsl/6438-conflicting-idents.vs.Vertex.glsl @@ -0,0 +1,23 @@ +#version 310 es + +precision highp float; +precision highp int; + +struct OurVertexShaderOutput { + vec4 position; + vec2 texcoord; +}; +layout(location = 0) in vec2 _p2vs_location0; +layout(location = 0) smooth out vec2 _vs2fs_location0; + +void main() { + vec2 xy = _p2vs_location0; + OurVertexShaderOutput vsOutput = OurVertexShaderOutput(vec4(0.0), vec2(0.0)); + vsOutput.position = vec4(xy, 0.0, 1.0); + OurVertexShaderOutput _e6 = vsOutput; + gl_Position = _e6.position; + _vs2fs_location0 = _e6.texcoord; + gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w); + return; +} + diff --git a/naga/tests/out/hlsl/6438-conflicting-idents.hlsl b/naga/tests/out/hlsl/6438-conflicting-idents.hlsl new file mode 100644 index 000000000..179ac8ec8 --- /dev/null +++ b/naga/tests/out/hlsl/6438-conflicting-idents.hlsl @@ -0,0 +1,25 @@ +struct OurVertexShaderOutput { + float4 position : SV_Position; + float2 texcoord : LOC0; +}; + +struct VertexOutput_vs { + float2 texcoord : LOC0; + float4 position : SV_Position; +}; + +VertexOutput_vs vs(float2 xy : LOC0) +{ + OurVertexShaderOutput vsOutput = (OurVertexShaderOutput)0; + + vsOutput.position = float4(xy, 0.0, 1.0); + OurVertexShaderOutput _e6 = vsOutput; + const OurVertexShaderOutput ourvertexshaderoutput = _e6; + const VertexOutput_vs ourvertexshaderoutput_1 = { ourvertexshaderoutput.texcoord, ourvertexshaderoutput.position }; + return ourvertexshaderoutput_1; +} + +float4 fs() : SV_Target0 +{ + return float4(1.0, 0.0, 0.0, 1.0); +} diff --git a/naga/tests/out/hlsl/6438-conflicting-idents.ron b/naga/tests/out/hlsl/6438-conflicting-idents.ron new file mode 100644 index 000000000..393d3d674 --- /dev/null +++ b/naga/tests/out/hlsl/6438-conflicting-idents.ron @@ -0,0 +1,16 @@ +( + vertex:[ + ( + entry_point:"vs", + target_profile:"vs_5_1", + ), + ], + fragment:[ + ( + entry_point:"fs", + target_profile:"ps_5_1", + ), + ], + compute:[ + ], +) diff --git a/naga/tests/out/msl/6438-conflicting-idents.msl b/naga/tests/out/msl/6438-conflicting-idents.msl new file mode 100644 index 000000000..fd5bd8b88 --- /dev/null +++ b/naga/tests/out/msl/6438-conflicting-idents.msl @@ -0,0 +1,37 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct OurVertexShaderOutput { + metal::float4 position; + metal::float2 texcoord; +}; + +struct vsInput { + metal::float2 xy [[attribute(0)]]; +}; +struct vsOutput { + metal::float4 position [[position]]; + metal::float2 texcoord [[user(loc0), center_perspective]]; +}; +vertex vsOutput vs( + vsInput varyings [[stage_in]] +) { + const auto xy = varyings.xy; + OurVertexShaderOutput vsOutput = {}; + vsOutput.position = metal::float4(xy, 0.0, 1.0); + OurVertexShaderOutput _e6 = vsOutput; + const auto _tmp = _e6; + return vsOutput { _tmp.position, _tmp.texcoord }; +} + + +struct fsOutput { + metal::float4 member_1 [[color(0)]]; +}; +fragment fsOutput fs( +) { + return fsOutput { metal::float4(1.0, 0.0, 0.0, 1.0) }; +} diff --git a/naga/tests/out/spv/6438-conflicting-idents.spvasm b/naga/tests/out/spv/6438-conflicting-idents.spvasm new file mode 100644 index 000000000..589eeb346 --- /dev/null +++ b/naga/tests/out/spv/6438-conflicting-idents.spvasm @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 36 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %15 "vs" %8 %11 %13 +OpEntryPoint Fragment %33 "fs" %32 +OpExecutionMode %33 OriginUpperLeft +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 16 +OpDecorate %8 Location 0 +OpDecorate %11 BuiltIn Position +OpDecorate %13 Location 0 +OpDecorate %32 Location 0 +%2 = OpTypeVoid +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%5 = OpTypeVector %4 2 +%6 = OpTypeStruct %3 %5 +%9 = OpTypePointer Input %5 +%8 = OpVariable %9 Input +%12 = OpTypePointer Output %3 +%11 = OpVariable %12 Output +%14 = OpTypePointer Output %5 +%13 = OpVariable %14 Output +%16 = OpTypeFunction %2 +%17 = OpConstant %4 0.0 +%18 = OpConstant %4 1.0 +%20 = OpTypePointer Function %6 +%21 = OpConstantNull %6 +%23 = OpTypePointer Function %3 +%26 = OpTypeInt 32 0 +%25 = OpConstant %26 0 +%32 = OpVariable %12 Output +%34 = OpConstantComposite %3 %18 %17 %17 %18 +%15 = OpFunction %2 None %16 +%7 = OpLabel +%19 = OpVariable %20 Function %21 +%10 = OpLoad %5 %8 +OpBranch %22 +%22 = OpLabel +%24 = OpCompositeConstruct %3 %10 %17 %18 +%27 = OpAccessChain %23 %19 %25 +OpStore %27 %24 +%28 = OpLoad %6 %19 +%29 = OpCompositeExtract %3 %28 0 +OpStore %11 %29 +%30 = OpCompositeExtract %5 %28 1 +OpStore %13 %30 +OpReturn +OpFunctionEnd +%33 = OpFunction %2 None %16 +%31 = OpLabel +OpBranch %35 +%35 = OpLabel +OpStore %32 %34 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/6438-conflicting-idents.wgsl b/naga/tests/out/wgsl/6438-conflicting-idents.wgsl new file mode 100644 index 000000000..d13216bf9 --- /dev/null +++ b/naga/tests/out/wgsl/6438-conflicting-idents.wgsl @@ -0,0 +1,18 @@ +struct OurVertexShaderOutput { + @builtin(position) position: vec4, + @location(0) texcoord: vec2, +} + +@vertex +fn vs(@location(0) xy: vec2) -> OurVertexShaderOutput { + var vsOutput: OurVertexShaderOutput; + + vsOutput.position = vec4(xy, 0f, 1f); + let _e6 = vsOutput; + return _e6; +} + +@fragment +fn fs() -> @location(0) vec4 { + return vec4(1f, 0f, 0f, 1f); +} diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index 244c9f506..e132bc3d4 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -937,6 +937,10 @@ fn convert_wgsl() { ), ("6220-break-from-loop", Targets::SPIRV), ("index-by-value", Targets::SPIRV | Targets::IR), + ( + "6438-conflicting-idents", + Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, + ), ]; for &(name, targets) in inputs.iter() {