diff --git a/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag b/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag index 4ad8db3..e7cb790 100644 --- a/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag +++ b/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -15,8 +15,6 @@ float4 _21; void frag_main() { - float4 _15; - float4 _17; float4 _33; do { diff --git a/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag index 9c9e087..204d3b8 100644 --- a/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -104,12 +104,6 @@ struct main0_out fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d SpecularMapTexture [[texture(7)]]) { main0_out out = {}; - float4 _178; - float4 _191; - float4 _205; - float4 _218; - float4 _283; - float4 _296; bool _173; VertexOutput _128 = _121; _128.HPosition = gl_FragCoord; @@ -148,15 +142,13 @@ fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[positio _173 = 0.0 == 0.0; if (_173) { - _178 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); - _193 = _178; + _193 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); break; } else { float _180 = 1.0 / (1.0 - 0.0); - _191 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - _193 = _191; + _193 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); break; } _193 = _192; @@ -167,15 +159,13 @@ fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[positio { if (_173) { - _205 = NormalMapTexture.sample(NormalMapSampler, _166); - _220 = _205; + _220 = NormalMapTexture.sample(NormalMapSampler, _166); break; } else { float _207 = 1.0 / (1.0 - 0.0); - _218 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - _220 = _218; + _220 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); break; } _220 = _219; @@ -195,15 +185,13 @@ fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[positio { if (0.75 == 0.0) { - _283 = SpecularMapTexture.sample(SpecularMapSampler, _166); - _298 = _283; + _298 = SpecularMapTexture.sample(SpecularMapSampler, _166); break; } else { float _285 = 1.0 / (1.0 - 0.75); - _296 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - _298 = _296; + _298 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); break; } _298 = _297; diff --git a/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag index f352e40..036774d 100644 --- a/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag +++ b/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag @@ -5,9 +5,7 @@ using namespace metal; fragment void main0() { - int _16; - int _23; - for (int _22 = 35; _22 >= 0; _23 = _22 - 1, _22 = _23) + for (int _22 = 35; _22 >= 0; _22--) { } } diff --git a/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag b/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag index 2afceda..90fbf1e 100644 --- a/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag +++ b/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag @@ -14,8 +14,6 @@ struct main0_out fragment main0_out main0() { main0_out out = {}; - float4 _20; - float4 _21; float4 _51; float4 _52; _51 = _50; diff --git a/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag b/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag index 86847dd..3e80051 100644 --- a/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag +++ b/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag @@ -18,8 +18,6 @@ struct main0_out fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; - float4 _15; - float4 _17; float4 _33; do { diff --git a/reference/opt/shaders-msl/comp/dowhile.comp b/reference/opt/shaders-msl/comp/dowhile.comp index d210e41..d7afacf 100644 --- a/reference/opt/shaders-msl/comp/dowhile.comp +++ b/reference/opt/shaders-msl/comp/dowhile.comp @@ -16,12 +16,10 @@ struct SSBO2 kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]]) { - float4 _33; float4 _42; int i = 0; - _33 = _28.in_data[gl_GlobalInvocationID.x]; float4 _56; - _56 = _33; + _56 = _28.in_data[gl_GlobalInvocationID.x]; for (;;) { _42 = _28.mvp * _56; diff --git a/reference/opt/shaders-msl/comp/return.comp b/reference/opt/shaders-msl/comp/return.comp index edbc6ca..eaa25c5 100644 --- a/reference/opt/shaders-msl/comp/return.comp +++ b/reference/opt/shaders-msl/comp/return.comp @@ -12,8 +12,6 @@ constant int _69 = {}; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]]) { - int _29; - int _65; if (gl_GlobalInvocationID.x == 2u) { _27.out_data[gl_GlobalInvocationID.x] = float4(20.0); @@ -26,7 +24,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic return; } } - for (int _68 = 0; _68 < 20; _65 = _69 + 1, _68 = _65) + for (int _68 = 0; _68 < 20; _68 = _69 + 1) { return; } diff --git a/reference/opt/shaders-msl/comp/torture-loop.comp b/reference/opt/shaders-msl/comp/torture-loop.comp index d161572..5e14eb9 100644 --- a/reference/opt/shaders-msl/comp/torture-loop.comp +++ b/reference/opt/shaders-msl/comp/torture-loop.comp @@ -18,22 +18,13 @@ constant uint _98 = {}; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]]) { - float4 _30; - float4 _46; - int _33; - int _48; int _40; - int _77; - uint _12; - uint _75; - float4 _71; - uint _73; - int _83; - _30 = _24.in_data[gl_GlobalInvocationID.x]; float4 _93; int _94; - _93 = _30; + _93 = _24.in_data[gl_GlobalInvocationID.x]; _94 = 0; + int _48; + float4 _46; for (;;) { _40 = _94 + 1; @@ -56,17 +47,19 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic _96 = _40; float4 _100; uint _101; - for (uint _97 = 0u, _99 = _98; _97 < 16u; _75 = _97 + uint(1), _77 = _96 + 1, _95 = _100, _96 = _77, _97 = _75, _99 = _101) + for (uint _97 = 0u, _99 = _98; _97 < 16u; _95 = _100, _96++, _97++, _99 = _101) { _100 = _95; _101 = 0u; - for (; _101 < 30u; _73 = _101 + uint(1), _100 = _71, _101 = _73) + float4 _71; + for (; _101 < 30u; _100 = _71, _101++) { _71 = _24.mvp * _100; } } int _102; _102 = _96; + int _83; for (;;) { _83 = _102 + 1; diff --git a/reference/opt/shaders-msl/frag/for-loop-init.frag b/reference/opt/shaders-msl/frag/for-loop-init.frag index 64723e4..0e5c92c 100644 --- a/reference/opt/shaders-msl/frag/for-loop-init.frag +++ b/reference/opt/shaders-msl/frag/for-loop-init.frag @@ -11,36 +11,26 @@ struct main0_out fragment main0_out main0() { main0_out out = {}; - int _12; - int _27; - int _26; - int _43; - int _59; - int _83; - int2 _93; - int2 _139; - int _62; - int _128; out.FragColor = 16; - for (int _140 = 0; _140 < 25; _27 = _140 + 1, _140 = _27) + for (int _140 = 0; _140 < 25; _140++) { out.FragColor += 10; } - for (int _141 = 1; _141 < 30; _43 = _141 + 1, _141 = _43) + for (int _141 = 1; _141 < 30; _141++) { out.FragColor += 11; } int _142; _142 = 0; - for (; _142 < 20; _59 = _142 + 1, _142 = _59) + for (; _142 < 20; _142++) { out.FragColor += 12; } - _62 = _142 + 3; + int _62 = _142 + 3; out.FragColor += _62; if (_62 == 40) { - for (int _143 = 0; _143 < 40; _83 = _143 + 1, _143 = _83) + for (int _143 = 0; _143 < 40; _143++) { out.FragColor += 13; } @@ -52,11 +42,12 @@ fragment main0_out main0() } int2 _144; _144 = int2(0); + int2 _139; for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139) { out.FragColor += _144.y; } - for (int _145 = _62; _145 < 40; _128 = _145 + 1, _145 = _128) + for (int _145 = _62; _145 < 40; _145++) { out.FragColor += _145; } diff --git a/reference/opt/shaders-msl/vert/copy.flatten.vert b/reference/opt/shaders-msl/vert/copy.flatten.vert index f056d54..dc87c84 100644 --- a/reference/opt/shaders-msl/vert/copy.flatten.vert +++ b/reference/opt/shaders-msl/vert/copy.flatten.vert @@ -31,11 +31,9 @@ struct main0_out vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) { main0_out out = {}; - int _12; - int _92; out.gl_Position = _21.uMVP * in.aVertex; out.vColor = float4(0.0); - for (int _103 = 0; _103 < 4; _92 = _103 + 1, _103 = _92) + for (int _103 = 0; _103 < 4; _103++) { float3 _68 = in.aVertex.xyz - _21.lights[_103].Position; out.vColor += ((_21.lights[_103].Color * clamp(1.0 - (length(_68) / _21.lights[_103].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_68))); diff --git a/reference/opt/shaders-msl/vert/dynamic.flatten.vert b/reference/opt/shaders-msl/vert/dynamic.flatten.vert index 2ccea69..eb38ab4 100644 --- a/reference/opt/shaders-msl/vert/dynamic.flatten.vert +++ b/reference/opt/shaders-msl/vert/dynamic.flatten.vert @@ -31,11 +31,9 @@ struct main0_out vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) { main0_out out = {}; - int _12; - int _81; out.gl_Position = _21.uMVP * in.aVertex; out.vColor = float4(0.0); - for (int _82 = 0; _82 < 4; _81 = _82 + 1, _82 = _81) + for (int _82 = 0; _82 < 4; _82++) { float3 _54 = in.aVertex.xyz - _21.lights[_82].Position; out.vColor += ((_21.lights[_82].Color * clamp(1.0 - (length(_54) / _21.lights[_82].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_54))); diff --git a/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag index 2b16105..78ff34f 100644 --- a/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -97,12 +97,6 @@ vec4 _297; void main() { - vec4 _178; - vec4 _191; - vec4 _205; - vec4 _218; - vec4 _283; - vec4 _296; bool _173; VertexOutput _128 = _121; _128.HPosition = gl_FragCoord; @@ -141,15 +135,13 @@ void main() _173 = 0.0 == 0.0; if (_173) { - _178 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); - _193 = _178; + _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); break; } else { float _180 = 1.0 / (1.0 - 0.0); - _191 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - _193 = _191; + _193 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); break; } _193 = _192; @@ -160,15 +152,13 @@ void main() { if (_173) { - _205 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); - _220 = _205; + _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); break; } else { float _207 = 1.0 / (1.0 - 0.0); - _218 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - _220 = _218; + _220 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); break; } _220 = _219; @@ -188,15 +178,13 @@ void main() { if (0.75 == 0.0) { - _283 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); - _298 = _283; + _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); break; } else { float _285 = 1.0 / (1.0 - 0.75); - _296 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - _298 = _296; + _298 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); break; } _298 = _297; diff --git a/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag index a160635..4fb4b75 100644 --- a/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ b/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -15,15 +15,11 @@ uint _155; int GetCascade(vec3 fragWorldPosition) { - uint _49; - uint _119; - mat4 _43; - mat4 _47; mat4 _153; _153 = _152; uint _156; mat4 _157; - for (uint _151 = 0u; _151 < _11.shadowCascadesNum; _119 = _156 + uint(1), _151 = _119, _153 = _157) + for (uint _151 = 0u; _151 < _11.shadowCascadesNum; _151 = _156 + uint(1), _153 = _157) { mat4 _154; _154 = _153; diff --git a/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag b/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag index e8de87d..c41c77c 100644 --- a/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag +++ b/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag @@ -7,14 +7,10 @@ layout(location = 0) flat in mediump int counter; void main() { - int _37; - mediump int _22; - uint _38; - mediump uint _25; FragColor = vec4(0.0); int _53 = 0; uint _54 = 1u; - for (; (_53 < 10) && (int(_54) < int(20u)); _22 = _53 + counter, _25 = _54 + uint(counter), _53 = _22, _54 = _25) + for (; (_53 < 10) && (int(_54) < int(20u)); _53 += counter, _54 += uint(counter)) { FragColor += vec4(float(_53)); FragColor += vec4(float(_54)); diff --git a/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag b/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag index 0fb5010..786ac74 100644 --- a/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag +++ b/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag @@ -2,9 +2,7 @@ void main() { - int _16; - int _23; - for (int _22 = 35; _22 >= 0; _23 = _22 - 1, _22 = _23) + for (int _22 = 35; _22 >= 0; _22--) { } } diff --git a/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag index d4cd58e..3917594 100644 --- a/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ b/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -14,13 +14,10 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - vec3 _14; - vec3 _29; - int _16; - int _32; vec3 _28; _28 = vec3(0.0); - for (int _31 = 0; _31 < 4; _32 = _31 + 1, _28 = _29, _31 = _32) + vec3 _29; + for (int _31 = 0; _31 < 4; _28 = _29, _31++) { _29 = _28 + _6.g_MyStruct[_31].color.xyz; } diff --git a/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag b/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag index e83221b..f903dc8 100644 --- a/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag +++ b/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag @@ -7,8 +7,6 @@ vec4 _50; void main() { - vec4 _20; - vec4 _21; vec4 _51; vec4 _52; _51 = _50; diff --git a/reference/opt/shaders/asm/frag/unreachable.asm.frag b/reference/opt/shaders/asm/frag/unreachable.asm.frag index 3358f84..d8126d7 100644 --- a/reference/opt/shaders/asm/frag/unreachable.asm.frag +++ b/reference/opt/shaders/asm/frag/unreachable.asm.frag @@ -7,8 +7,6 @@ vec4 _21; void main() { - vec4 _15; - vec4 _17; vec4 _33; do { diff --git a/reference/opt/shaders/comp/cfg.comp b/reference/opt/shaders/comp/cfg.comp index f9e02e1..c2c7136 100644 --- a/reference/opt/shaders/comp/cfg.comp +++ b/reference/opt/shaders/comp/cfg.comp @@ -10,9 +10,6 @@ float _180; void main() { - int _13; - int _166; - float _168; if (_11.data != 0.0) { _11.data = 10.0; @@ -47,7 +44,7 @@ void main() } float _181; _181 = _180; - for (int _179 = 0; _179 < 20; _166 = _179 + 1, _168 = _181 + 10.0, _179 = _166, _181 = _168) + for (int _179 = 0; _179 < 20; _179++, _181 += 10.0) { } _11.data = _181; diff --git a/reference/opt/shaders/comp/dowhile.comp b/reference/opt/shaders/comp/dowhile.comp index 2042954..7109c5b 100644 --- a/reference/opt/shaders/comp/dowhile.comp +++ b/reference/opt/shaders/comp/dowhile.comp @@ -16,12 +16,10 @@ int i; void main() { - vec4 _33; vec4 _42; i = 0; - _33 = _28.in_data[gl_GlobalInvocationID.x]; vec4 _56; - _56 = _33; + _56 = _28.in_data[gl_GlobalInvocationID.x]; for (;;) { _42 = _28.mvp * _56; diff --git a/reference/opt/shaders/comp/generate_height.comp b/reference/opt/shaders/comp/generate_height.comp index ce4c89e..1b5e0c3 100644 --- a/reference/opt/shaders/comp/generate_height.comp +++ b/reference/opt/shaders/comp/generate_height.comp @@ -18,9 +18,6 @@ layout(binding = 1, std430) writeonly buffer HeightmapFFT void main() { - uint _66; - uint _435; - uint _439; uvec2 _263 = uvec2(64u, 1u) * gl_NumWorkGroups.xy; uvec2 _268 = _263 - gl_GlobalInvocationID.xy; bvec2 _270 = equal(gl_GlobalInvocationID.xy, uvec2(0u)); @@ -31,8 +28,7 @@ void main() } else { - _435 = _268.x; - _470 = _435; + _470 = _268.x; } uint _471; if (_270.y) @@ -41,8 +37,7 @@ void main() } else { - _439 = _268.y; - _471 = _439; + _471 = _268.y; } vec2 _296 = vec2(gl_GlobalInvocationID.xy); vec2 _298 = vec2(_263); diff --git a/reference/opt/shaders/comp/return.comp b/reference/opt/shaders/comp/return.comp index 4c3200a..ea41907 100644 --- a/reference/opt/shaders/comp/return.comp +++ b/reference/opt/shaders/comp/return.comp @@ -10,8 +10,6 @@ int _69; void main() { - int _29; - int _65; if (gl_GlobalInvocationID.x == 2u) { _27.out_data[gl_GlobalInvocationID.x] = vec4(20.0); @@ -24,7 +22,7 @@ void main() return; } } - for (int _68 = 0; _68 < 20; _65 = _69 + 1, _68 = _65) + for (int _68 = 0; _68 < 20; _68 = _69 + 1) { return; } diff --git a/reference/opt/shaders/comp/torture-loop.comp b/reference/opt/shaders/comp/torture-loop.comp index 2b88cf8..1ba8a73 100644 --- a/reference/opt/shaders/comp/torture-loop.comp +++ b/reference/opt/shaders/comp/torture-loop.comp @@ -16,22 +16,13 @@ uint _98; void main() { - vec4 _30; - vec4 _46; - int _33; - int _48; int _40; - int _77; - uint _12; - uint _75; - vec4 _71; - uint _73; - int _83; - _30 = _24.in_data[gl_GlobalInvocationID.x]; vec4 _93; int _94; - _93 = _30; + _93 = _24.in_data[gl_GlobalInvocationID.x]; _94 = 0; + int _48; + vec4 _46; for (;;) { _40 = _94 + 1; @@ -54,17 +45,19 @@ void main() _96 = _40; vec4 _100; uint _101; - for (uint _97 = 0u, _99 = _98; _97 < 16u; _75 = _97 + uint(1), _77 = _96 + 1, _95 = _100, _96 = _77, _97 = _75, _99 = _101) + for (uint _97 = 0u, _99 = _98; _97 < 16u; _95 = _100, _96++, _97++, _99 = _101) { _100 = _95; _101 = 0u; - for (; _101 < 30u; _73 = _101 + uint(1), _100 = _71, _101 = _73) + vec4 _71; + for (; _101 < 30u; _100 = _71, _101++) { _71 = _24.mvp * _100; } } int _102; _102 = _96; + int _83; for (;;) { _83 = _102 + 1; diff --git a/reference/opt/shaders/flatten/copy.flatten.vert b/reference/opt/shaders/flatten/copy.flatten.vert index 833c6a2..59f0dc1 100644 --- a/reference/opt/shaders/flatten/copy.flatten.vert +++ b/reference/opt/shaders/flatten/copy.flatten.vert @@ -14,11 +14,9 @@ layout(location = 1) in vec3 aNormal; void main() { - int _12; - int _92; gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; vColor = vec4(0.0); - for (int _103 = 0; _103 < 4; _92 = _103 + 1, _103 = _92) + for (int _103 = 0; _103 < 4; _103++) { vec3 _68 = aVertex.xyz - Light(UBO[_103 * 2 + 4].xyz, UBO[_103 * 2 + 4].w, UBO[_103 * 2 + 5]).Position; vColor += (((UBO[_103 * 2 + 5]) * clamp(1.0 - (length(_68) / Light(UBO[_103 * 2 + 4].xyz, UBO[_103 * 2 + 4].w, UBO[_103 * 2 + 5]).Radius), 0.0, 1.0)) * dot(aNormal, normalize(_68))); diff --git a/reference/opt/shaders/flatten/dynamic.flatten.vert b/reference/opt/shaders/flatten/dynamic.flatten.vert index cb024a2..c08f744 100644 --- a/reference/opt/shaders/flatten/dynamic.flatten.vert +++ b/reference/opt/shaders/flatten/dynamic.flatten.vert @@ -14,11 +14,9 @@ layout(location = 1) in vec3 aNormal; void main() { - int _12; - int _81; gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; vColor = vec4(0.0); - for (int _82 = 0; _82 < 4; _81 = _82 + 1, _82 = _81) + for (int _82 = 0; _82 < 4; _82++) { vec3 _54 = aVertex.xyz - (UBO[_82 * 2 + 4].xyz); vColor += (((UBO[_82 * 2 + 5]) * clamp(1.0 - (length(_54) / (UBO[_82 * 2 + 4].w)), 0.0, 1.0)) * dot(aNormal, normalize(_54))); diff --git a/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag index 6a5c7b0..df33ef7 100644 --- a/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag +++ b/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag @@ -10,22 +10,18 @@ int _93; void main() { - int _9; - int _76; - int _74; - int _72; vec4 values3[2 * 3 * 1]; int _96; int _97; - for (int _92 = 0, _94 = _93, _95 = _93; _92 < 2; _76 = _92 + 1, _92 = _76, _94 = _96, _95 = _97) + for (int _92 = 0, _94 = _93, _95 = _93; _92 < 2; _92++, _94 = _96, _95 = _97) { _96 = 0; _97 = _95; int _98; - for (; _96 < 3; _74 = _96 + 1, _96 = _74, _97 = _98) + for (; _96 < 3; _96++, _97 = _98) { _98 = 0; - for (; _98 < 1; _72 = _98 + 1, _98 = _72) + for (; _98 < 1; _98++) { values3[_92 * 3 * 1 + _96 * 1 + _98] = texture(uTextures[_92 * 3 * 1 + _96 * 1 + _98], vUV); } diff --git a/reference/opt/shaders/frag/for-loop-init.frag b/reference/opt/shaders/frag/for-loop-init.frag index f7df5ec..626d7c8 100644 --- a/reference/opt/shaders/frag/for-loop-init.frag +++ b/reference/opt/shaders/frag/for-loop-init.frag @@ -6,36 +6,26 @@ layout(location = 0) out mediump int FragColor; void main() { - int _12; - mediump int _27; - int _26; - mediump int _43; - mediump int _59; - mediump int _83; - ivec2 _93; - ivec2 _139; - mediump int _62; - mediump int _128; FragColor = 16; - for (int _140 = 0; _140 < 25; _27 = _140 + 1, _140 = _27) + for (int _140 = 0; _140 < 25; _140++) { FragColor += 10; } - for (int _141 = 1; _141 < 30; _43 = _141 + 1, _141 = _43) + for (int _141 = 1; _141 < 30; _141++) { FragColor += 11; } int _142; _142 = 0; - for (; _142 < 20; _59 = _142 + 1, _142 = _59) + for (; _142 < 20; _142++) { FragColor += 12; } - _62 = _142 + 3; + mediump int _62 = _142 + 3; FragColor += _62; if (_62 == 40) { - for (int _143 = 0; _143 < 40; _83 = _143 + 1, _143 = _83) + for (int _143 = 0; _143 < 40; _143++) { FragColor += 13; } @@ -47,11 +37,12 @@ void main() } ivec2 _144; _144 = ivec2(0); + ivec2 _139; for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139) { FragColor += _144.y; } - for (int _145 = _62; _145 < 40; _128 = _145 + 1, _145 = _128) + for (int _145 = _62; _145 < 40; _145++) { FragColor += _145; } diff --git a/reference/opt/shaders/tesc/water_tess.tesc b/reference/opt/shaders/tesc/water_tess.tesc index 0e2ec69..0320fff 100644 --- a/reference/opt/shaders/tesc/water_tess.tesc +++ b/reference/opt/shaders/tesc/water_tess.tesc @@ -18,20 +18,17 @@ layout(location = 0) in vec2 vPatchPosBase[]; void main() { - bool _515; - bool _524; vec2 _430 = (vPatchPosBase[0] - vec2(10.0)) * _41.uScale.xy; vec2 _440 = ((vPatchPosBase[0] + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; vec3 _445 = vec3(_430.x, -10.0, _430.y); vec3 _450 = vec3(_440.x, 10.0, _440.y); vec3 _454 = (_445 + _450) * 0.5; float _459 = 0.5 * length(_450 - _445); - _515 = any(lessThanEqual(vec3(dot(_41.uFrustum[0], vec4(_454, 1.0)), dot(_41.uFrustum[1], vec4(_454, 1.0)), dot(_41.uFrustum[2], vec4(_454, 1.0))), vec3(-_459))); + bool _515 = any(lessThanEqual(vec3(dot(_41.uFrustum[0], vec4(_454, 1.0)), dot(_41.uFrustum[1], vec4(_454, 1.0)), dot(_41.uFrustum[2], vec4(_454, 1.0))), vec3(-_459))); bool _525; if (!_515) { - _524 = any(lessThanEqual(vec3(dot(_41.uFrustum[3], vec4(_454, 1.0)), dot(_41.uFrustum[4], vec4(_454, 1.0)), dot(_41.uFrustum[5], vec4(_454, 1.0))), vec3(-_459))); - _525 = _524; + _525 = any(lessThanEqual(vec3(dot(_41.uFrustum[3], vec4(_454, 1.0)), dot(_41.uFrustum[4], vec4(_454, 1.0)), dot(_41.uFrustum[5], vec4(_454, 1.0))), vec3(-_459))); } else { diff --git a/reference/opt/shaders/vert/ground.vert b/reference/opt/shaders/vert/ground.vert index 19abb3e..790c4c8 100644 --- a/reference/opt/shaders/vert/ground.vert +++ b/reference/opt/shaders/vert/ground.vert @@ -51,9 +51,6 @@ layout(location = 0) out vec2 TexCoord; void main() { - uint _372; - uint _28; - uint _376; float _300 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); float _302 = floor(_300); uint _307 = uint(_302); @@ -62,8 +59,7 @@ void main() uint _395; if (_309.x < 32u) { - _372 = _316.x; - _395 = _372; + _395 = _316.x; } else { @@ -72,8 +68,7 @@ void main() uint _396; if (_309.y < 32u) { - _376 = _316.y; - _396 = _376; + _396 = _316.y; } else { diff --git a/reference/opt/shaders/vert/ocean.vert b/reference/opt/shaders/vert/ocean.vert index b363465..d37a0a8 100644 --- a/reference/opt/shaders/vert/ocean.vert +++ b/reference/opt/shaders/vert/ocean.vert @@ -54,11 +54,6 @@ uvec4 _483; void main() { - uint _443; - uint _28; - uint _449; - uint _455; - uint _461; float _350 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); float _352 = floor(_350); uint _357 = uint(_352); @@ -67,8 +62,7 @@ void main() uint _482; if (_359.x < 32u) { - _443 = _366.x; - _482 = _443; + _482 = _366.x; } else { @@ -79,8 +73,7 @@ void main() uint _484; if (_359.y < 32u) { - _449 = _366.x; - _484 = _449; + _484 = _366.x; } else { @@ -91,8 +84,7 @@ void main() uint _485; if (_359.x < 32u) { - _455 = _366.y; - _485 = _455; + _485 = _366.y; } else { @@ -103,8 +95,7 @@ void main() uint _486; if (_359.y < 32u) { - _461 = _366.y; - _486 = _461; + _486 = _366.y; } else { diff --git a/reference/shaders-hlsl/asm/frag/unreachable.asm.frag b/reference/shaders-hlsl/asm/frag/unreachable.asm.frag index aacadb9..3d99edc 100644 --- a/reference/shaders-hlsl/asm/frag/unreachable.asm.frag +++ b/reference/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -15,8 +15,6 @@ float4 _21; void frag_main() { - float4 _15; - float4 _17; float4 _24; float4 _33; _24 = _21; diff --git a/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag index 9c9e087..204d3b8 100644 --- a/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -104,12 +104,6 @@ struct main0_out fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d SpecularMapTexture [[texture(7)]]) { main0_out out = {}; - float4 _178; - float4 _191; - float4 _205; - float4 _218; - float4 _283; - float4 _296; bool _173; VertexOutput _128 = _121; _128.HPosition = gl_FragCoord; @@ -148,15 +142,13 @@ fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[positio _173 = 0.0 == 0.0; if (_173) { - _178 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); - _193 = _178; + _193 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); break; } else { float _180 = 1.0 / (1.0 - 0.0); - _191 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - _193 = _191; + _193 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); break; } _193 = _192; @@ -167,15 +159,13 @@ fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[positio { if (_173) { - _205 = NormalMapTexture.sample(NormalMapSampler, _166); - _220 = _205; + _220 = NormalMapTexture.sample(NormalMapSampler, _166); break; } else { float _207 = 1.0 / (1.0 - 0.0); - _218 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - _220 = _218; + _220 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); break; } _220 = _219; @@ -195,15 +185,13 @@ fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[positio { if (0.75 == 0.0) { - _283 = SpecularMapTexture.sample(SpecularMapSampler, _166); - _298 = _283; + _298 = SpecularMapTexture.sample(SpecularMapSampler, _166); break; } else { float _285 = 1.0 / (1.0 - 0.75); - _296 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - _298 = _296; + _298 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); break; } _298 = _297; diff --git a/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag index f352e40..036774d 100644 --- a/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag +++ b/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag @@ -5,9 +5,7 @@ using namespace metal; fragment void main0() { - int _16; - int _23; - for (int _22 = 35; _22 >= 0; _23 = _22 - 1, _22 = _23) + for (int _22 = 35; _22 >= 0; _22--) { } } diff --git a/reference/shaders-msl/asm/frag/unreachable.asm.frag b/reference/shaders-msl/asm/frag/unreachable.asm.frag index c7c9a2d..b0555c0 100644 --- a/reference/shaders-msl/asm/frag/unreachable.asm.frag +++ b/reference/shaders-msl/asm/frag/unreachable.asm.frag @@ -18,8 +18,6 @@ struct main0_out fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; - float4 _15; - float4 _17; float4 _24; float4 _33; _24 = _21; diff --git a/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag index 2b16105..78ff34f 100644 --- a/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -97,12 +97,6 @@ vec4 _297; void main() { - vec4 _178; - vec4 _191; - vec4 _205; - vec4 _218; - vec4 _283; - vec4 _296; bool _173; VertexOutput _128 = _121; _128.HPosition = gl_FragCoord; @@ -141,15 +135,13 @@ void main() _173 = 0.0 == 0.0; if (_173) { - _178 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); - _193 = _178; + _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); break; } else { float _180 = 1.0 / (1.0 - 0.0); - _191 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - _193 = _191; + _193 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); break; } _193 = _192; @@ -160,15 +152,13 @@ void main() { if (_173) { - _205 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); - _220 = _205; + _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); break; } else { float _207 = 1.0 / (1.0 - 0.0); - _218 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - _220 = _218; + _220 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); break; } _220 = _219; @@ -188,15 +178,13 @@ void main() { if (0.75 == 0.0) { - _283 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); - _298 = _283; + _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); break; } else { float _285 = 1.0 / (1.0 - 0.75); - _296 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - _298 = _296; + _298 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); break; } _298 = _297; diff --git a/reference/shaders/asm/frag/phi-loop-variable.asm.frag b/reference/shaders/asm/frag/phi-loop-variable.asm.frag index 0fb5010..786ac74 100644 --- a/reference/shaders/asm/frag/phi-loop-variable.asm.frag +++ b/reference/shaders/asm/frag/phi-loop-variable.asm.frag @@ -2,9 +2,7 @@ void main() { - int _16; - int _23; - for (int _22 = 35; _22 >= 0; _23 = _22 - 1, _22 = _23) + for (int _22 = 35; _22 >= 0; _22--) { } } diff --git a/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag index d4cd58e..3917594 100644 --- a/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ b/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -14,13 +14,10 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - vec3 _14; - vec3 _29; - int _16; - int _32; vec3 _28; _28 = vec3(0.0); - for (int _31 = 0; _31 < 4; _32 = _31 + 1, _28 = _29, _31 = _32) + vec3 _29; + for (int _31 = 0; _31 < 4; _28 = _29, _31++) { _29 = _28 + _6.g_MyStruct[_31].color.xyz; } diff --git a/reference/shaders/asm/frag/unreachable.asm.frag b/reference/shaders/asm/frag/unreachable.asm.frag index 0ada3ea..e75090a 100644 --- a/reference/shaders/asm/frag/unreachable.asm.frag +++ b/reference/shaders/asm/frag/unreachable.asm.frag @@ -7,8 +7,6 @@ vec4 _21; void main() { - vec4 _15; - vec4 _17; vec4 _24; vec4 _33; _24 = _21; diff --git a/reference/shaders/tesc/water_tess.tesc b/reference/shaders/tesc/water_tess.tesc index 3f51d55..26611b8 100644 --- a/reference/shaders/tesc/water_tess.tesc +++ b/reference/shaders/tesc/water_tess.tesc @@ -18,8 +18,6 @@ layout(location = 0) in vec2 vPatchPosBase[]; bool frustum_cull(vec2 p0) { - bool _205; - bool _214; vec2 min_xz = (p0 - vec2(10.0)) * _41.uScale.xy; vec2 max_xz = ((p0 + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; vec3 bb_min = vec3(min_xz.x, -10.0, min_xz.y); @@ -28,12 +26,12 @@ bool frustum_cull(vec2 p0) float radius = 0.5 * length(bb_max - bb_min); vec3 f0 = vec3(dot(_41.uFrustum[0], vec4(center, 1.0)), dot(_41.uFrustum[1], vec4(center, 1.0)), dot(_41.uFrustum[2], vec4(center, 1.0))); vec3 f1 = vec3(dot(_41.uFrustum[3], vec4(center, 1.0)), dot(_41.uFrustum[4], vec4(center, 1.0)), dot(_41.uFrustum[5], vec4(center, 1.0))); - _205 = any(lessThanEqual(f0, vec3(-radius))); + vec3 _199 = f0; + bool _205 = any(lessThanEqual(_199, vec3(-radius))); bool _215; if (!_205) { - _214 = any(lessThanEqual(f1, vec3(-radius))); - _215 = _214; + _215 = any(lessThanEqual(f1, vec3(-radius))); } else { diff --git a/spirv_cross.cpp b/spirv_cross.cpp index 6736373..c2f9396 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -3129,36 +3129,12 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) accessed_variables_to_block[phi.function_variable].insert(block.self); // Phi variables are also accessed in our target branch block. accessed_variables_to_block[phi.function_variable].insert(next.self); + + notify_variable_access(phi.local_variable, block.self); } } }; - // A Phi node might be reading other phi variables as input, so check for this as well. - for (auto &phi : block.phi_variables) - { - if (id_is_phi_variable(phi.local_variable)) - accessed_variables_to_block[phi.local_variable].insert(block.self); - else - { - // Temporary variable, due to potential issues with scoping, - // always declare these variables up-front in the entry block. - if (!compiler.hoisted_temporaries.count(phi.local_variable)) - { - auto *undef = compiler.maybe_get(phi.local_variable); - // Undef variables are declared as global variables without initializer. - // Never declare these variables. - if (!undef) - { - auto &var = compiler.get(phi.function_variable); - auto &entry_block = compiler.get(entry.entry_block); - entry_block.declare_temporary.emplace_back(var.basetype, phi.local_variable); - compiler.hoisted_temporaries.insert(phi.local_variable); - compiler.forced_temporaries.insert(phi.local_variable); - } - } - } - } - switch (block.terminator) { case SPIRBlock::Direct: @@ -3212,6 +3188,11 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) bool handle(spv::Op op, const uint32_t *args, uint32_t length) { + // Keep track of the types of temporaries, so we can hoist them out as necessary. + uint32_t result_type, result_id; + if (compiler.instruction_to_result_type(result_type, result_id, op, args, length)) + result_id_to_type[result_id] = result_type; + switch (op) { case OpStore: @@ -3374,6 +3355,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) SPIRFunction &entry; std::unordered_map> accessed_variables_to_block; std::unordered_map> accessed_temporaries_to_block; + std::unordered_map result_id_to_type; std::unordered_map> complete_write_variables_to_block; const SPIRBlock *current_block = nullptr; } handler(*this, entry); @@ -3445,18 +3427,48 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) for (auto &var : handler.accessed_temporaries_to_block) { + auto itr = handler.result_id_to_type.find(var.first); + + if (itr == end(handler.result_id_to_type)) + { + // We found a false positive ID being used, ignore. + // This should probably be an assert. + continue; + } + DominatorBuilder builder(cfg); // Figure out which block is dominating all accesses of those temporaries. auto &blocks = var.second; for (auto &block : blocks) + { builder.add_block(block); - builder.lift_continue_block_dominator(); + // If a temporary is used in more than one block, we might have to lift continue block + // access up to loop header like we did for variables. + if (blocks.size() != 1 && this->is_continue(block)) + builder.add_block(continue_block_to_loop_header[block]); + } uint32_t dominating_block = builder.get_dominator(); if (dominating_block) - expected_dominator_for_temporary[var.first] = dominating_block; + { + // If we touch a variable in the dominating block, this is the expected setup. + // SPIR-V normally mandates this, but we have extra cases for temporary use inside loops. + bool first_use_is_dominator = blocks.count(dominating_block) != 0; + + if (!first_use_is_dominator) + { + // This should be very rare, but if we try to declare a temporary inside a loop, + // and that temporary is used outside the loop as well (spirv-opt inliner likes this) + // we should actually emit the temporary outside the loop. + hoisted_temporaries.insert(var.first); + forced_temporaries.insert(var.first); + + auto &block_temporaries = get(dominating_block).declare_temporary; + block_temporaries.emplace_back(handler.result_id_to_type[var.first], var.first); + } + } } unordered_set seen_blocks; @@ -3897,3 +3909,43 @@ std::string Compiler::get_remapped_declared_block_name(uint32_t id) const return block_name.empty() ? get_block_fallback_name(id) : block_name; } } + +bool Compiler::instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args, + uint32_t length) +{ + // Most instructions follow the pattern of . + // There are some exceptions. + switch (op) + { + case OpStore: + case OpCopyMemory: + case OpCopyMemorySized: + case OpImageWrite: + case OpAtomicStore: + case OpAtomicFlagClear: + case OpEmitStreamVertex: + case OpEndStreamPrimitive: + case OpControlBarrier: + case OpMemoryBarrier: + case OpGroupWaitEvents: + case OpRetainEvent: + case OpReleaseEvent: + case OpSetUserEventStatus: + case OpCaptureEventProfilingInfo: + case OpCommitReadPipe: + case OpCommitWritePipe: + case OpGroupCommitReadPipe: + case OpGroupCommitWritePipe: + return false; + + default: + if (length > 1) + { + result_type = args[0]; + result_id = args[1]; + return true; + } + else + return false; + } +} diff --git a/spirv_cross.hpp b/spirv_cross.hpp index d5ecf04..ce928f7 100644 --- a/spirv_cross.hpp +++ b/spirv_cross.hpp @@ -705,10 +705,6 @@ protected: std::unordered_set forwarded_temporaries; std::unordered_set hoisted_temporaries; - // Based on initial analysis, we expect a temporary to be declared in a certain block. - // If we end up declaring a temporary in another block, we'll hoist out that temporary later. - std::unordered_map expected_dominator_for_temporary; - uint64_t active_input_builtins = 0; uint64_t active_output_builtins = 0; // Traverses all reachable opcodes and sets active_builtins to a bitmask of all builtin variables which are accessed in the shader. @@ -748,6 +744,9 @@ protected: std::vector declared_capabilities; std::vector declared_extensions; std::unordered_map declared_block_names; + + bool instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args, + uint32_t length); }; } diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 609e3de..c7b3656 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -2745,24 +2745,6 @@ string CompilerGLSL::declare_temporary(uint32_t result_type, uint32_t result_id) auto &type = get(result_type); auto flags = meta[result_id].decoration.decoration_flags; - auto itr = expected_dominator_for_temporary.find(result_id); - if (!hoisted_temporaries.count(result_id) && itr != end(expected_dominator_for_temporary)) - { - if (current_emitting_block->self != itr->second) - { - // This should be very rare, but if we try to declare a temporary inside a loop, - // and that temporary is used outside the loop as well (spirv-opt inliner likes this) - // we should actually emit the temporary outside the loop. We don't know the result types - // before declaring the temporary unless we check every possible opcode during CFG traversal, - // so do it lazily like this where we fallback in these rare scenarios. - - hoisted_temporaries.insert(result_id); - forced_temporaries.insert(result_id); - get(itr->second).declare_temporary.emplace_back(result_type, result_id); - force_recompile = true; - } - } - // If we're declaring temporaries inside continue blocks, // we must declare the temporary in the loop header so that the continue block can avoid declaring new variables. if (current_continue_block && !hoisted_temporaries.count(result_id)) @@ -2774,6 +2756,7 @@ string CompilerGLSL::declare_temporary(uint32_t result_type, uint32_t result_id) }) == end(header.declare_temporary)) { header.declare_temporary.emplace_back(result_type, result_id); + hoisted_temporaries.insert(result_id); force_recompile = true; } diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 7f5186c..2ca6c06 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -3449,34 +3449,9 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui } // If it has one, keep track of the instruction's result type, mapped by ID - switch (opcode) - { - case OpStore: - case OpCopyMemory: - case OpCopyMemorySized: - case OpImageWrite: - case OpAtomicStore: - case OpAtomicFlagClear: - case OpEmitStreamVertex: - case OpEndStreamPrimitive: - case OpControlBarrier: - case OpMemoryBarrier: - case OpGroupWaitEvents: - case OpRetainEvent: - case OpReleaseEvent: - case OpSetUserEventStatus: - case OpCaptureEventProfilingInfo: - case OpCommitReadPipe: - case OpCommitWritePipe: - case OpGroupCommitReadPipe: - case OpGroupCommitWritePipe: - break; - - default: - if (length > 1) - result_types[args[1]] = args[0]; - break; - } + uint32_t result_type, result_id; + if (compiler.instruction_to_result_type(result_type, result_id, opcode, args, length)) + result_types[result_id] = result_type; return true; }