[Mesa-dev] [PATCH 16/17] glsl: Set gl_MaxVaryingFloats et al. from VertexProgram.MaxOutputComponents and FragmentProgram.MaxInputComponents

Ian Romanick idr at freedesktop.org
Tue Sep 10 14:06:38 PDT 2013


On 09/10/2013 03:47 PM, Brian Paul wrote:
> On 09/10/2013 01:11 PM, Ian Romanick wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Some language versions have the vertex output components minimum-maximum
>> lower (GLSL 1.50), and some have the fragment input components
>> minimum-maximum lower (GLSL ES 3.0).  Use whichever value is lower, and
>> call it done.
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> Cc: Paul Berry <stereotype441 at gmail.com>
>> ---
>>   src/glsl/builtin_variables.cpp | 14 +++++++++-----
>>   1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/glsl/builtin_variables.cpp
>> b/src/glsl/builtin_variables.cpp
>> index 6a808c0..79e1db4 100644
>> --- a/src/glsl/builtin_variables.cpp
>> +++ b/src/glsl/builtin_variables.cpp
>> @@ -475,6 +475,10 @@ builtin_variable_generator::add_const(const char
>> *name, int value)
>>   void
>>   builtin_variable_generator::generate_constants()
>>   {
>> +   const max_varying_components =
> 
> Want to throw a type like unsigned in there?

The last minute changes always burn me... Yes, that should be 'const
unsigned'.  Just for good measure, I compiled the code (make && make
check), and ran piglit. :)

>> +      MIN2(state->ctx->Const.VertexProgram.MaxOutputComponents,
>> +       state->ctx->Const.FragmentProgram.MaxInputComponents);
>> +
>>      add_const("gl_MaxVertexAttribs", state->Const.MaxVertexAttribs);
>>      add_const("gl_MaxVertexTextureImageUnits",
>>                state->Const.MaxVertexTextureImageUnits);
>> @@ -497,11 +501,11 @@ builtin_variable_generator::generate_constants()
>>          */
>>         if (state->is_version(0, 300)) {
>>            add_const("gl_MaxVertexOutputVectors",
>> -                   state->Const.MaxVaryingFloats / 4);
>> +                  
>> state->ctx->Const.VertexProgram.MaxOutputComponents / 4);
>>            add_const("gl_MaxFragmentInputVectors",
>> -                   state->Const.MaxVaryingFloats / 4);
>> +                  
>> state->ctx->Const.FragmentProgram.MaxInputComponents / 4);
>>         } else {
>> -         add_const("gl_MaxVaryingVectors",
>> state->Const.MaxVaryingFloats / 4);
>> +         add_const("gl_MaxVaryingVectors", max_varying_components / 4);
>>         }
>>      } else {
>>         add_const("gl_MaxVertexUniformComponents",
>> @@ -510,7 +514,7 @@ builtin_variable_generator::generate_constants()
>>         /* Note: gl_MaxVaryingFloats was deprecated in GLSL 1.30+, but
>> not
>>          * removed
>>          */
>> -      add_const("gl_MaxVaryingFloats", state->Const.MaxVaryingFloats);
>> +      add_const("gl_MaxVaryingFloats", max_varying_components);
>>
>>         add_const("gl_MaxFragmentUniformComponents",
>>                   state->Const.MaxFragmentUniformComponents);
>> @@ -531,7 +535,7 @@ builtin_variable_generator::generate_constants()
>>
>>      if (state->is_version(130, 0)) {
>>         add_const("gl_MaxClipDistances", state->Const.MaxClipPlanes);
>> -      add_const("gl_MaxVaryingComponents",
>> state->Const.MaxVaryingFloats);
>> +      add_const("gl_MaxVaryingComponents", max_varying_components);
>>      }
>>
>>      if (compatibility) {
>>



More information about the mesa-dev mailing list