diff options
author | Paul Berry <[email protected]> | 2012-07-18 23:18:14 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2012-07-20 09:33:07 -0700 |
commit | 0f1f2ff8db8c19be27b9f51f07134091e109e4b2 (patch) | |
tree | 170072da554c3850fe4bb5d4f2773ae5b537ad88 /src/glsl/ir_set_program_inouts.cpp | |
parent | a8c092266e9885f3370bbeae15bd80ebf035d05d (diff) |
mesa: Set gl_fragment_program::UsesKill in do_set_program_inouts.
Previously, the code for setting this flag for GLSL programs was
duplicated in three places: brw_link_shader(), glsl_to_tgsi_visitor,
and ir_to_mesa_visitor. In addition to the unnecessary duplication,
there was a performance problem on i965: brw_link_shader() set the
flag before doing its final round of optimizations, which meant that
if the optimizations managed to eliminate all the discard operations,
the flag would still be set, resulting (at least in theory) in slower
performance.
This patch consolidates all of the code that sets UsesKill for GLSL
programs into do_set_program_inouts(), which already is doing a
similar job for UsesDFdy, and which occurs after i965's final round of
optimizations.
Non-GLSL programs (ARB programs and the state tracker's glBitmap
program) are unaffected.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/ir_set_program_inouts.cpp')
-rw-r--r-- | src/glsl/ir_set_program_inouts.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp index 845aa114477..e5de07e0122 100644 --- a/src/glsl/ir_set_program_inouts.cpp +++ b/src/glsl/ir_set_program_inouts.cpp @@ -62,6 +62,7 @@ public: virtual ir_visitor_status visit_enter(ir_dereference_array *); virtual ir_visitor_status visit_enter(ir_function_signature *); virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_discard *); virtual ir_visitor_status visit(ir_dereference_variable *); virtual ir_visitor_status visit(ir_variable *); @@ -180,6 +181,18 @@ ir_set_program_inouts_visitor::visit_enter(ir_expression *ir) return visit_continue; } +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_discard *) +{ + /* discards are only allowed in fragment shaders. */ + assert(is_fragment_shader); + + gl_fragment_program *fprog = (gl_fragment_program *) prog; + fprog->UsesKill = true; + + return visit_continue; +} + void do_set_program_inouts(exec_list *instructions, struct gl_program *prog, bool is_fragment_shader) @@ -194,6 +207,7 @@ do_set_program_inouts(exec_list *instructions, struct gl_program *prog, memset(fprog->InterpQualifier, 0, sizeof(fprog->InterpQualifier)); fprog->IsCentroid = 0; fprog->UsesDFdy = false; + fprog->UsesKill = false; } visit_list_elements(&v, instructions); } |