X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fglsl%2Fopt_dead_builtin_varyings.cpp;h=853847ebfd55748fa04caedfbe0ade4d7a4f6ce1;hb=f5808e60888a8889b93ae9f0516c6319ff17c4f6;hp=37bcbccf0c5f9578655956c2bbcd1069a78279b6;hpb=741744f691d6ef63e9f9a4c03136f969f2ffb0bf;p=mesa.git diff --git a/src/compiler/glsl/opt_dead_builtin_varyings.cpp b/src/compiler/glsl/opt_dead_builtin_varyings.cpp index 37bcbccf0c5..853847ebfd5 100644 --- a/src/compiler/glsl/opt_dead_builtin_varyings.cpp +++ b/src/compiler/glsl/opt_dead_builtin_varyings.cpp @@ -46,13 +46,14 @@ * The same is done for the gl_FragData fragment shader output. */ -#include "main/core.h" /* for snprintf and ARRAY_SIZE */ #include "ir.h" #include "ir_rvalue_visitor.h" #include "ir_optimization.h" #include "ir_print_visitor.h" #include "compiler/glsl_types.h" #include "link_varyings.h" +#include "main/mtypes.h" +#include "util/u_string.h" namespace { @@ -85,10 +86,14 @@ public: { ir_variable *var = ir->variable_referenced(); - if (!var || var->data.mode != this->mode || !var->type->is_array()) + if (!var || var->data.mode != this->mode || !var->type->is_array() || + !is_gl_identifier(var->name)) return visit_continue; - if (this->find_frag_outputs && var->data.location == FRAG_RESULT_DATA0) { + /* Only match gl_FragData[], not gl_SecondaryFragDataEXT[] or + * gl_LastFragData[]. + */ + if (this->find_frag_outputs && strcmp(var->name, "gl_FragData") == 0) { this->fragdata_array = var; ir_constant *index = ir->array_index->as_constant(); @@ -143,7 +148,8 @@ public: if (var->data.mode != this->mode || !var->type->is_array()) return visit_continue; - if (this->find_frag_outputs && var->data.location == FRAG_RESULT_DATA0) { + if (this->find_frag_outputs && var->data.location == FRAG_RESULT_DATA0 && + var->data.index == 0) { /* This is a whole array dereference. */ this->fragdata_usage |= (1 << var->type->array_size()) - 1; this->lower_fragdata_array = false; @@ -269,7 +275,7 @@ public: */ class replace_varyings_visitor : public ir_rvalue_visitor { public: - replace_varyings_visitor(struct gl_shader *sha, + replace_varyings_visitor(struct gl_linked_shader *sha, const varying_info_visitor *info, unsigned external_texcoord_usage, unsigned external_color_usage, @@ -375,7 +381,7 @@ public: new_var[i]->data.explicit_index = 0; } - ir->head->insert_before(new_var[i]); + ir->get_head_raw()->insert_before(new_var[i]); } } } @@ -496,7 +502,7 @@ public: } private: - struct gl_shader *shader; + struct gl_linked_shader *shader; const varying_info_visitor *info; ir_variable *new_fragdata[MAX_DRAW_BUFFERS]; ir_variable *new_texcoord[MAX_TEXTURE_COORD_UNITS]; @@ -508,7 +514,7 @@ private: } /* anonymous namespace */ static void -lower_texcoord_array(struct gl_shader *shader, const varying_info_visitor *info) +lower_texcoord_array(struct gl_linked_shader *shader, const varying_info_visitor *info) { replace_varyings_visitor(shader, info, (1 << MAX_TEXTURE_COORD_UNITS) - 1, @@ -516,7 +522,7 @@ lower_texcoord_array(struct gl_shader *shader, const varying_info_visitor *info) } static void -lower_fragdata_array(struct gl_shader *shader) +lower_fragdata_array(struct gl_linked_shader *shader) { varying_info_visitor info(ir_var_shader_out, true); info.get(shader->ir, 0, NULL); @@ -527,7 +533,8 @@ lower_fragdata_array(struct gl_shader *shader) void do_dead_builtin_varyings(struct gl_context *ctx, - gl_shader *producer, gl_shader *consumer, + gl_linked_shader *producer, + gl_linked_shader *consumer, unsigned num_tfeedback_decls, tfeedback_decl *tfeedback_decls) { @@ -551,6 +558,9 @@ do_dead_builtin_varyings(struct gl_context *ctx, if (producer) { producer_info.get(producer->ir, num_tfeedback_decls, tfeedback_decls); + if (producer->Stage == MESA_SHADER_TESS_CTRL) + producer_info.lower_texcoord_array = false; + if (!consumer) { /* At least eliminate unused gl_TexCoord elements. */ if (producer_info.lower_texcoord_array) { @@ -563,6 +573,9 @@ do_dead_builtin_varyings(struct gl_context *ctx, if (consumer) { consumer_info.get(consumer->ir, 0, NULL); + if (consumer->Stage != MESA_SHADER_FRAGMENT) + consumer_info.lower_texcoord_array = false; + if (!producer) { /* At least eliminate unused gl_TexCoord elements. */ if (consumer_info.lower_texcoord_array) {