[Mesa-dev] [PATCH] glsl: extend GLSLSkipStrictMaxUniformLimitCheck to uniform block size

Marcin Ślusarz marcin.slusarz at gmail.com
Mon Apr 13 14:56:19 PDT 2015


On Mon, Apr 13, 2015 at 02:17:24PM -0700, Ian Romanick wrote:
> On 04/11/2015 09:48 AM, Marcin Ślusarz wrote:
> > ARB_uniform_buffer_object spec says:
> > "The total amount of buffer object storage available for any given uniform
> > block is subject to an implementation-dependent limit; the maximum amount
> > of available space, in basic machine units, can be queried by calling
> > GetIntegerv with the constant MAX_UNIFORM_BLOCK_SIZE.  If the amount
> > of storage required for a uniform block exceeds this limit, a program may
> > fail to link."
> > 
> > Fixes these piglit tests:
> > spec at arb_uniform_buffer_object@maxuniformblocksize at fsexceed
> > spec at arb_uniform_buffer_object@maxuniformblocksize at vsexceed
> > on nouveau/gk107.
> 
> Can you elaborate on how this fixes the test?
Yeah

> The fsexceed and vsexceed tests are supposed to pass if linking fails.

Currently *exceed tests fail on nouveau because shader can't calculate
expected values. With this patch linking fails (GLSLSkipStrictMaxUniformLimitCheck
is false on nouveau), allowing tests to pass.

> 
> > ---
> >  src/glsl/linker.cpp | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> > index 85830e6..88a4548 100644
> > --- a/src/glsl/linker.cpp
> > +++ b/src/glsl/linker.cpp
> > @@ -2308,6 +2308,25 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
> >                           _mesa_shader_stage_to_string(i));
> >           }
> >        }
> > +
> > +      for (unsigned j = 0; j < sh->NumUniformBlocks; ++j) {
> > +         if (sh->UniformBlocks[j].UniformBufferSize >
> > +                  ctx->Const.MaxUniformBlockSize) {
> > +            if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
> > +               linker_warning(prog,
> > +                              "%s shader uses uniform block whose size exceeds "
> > +                              "MAX_UNIFORM_BLOCK_SIZE, but the driver will try "
> > +                              "to optimize them out; this is non-portable "
> > +                              "out-of-spec behaviour\n",
> > +                              _mesa_shader_stage_to_string(i));
> > +            } else {
> > +               linker_error(prog,
> > +                            "%s shader uses uniform block whose size exceeds "
> > +                            "MAX_UNIFORM_BLOCK_SIZE\n",
> > +                            _mesa_shader_stage_to_string(i));
> > +            }
> > +         }
> > +      }
> >     }
> >  
> >     unsigned blocks[MESA_SHADER_STAGES] = {0};
> > 
> 


More information about the mesa-dev mailing list