[Mesa-dev] [PATCH 03/10] mesa: add new enum MAX_UNIFORM_LOCATIONS

Tapani tapani.palli at intel.com
Mon May 19 22:20:33 PDT 2014


On 05/19/2014 08:26 PM, Ian Romanick wrote:
> On 04/09/2014 02:56 AM, Tapani Pälli wrote:
>> Patch adds new implementation dependent value required by the
>> GL_ARB_explicit_uniform_location extension. Default value for user
>> assignable locations is calculated as sum of MaxUniformComponents
>> for each stage.
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>>   src/mesa/main/context.c              | 10 +++++++++-
>>   src/mesa/main/get.c                  |  1 +
>>   src/mesa/main/get_hash_params.py     |  1 +
>>   src/mesa/main/mtypes.h               |  5 +++++
>>   src/mesa/main/tests/enum_strings.cpp |  1 +
>>   5 files changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
>> index 860ae86..8b77df1 100644
>> --- a/src/mesa/main/context.c
>> +++ b/src/mesa/main/context.c
>> @@ -610,8 +610,16 @@ _mesa_init_constants(struct gl_context *ctx)
>>      ctx->Const.MaxUniformBlockSize = 16384;
>>      ctx->Const.UniformBufferOffsetAlignment = 1;
>>   
>> -   for (i = 0; i < MESA_SHADER_STAGES; i++)
>> +   /* GL_ARB_explicit_uniform_location, initial value calculated
>> +    * as sum of MaxUniformComponents for each stage.
>> +    */
>> +   ctx->Const.MaxUserAssignableUniformLocations = 0;
>> +
>> +   for (i = 0; i < MESA_SHADER_STAGES; i++) {
>>         init_program_limits(ctx, i, &ctx->Const.Program[i]);
>> +      ctx->Const.MaxUserAssignableUniformLocations +=
>> +         ctx->Const.Program[i].MaxUniformComponents;
>> +   }
> This is just going to set ctx->Const.MaxUserAssignableUniformLocations
> to 4 * 4 * MAX_UNIFORMS, and that's probably not what we want.  Maybe
> just set 4 * MAX_UNIFORMS with a comment saying it's, "MAX_UNIFORMS for
> each possible shader stage."

There should be much more locations than number of uniforms though (?) 
MAX_UNIFORMS refers to count of available vec4 uniforms, each of these 
should have 4 locations available. Also, value from the above formula 
nicely matches with binary drivers so IMO it shouldn't be 'too much'.

>>      ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
>>      ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
>> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
>> index 6d95790..8b50441 100644
>> --- a/src/mesa/main/get.c
>> +++ b/src/mesa/main/get.c
>> @@ -395,6 +395,7 @@ EXTRA_EXT(ARB_viewport_array);
>>   EXTRA_EXT(ARB_compute_shader);
>>   EXTRA_EXT(ARB_gpu_shader5);
>>   EXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5);
>> +EXTRA_EXT(ARB_explicit_uniform_location);
>>   
>>   static const int
>>   extra_ARB_color_buffer_float_or_glcore[] = {
>> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
>> index 06d0bba..5709d42 100644
>> --- a/src/mesa/main/get_hash_params.py
>> +++ b/src/mesa/main/get_hash_params.py
>> @@ -474,6 +474,7 @@ descriptor=[
>>     [ "MAX_LIST_NESTING", "CONST(MAX_LIST_NESTING), NO_EXTRA" ],
>>     [ "MAX_NAME_STACK_DEPTH", "CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA" ],
>>     [ "MAX_PIXEL_MAP_TABLE", "CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA" ],
>> +  [ "MAX_UNIFORM_LOCATIONS", "CONTEXT_INT(Const.MaxUserAssignableUniformLocations), NO_EXTRA" ],
> Ditto on Petri's comment.
>
>>     [ "NAME_STACK_DEPTH", "CONTEXT_INT(Select.NameStackDepth), NO_EXTRA" ],
>>     [ "PACK_LSB_FIRST", "CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA" ],
>>     [ "PACK_SWAP_BYTES", "CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA" ],
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index 7ac6bbe..fefbe06 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -3311,6 +3311,11 @@ struct gl_constants
>>      GLuint UniformBufferOffsetAlignment;
>>      /** @} */
>>   
>> +   /**
>> +    * GL_ARB_explicit_uniform_location
>> +    */
>> +   GLuint MaxUserAssignableUniformLocations;
>> +
>>      /** GL_ARB_geometry_shader4 */
>>      GLuint MaxGeometryOutputVertices;
>>      GLuint MaxGeometryTotalOutputComponents;
>> diff --git a/src/mesa/main/tests/enum_strings.cpp b/src/mesa/main/tests/enum_strings.cpp
>> index 3795700..298ff6a 100644
>> --- a/src/mesa/main/tests/enum_strings.cpp
>> +++ b/src/mesa/main/tests/enum_strings.cpp
>> @@ -787,6 +787,7 @@ const struct enum_info everything[] = {
>>      { 0x8256, "GL_RESET_NOTIFICATION_STRATEGY_ARB" },
>>      { 0x8257, "GL_PROGRAM_BINARY_RETRIEVABLE_HINT" },
>>      { 0x8261, "GL_NO_RESET_NOTIFICATION_ARB" },
>> +   { 0x826E, "GL_MAX_UNIFORM_LOCATIONS" },
>>      { 0x82DF, "GL_TEXTURE_IMMUTABLE_LEVELS" },
>>      { 0x8362, "GL_UNSIGNED_BYTE_2_3_3_REV" },
>>      { 0x8363, "GL_UNSIGNED_SHORT_5_6_5" },
>>



More information about the mesa-dev mailing list