mesa: add bind_buffer_offset() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 24 Aug 2017 09:34:38 +0000 (11:34 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 25 Aug 2017 09:35:30 +0000 (11:35 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/transformfeedback.c

index b79b41d35ef7f71b2d7d0fd3d877015748745fe2..44a6e149dbaa7793237d803b4d7564cd2f71f3ee 100644 (file)
@@ -779,12 +779,33 @@ _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
  * offset in the buffer to start placing results.
  * This function is part of GL_EXT_transform_feedback, but not GL3.
  */
+static ALWAYS_INLINE void
+bind_buffer_offset(struct gl_context *ctx,
+                   struct gl_transform_feedback_object *obj, GLuint index,
+                   GLuint buffer, GLintptr offset, bool no_error)
+{
+   struct gl_buffer_object *bufObj;
+
+   if (buffer == 0) {
+      bufObj = ctx->Shared->NullBufferObj;
+   } else {
+      bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+      if (!no_error && !bufObj) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glBindBufferOffsetEXT(invalid buffer=%u)", buffer);
+         return;
+      }
+   }
+
+   _mesa_bind_buffer_range_xfb(ctx, obj, index, bufObj, offset, 0);
+}
+
+
 void GLAPIENTRY
 _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
                           GLintptr offset)
 {
    struct gl_transform_feedback_object *obj;
-   struct gl_buffer_object *bufObj;
    GET_CURRENT_CONTEXT(ctx);
 
    if (target != GL_TRANSFORM_FEEDBACK_BUFFER) {
@@ -813,18 +834,7 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
       return;
    }
 
-   if (buffer == 0) {
-      bufObj = ctx->Shared->NullBufferObj;
-   } else {
-      bufObj = _mesa_lookup_bufferobj(ctx, buffer);
-      if (!bufObj) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glBindBufferOffsetEXT(invalid buffer=%u)", buffer);
-         return;
-      }
-   }
-
-   _mesa_bind_buffer_range_xfb(ctx, obj, index, bufObj, offset, 0);
+   bind_buffer_offset(ctx, obj, index, buffer, offset, false);
 }