[Mesa-dev] [PATCH] i965: Advertise 65536 for GL_MAX_UNIFORM_BLOCK_SIZE.

Ian Romanick idr at freedesktop.org
Wed Sep 9 09:59:27 PDT 2015


On 09/08/2015 10:43 PM, Kenneth Graunke wrote:
> On Tuesday, September 08, 2015 08:50:41 PM Ian Romanick wrote:
>> On 09/08/2015 06:04 PM, Kenneth Graunke wrote:
>>> Our old value of 16384 is the minimum value.  DirectX apparently
>>> requires 65536 at a minimum; that's also what nVidia and the Intel
>>> Windows driver advertise.  AMD advertises MAX_INT.
>>>
>>> Ilia Mirkin noticed that "Shadow Warrior" uses UBOs larger than 16k
>>> on Nouveau, which advertises 65536 bytes for this limit.  Traces
>>> captured on Nouveau don't work on i965 because our lower limit causes
>>> the GLSL linker to reject the captured shaders.  While this isn't
>>> important in and of itself, it does suggest that raising the limit
>>> would be beneficial.
>>>
>>> We can read linear buffers up to 2^27 bytes in size, so raising this
>>> should be safe; we could probably even go larger.  For now, matching
>>> nVidia and Intel/Windows seems like a good plan.
>>>
>>> We have to reinitialize MaxCombinedUniformComponents as core Mesa will
>>> have set it based on a stale value for MaxUniformBlockSize.
>>>
>>> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>>> ---
>>>  src/mesa/drivers/dri/i965/brw_context.c | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
>>> index 907b2a0..7c1c133 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_context.c
>>> +++ b/src/mesa/drivers/dri/i965/brw_context.c
>>> @@ -323,6 +323,15 @@ brw_initialize_context_constants(struct brw_context *brw)
>>>  
>>>     ctx->Const.StripTextureBorder = true;
>>>  
>>> +   ctx->Const.MaxUniformBlockSize = 65536;
>>> +   for (int i = 0; i < MESA_SHADER_STAGES; i++) {
>>> +      struct gl_program_constants *prog = &ctx->Const.Program[i];
>>> +      prog->MaxUniformBlocks = 12;
>>
>> Is this actually necessary?  It looks like this is that value already
>> set in init_program_limits.  Either way, this patch is
>>
>> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> 
> You're right, setting prog->MaxUniformBlocks = 12 is unnecessary.
> 
> We do need to reset prog->MaxCombinedUniformComponents since
> init_program_limits computed a value using a stale MaxUniformBlockSize.
> 
> I figured since the three values are related, we may as well just
> explicitly initialize them all.  But if you'd prefer I take it out,
> I'm fine with that too.  What do you prefer?

təˈmeɪtoʊ / təˈmɑːtoʊ.  I mostly wanted to be sure I wasn't missing
something.

> Thanks for the quick review!
> 
> --Ken
> 
>>> +      prog->MaxCombinedUniformComponents =
>>> +         prog->MaxUniformComponents +
>>> +         ctx->Const.MaxUniformBlockSize / 4 * prog->MaxUniformBlocks;
>>> +   }
>>> +
>>>     ctx->Const.MaxDualSourceDrawBuffers = 1;
>>>     ctx->Const.MaxDrawBuffers = BRW_MAX_DRAW_BUFFERS;
>>>     ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = max_samplers;
>>>
>>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150909/159d70a7/attachment.sig>


More information about the mesa-dev mailing list