summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-06-12 13:23:48 +0200
committerMarek Olšák <[email protected]>2013-07-02 17:02:14 +0200
commitb3d8b4c0b423539f17c13713673cfeb6d66ff7ed (patch)
tree58ea816c6292ff40f5b820a1bdc2398b78708ebd /src/glsl/linker.cpp
parent3c555827c3e2fdb84ee4b4b8fd8296985cbb1fda (diff)
glsl/linker: eliminate unused and set-but-unused built-in varyings
This eliminates built-in varyings such as gl_Color, gl_SecondaryColor, gl_TexCoord, and gl_FogFragCoord if they are unused by the next stage or not written at all (e.g. gl_TexCoord elements). The gl_TexCoord array is broken down into separate vec4s if needed. v2: - use a switch statement in varying_info_visitor::visit(ir_variable*) - use snprintf - disable the optimization for GLES2 Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/linker.cpp')
-rw-r--r--src/glsl/linker.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 6d7357820c9..ba97ade25e0 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1887,6 +1887,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
goto done;
}
+ do_dead_builtin_varyings(ctx, sh->ir, NULL,
+ num_tfeedback_decls, tfeedback_decls);
+
demote_shader_inputs_and_outputs(sh, ir_var_shader_out);
/* Eliminate code that is now dead due to unused outputs being demoted.
@@ -1895,11 +1898,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
;
}
else if (first == MESA_SHADER_FRAGMENT) {
- /* If the program only contains a fragment shader, just demote
- * user-defined varyings.
+ /* If the program only contains a fragment shader...
*/
gl_shader *const sh = prog->_LinkedShaders[first];
+ do_dead_builtin_varyings(ctx, NULL, sh->ir,
+ num_tfeedback_decls, tfeedback_decls);
+
demote_shader_inputs_and_outputs(sh, ir_var_shader_in);
while (do_dead_code(sh->ir, false))
@@ -1919,6 +1924,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
tfeedback_decls))
goto done;
+ do_dead_builtin_varyings(ctx, sh_i->ir, sh_next->ir,
+ next == MESA_SHADER_FRAGMENT ? num_tfeedback_decls : 0,
+ tfeedback_decls);
+
demote_shader_inputs_and_outputs(sh_i, ir_var_shader_out);
demote_shader_inputs_and_outputs(sh_next, ir_var_shader_in);