mesa: split bind_buffer_range_uniform_buffer() in two
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 22 May 2017 05:46:56 +0000 (15:46 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 29 May 2017 22:03:32 +0000 (08:03 +1000)
This will help us implement KHR_no_error support.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/mesa/main/bufferobj.c

index 461d697..2c5d56b 100644 (file)
@@ -3119,6 +3119,20 @@ bind_shader_storage_buffer(struct gl_context *ctx,
    set_ssbo_binding(ctx, binding, bufObj, offset, size, autoSize);
 }
 
+static void
+bind_buffer_range_uniform_buffer(struct gl_context *ctx, GLuint index,
+                                 struct gl_buffer_object *bufObj,
+                                 GLintptr offset, GLsizeiptr size)
+{
+   if (bufObj == ctx->Shared->NullBufferObj) {
+      offset = -1;
+      size = -1;
+   }
+
+   _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
+   bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
+}
+
 /**
  * Bind a region of a buffer object to a uniform block binding point.
  * \param index  the uniform buffer binding point index
@@ -3127,11 +3141,9 @@ bind_shader_storage_buffer(struct gl_context *ctx,
  * \param size  size of the buffer object region
  */
 static void
-bind_buffer_range_uniform_buffer(struct gl_context *ctx,
-                                GLuint index,
-                                struct gl_buffer_object *bufObj,
-                                GLintptr offset,
-                                GLsizeiptr size)
+bind_buffer_range_uniform_buffer_err(struct gl_context *ctx, GLuint index,
+                                     struct gl_buffer_object *bufObj,
+                                     GLintptr offset, GLsizeiptr size)
 {
    if (index >= ctx->Const.MaxUniformBufferBindings) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index);
@@ -3145,13 +3157,7 @@ bind_buffer_range_uniform_buffer(struct gl_context *ctx,
       return;
    }
 
-   if (bufObj == ctx->Shared->NullBufferObj) {
-      offset = -1;
-      size = -1;
-   }
-
-   _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
-   bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
+   bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
 }
 
 /**
@@ -4016,7 +4022,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
                                                  false);
       return;
    case GL_UNIFORM_BUFFER:
-      bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
+      bind_buffer_range_uniform_buffer_err(ctx, index, bufObj, offset, size);
       return;
    case GL_SHADER_STORAGE_BUFFER:
       bind_buffer_range_shader_storage_buffer(ctx, index, bufObj, offset, size);