summaryrefslogtreecommitdiff
path: root/src/glsl/opt_dead_builtin_varyings.cpp
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2013-08-09 22:34:45 +0200
committerMarek Olšák <marek.olsak@amd.com>2013-08-18 12:27:08 +0200
commitd13003f544417db6de44c65a0c118bd2b189458a (patch)
tree0f624838b9ff48cc4ace48050048c6c46f264052 /src/glsl/opt_dead_builtin_varyings.cpp
parenta8346a2f52d08233d376db3aa8205d0b2cc74318 (diff)
glsl: don't eliminate texcoords that can be set by GL_COORD_REPLACE
Tested by examining generated TGSI shaders from piglit/glsl-routing. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Henri Verbeet <hverbeet@gmail.com> Tested-by: Henri Verbeet <hverbeet@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/opt_dead_builtin_varyings.cpp')
-rw-r--r--src/glsl/opt_dead_builtin_varyings.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/glsl/opt_dead_builtin_varyings.cpp b/src/glsl/opt_dead_builtin_varyings.cpp
index 2e813d24ec..6745d5c64b 100644
--- a/src/glsl/opt_dead_builtin_varyings.cpp
+++ b/src/glsl/opt_dead_builtin_varyings.cpp
@@ -409,7 +409,7 @@ lower_texcoord_array(exec_list *ir, const varying_info_visitor *info)
void
do_dead_builtin_varyings(struct gl_context *ctx,
- exec_list *producer, exec_list *consumer,
+ gl_shader *producer, gl_shader *consumer,
unsigned num_tfeedback_decls,
tfeedback_decl *tfeedback_decls)
{
@@ -431,44 +431,55 @@ do_dead_builtin_varyings(struct gl_context *ctx,
varying_info_visitor consumer_info(ir_var_shader_in);
if (producer) {
- producer_info.get(producer, num_tfeedback_decls, tfeedback_decls);
+ producer_info.get(producer->ir, num_tfeedback_decls, tfeedback_decls);
if (!consumer) {
/* At least eliminate unused gl_TexCoord elements. */
if (producer_info.lower_texcoord_array) {
- lower_texcoord_array(producer, &producer_info);
+ lower_texcoord_array(producer->ir, &producer_info);
}
return;
}
}
if (consumer) {
- consumer_info.get(consumer, 0, NULL);
+ consumer_info.get(consumer->ir, 0, NULL);
if (!producer) {
/* At least eliminate unused gl_TexCoord elements. */
if (consumer_info.lower_texcoord_array) {
- lower_texcoord_array(consumer, &consumer_info);
+ lower_texcoord_array(consumer->ir, &consumer_info);
}
return;
}
}
- /* Eliminate the varyings unused by the other shader. */
+ /* Eliminate the outputs unused by the consumer. */
if (producer_info.lower_texcoord_array ||
producer_info.color_usage ||
producer_info.has_fog) {
- replace_varyings_visitor(producer,
+ replace_varyings_visitor(producer->ir,
&producer_info,
consumer_info.texcoord_usage,
consumer_info.color_usage,
consumer_info.has_fog);
}
+ /* The gl_TexCoord fragment shader inputs can be initialized
+ * by GL_COORD_REPLACE, so we can't eliminate them.
+ *
+ * This doesn't prevent elimination of the gl_TexCoord elements which
+ * are not read by the fragment shader. We want to eliminate those anyway.
+ */
+ if (consumer->Type == GL_FRAGMENT_SHADER) {
+ producer_info.texcoord_usage = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
+ }
+
+ /* Eliminate the inputs uninitialized by the producer. */
if (consumer_info.lower_texcoord_array ||
consumer_info.color_usage ||
consumer_info.has_fog) {
- replace_varyings_visitor(consumer,
+ replace_varyings_visitor(consumer->ir,
&consumer_info,
producer_info.texcoord_usage,
producer_info.color_usage,