From 44b3216611df7449a7b4f5f22a2f91a587fcb447 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Fri, 16 Dec 2016 14:01:09 +0100 Subject: [PATCH] Sort loop variables to make sure Travis CI runs are reproducable. --- reference/shaders/frag/for-loop-init.frag | 2 +- spirv_cross.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/reference/shaders/frag/for-loop-init.frag b/reference/shaders/frag/for-loop-init.frag index 98f1b8ce..7c22e5c7 100644 --- a/reference/shaders/frag/for-loop-init.frag +++ b/reference/shaders/frag/for-loop-init.frag @@ -11,7 +11,7 @@ void main() { FragColor += 10; } - for (mediump int j = 4, i_1 = 1; i_1 < 30; i_1++, j += 4) + for (mediump int i_1 = 1, j = 4; i_1 < 30; i_1++, j += 4) { FragColor += 11; } diff --git a/spirv_cross.cpp b/spirv_cross.cpp index 39ea21f6..64130575 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -3025,6 +3025,9 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // We have a loop variable. header_block.loop_variables.push_back(loop_variable.first); + // Need to sort here as variables come from an unordered container, and pushing stuff in wrong order + // will break reproducability in regression runs. + sort(begin(header_block.loop_variables), end(header_block.loop_variables)); get(loop_variable.first).loop_variable = true; } }