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 8d2c7e5..2ee8def 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 @@ -18,8 +18,8 @@ fragment main0_out main0() float4 _20; float4 _21; float4 _38; - float4 _52; float4 _51; + float4 _52; _51 = _50; for (;;) { diff --git a/reference/opt/shaders-msl/comp/loop.comp b/reference/opt/shaders-msl/comp/loop.comp index 4ab12a3..61174ec 100644 --- a/reference/opt/shaders-msl/comp/loop.comp +++ b/reference/opt/shaders-msl/comp/loop.comp @@ -43,8 +43,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic uint _186; if (_24.in_data[gl_GlobalInvocationID.x].y == 20.0) { - uint _184; int _183; + uint _184; _183 = 0; _184 = 0u; for (;;) diff --git a/reference/opt/shaders-msl/comp/torture-loop.comp b/reference/opt/shaders-msl/comp/torture-loop.comp index b8c732e..0c1218e 100644 --- a/reference/opt/shaders-msl/comp/torture-loop.comp +++ b/reference/opt/shaders-msl/comp/torture-loop.comp @@ -31,8 +31,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic uint _73; int _83; _30 = _24.in_data[gl_GlobalInvocationID.x]; - int _94; float4 _93; + int _94; _93 = _30; _94 = 0; for (;;) @@ -55,8 +55,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic int _96; _95 = _93; _96 = _40; - uint _101; 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) { _100 = _95; 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 46c8f9e..4f35769 100644 --- a/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag +++ b/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag @@ -11,8 +11,8 @@ void main() vec4 _20; vec4 _21; vec4 _38; - vec4 _52; vec4 _51; + vec4 _52; _51 = _50; for (;;) { diff --git a/reference/opt/shaders/comp/torture-loop.comp b/reference/opt/shaders/comp/torture-loop.comp index c6fc965..1096703 100644 --- a/reference/opt/shaders/comp/torture-loop.comp +++ b/reference/opt/shaders/comp/torture-loop.comp @@ -29,8 +29,8 @@ void main() uint _73; int _83; _30 = _24.in_data[gl_GlobalInvocationID.x]; - int _94; vec4 _93; + int _94; _93 = _30; _94 = 0; for (;;) @@ -53,8 +53,8 @@ void main() int _96; _95 = _93; _96 = _40; - uint _101; 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) { _100 = _95; diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index c49d608..3feae23 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -7900,6 +7900,9 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method void CompilerGLSL::flush_undeclared_variables(SPIRBlock &block) { + // Enforce declaration order for regression testing purposes. + sort(begin(block.dominated_variables), end(block.dominated_variables)); + for (auto &v : block.dominated_variables) { auto &var = get(v);