Merge pull request #415 from KhronosGroup/fix-temp-decl-order

Need to sort declared temporaries to ensure stable output.
This commit is contained in:
Hans-Kristian Arntzen 2018-01-29 10:32:36 +01:00 committed by GitHub
commit ab3907e4b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -22,9 +22,9 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic
int _94;
_93 = _24.in_data[gl_GlobalInvocationID.x];
_94 = 0;
int _48;
int _40;
float4 _46;
int _48;
for (;;)
{
_40 = _94 + 1;

View File

@ -20,9 +20,9 @@ void main()
int _94;
_93 = _24.in_data[gl_GlobalInvocationID.x];
_94 = 0;
int _48;
int _40;
vec4 _46;
int _48;
for (;;)
{
_40 = _94 + 1;

View File

@ -8265,6 +8265,10 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
bool emitted_for_loop_header = false;
// If we need to force temporaries for certain IDs due to continue blocks, do it before starting loop header.
// Need to sort these to ensure that reference output is stable.
sort(begin(block.declare_temporary), end(block.declare_temporary),
[](const pair<uint32_t, uint32_t> &a, const pair<uint32_t, uint32_t> &b) { return a.second < b.second; });
for (auto &tmp : block.declare_temporary)
{
auto flags = meta[tmp.second].decoration.decoration_flags;