[Mesa-dev] [PATCH 3/4] glsl: Set UsesDFdy appropriately for GLSL shaders.

Paul Berry stereotype441 at gmail.com
Wed Jul 18 16:24:37 PDT 2012


On 18 July 2012 14:16, Brian Paul <brianp at vmware.com> wrote:

> On 07/18/2012 01:16 PM, Paul Berry wrote:
>
>> 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.
>> ---
>>   src/glsl/ir_set_program_**inouts.cpp |   16 ++++++++++++++--
>>   1 files changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/glsl/ir_set_program_**inouts.cpp
>> b/src/glsl/ir_set_program_**inouts.cpp
>> index a7415c7..9b82f17 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)
>> @@ -182,6 +193,7 @@ do_set_program_inouts(exec_**list *instructions,
>> struct gl_program *prog,
>>         memset(((gl_fragment_program *) prog)->InterpQualifier, 0,
>>                sizeof(((gl_fragment_program *) prog)->InterpQualifier));
>>         ((gl_fragment_program *) prog)->IsCentroid = 0;
>> +      ((gl_fragment_program *) prog)->UsesDFdy = false;
>>      }
>>      visit_list_elements(&v, instructions);
>>   }
>>
>
> Reviewed-by: Brian Paul <brianp at vmware.com>
>
> BTW, I thought we had a cast wrapper somewhere for casting gl_program to
> gl_fragment_program or gl_vertex_program, etc. but I can't find it at the
> moment.  It would be good to use wrapper like that instead of casts
> everywhere.  The last hunk has 3 such casts.  A local 'fprog' var would
> make things a bit more readable there.
>

Good point, thanks.  I'll add a local 'fprog' var before pushing the patch.


>
> -Brian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120718/ed00ab67/attachment.html>


More information about the mesa-dev mailing list