diff options
author | Paul Berry <[email protected]> | 2012-06-20 12:49:29 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2012-07-19 10:02:21 -0700 |
commit | ce1d2f08f9d08bd5d49b2072a94b3d85e3169fb5 (patch) | |
tree | 3257de0c72c77ec5b3c6eeb485d3d480fb2f6bb2 /src | |
parent | a0f7b869592013b24a5bacf0ceb2bdb1e9146378 (diff) |
glsl: Set UsesDFdy appropriately for GLSL shaders.
This patch updates the ir_set_program_inouts_visitor so that it also
sets gl_fragment_program::UsesDFdy.
This is a bit of a hack (since dFdy() isn't an input or an output),
but there's no other obvious visitor to squeeze this functionality
into, and it would be silly to create a brand new visitor just for
this purpose.
v2: use local 'fprog' var to avoid repeated casting.
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ir_set_program_inouts.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp index a7415c7e3f8..845aa114477 100644 --- a/src/glsl/ir_set_program_inouts.cpp +++ b/src/glsl/ir_set_program_inouts.cpp @@ -26,8 +26,8 @@ * * Sets the InputsRead and OutputsWritten of Mesa programs. * - * Additionally, for fragment shaders, sets the InterpQualifier array and - * IsCentroid bitfield. + * Additionally, for fragment shaders, sets the InterpQualifier array, the + * IsCentroid bitfield, and the UsesDFdy flag. * * Mesa programs (gl_program, not gl_shader_program) have a set of * flags indicating which varyings are read and written. Computing @@ -61,6 +61,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(ir_dereference_variable *); virtual ir_visitor_status visit(ir_variable *); @@ -169,6 +170,16 @@ ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir) return visit_continue_with_parent; } +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_expression *ir) +{ + if (is_fragment_shader && ir->operation == ir_unop_dFdy) { + gl_fragment_program *fprog = (gl_fragment_program *) prog; + fprog->UsesDFdy = true; + } + return visit_continue; +} + void do_set_program_inouts(exec_list *instructions, struct gl_program *prog, bool is_fragment_shader) @@ -179,9 +190,10 @@ do_set_program_inouts(exec_list *instructions, struct gl_program *prog, prog->OutputsWritten = 0; prog->SystemValuesRead = 0; if (is_fragment_shader) { - memset(((gl_fragment_program *) prog)->InterpQualifier, 0, - sizeof(((gl_fragment_program *) prog)->InterpQualifier)); - ((gl_fragment_program *) prog)->IsCentroid = 0; + gl_fragment_program *fprog = (gl_fragment_program *) prog; + memset(fprog->InterpQualifier, 0, sizeof(fprog->InterpQualifier)); + fprog->IsCentroid = 0; + fprog->UsesDFdy = false; } visit_list_elements(&v, instructions); } |