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>
This commit is contained in:
@@ -77,7 +77,7 @@ bool do_copy_propagation(exec_list *instructions);
|
|||||||
bool do_copy_propagation_elements(exec_list *instructions);
|
bool do_copy_propagation_elements(exec_list *instructions);
|
||||||
bool do_constant_propagation(exec_list *instructions);
|
bool do_constant_propagation(exec_list *instructions);
|
||||||
void do_dead_builtin_varyings(struct gl_context *ctx,
|
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,
|
unsigned num_tfeedback_decls,
|
||||||
class tfeedback_decl *tfeedback_decls);
|
class tfeedback_decl *tfeedback_decls);
|
||||||
bool do_dead_code(exec_list *instructions, bool uniform_locations_assigned);
|
bool do_dead_code(exec_list *instructions, bool uniform_locations_assigned);
|
||||||
|
@@ -2091,7 +2091,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_dead_builtin_varyings(ctx, sh->ir, NULL,
|
do_dead_builtin_varyings(ctx, sh, NULL,
|
||||||
num_tfeedback_decls, tfeedback_decls);
|
num_tfeedback_decls, tfeedback_decls);
|
||||||
|
|
||||||
demote_shader_inputs_and_outputs(sh, ir_var_shader_out);
|
demote_shader_inputs_and_outputs(sh, ir_var_shader_out);
|
||||||
@@ -2106,7 +2106,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
*/
|
*/
|
||||||
gl_shader *const sh = prog->_LinkedShaders[first];
|
gl_shader *const sh = prog->_LinkedShaders[first];
|
||||||
|
|
||||||
do_dead_builtin_varyings(ctx, NULL, sh->ir,
|
do_dead_builtin_varyings(ctx, NULL, sh,
|
||||||
num_tfeedback_decls, tfeedback_decls);
|
num_tfeedback_decls, tfeedback_decls);
|
||||||
|
|
||||||
demote_shader_inputs_and_outputs(sh, ir_var_shader_in);
|
demote_shader_inputs_and_outputs(sh, ir_var_shader_in);
|
||||||
@@ -2130,7 +2130,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
tfeedback_decls, gs_input_vertices))
|
tfeedback_decls, gs_input_vertices))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
do_dead_builtin_varyings(ctx, sh_i->ir, sh_next->ir,
|
do_dead_builtin_varyings(ctx, sh_i, sh_next,
|
||||||
next == MESA_SHADER_FRAGMENT ? num_tfeedback_decls : 0,
|
next == MESA_SHADER_FRAGMENT ? num_tfeedback_decls : 0,
|
||||||
tfeedback_decls);
|
tfeedback_decls);
|
||||||
|
|
||||||
|
@@ -409,7 +409,7 @@ lower_texcoord_array(exec_list *ir, const varying_info_visitor *info)
|
|||||||
|
|
||||||
void
|
void
|
||||||
do_dead_builtin_varyings(struct gl_context *ctx,
|
do_dead_builtin_varyings(struct gl_context *ctx,
|
||||||
exec_list *producer, exec_list *consumer,
|
gl_shader *producer, gl_shader *consumer,
|
||||||
unsigned num_tfeedback_decls,
|
unsigned num_tfeedback_decls,
|
||||||
tfeedback_decl *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);
|
varying_info_visitor consumer_info(ir_var_shader_in);
|
||||||
|
|
||||||
if (producer) {
|
if (producer) {
|
||||||
producer_info.get(producer, num_tfeedback_decls, tfeedback_decls);
|
producer_info.get(producer->ir, num_tfeedback_decls, tfeedback_decls);
|
||||||
|
|
||||||
if (!consumer) {
|
if (!consumer) {
|
||||||
/* At least eliminate unused gl_TexCoord elements. */
|
/* At least eliminate unused gl_TexCoord elements. */
|
||||||
if (producer_info.lower_texcoord_array) {
|
if (producer_info.lower_texcoord_array) {
|
||||||
lower_texcoord_array(producer, &producer_info);
|
lower_texcoord_array(producer->ir, &producer_info);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consumer) {
|
if (consumer) {
|
||||||
consumer_info.get(consumer, 0, NULL);
|
consumer_info.get(consumer->ir, 0, NULL);
|
||||||
|
|
||||||
if (!producer) {
|
if (!producer) {
|
||||||
/* At least eliminate unused gl_TexCoord elements. */
|
/* At least eliminate unused gl_TexCoord elements. */
|
||||||
if (consumer_info.lower_texcoord_array) {
|
if (consumer_info.lower_texcoord_array) {
|
||||||
lower_texcoord_array(consumer, &consumer_info);
|
lower_texcoord_array(consumer->ir, &consumer_info);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Eliminate the varyings unused by the other shader. */
|
/* Eliminate the outputs unused by the consumer. */
|
||||||
if (producer_info.lower_texcoord_array ||
|
if (producer_info.lower_texcoord_array ||
|
||||||
producer_info.color_usage ||
|
producer_info.color_usage ||
|
||||||
producer_info.has_fog) {
|
producer_info.has_fog) {
|
||||||
replace_varyings_visitor(producer,
|
replace_varyings_visitor(producer->ir,
|
||||||
&producer_info,
|
&producer_info,
|
||||||
consumer_info.texcoord_usage,
|
consumer_info.texcoord_usage,
|
||||||
consumer_info.color_usage,
|
consumer_info.color_usage,
|
||||||
consumer_info.has_fog);
|
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 ||
|
if (consumer_info.lower_texcoord_array ||
|
||||||
consumer_info.color_usage ||
|
consumer_info.color_usage ||
|
||||||
consumer_info.has_fog) {
|
consumer_info.has_fog) {
|
||||||
replace_varyings_visitor(consumer,
|
replace_varyings_visitor(consumer->ir,
|
||||||
&consumer_info,
|
&consumer_info,
|
||||||
producer_info.texcoord_usage,
|
producer_info.texcoord_usage,
|
||||||
producer_info.color_usage,
|
producer_info.color_usage,
|
||||||
|
Reference in New Issue
Block a user