[Mesa-dev] [PATCH] mesa/st: fix number of ubos being declared in a shader

Roland Scheidegger sroland at vmware.com
Wed May 14 13:13:36 PDT 2014


Am 14.05.2014 21:45, schrieb Brian Paul:
> On 05/14/2014 01:07 PM, sroland at vmware.com wrote:
>> From: Roland Scheidegger <sroland at vmware.com>
>>
>> Previously the code used the total number of ubos being declared in the
>> linked program (so the ubos of all shaders combined), use the number
>> from the particular shader instead.
>> This fixes an assertion failure with piglit
>> arb_uniform_buffer_object-maxblocks
>> seen in llvmpipe since 8a9f5ecdb116d0449d63f7b94efbfa8b205d826f as it
>> now emits
>> code for each declared buffer, not just the ones actually used.
>> ---
>>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> index f3535c5..79d013d 100644
>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> @@ -325,6 +325,7 @@ public:
>>      struct gl_context *ctx;
>>      struct gl_program *prog;
>>      struct gl_shader_program *shader_program;
>> +   struct gl_shader *shader;
>>      struct gl_shader_compiler_options *options;
>>
>>      int next_temp;
>> @@ -5096,11 +5097,11 @@ st_translate_program(
>>         }
>>      }
>>
>> -   if (program->shader_program) {
>> -      unsigned num_ubos = program->shader_program->NumUniformBlocks;
>> +   if (program->shader) {
>> +      unsigned num_ubos = program->shader->NumUniformBlocks;
>>
>>         for (i = 0; i < num_ubos; i++) {
>> -         ureg_DECL_constant2D(t->ureg, 0,
>> program->shader_program->UniformBlocks[i].UniformBufferSize / 4, i + 1);
>> +         ureg_DECL_constant2D(t->ureg, 0,
>> program->shader->UniformBlocks[i].UniformBufferSize / 4, i + 1);
>>         }
>>      }
>>
>> @@ -5221,6 +5222,7 @@ get_mesa_program(struct gl_context *ctx,
>>      v->ctx = ctx;
>>      v->prog = prog;
>>      v->shader_program = shader_program;
>> +   v->shader = shader;
>>      v->options = options;
>>      v->glsl_version = ctx->Const.GLSLVersion;
>>      v->native_integers = ctx->Const.NativeIntegers;
>>
> 
> LGTM.
> Reviewed-by: Brian Paul <brianp at vmware.com>
> 
> Should this fix go into the 10.2 or 10.1 branches?
> 

Oh I didn't think about that. The bug is old and didn't seem to have
caused issues so far (actually the declared sizes of the buffers would
have been wrong too but probably everyone ignored that too). I guess
though it should be safe for 10.1 and 10.2, so I'll add that.

Roland


More information about the mesa-dev mailing list