[Mesa-dev] [PATCH] [rfc] mesa/program_resource: return -1 for index if no location.

Eduardo Lima Mitev elima at igalia.com
Fri Jun 3 07:33:06 UTC 2016


Hi Dave,

I fixed this test too using a slightly different check. See
https://github.com/Igalia/mesa/commit/45bb76f54bd406d8395df46e0cdcb7a59e87f468.

I check variable is a built-in by using the "gl_" prefix check,  because
that's what is consistently used in the file. Checking location == -1
seems more elegant though.

In any case, you should probably use
_mesa_program_resource_location_index() in the switch case, as I did in
my patch.

With that, patch is:

Reviewed-by: Eduardo Lima Mitev <elima at igalia.com>

Thanks!

On 06/03/2016 12:21 AM, Dave Airlie wrote:
> ping?
> 
> 
> On 24 May 2016 at 06:43, Dave Airlie <airlied at gmail.com> wrote:
>> From: Dave Airlie <airlied at redhat.com>
>>
>> The GL4.5 spec quote seems clear on this:
>> "The value -1 will be returned by either command if an error occurs,
>> if name does not identify an active variable on programInterface,
>> or if name identifies an active variable that does not have a valid
>> location assigned, as described above."
>>
>> This fixes:
>> GL45-CTS.program_interface_query.output-built-in
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>>  src/mesa/main/shader_query.cpp | 20 +++++++++++++++++---
>>  1 file changed, 17 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
>> index c8c3df4..467e9b7 100644
>> --- a/src/mesa/main/shader_query.cpp
>> +++ b/src/mesa/main/shader_query.cpp
>> @@ -884,6 +884,13 @@ _mesa_program_resource_location_index(struct gl_shader_program *shProg,
>>     if (!res || !(res->StageReferences & (1 << MESA_SHADER_FRAGMENT)))
>>        return -1;
>>
>> +   /* From OpenGL 4.5 spec, 7.3 Program Objects
>> +    * "The value -1 will be returned by either command...
>> +    *  ... or if name identifies an active variable that does not have a
>> +    * valid location assigned.
>> +    */
>> +   if (RESOURCE_VAR(res)->location == -1)
>> +      return -1;
>>     return RESOURCE_VAR(res)->index;
>>  }
>>
>> @@ -1238,12 +1245,19 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
>>        default:
>>           goto invalid_operation;
>>        }
>> -   case GL_LOCATION_INDEX:
>> +   case GL_LOCATION_INDEX: {
>> +      int tmp;
>>        if (res->Type != GL_PROGRAM_OUTPUT)
>>           goto invalid_operation;
>> -      *val = RESOURCE_VAR(res)->index;
>> +      tmp = program_resource_location(shProg, res,
>> +                                      _mesa_program_resource_name(res),
>> +                                      0);
>> +      if (tmp == -1)
>> +         *val = -1;
>> +      else
>> +         *val = RESOURCE_VAR(res)->index;
>>        return 1;
>> -
>> +   }
>>     case GL_NUM_COMPATIBLE_SUBROUTINES:
>>        if (res->Type != GL_VERTEX_SUBROUTINE_UNIFORM &&
>>            res->Type != GL_FRAGMENT_SUBROUTINE_UNIFORM &&
>> --
>> 2.5.5
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list