[Mesa-dev] [PATCH 03/11] mesa: Add support for glUniformBlockBinding() and the API to get it back.
Eric Anholt
eric at anholt.net
Tue Jul 31 10:28:30 PDT 2012
Kenneth Graunke <kenneth at whitecape.org> writes:
> On 07/20/2012 03:33 PM, Eric Anholt wrote:
>> Fixes piglit ARB_uniform_buffer_object/uniformbufferbinding.
>> ---
>> src/mesa/main/uniforms.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 95 insertions(+)
>>
>> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
>> index ccbd753..940cb07 100644
>> --- a/src/mesa/main/uniforms.c
>> +++ b/src/mesa/main/uniforms.c
>> @@ -41,6 +41,7 @@
>> #include "main/shaderapi.h"
>> #include "main/shaderobj.h"
>> #include "main/uniforms.h"
>> +#include "main/enums.h"
>> #include "ir_uniform.h"
>> #include "glsl_types.h"
>>
>> @@ -583,6 +584,98 @@ _mesa_GetUniformIndices(GLuint program,
>> }
>> }
>>
>> +static void GLAPIENTRY
>> +_mesa_UniformBlockBinding(GLuint program,
>> + GLuint uniformBlockIndex,
>> + GLuint uniformBlockBinding)
>> +{
>> + GET_CURRENT_CONTEXT(ctx);
>> + struct gl_shader_program *shProg;
>> +
>> + if (!ctx->Extensions.ARB_uniform_buffer_object) {
>> + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformBlockBinding");
>> + return;
>> + }
>> +
>> + shProg = _mesa_lookup_shader_program_err(ctx, program,
>> + "glUniformBlockBinding");
>> + if (!shProg)
>> + return;
>> +
>> + if (uniformBlockIndex >= shProg->NumUniformBlocks) {
>> + _mesa_error(ctx, GL_INVALID_VALUE,
>> + "glUniformBlockBinding(block index %d >= %d)",
>> + uniformBlockIndex, shProg->NumUniformBlocks);
>> + return;
>> + }
>> +
>> + if (uniformBlockBinding >= ctx->Const.MaxUniformBufferBindings) {
>> + _mesa_error(ctx, GL_INVALID_VALUE,
>> + "glUniformBlockBinding(block binding %d >= %d)",
>> + uniformBlockBinding, ctx->Const.MaxUniformBufferBindings);
>> + return;
>> + }
>> +
>> + if (shProg->UniformBlocks[uniformBlockIndex].Binding !=
>> + uniformBlockBinding) {
>> + int i;
>> +
>> + FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
>> + shProg->UniformBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
>
> I'd almost expect to see a _NEW_PROGRAM_CONSTANTS when a new uniform
> buffer gets bound. Then again, that would cause re-uploading of all the
> non-UBO uniforms, which is pointless and expensive. Looking at the i965
> backend, it looks like _NEW_PROGRAM_CONSTANTS mostly deals with push
> constants, and your new patch for UBOs properly uses this flag. So it
> should be fine.
>
> Everything else looks good. For the series:
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Yeah, the driver has to pay attention to _NEW_BUFFER_OBJECT anyway
because that signals glBufferData() changing the driver BO being
referenced, so reusing that seemed good.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120731/d973611b/attachment.pgp>
More information about the mesa-dev
mailing list