[Mesa-dev] [PATCH 3/5] glsl: Add gl_MESACurrentAttrib{Vert, Frag} internal builtin uniforms.

Ian Romanick idr at freedesktop.org
Thu Oct 6 14:41:35 PDT 2011


On 10/06/2011 02:11 PM, Marek Olšák wrote:
> If I get this right... Why not use a vertex array with stride == 0 instead?

In the GL API, stride == 0 is a magic value that tells the GL 
implementation to figure out what the stride should be.  As far as I 
know, most hardware can't do true zero-stride arrays.

> On Thu, Oct 6, 2011 at 6:36 PM, Eric Anholt<eric at anholt.net>  wrote:
>> These will be used by the FF VS/FS to represent the current attributes
>> when they don't have an active vertex array.
>> ---
>>   src/glsl/ir_variable.cpp |   25 ++++++++++++++++++++++++-
>>   1 files changed, 24 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
>> index 58be64b..03fa43f 100644
>> --- a/src/glsl/ir_variable.cpp
>> +++ b/src/glsl/ir_variable.cpp
>> @@ -178,6 +178,14 @@ static struct gl_builtin_uniform_element gl_MESAFogParamsOptimized_elements[] =
>>     {NULL, {STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED}, SWIZZLE_XYZW},
>>   };
>>
>> +static struct gl_builtin_uniform_element gl_MESACurrentAttribVert_elements[] = {
>> +   {NULL, {STATE_INTERNAL, STATE_CURRENT_ATTRIB, 0}, SWIZZLE_XYZW},
>> +};
>> +
>> +static struct gl_builtin_uniform_element gl_MESACurrentAttribFrag_elements[] = {
>> +   {NULL, {STATE_INTERNAL, STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, 0}, SWIZZLE_XYZW},
>> +};
>> +
>>   #define MATRIX(name, statevar, modifier)                               \
>>     static struct gl_builtin_uniform_element name ## _elements[] = {    \
>>        { NULL, { statevar, 0, 0, 0, modifier}, SWIZZLE_XYZW },          \
>> @@ -284,6 +292,8 @@ const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = {
>>     STATEVAR(gl_MESABumpRotMatrix0),
>>     STATEVAR(gl_MESABumpRotMatrix1),
>>     STATEVAR(gl_MESAFogParamsOptimized),
>> +   STATEVAR(gl_MESACurrentAttribVert),
>> +   STATEVAR(gl_MESACurrentAttribFrag),
>>
>>     {NULL, NULL, 0}
>>   };
>> @@ -355,7 +365,12 @@ add_uniform(exec_list *instructions, glsl_symbol_table *symtab,
>>
>>          memcpy(slots->tokens, element->tokens, sizeof(element->tokens));
>>          if (type->is_array()) {
>> -           slots->tokens[1] = a;
>> +           if (strcmp(name, "gl_MESACurrentAttribVert") == 0 ||
>> +               strcmp(name, "gl_MESACurrentAttribFrag") == 0) {
>> +              slots->tokens[2] = a;
>> +           } else {
>> +              slots->tokens[1] = a;
>> +           }
>>          }
>>
>>          slots->swizzle = element->swizzle;
>> @@ -518,6 +533,14 @@ generate_110_uniforms(exec_list *instructions,
>>
>>     add_uniform(instructions, symtab, "gl_Fog",
>>                symtab->get_type("gl_FogParameters"));
>> +
>> +   /* Mesa-internal current attrib state */
>> +   const glsl_type *const vert_attribs =
>> +      glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX);
>> +   add_uniform(instructions, symtab, "gl_MESACurrentAttribVert", vert_attribs);
>> +   const glsl_type *const frag_attribs =
>> +      glsl_type::get_array_instance(glsl_type::vec4_type, FRAG_ATTRIB_MAX);
>> +   add_uniform(instructions, symtab, "gl_MESACurrentAttribFrag", frag_attribs);
>>   }
>>
>>   /* This function should only be called for ES, not desktop GL. */
>> --
>> 1.7.6.3



More information about the mesa-dev mailing list