[Mesa-dev] [PATCH 17/24] mesa/main: Add a 'spirv' flag to gl_shader_program_data

Eduardo Lima Mitev elima at igalia.com
Mon Nov 20 08:00:23 UTC 2017


On 11/16/2017 12:23 AM, Timothy Arceri wrote:
> On 16/11/17 00:22, Eduardo Lima Mitev wrote:
>> This will be used by the linker code to dfferentiate between
>> programs made out of SPIR-V or GLSL shaders.
>
> So far everywhere this is used it seems you could just do something like:
>
>  if (shProg->_LinkedShaders[stage]->spirv_data)
>    ... spriv stuff ...
>  else
>    ... glsl stuff ...
>
>
This flag is a per-program variable (as oppose to a per-shader one). 
While it would be possible to know the type of program (spirv vs. glsl) 
indirectly by looking at its linked shaders, I think it is clearer and 
more readable (and more formal) to have a flag in the program data for this.

This also allows for releasing the memory of the spirv_data structure 
when we don't need it, and still being able to know what kind of program 
we have.

I would personally keep this flag.

Are there more opinions about this?

Thanks for reviewing, Timothy.

Edu

>
>> ---
>>   src/mesa/main/mtypes.h | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index d624f2cbd19..db9c2e1deaa 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -2902,6 +2902,12 @@ struct gl_shader_program_data
>>        /* Mask of stages this program was linked against */
>>      unsigned linked_stages;
>> +
>> +   /* Whether the shaders of this program are loaded from SPIR-V 
>> binaries
>> +    * (all have the SPIR_V_BINARY_ARB state). This was introduced by 
>> the
>> +    * ARB_gl_spirv extension.
>> +    */
>> +   bool spirv;
>>   };
>>     /**
>>
>



More information about the mesa-dev mailing list