[Mesa-dev] [PATCH 2/6] mesa: set the gl_FragDepth layout in the GLSL linker

Kenneth Graunke kenneth at whitecape.org
Fri Nov 18 12:58:11 PST 2011


On 11/18/2011 12:44 PM, Ian Romanick wrote:
> On 11/18/2011 11:27 AM, Marek Olšák wrote:
>> ---
>>   src/glsl/linker.cpp                        |   45
>> ++++++++++++++++++++++++++++
>>   src/mesa/main/mtypes.h                     |    3 ++
>>   src/mesa/program/ir_to_mesa.cpp            |   29 ++++--------------
>>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   23 --------------
>>   4 files changed, 54 insertions(+), 46 deletions(-)
>>
>> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
>> index 0ec773d..226aa6f 100644
>> --- a/src/glsl/linker.cpp
>> +++ b/src/glsl/linker.cpp
>> @@ -1876,6 +1876,50 @@ store_tfeedback_info(struct gl_context *ctx,
>> struct gl_shader_program *prog,
>>   }
>>
>>   /**
>> + * Store the gl_FragDepth layout in the gl_shader_program struct.
>> + */
>> +static void
>> +store_fragdepth_layout(struct gl_shader_program *prog)
>> +{
>> +   if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
>> +      return;
>> +   }
>> +
>> +   struct exec_list *ir =
>> prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir;
>> +
>> +   foreach_list(node, ir) {
>> +      ir_variable *const var = ((ir_instruction *) node)->as_variable();
>> +
>> +      if (var == NULL || var->mode != ir_var_out) {
>> +         continue;
>> +      }
>> +
>> +      if (strcmp(var->name, "gl_FragDepth") == 0) {
> 
> It's probably worth explaining why you can't just look up gl_FragDepth
> in the symbol table here.  I was going to suggest changing to that, but
> I managed to convince myself that looping over the IR is correct.
> 
> With that small change, this patch is
> 
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

Agreed.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>



More information about the mesa-dev mailing list