Mesa (master): mesa: add vao/vbo lookup helper for EXT_dsa

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 5 13:52:08 UTC 2019


Module: Mesa
Branch: master
Commit: a78d4e7e757f83f3fc5eaa289c5a608e4a3a338e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a78d4e7e757f83f3fc5eaa289c5a608e4a3a338e

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Fri Oct 25 14:28:21 2019 +0200

mesa: add vao/vbo lookup helper for EXT_dsa

Add a single helper dealing with the lookup of both the vao
and the vbo to avoid duplicating this code in all the
glVertexArray* functions.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/main/varray.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 963775edad6..cc9321a8327 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -625,6 +625,38 @@ update_array(struct gl_context *ctx,
                             effectiveStride);
 }
 
+
+/* Helper function for all EXT_direct_state_access glVertexArray* functions */
+static bool
+_lookup_vao_and_vbo_dsa(struct gl_context *ctx,
+                        GLuint vaobj, GLuint buffer,
+                        GLintptr offset,
+                        struct gl_vertex_array_object** vao,
+                        struct gl_buffer_object** vbo,
+                        const char* caller)
+{
+   *vao = _mesa_lookup_vao_err(ctx, vaobj, true, caller);
+   if (!(*vao))
+      return false;
+
+   if (buffer != 0) {
+      *vbo = _mesa_lookup_bufferobj(ctx, buffer);
+      if (!_mesa_handle_bind_buffer_gen(ctx, buffer, vbo, caller))
+         return false;
+
+      if (offset < 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(negative offset with non-0 buffer)", caller);
+         return false;
+      }
+   } else {
+      *vbo = ctx->Shared->NullBufferObj;
+   }
+
+   return true;
+}
+
+
 void GLAPIENTRY
 _mesa_VertexPointer_no_error(GLint size, GLenum type, GLsizei stride,
                              const GLvoid *ptr)




More information about the mesa-commit mailing list