From f76af4e53aaf354bfcf7d1b63b3416b9980a2534 Mon Sep 17 00:00:00 2001 From: Igor Shaposhnik Date: Fri, 29 Apr 2022 20:48:27 +0300 Subject: [PATCH] [wgsl] Remove buffer, texture, in, out, input, output from reserved keywords --- src/keywords/wgsl.rs | 6 ----- tests/in/extra.wgsl | 8 +++--- tests/in/interface.wgsl | 8 +++--- tests/in/interpolate.wgsl | 20 +++++++------- tests/in/push-constants.wgsl | 4 +-- tests/in/shadow.wgsl | 26 +++++++++---------- tests/in/skybox.wgsl | 4 +-- .../glsl/interpolate.vert_main.Vertex.glsl | 20 +++++++------- .../glsl/push-constants.main.Fragment.glsl | 4 +-- tests/out/glsl/shadow.fs_main.Fragment.glsl | 8 +++--- ...adow.fs_main_without_storage.Fragment.glsl | 8 +++--- tests/out/glsl/shadow.vs_main.Vertex.glsl | 10 +++---- tests/out/glsl/skybox.fs_main.Fragment.glsl | 4 +-- tests/out/hlsl/interface.hlsl | 8 +++--- tests/out/hlsl/interpolate.hlsl | 20 +++++++------- tests/out/hlsl/shadow.hlsl | 26 +++++++++---------- tests/out/hlsl/skybox.hlsl | 4 +-- tests/out/msl/extra.msl | 8 +++--- tests/out/msl/interface.msl | 8 +++--- tests/out/msl/interpolate.msl | 20 +++++++------- tests/out/msl/shadow.msl | 26 +++++++++---------- tests/out/msl/skybox.msl | 4 +-- tests/out/spv/interpolate.spvasm | 2 +- tests/out/spv/shadow.spvasm | 2 +- tests/out/wgsl/extra.wgsl | 8 +++--- tests/out/wgsl/interface.wgsl | 8 +++--- tests/out/wgsl/interpolate.wgsl | 20 +++++++------- tests/out/wgsl/shadow.wgsl | 26 +++++++++---------- tests/out/wgsl/skybox.wgsl | 4 +-- 29 files changed, 159 insertions(+), 165 deletions(-) diff --git a/src/keywords/wgsl.rs b/src/keywords/wgsl.rs index 36a8a55a1..0f6336255 100644 --- a/src/keywords/wgsl.rs +++ b/src/keywords/wgsl.rs @@ -134,7 +134,6 @@ pub const RESERVED: &[&str] = &[ "await", "become", "bf16", - "buffer", "cast", "catch", "cbuffer", @@ -217,10 +216,8 @@ pub const RESERVED: &[&str] = &[ "impl", "implements", "import", - "in", "inline", "inout", - "input", "instanceof", "interface", "invariant", @@ -276,8 +273,6 @@ pub const RESERVED: &[&str] = &[ "nullptr", "of", "operator", - "out", - "output", "package", "packoffset", "partition", @@ -348,7 +343,6 @@ pub const RESERVED: &[&str] = &[ "technique10", "technique11", "template", - "texture", "texture1D", "texture1DArray", "texture2D", diff --git a/tests/in/extra.wgsl b/tests/in/extra.wgsl index 5ce69c14f..ef68f4aa8 100644 --- a/tests/in/extra.wgsl +++ b/tests/in/extra.wgsl @@ -10,10 +10,10 @@ struct FragmentIn { } @fragment -fn main(_in: FragmentIn) -> @location(0) vec4 { - if _in.primitive_index == pc.index { - return _in.color; +fn main(in: FragmentIn) -> @location(0) vec4 { + if in.primitive_index == pc.index { + return in.color; } else { - return vec4(vec3(1.0) - _in.color.rgb, _in.color.a); + return vec4(vec3(1.0) - in.color.rgb, in.color.a); } } diff --git a/tests/in/interface.wgsl b/tests/in/interface.wgsl index e4316a244..0f64f9564 100644 --- a/tests/in/interface.wgsl +++ b/tests/in/interface.wgsl @@ -23,17 +23,17 @@ struct FragmentOutput { @fragment fn fragment( - _in: VertexOutput, + in: VertexOutput, @builtin(front_facing) front_facing: bool, @builtin(sample_index) sample_index: u32, @builtin(sample_mask) sample_mask: u32, ) -> FragmentOutput { let mask = sample_mask & (1u << sample_index); let color = select(0.0, 1.0, front_facing); - return FragmentOutput(_in._varying, mask, color); + return FragmentOutput(in._varying, mask, color); } -var _output: array; +var output: array; @compute @workgroup_size(1) fn compute( @@ -43,7 +43,7 @@ fn compute( @builtin(workgroup_id) wg_id: vec3, @builtin(num_workgroups) num_wgs: vec3, ) { - _output[0] = global_id.x + local_id.x + local_index + wg_id.x + num_wgs.x; + output[0] = global_id.x + local_id.x + local_index + wg_id.x + num_wgs.x; } struct Input1 { diff --git a/tests/in/interpolate.wgsl b/tests/in/interpolate.wgsl index 6b8837903..2f6967b3e 100644 --- a/tests/in/interpolate.wgsl +++ b/tests/in/interpolate.wgsl @@ -13,18 +13,18 @@ struct FragmentInput { @vertex fn vert_main() -> FragmentInput { - var _out: FragmentInput; + var out: FragmentInput; - _out.position = vec4(2.0, 4.0, 5.0, 6.0); - _out._flat = 8u; - _out._linear = 27.0; - _out.linear_centroid = vec2(64.0, 125.0); - _out.linear_sample = vec3(216.0, 343.0, 512.0); - _out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); - _out.perspective_centroid = 2197.0; - _out.perspective_sample = 2744.0; + out.position = vec4(2.0, 4.0, 5.0, 6.0); + out._flat = 8u; + out._linear = 27.0; + out.linear_centroid = vec2(64.0, 125.0); + out.linear_sample = vec3(216.0, 343.0, 512.0); + out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); + out.perspective_centroid = 2197.0; + out.perspective_sample = 2744.0; - return _out; + return out; } @fragment diff --git a/tests/in/push-constants.wgsl b/tests/in/push-constants.wgsl index 44152e561..cc8c4ab02 100644 --- a/tests/in/push-constants.wgsl +++ b/tests/in/push-constants.wgsl @@ -8,6 +8,6 @@ struct FragmentIn { } @fragment -fn main(_in: FragmentIn) -> @location(0) vec4 { - return _in.color * pc.multiplier; +fn main(in: FragmentIn) -> @location(0) vec4 { + return in.color * pc.multiplier; } diff --git a/tests/in/shadow.wgsl b/tests/in/shadow.wgsl index 61c63d0dc..575018863 100644 --- a/tests/in/shadow.wgsl +++ b/tests/in/shadow.wgsl @@ -36,11 +36,11 @@ fn vs_main( ) -> VertexOutput { let w = u_entity.world; let world_pos = u_entity.world * vec4(position); - var _out: VertexOutput; - _out.world_normal = mat3x3(w.x.xyz, w.y.xyz, w.z.xyz) * vec3(normal.xyz); - _out.world_position = world_pos; - _out.proj_position = u_globals.view_proj * world_pos; - return _out; + var out: VertexOutput; + out.world_normal = mat3x3(w.x.xyz, w.y.xyz, w.z.xyz) * vec3(normal.xyz); + out.world_position = world_pos; + out.proj_position = u_globals.view_proj * world_pos; + return out; } // fragment shader @@ -81,16 +81,16 @@ let c_ambient: vec3 = vec3(0.05, 0.05, 0.05); let c_max_lights: u32 = 10u; @fragment -fn fs_main(_in: VertexOutput) -> @location(0) vec4 { - let normal = normalize(_in.world_normal); +fn fs_main(in: VertexOutput) -> @location(0) vec4 { + let normal = normalize(in.world_normal); // accumulate color var color: vec3 = c_ambient; for(var i = 0u; i < min(u_globals.num_lights.x, c_max_lights); i++) { let light = s_lights[i]; // project into the light space - let shadow = fetch_shadow(i, light.proj * _in.world_position); + let shadow = fetch_shadow(i, light.proj * in.world_position); // compute Lambertian diffuse term - let light_dir = normalize(light.pos.xyz - _in.world_position.xyz); + let light_dir = normalize(light.pos.xyz - in.world_position.xyz); let diffuse = max(0.0, dot(normal, light_dir)); // add light contribution color += shadow * diffuse * light.color.xyz; @@ -101,15 +101,15 @@ fn fs_main(_in: VertexOutput) -> @location(0) vec4 { // The fragment entrypoint used when storage buffers are not available for the lights @fragment -fn fs_main_without_storage(_in: VertexOutput) -> @location(0) vec4 { - let normal = normalize(_in.world_normal); +fn fs_main_without_storage(in: VertexOutput) -> @location(0) vec4 { + let normal = normalize(in.world_normal); var color: vec3 = c_ambient; for(var i = 0u; i < min(u_globals.num_lights.x, c_max_lights); i++) { // This line is the only difference from the entrypoint above. It uses the lights // uniform instead of the lights storage buffer let light = u_lights[i]; - let shadow = fetch_shadow(i, light.proj * _in.world_position); - let light_dir = normalize(light.pos.xyz - _in.world_position.xyz); + let shadow = fetch_shadow(i, light.proj * in.world_position); + let light_dir = normalize(light.pos.xyz - in.world_position.xyz); let diffuse = max(0.0, dot(normal, light_dir)); color += shadow * diffuse * light.color.xyz; } diff --git a/tests/in/skybox.wgsl b/tests/in/skybox.wgsl index 5d36951c6..f4cc37a44 100644 --- a/tests/in/skybox.wgsl +++ b/tests/in/skybox.wgsl @@ -33,6 +33,6 @@ var r_texture: texture_cube; var r_sampler: sampler; @fragment -fn fs_main(_in: VertexOutput) -> @location(0) vec4 { - return textureSample(r_texture, r_sampler, _in.uv); +fn fs_main(in: VertexOutput) -> @location(0) vec4 { + return textureSample(r_texture, r_sampler, in.uv); } diff --git a/tests/out/glsl/interpolate.vert_main.Vertex.glsl b/tests/out/glsl/interpolate.vert_main.Vertex.glsl index 5155e7852..f423a3dc1 100644 --- a/tests/out/glsl/interpolate.vert_main.Vertex.glsl +++ b/tests/out/glsl/interpolate.vert_main.Vertex.glsl @@ -18,16 +18,16 @@ smooth centroid out float _vs2fs_location5; smooth sample out float _vs2fs_location6; void main() { - FragmentInput _out = FragmentInput(vec4(0.0), 0u, 0.0, vec2(0.0), vec3(0.0), vec4(0.0), 0.0, 0.0); - _out.position = vec4(2.0, 4.0, 5.0, 6.0); - _out._flat = 8u; - _out._linear = 27.0; - _out.linear_centroid = vec2(64.0, 125.0); - _out.linear_sample = vec3(216.0, 343.0, 512.0); - _out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); - _out.perspective_centroid = 2197.0; - _out.perspective_sample = 2744.0; - FragmentInput _e30 = _out; + FragmentInput out_ = FragmentInput(vec4(0.0), 0u, 0.0, vec2(0.0), vec3(0.0), vec4(0.0), 0.0, 0.0); + out_.position = vec4(2.0, 4.0, 5.0, 6.0); + out_._flat = 8u; + out_._linear = 27.0; + out_.linear_centroid = vec2(64.0, 125.0); + out_.linear_sample = vec3(216.0, 343.0, 512.0); + out_.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); + out_.perspective_centroid = 2197.0; + out_.perspective_sample = 2744.0; + FragmentInput _e30 = out_; gl_Position = _e30.position; _vs2fs_location0 = _e30._flat; _vs2fs_location1 = _e30._linear; diff --git a/tests/out/glsl/push-constants.main.Fragment.glsl b/tests/out/glsl/push-constants.main.Fragment.glsl index d092ee05f..fa1be9f61 100644 --- a/tests/out/glsl/push-constants.main.Fragment.glsl +++ b/tests/out/glsl/push-constants.main.Fragment.glsl @@ -15,9 +15,9 @@ layout(location = 0) smooth in vec4 _vs2fs_location0; layout(location = 0) out vec4 _fs2p_location0; void main() { - FragmentIn _in = FragmentIn(_vs2fs_location0); + FragmentIn in_ = FragmentIn(_vs2fs_location0); float _e4 = pc.multiplier; - _fs2p_location0 = (_in.color * _e4); + _fs2p_location0 = (in_.color * _e4); return; } diff --git a/tests/out/glsl/shadow.fs_main.Fragment.glsl b/tests/out/glsl/shadow.fs_main.Fragment.glsl index fca6f9faa..fef409f10 100644 --- a/tests/out/glsl/shadow.fs_main.Fragment.glsl +++ b/tests/out/glsl/shadow.fs_main.Fragment.glsl @@ -45,10 +45,10 @@ float fetch_shadow(uint light_id, vec4 homogeneous_coords) { } void main() { - VertexOutput _in = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1); + VertexOutput in_ = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1); vec3 color = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); uint i = 0u; - vec3 normal_1 = normalize(_in.world_normal); + vec3 normal_1 = normalize(in_.world_normal); bool loop_init = true; while(true) { if (!loop_init) { @@ -65,8 +65,8 @@ void main() { uint _e23 = i; Light light = _group_0_binding_1_fs[_e23]; uint _e26 = i; - float _e30 = fetch_shadow(_e26, (light.proj * _in.world_position)); - vec3 light_dir = normalize((light.pos.xyz - _in.world_position.xyz)); + float _e30 = fetch_shadow(_e26, (light.proj * in_.world_position)); + vec3 light_dir = normalize((light.pos.xyz - in_.world_position.xyz)); float diffuse = max(0.0, dot(normal_1, light_dir)); vec3 _e40 = color; color = (_e40 + ((_e30 * diffuse) * light.color.xyz)); diff --git a/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl b/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl index 4fc36ae9e..43f02cae1 100644 --- a/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl +++ b/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl @@ -45,10 +45,10 @@ float fetch_shadow(uint light_id, vec4 homogeneous_coords) { } void main() { - VertexOutput _in_1 = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1); + VertexOutput in_1 = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1); vec3 color_1 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); uint i_1 = 0u; - vec3 normal_1 = normalize(_in_1.world_normal); + vec3 normal_1 = normalize(in_1.world_normal); bool loop_init = true; while(true) { if (!loop_init) { @@ -65,8 +65,8 @@ void main() { uint _e23 = i_1; Light light = _group_0_binding_1_fs[_e23]; uint _e26 = i_1; - float _e30 = fetch_shadow(_e26, (light.proj * _in_1.world_position)); - vec3 light_dir = normalize((light.pos.xyz - _in_1.world_position.xyz)); + float _e30 = fetch_shadow(_e26, (light.proj * in_1.world_position)); + vec3 light_dir = normalize((light.pos.xyz - in_1.world_position.xyz)); float diffuse = max(0.0, dot(normal_1, light_dir)); vec3 _e40 = color_1; color_1 = (_e40 + ((_e30 * diffuse) * light.color.xyz)); diff --git a/tests/out/glsl/shadow.vs_main.Vertex.glsl b/tests/out/glsl/shadow.vs_main.Vertex.glsl index 8c2aff6a3..dce8b2f7d 100644 --- a/tests/out/glsl/shadow.vs_main.Vertex.glsl +++ b/tests/out/glsl/shadow.vs_main.Vertex.glsl @@ -33,15 +33,15 @@ layout(location = 1) smooth out vec4 _vs2fs_location1; void main() { ivec4 position = _p2vs_location0; ivec4 normal = _p2vs_location1; - VertexOutput _out = VertexOutput(vec4(0.0), vec3(0.0), vec4(0.0)); + VertexOutput out_ = VertexOutput(vec4(0.0), vec3(0.0), vec4(0.0)); mat4x4 w = _group_1_binding_0_vs.world; mat4x4 _e7 = _group_1_binding_0_vs.world; vec4 world_pos = (_e7 * vec4(position)); - _out.world_normal = (mat3x3(w[0].xyz, w[1].xyz, w[2].xyz) * vec3(normal.xyz)); - _out.world_position = world_pos; + out_.world_normal = (mat3x3(w[0].xyz, w[1].xyz, w[2].xyz) * vec3(normal.xyz)); + out_.world_position = world_pos; mat4x4 _e25 = _group_0_binding_0_vs.view_proj; - _out.proj_position = (_e25 * world_pos); - VertexOutput _e27 = _out; + out_.proj_position = (_e25 * world_pos); + VertexOutput _e27 = out_; gl_Position = _e27.proj_position; _vs2fs_location0 = _e27.world_normal; _vs2fs_location1 = _e27.world_position; diff --git a/tests/out/glsl/skybox.fs_main.Fragment.glsl b/tests/out/glsl/skybox.fs_main.Fragment.glsl index 77d686530..2b151db2a 100644 --- a/tests/out/glsl/skybox.fs_main.Fragment.glsl +++ b/tests/out/glsl/skybox.fs_main.Fragment.glsl @@ -17,8 +17,8 @@ layout(location = 0) smooth in vec3 _vs2fs_location0; layout(location = 0) out vec4 _fs2p_location0; void main() { - VertexOutput _in = VertexOutput(gl_FragCoord, _vs2fs_location0); - vec4 _e5 = texture(_group_0_binding_1_fs, vec3(_in.uv)); + VertexOutput in_ = VertexOutput(gl_FragCoord, _vs2fs_location0); + vec4 _e5 = texture(_group_0_binding_1_fs, vec3(in_.uv)); _fs2p_location0 = _e5; return; } diff --git a/tests/out/hlsl/interface.hlsl b/tests/out/hlsl/interface.hlsl index 7cf1c67cb..341b515ec 100644 --- a/tests/out/hlsl/interface.hlsl +++ b/tests/out/hlsl/interface.hlsl @@ -24,7 +24,7 @@ struct Input2_ { uint index : SV_InstanceID; }; -groupshared uint _output[1]; +groupshared uint output[1]; struct VertexOutput_vertex { float _varying : LOC1; @@ -64,20 +64,20 @@ FragmentOutput ConstructFragmentOutput(float arg0, uint arg1, float arg2) { FragmentOutput fragment(FragmentInput_fragment fragmentinput_fragment) { - VertexOutput _in = { fragmentinput_fragment.position_1, fragmentinput_fragment._varying_1 }; + VertexOutput in_ = { fragmentinput_fragment.position_1, fragmentinput_fragment._varying_1 }; bool front_facing = fragmentinput_fragment.front_facing_1; uint sample_index = fragmentinput_fragment.sample_index_1; uint sample_mask = fragmentinput_fragment.sample_mask_1; uint mask = (sample_mask & (1u << sample_index)); float color_1 = (front_facing ? 1.0 : 0.0); - const FragmentOutput fragmentoutput = ConstructFragmentOutput(_in._varying, mask, color_1); + const FragmentOutput fragmentoutput = ConstructFragmentOutput(in_._varying, mask, color_1); return fragmentoutput; } [numthreads(1, 1, 1)] void compute(uint3 global_id : SV_DispatchThreadID, uint3 local_id : SV_GroupThreadID, uint local_index : SV_GroupIndex, uint3 wg_id : SV_GroupID, uint3 num_wgs : SV_GroupID) { - _output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + uint3(_NagaConstants.base_vertex, _NagaConstants.base_instance, _NagaConstants.other).x); + output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + uint3(_NagaConstants.base_vertex, _NagaConstants.base_instance, _NagaConstants.other).x); return; } diff --git a/tests/out/hlsl/interpolate.hlsl b/tests/out/hlsl/interpolate.hlsl index 44d63239f..a9bd0c346 100644 --- a/tests/out/hlsl/interpolate.hlsl +++ b/tests/out/hlsl/interpolate.hlsl @@ -34,17 +34,17 @@ struct FragmentInput_frag_main { VertexOutput_vert_main vert_main() { - FragmentInput _out = (FragmentInput)0; + FragmentInput out_ = (FragmentInput)0; - _out.position = float4(2.0, 4.0, 5.0, 6.0); - _out._flat = 8u; - _out._linear = 27.0; - _out.linear_centroid = float2(64.0, 125.0); - _out.linear_sample = float3(216.0, 343.0, 512.0); - _out.perspective = float4(729.0, 1000.0, 1331.0, 1728.0); - _out.perspective_centroid = 2197.0; - _out.perspective_sample = 2744.0; - FragmentInput _expr30 = _out; + out_.position = float4(2.0, 4.0, 5.0, 6.0); + out_._flat = 8u; + out_._linear = 27.0; + out_.linear_centroid = float2(64.0, 125.0); + out_.linear_sample = float3(216.0, 343.0, 512.0); + out_.perspective = float4(729.0, 1000.0, 1331.0, 1728.0); + out_.perspective_centroid = 2197.0; + out_.perspective_sample = 2744.0; + FragmentInput _expr30 = out_; const FragmentInput fragmentinput = _expr30; const VertexOutput_vert_main fragmentinput_1 = { fragmentinput._flat, fragmentinput._linear, fragmentinput.linear_centroid, fragmentinput.linear_sample, fragmentinput.perspective, fragmentinput.perspective_centroid, fragmentinput.perspective_sample, fragmentinput.position }; return fragmentinput_1; diff --git a/tests/out/hlsl/shadow.hlsl b/tests/out/hlsl/shadow.hlsl index 4635f9f28..b66713092 100644 --- a/tests/out/hlsl/shadow.hlsl +++ b/tests/out/hlsl/shadow.hlsl @@ -62,16 +62,16 @@ float fetch_shadow(uint light_id, float4 homogeneous_coords) VertexOutput_vs_main vs_main(int4 position : LOC0, int4 normal : LOC1) { - VertexOutput _out = (VertexOutput)0; + VertexOutput out_ = (VertexOutput)0; float4x4 w = u_entity.world; float4x4 _expr7 = u_entity.world; float4 world_pos = mul(float4(position), _expr7); - _out.world_normal = mul(float3(normal.xyz), float3x3(w[0].xyz, w[1].xyz, w[2].xyz)); - _out.world_position = world_pos; + out_.world_normal = mul(float3(normal.xyz), float3x3(w[0].xyz, w[1].xyz, w[2].xyz)); + out_.world_position = world_pos; float4x4 _expr25 = u_globals.view_proj; - _out.proj_position = mul(world_pos, _expr25); - VertexOutput _expr27 = _out; + out_.proj_position = mul(world_pos, _expr25); + VertexOutput _expr27 = out_; const VertexOutput vertexoutput = _expr27; const VertexOutput_vs_main vertexoutput_1 = { vertexoutput.world_normal, vertexoutput.world_position, vertexoutput.proj_position }; return vertexoutput_1; @@ -79,11 +79,11 @@ VertexOutput_vs_main vs_main(int4 position : LOC0, int4 normal : LOC1) float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 { - VertexOutput _in = { fragmentinput_fs_main.proj_position_1, fragmentinput_fs_main.world_normal_1, fragmentinput_fs_main.world_position_1 }; + VertexOutput in_ = { fragmentinput_fs_main.proj_position_1, fragmentinput_fs_main.world_normal_1, fragmentinput_fs_main.world_position_1 }; float3 color = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); uint i = 0u; - float3 normal_1 = normalize(_in.world_normal); + float3 normal_1 = normalize(in_.world_normal); bool loop_init = true; while(true) { if (!loop_init) { @@ -100,8 +100,8 @@ float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 uint _expr23 = i; Light light = {float4x4(asfloat(s_lights.Load4(_expr23*96+0+0)), asfloat(s_lights.Load4(_expr23*96+0+16)), asfloat(s_lights.Load4(_expr23*96+0+32)), asfloat(s_lights.Load4(_expr23*96+0+48))), asfloat(s_lights.Load4(_expr23*96+64)), asfloat(s_lights.Load4(_expr23*96+80))}; uint _expr26 = i; - const float _e30 = fetch_shadow(_expr26, mul(_in.world_position, light.proj)); - float3 light_dir = normalize((light.pos.xyz - _in.world_position.xyz)); + const float _e30 = fetch_shadow(_expr26, mul(in_.world_position, light.proj)); + float3 light_dir = normalize((light.pos.xyz - in_.world_position.xyz)); float diffuse = max(0.0, dot(normal_1, light_dir)); float3 _expr40 = color; color = (_expr40 + ((_e30 * diffuse) * light.color.xyz)); @@ -113,11 +113,11 @@ float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 float4 fs_main_without_storage(FragmentInput_fs_main_without_storage fragmentinput_fs_main_without_storage) : SV_Target0 { - VertexOutput _in_1 = { fragmentinput_fs_main_without_storage.proj_position_2, fragmentinput_fs_main_without_storage.world_normal_2, fragmentinput_fs_main_without_storage.world_position_2 }; + VertexOutput in_1 = { fragmentinput_fs_main_without_storage.proj_position_2, fragmentinput_fs_main_without_storage.world_normal_2, fragmentinput_fs_main_without_storage.world_position_2 }; float3 color_1 = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); uint i_1 = 0u; - float3 normal_2 = normalize(_in_1.world_normal); + float3 normal_2 = normalize(in_1.world_normal); bool loop_init_1 = true; while(true) { if (!loop_init_1) { @@ -134,8 +134,8 @@ float4 fs_main_without_storage(FragmentInput_fs_main_without_storage fragmentinp uint _expr23 = i_1; Light light_1 = u_lights[_expr23]; uint _expr26 = i_1; - const float _e30 = fetch_shadow(_expr26, mul(_in_1.world_position, light_1.proj)); - float3 light_dir_1 = normalize((light_1.pos.xyz - _in_1.world_position.xyz)); + const float _e30 = fetch_shadow(_expr26, mul(in_1.world_position, light_1.proj)); + float3 light_dir_1 = normalize((light_1.pos.xyz - in_1.world_position.xyz)); float diffuse_1 = max(0.0, dot(normal_2, light_dir_1)); float3 _expr40 = color_1; color_1 = (_expr40 + ((_e30 * diffuse_1) * light_1.color.xyz)); diff --git a/tests/out/hlsl/skybox.hlsl b/tests/out/hlsl/skybox.hlsl index 6e119903d..3664c497c 100644 --- a/tests/out/hlsl/skybox.hlsl +++ b/tests/out/hlsl/skybox.hlsl @@ -59,7 +59,7 @@ VertexOutput_vs_main vs_main(uint vertex_index : SV_VertexID) float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 { - VertexOutput _in = { fragmentinput_fs_main.position_1, fragmentinput_fs_main.uv_1 }; - float4 _expr5 = r_texture.Sample(r_sampler, _in.uv); + VertexOutput in_ = { fragmentinput_fs_main.position_1, fragmentinput_fs_main.uv_1 }; + float4 _expr5 = r_texture.Sample(r_sampler, in_.uv); return _expr5; } diff --git a/tests/out/msl/extra.msl b/tests/out/msl/extra.msl index 683b074f2..8288dfad9 100644 --- a/tests/out/msl/extra.msl +++ b/tests/out/msl/extra.msl @@ -25,11 +25,11 @@ fragment main_Output main_( , uint primitive_index [[primitive_id]] , constant PushConstants& pc [[buffer(1)]] ) { - const FragmentIn _in = { varyings.color, primitive_index }; + const FragmentIn in = { varyings.color, primitive_index }; uint _e4 = pc.index; - if (_in.primitive_index == _e4) { - return main_Output { _in.color }; + if (in.primitive_index == _e4) { + return main_Output { in.color }; } else { - return main_Output { metal::float4(metal::float3(1.0) - _in.color.xyz, _in.color.w) }; + return main_Output { metal::float4(metal::float3(1.0) - in.color.xyz, in.color.w) }; } } diff --git a/tests/out/msl/interface.msl b/tests/out/msl/interface.msl index 7cb6a401f..9b8013531 100644 --- a/tests/out/msl/interface.msl +++ b/tests/out/msl/interface.msl @@ -58,10 +58,10 @@ fragment fragment_Output fragment_( , uint sample_index [[sample_id]] , uint sample_mask [[sample_mask]] ) { - const VertexOutput _in = { position, varyings_1._varying }; + const VertexOutput in = { position, varyings_1._varying }; uint mask = sample_mask & (1u << sample_index); float color_1 = front_facing ? 1.0 : 0.0; - const auto _tmp = FragmentOutput {_in._varying, mask, color_1}; + const auto _tmp = FragmentOutput {in._varying, mask, color_1}; return fragment_Output { _tmp.depth, _tmp.sample_mask, _tmp.color }; } @@ -74,9 +74,9 @@ kernel void compute_( , uint local_index [[thread_index_in_threadgroup]] , metal::uint3 wg_id [[threadgroup_position_in_grid]] , metal::uint3 num_wgs [[threadgroups_per_grid]] -, threadgroup type_4& _output +, threadgroup type_4& output ) { - _output.inner[0] = (((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x; + output.inner[0] = (((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x; return; } diff --git a/tests/out/msl/interpolate.msl b/tests/out/msl/interpolate.msl index cefc07ab9..4dd84c623 100644 --- a/tests/out/msl/interpolate.msl +++ b/tests/out/msl/interpolate.msl @@ -27,16 +27,16 @@ struct vert_mainOutput { }; vertex vert_mainOutput vert_main( ) { - FragmentInput _out; - _out.position = metal::float4(2.0, 4.0, 5.0, 6.0); - _out._flat = 8u; - _out._linear = 27.0; - _out.linear_centroid = metal::float2(64.0, 125.0); - _out.linear_sample = metal::float3(216.0, 343.0, 512.0); - _out.perspective = metal::float4(729.0, 1000.0, 1331.0, 1728.0); - _out.perspective_centroid = 2197.0; - _out.perspective_sample = 2744.0; - FragmentInput _e30 = _out; + FragmentInput out; + out.position = metal::float4(2.0, 4.0, 5.0, 6.0); + out._flat = 8u; + out._linear = 27.0; + out.linear_centroid = metal::float2(64.0, 125.0); + out.linear_sample = metal::float3(216.0, 343.0, 512.0); + out.perspective = metal::float4(729.0, 1000.0, 1331.0, 1728.0); + out.perspective_centroid = 2197.0; + out.perspective_sample = 2744.0; + FragmentInput _e30 = out; const auto _tmp = _e30; return vert_mainOutput { _tmp.position, _tmp._flat, _tmp._linear, _tmp.linear_centroid, _tmp.linear_sample, _tmp.perspective, _tmp.perspective_centroid, _tmp.perspective_sample }; } diff --git a/tests/out/msl/shadow.msl b/tests/out/msl/shadow.msl index ba723742a..5286b0bd0 100644 --- a/tests/out/msl/shadow.msl +++ b/tests/out/msl/shadow.msl @@ -65,15 +65,15 @@ vertex vs_mainOutput vs_main( ) { const auto position = varyings.position; const auto normal = varyings.normal; - VertexOutput _out; + VertexOutput out; metal::float4x4 w = u_entity.world; metal::float4x4 _e7 = u_entity.world; metal::float4 world_pos = _e7 * static_cast(position); - _out.world_normal = metal::float3x3(w[0].xyz, w[1].xyz, w[2].xyz) * static_cast(normal.xyz); - _out.world_position = world_pos; + out.world_normal = metal::float3x3(w[0].xyz, w[1].xyz, w[2].xyz) * static_cast(normal.xyz); + out.world_position = world_pos; metal::float4x4 _e25 = u_globals.view_proj; - _out.proj_position = _e25 * world_pos; - VertexOutput _e27 = _out; + out.proj_position = _e25 * world_pos; + VertexOutput _e27 = out; const auto _tmp = _e27; return vs_mainOutput { _tmp.proj_position, _tmp.world_normal, _tmp.world_position }; } @@ -96,10 +96,10 @@ fragment fs_mainOutput fs_main( , metal::sampler sampler_shadow [[user(fake0)]] , constant _mslBufferSizes& _buffer_sizes [[user(fake0)]] ) { - const VertexOutput _in = { proj_position, varyings_1.world_normal, varyings_1.world_position }; + const VertexOutput in = { proj_position, varyings_1.world_normal, varyings_1.world_position }; metal::float3 color = c_ambient; uint i = 0u; - metal::float3 normal_1 = metal::normalize(_in.world_normal); + metal::float3 normal_1 = metal::normalize(in.world_normal); bool loop_init = true; while(true) { if (!loop_init) { @@ -116,8 +116,8 @@ fragment fs_mainOutput fs_main( uint _e23 = i; Light light = s_lights[_e23]; uint _e26 = i; - float _e30 = fetch_shadow(_e26, light.proj * _in.world_position, t_shadow, sampler_shadow); - metal::float3 light_dir = metal::normalize(light.pos.xyz - _in.world_position.xyz); + float _e30 = fetch_shadow(_e26, light.proj * in.world_position, t_shadow, sampler_shadow); + metal::float3 light_dir = metal::normalize(light.pos.xyz - in.world_position.xyz); float diffuse = metal::max(0.0, metal::dot(normal_1, light_dir)); metal::float3 _e40 = color; color = _e40 + ((_e30 * diffuse) * light.color.xyz); @@ -144,10 +144,10 @@ fragment fs_main_without_storageOutput fs_main_without_storage( , metal::depth2d_array t_shadow [[user(fake0)]] , metal::sampler sampler_shadow [[user(fake0)]] ) { - const VertexOutput _in_1 = { proj_position_1, varyings_2.world_normal, varyings_2.world_position }; + const VertexOutput in_1 = { proj_position_1, varyings_2.world_normal, varyings_2.world_position }; metal::float3 color_1 = c_ambient; uint i_1 = 0u; - metal::float3 normal_2 = metal::normalize(_in_1.world_normal); + metal::float3 normal_2 = metal::normalize(in_1.world_normal); bool loop_init_1 = true; while(true) { if (!loop_init_1) { @@ -164,8 +164,8 @@ fragment fs_main_without_storageOutput fs_main_without_storage( uint _e23 = i_1; Light light_1 = u_lights.inner[_e23]; uint _e26 = i_1; - float _e30 = fetch_shadow(_e26, light_1.proj * _in_1.world_position, t_shadow, sampler_shadow); - metal::float3 light_dir_1 = metal::normalize(light_1.pos.xyz - _in_1.world_position.xyz); + float _e30 = fetch_shadow(_e26, light_1.proj * in_1.world_position, t_shadow, sampler_shadow); + metal::float3 light_dir_1 = metal::normalize(light_1.pos.xyz - in_1.world_position.xyz); float diffuse_1 = metal::max(0.0, metal::dot(normal_2, light_dir_1)); metal::float3 _e40 = color_1; color_1 = _e40 + ((_e30 * diffuse_1) * light_1.color.xyz); diff --git a/tests/out/msl/skybox.msl b/tests/out/msl/skybox.msl index f6b8c006f..bf8725043 100644 --- a/tests/out/msl/skybox.msl +++ b/tests/out/msl/skybox.msl @@ -60,7 +60,7 @@ fragment fs_mainOutput fs_main( metal::min_filter::linear, metal::coord::normalized ); - const VertexOutput _in = { position, varyings_1.uv }; - metal::float4 _e5 = r_texture.sample(r_sampler, _in.uv); + const VertexOutput in = { position, varyings_1.uv }; + metal::float4 _e5 = r_texture.sample(r_sampler, in.uv); return fs_mainOutput { _e5 }; } diff --git a/tests/out/spv/interpolate.spvasm b/tests/out/spv/interpolate.spvasm index 7c48cb646..da47ff164 100644 --- a/tests/out/spv/interpolate.spvasm +++ b/tests/out/spv/interpolate.spvasm @@ -19,7 +19,7 @@ OpMemberName %25 5 "perspective" OpMemberName %25 6 "perspective_centroid" OpMemberName %25 7 "perspective_sample" OpName %25 "FragmentInput" -OpName %26 "_out" +OpName %26 "out" OpName %29 "position" OpName %31 "_flat" OpName %33 "_linear" diff --git a/tests/out/spv/shadow.spvasm b/tests/out/spv/shadow.spvasm index 9e42405fb..aeb85c96b 100644 --- a/tests/out/spv/shadow.spvasm +++ b/tests/out/spv/shadow.spvasm @@ -37,7 +37,7 @@ OpName %45 "sampler_shadow" OpName %48 "light_id" OpName %49 "homogeneous_coords" OpName %50 "fetch_shadow" -OpName %80 "_out" +OpName %80 "out" OpName %83 "position" OpName %86 "normal" OpName %88 "proj_position" diff --git a/tests/out/wgsl/extra.wgsl b/tests/out/wgsl/extra.wgsl index a4542763b..34a2e176c 100644 --- a/tests/out/wgsl/extra.wgsl +++ b/tests/out/wgsl/extra.wgsl @@ -11,11 +11,11 @@ struct FragmentIn { var pc: PushConstants; @fragment -fn main(_in: FragmentIn) -> @location(0) vec4 { +fn main(in: FragmentIn) -> @location(0) vec4 { let _e4 = pc.index; - if (_in.primitive_index == _e4) { - return _in.color; + if (in.primitive_index == _e4) { + return in.color; } else { - return vec4((vec3(1.0) - _in.color.xyz), _in.color.w); + return vec4((vec3(1.0) - in.color.xyz), in.color.w); } } diff --git a/tests/out/wgsl/interface.wgsl b/tests/out/wgsl/interface.wgsl index eda7d72de..a17865c5a 100644 --- a/tests/out/wgsl/interface.wgsl +++ b/tests/out/wgsl/interface.wgsl @@ -17,7 +17,7 @@ struct Input2_ { @builtin(instance_index) index: u32, } -var _output: array; +var output: array; @vertex fn vertex(@builtin(vertex_index) vertex_index: u32, @builtin(instance_index) instance_index: u32, @location(10) color: u32) -> VertexOutput { @@ -26,15 +26,15 @@ fn vertex(@builtin(vertex_index) vertex_index: u32, @builtin(instance_index) ins } @fragment -fn fragment(_in: VertexOutput, @builtin(front_facing) front_facing: bool, @builtin(sample_index) sample_index: u32, @builtin(sample_mask) sample_mask: u32) -> FragmentOutput { +fn fragment(in: VertexOutput, @builtin(front_facing) front_facing: bool, @builtin(sample_index) sample_index: u32, @builtin(sample_mask) sample_mask: u32) -> FragmentOutput { let mask: u32 = (sample_mask & (1u << sample_index)); let color_1: f32 = select(0.0, 1.0, front_facing); - return FragmentOutput(_in._varying, mask, color_1); + return FragmentOutput(in._varying, mask, color_1); } @compute @workgroup_size(1, 1, 1) fn compute(@builtin(global_invocation_id) global_id: vec3, @builtin(local_invocation_id) local_id: vec3, @builtin(local_invocation_index) local_index: u32, @builtin(workgroup_id) wg_id: vec3, @builtin(num_workgroups) num_wgs: vec3) { - _output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x); + output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x); return; } diff --git a/tests/out/wgsl/interpolate.wgsl b/tests/out/wgsl/interpolate.wgsl index dbccb1ac8..d566aae80 100644 --- a/tests/out/wgsl/interpolate.wgsl +++ b/tests/out/wgsl/interpolate.wgsl @@ -11,17 +11,17 @@ struct FragmentInput { @vertex fn vert_main() -> FragmentInput { - var _out: FragmentInput; + var out: FragmentInput; - _out.position = vec4(2.0, 4.0, 5.0, 6.0); - _out._flat = 8u; - _out._linear = 27.0; - _out.linear_centroid = vec2(64.0, 125.0); - _out.linear_sample = vec3(216.0, 343.0, 512.0); - _out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); - _out.perspective_centroid = 2197.0; - _out.perspective_sample = 2744.0; - let _e30 = _out; + out.position = vec4(2.0, 4.0, 5.0, 6.0); + out._flat = 8u; + out._linear = 27.0; + out.linear_centroid = vec2(64.0, 125.0); + out.linear_sample = vec3(216.0, 343.0, 512.0); + out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); + out.perspective_centroid = 2197.0; + out.perspective_sample = 2744.0; + let _e30 = out; return _e30; } diff --git a/tests/out/wgsl/shadow.wgsl b/tests/out/wgsl/shadow.wgsl index 653264454..8bb6b5813 100644 --- a/tests/out/wgsl/shadow.wgsl +++ b/tests/out/wgsl/shadow.wgsl @@ -49,25 +49,25 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4) -> f32 { @vertex fn vs_main(@location(0) position: vec4, @location(1) normal: vec4) -> VertexOutput { - var _out: VertexOutput; + var out: VertexOutput; let w = u_entity.world; let _e7 = u_entity.world; let world_pos = (_e7 * vec4(position)); - _out.world_normal = (mat3x3(w[0].xyz, w[1].xyz, w[2].xyz) * vec3(normal.xyz)); - _out.world_position = world_pos; + out.world_normal = (mat3x3(w[0].xyz, w[1].xyz, w[2].xyz) * vec3(normal.xyz)); + out.world_position = world_pos; let _e25 = u_globals.view_proj; - _out.proj_position = (_e25 * world_pos); - let _e27 = _out; + out.proj_position = (_e25 * world_pos); + let _e27 = out; return _e27; } @fragment -fn fs_main(_in: VertexOutput) -> @location(0) vec4 { +fn fs_main(in: VertexOutput) -> @location(0) vec4 { var color: vec3 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); var i: u32 = 0u; - let normal_1 = normalize(_in.world_normal); + let normal_1 = normalize(in.world_normal); loop { let _e14 = i; let _e17 = u_globals.num_lights.x; @@ -78,8 +78,8 @@ fn fs_main(_in: VertexOutput) -> @location(0) vec4 { let _e23 = i; let light = s_lights[_e23]; let _e26 = i; - let _e30 = fetch_shadow(_e26, (light.proj * _in.world_position)); - let light_dir = normalize((light.pos.xyz - _in.world_position.xyz)); + let _e30 = fetch_shadow(_e26, (light.proj * in.world_position)); + let light_dir = normalize((light.pos.xyz - in.world_position.xyz)); let diffuse = max(0.0, dot(normal_1, light_dir)); let _e40 = color; color = (_e40 + ((_e30 * diffuse) * light.color.xyz)); @@ -94,11 +94,11 @@ fn fs_main(_in: VertexOutput) -> @location(0) vec4 { } @fragment -fn fs_main_without_storage(_in_1: VertexOutput) -> @location(0) vec4 { +fn fs_main_without_storage(in_1: VertexOutput) -> @location(0) vec4 { var color_1: vec3 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); var i_1: u32 = 0u; - let normal_2 = normalize(_in_1.world_normal); + let normal_2 = normalize(in_1.world_normal); loop { let _e14 = i_1; let _e17 = u_globals.num_lights.x; @@ -109,8 +109,8 @@ fn fs_main_without_storage(_in_1: VertexOutput) -> @location(0) vec4 { let _e23 = i_1; let light_1 = u_lights[_e23]; let _e26 = i_1; - let _e30 = fetch_shadow(_e26, (light_1.proj * _in_1.world_position)); - let light_dir_1 = normalize((light_1.pos.xyz - _in_1.world_position.xyz)); + let _e30 = fetch_shadow(_e26, (light_1.proj * in_1.world_position)); + let light_dir_1 = normalize((light_1.pos.xyz - in_1.world_position.xyz)); let diffuse_1 = max(0.0, dot(normal_2, light_dir_1)); let _e40 = color_1; color_1 = (_e40 + ((_e30 * diffuse_1) * light_1.color.xyz)); diff --git a/tests/out/wgsl/skybox.wgsl b/tests/out/wgsl/skybox.wgsl index f759f48de..c9be90196 100644 --- a/tests/out/wgsl/skybox.wgsl +++ b/tests/out/wgsl/skybox.wgsl @@ -35,7 +35,7 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput { } @fragment -fn fs_main(_in: VertexOutput) -> @location(0) vec4 { - let _e5 = textureSample(r_texture, r_sampler, _in.uv); +fn fs_main(in: VertexOutput) -> @location(0) vec4 { + let _e5 = textureSample(r_texture, r_sampler, in.uv); return _e5; }