diff options
author | Nicolai Hähnle <[email protected]> | 2016-10-18 17:35:45 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2016-10-20 10:37:06 +0200 |
commit | 3d9b57e49304f9690c4a2b50afb8cdd4d253a1df (patch) | |
tree | bc96b9fa5f197a2872f7196c7695dd7fe753b6de | |
parent | a1895685f8f341e7facf3c5705bdee99860e3082 (diff) |
st/glsl_to_tgsi: sort input and output decls by TGSI index
Fixes a regression introduced by commit 777dcf81b.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98307
Reviewed-by: Marek Olšák <[email protected]>
Cc: 13.0 <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 854decc39ac..f3764623d50 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -55,6 +55,7 @@ #include "st_glsl_types.h" #include "st_nir.h" +#include <algorithm> #define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) | \ (1 << PROGRAM_CONSTANT) | \ @@ -5873,6 +5874,29 @@ emit_compute_block_size(const struct gl_program *program, cp->LocalSize[2]); } +struct sort_inout_decls { + bool operator()(const struct inout_decl &a, const struct inout_decl &b) const { + return mapping[a.mesa_index] < mapping[b.mesa_index]; + } + + const GLuint *mapping; +}; + +/* Sort the given array of decls by the corresponding slot (TGSI file index). + * + * This is for the benefit of older drivers which are broken when the + * declarations aren't sorted in this way. + */ +static void +sort_inout_decls_by_slot(struct inout_decl *decls, + unsigned count, + const GLuint mapping[]) +{ + sort_inout_decls sorter; + sorter.mapping = mapping; + std::sort(decls, decls + count, sorter); +} + /** * Translate intermediate IR (glsl_to_tgsi_instruction) to TGSI format. * \param program the program to translate @@ -5945,6 +5969,8 @@ st_translate_program( case PIPE_SHADER_GEOMETRY: case PIPE_SHADER_TESS_EVAL: case PIPE_SHADER_TESS_CTRL: + sort_inout_decls_by_slot(program->inputs, program->num_inputs, inputMapping); + for (i = 0; i < program->num_inputs; ++i) { struct inout_decl *decl = &program->inputs[i]; unsigned slot = inputMapping[decl->mesa_index]; @@ -5997,6 +6023,8 @@ st_translate_program( case PIPE_SHADER_TESS_EVAL: case PIPE_SHADER_TESS_CTRL: case PIPE_SHADER_VERTEX: + sort_inout_decls_by_slot(program->outputs, program->num_outputs, outputMapping); + for (i = 0; i < program->num_outputs; ++i) { struct inout_decl *decl = &program->outputs[i]; unsigned slot = outputMapping[decl->mesa_index]; |