[Mesa-dev] [PATCH 2/2] mesa: move glDraw-related functions into new draw.[ch] files

Brian Paul brianp at vmware.com
Wed Nov 13 10:38:18 PST 2013


To trim down the varray.c file so it's just vertex array functions.
---
 src/mapi/glapi/gen/gl_genexec.py     |    1 +
 src/mesa/Makefile.sources            |    1 +
 src/mesa/SConscript                  |    1 +
 src/mesa/drivers/common/meta.c       |    1 +
 src/mesa/main/draw.c                 |  136 ++++++++++++++++++++++++++++++++++
 src/mesa/main/draw.h                 |   87 ++++++++++++++++++++++
 src/mesa/main/varray.c               |  105 --------------------------
 src/mesa/main/varray.h               |   55 --------------
 src/mesa/vbo/vbo_exec_array.c        |    1 +
 src/mesa/vbo/vbo_primitive_restart.c |    2 +-
 10 files changed, 229 insertions(+), 161 deletions(-)
 create mode 100644 src/mesa/main/draw.c
 create mode 100644 src/mesa/main/draw.h

diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 3ce190f..516acc3 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -62,6 +62,7 @@ header = """/**
 #include "main/convolve.h"
 #include "main/depth.h"
 #include "main/dlist.h"
+#include "main/draw.h"
 #include "main/drawpix.h"
 #include "main/drawtex.h"
 #include "main/rastpos.h"
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index a84f8a7..d400fb9 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -30,6 +30,7 @@ MAIN_FILES = \
 	$(SRCDIR)main/debug.c \
 	$(SRCDIR)main/depth.c \
 	$(SRCDIR)main/dlist.c \
+	$(SRCDIR)main/draw.c \
 	$(SRCDIR)main/drawpix.c \
 	$(SRCDIR)main/drawtex.c \
 	$(SRCDIR)main/enable.c \
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 4213498..64e19aa 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -61,6 +61,7 @@ main_sources = [
     'main/debug.c',
     'main/depth.c',
     'main/dlist.c',
+    'main/draw.c',
     'main/drawpix.c',
     'main/drawtex.c',
     'main/enable.c',
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 99b02ba..d04d9eb 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -42,6 +42,7 @@
 #include "main/colortab.h"
 #include "main/condrender.h"
 #include "main/depth.h"
+#include "main/draw.h"
 #include "main/enable.h"
 #include "main/fbobject.h"
 #include "main/feedback.h"
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
new file mode 100644
index 0000000..6b8c58b
--- /dev/null
+++ b/src/mesa/main/draw.c
@@ -0,0 +1,136 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2013  VMware, Inc.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "context.h"
+#include "dispatch.h"
+#include "draw.h"
+
+
+/* GL_EXT_multi_draw_arrays */
+void GLAPIENTRY
+_mesa_MultiDrawArrays(GLenum mode, const GLint *first,
+                      const GLsizei *count, GLsizei primcount)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   GLint i;
+
+   FLUSH_VERTICES(ctx, 0);
+
+   for (i = 0; i < primcount; i++) {
+      if (count[i] > 0) {
+         CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
+      }
+   }
+}
+
+
+/* GL_IBM_multimode_draw_arrays */
+void GLAPIENTRY
+_mesa_MultiModeDrawArraysIBM(const GLenum *mode, const GLint *first,
+			     const GLsizei *count,
+			     GLsizei primcount, GLint modestride)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   GLint i;
+
+   FLUSH_VERTICES(ctx, 0);
+
+   for (i = 0 ; i < primcount ; i++) {
+      if (count[i] > 0) {
+         GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
+	 CALL_DrawArrays(ctx->Exec, (m, first[i], count[i]));
+      }
+   }
+}
+
+
+/* GL_IBM_multimode_draw_arrays */
+void GLAPIENTRY
+_mesa_MultiModeDrawElementsIBM(const GLenum *mode, const GLsizei *count,
+                               GLenum type, const GLvoid * const *indices,
+                               GLsizei primcount, GLint modestride)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   GLint i;
+
+   FLUSH_VERTICES(ctx, 0);
+
+   /* XXX not sure about ARB_vertex_buffer_object handling here */
+
+   for (i = 0 ; i < primcount ; i++) {
+      if (count[i] > 0) {
+         GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
+	 CALL_DrawElements(ctx->Exec, (m, count[i], type, indices[i]));
+      }
+   }
+}
+
+
+/**
+ * GL_NV_primitive_restart and GL 3.1
+ */
+void GLAPIENTRY
+_mesa_PrimitiveRestartIndex(GLuint index)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!ctx->Extensions.NV_primitive_restart && ctx->Version < 31) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndexNV()");
+      return;
+   }
+
+   if (ctx->Array.RestartIndex != index) {
+      FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+      ctx->Array.RestartIndex = index;
+   }
+}
+
+
+/**
+ * Returns the current/active primitive restart index value.
+ */
+unsigned
+_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type)
+{
+   /* From the OpenGL 4.3 core specification, page 302:
+    * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are
+    *  enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX
+    *  is used."
+    */
+   if (ctx->Array.PrimitiveRestartFixedIndex) {
+      switch (ib_type) {
+      case GL_UNSIGNED_BYTE:
+         return 0xff;
+      case GL_UNSIGNED_SHORT:
+         return 0xffff;
+      case GL_UNSIGNED_INT:
+         return 0xffffffff;
+      default:
+         assert(!"_mesa_primitive_restart_index: Invalid index buffer type.");
+      }
+   }
+
+   return ctx->Array.RestartIndex;
+}
diff --git a/src/mesa/main/draw.h b/src/mesa/main/draw.h
new file mode 100644
index 0000000..fc5679c
--- /dev/null
+++ b/src/mesa/main/draw.h
@@ -0,0 +1,87 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2013  VMware, Inc.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DRAW_H
+#define DRAW_H
+
+
+#include "glheader.h"
+
+
+extern void GLAPIENTRY
+_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
+
+extern void GLAPIENTRY
+_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
+                   const GLvoid *indices);
+
+extern void GLAPIENTRY
+_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
+                        GLenum type, const GLvoid *indices);
+
+extern void GLAPIENTRY
+_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
+			     const GLvoid *indices, GLint basevertex);
+
+extern void GLAPIENTRY
+_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
+				  GLsizei count, GLenum type,
+				  const GLvoid *indices, GLint basevertex);
+
+extern void GLAPIENTRY
+_mesa_DrawTransformFeedback(GLenum mode, GLuint name);
+
+
+extern void GLAPIENTRY
+_mesa_MultiDrawArrays(GLenum mode, const GLint *first,
+                      const GLsizei *count, GLsizei primcount);
+
+extern void GLAPIENTRY
+_mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
+                           const GLvoid **indices, GLsizei primcount);
+
+extern void GLAPIENTRY
+_mesa_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
+                                  GLenum type, const GLvoid **indices,
+                                  GLsizei primcount, const GLint *basevertex);
+
+extern void GLAPIENTRY
+_mesa_MultiModeDrawArraysIBM(const GLenum *mode, const GLint *first,
+                             const GLsizei *count,
+                             GLsizei primcount, GLint modestride);
+
+
+extern void GLAPIENTRY
+_mesa_MultiModeDrawElementsIBM(const GLenum *mode, const GLsizei *count,
+                               GLenum type, const GLvoid * const *indices,
+                               GLsizei primcount, GLint modestride);
+
+extern void GLAPIENTRY
+_mesa_PrimitiveRestartIndex(GLuint index);
+
+extern unsigned
+_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type);
+
+#endif /* DRAW_H */
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 0f38270..3786c74 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1211,86 +1211,6 @@ _mesa_UnlockArraysEXT( void )
 }
 
 
-/* GL_EXT_multi_draw_arrays */
-void GLAPIENTRY
-_mesa_MultiDrawArrays( GLenum mode, const GLint *first,
-                          const GLsizei *count, GLsizei primcount )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   GLint i;
-
-   FLUSH_VERTICES(ctx, 0);
-
-   for (i = 0; i < primcount; i++) {
-      if (count[i] > 0) {
-         CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
-      }
-   }
-}
-
-
-/* GL_IBM_multimode_draw_arrays */
-void GLAPIENTRY
-_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
-			      const GLsizei * count,
-			      GLsizei primcount, GLint modestride )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   GLint i;
-
-   FLUSH_VERTICES(ctx, 0);
-
-   for ( i = 0 ; i < primcount ; i++ ) {
-      if ( count[i] > 0 ) {
-         GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
-	 CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] ));
-      }
-   }
-}
-
-
-/* GL_IBM_multimode_draw_arrays */
-void GLAPIENTRY
-_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
-				GLenum type, const GLvoid * const * indices,
-				GLsizei primcount, GLint modestride )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   GLint i;
-
-   FLUSH_VERTICES(ctx, 0);
-
-   /* XXX not sure about ARB_vertex_buffer_object handling here */
-
-   for ( i = 0 ; i < primcount ; i++ ) {
-      if ( count[i] > 0 ) {
-         GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
-	 CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] ));
-      }
-   }
-}
-
-
-/**
- * GL_NV_primitive_restart and GL 3.1
- */
-void GLAPIENTRY
-_mesa_PrimitiveRestartIndex(GLuint index)
-{
-   GET_CURRENT_CONTEXT(ctx);
-
-   if (!ctx->Extensions.NV_primitive_restart && ctx->Version < 31) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndexNV()");
-      return;
-   }
-
-   if (ctx->Array.RestartIndex != index) {
-      FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
-      ctx->Array.RestartIndex = index;
-   }
-}
-
-
 /**
  * See GL_ARB_instanced_arrays.
  * Note that the instance divisor only applies to generic arrays, not
@@ -1332,31 +1252,6 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
 }
 
 
-unsigned
-_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type)
-{
-   /* From the OpenGL 4.3 core specification, page 302:
-    * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are
-    *  enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX
-    *  is used."
-    */
-   if (ctx->Array.PrimitiveRestartFixedIndex) {
-      switch (ib_type) {
-      case GL_UNSIGNED_BYTE:
-         return 0xff;
-      case GL_UNSIGNED_SHORT:
-         return 0xffff;
-      case GL_UNSIGNED_INT:
-         return 0xffffffff;
-      default:
-         assert(!"_mesa_primitive_restart_index: Invalid index buffer type.");
-      }
-   }
-
-   return ctx->Array.RestartIndex;
-}
-
-
 /**
  * GL_ARB_vertex_attrib_binding
  */
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index bc820ed..83ebcc1 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -221,31 +221,6 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
 
 
 extern void GLAPIENTRY
-_mesa_MultiDrawArrays( GLenum mode, const GLint *first,
-                          const GLsizei *count, GLsizei primcount );
-
-extern void GLAPIENTRY
-_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
-                            const GLvoid **indices, GLsizei primcount );
-
-extern void GLAPIENTRY
-_mesa_MultiDrawElementsBaseVertex( GLenum mode,
-				   const GLsizei *count, GLenum type,
-				   const GLvoid **indices, GLsizei primcount,
-				   const GLint *basevertex);
-
-extern void GLAPIENTRY
-_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
-			      const GLsizei * count,
-			      GLsizei primcount, GLint modestride );
-
-
-extern void GLAPIENTRY
-_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
-				GLenum type, const GLvoid * const * indices,
-				GLsizei primcount, GLint modestride );
-
-extern void GLAPIENTRY
 _mesa_LockArraysEXT(GLint first, GLsizei count);
 
 extern void GLAPIENTRY
@@ -253,38 +228,8 @@ _mesa_UnlockArraysEXT( void );
 
 
 extern void GLAPIENTRY
-_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
-
-extern void GLAPIENTRY
-_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
-                   const GLvoid *indices);
-
-extern void GLAPIENTRY
-_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
-                        GLenum type, const GLvoid *indices);
-
-extern void GLAPIENTRY
-_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
-			     const GLvoid *indices, GLint basevertex);
-
-extern void GLAPIENTRY
-_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
-				  GLsizei count, GLenum type,
-				  const GLvoid *indices,
-				  GLint basevertex);
-
-extern void GLAPIENTRY
-_mesa_DrawTransformFeedback(GLenum mode, GLuint name);
-
-extern void GLAPIENTRY
-_mesa_PrimitiveRestartIndex(GLuint index);
-
-
-extern void GLAPIENTRY
 _mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
 
-extern unsigned
-_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type);
 
 extern void GLAPIENTRY
 _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index d723823..286a03c 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -28,6 +28,7 @@
 
 #include "main/glheader.h"
 #include "main/context.h"
+#include "main/draw.h"
 #include "main/state.h"
 #include "main/api_validate.h"
 #include "main/dispatch.h"
diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c
index 418f882..d84ba19 100644
--- a/src/mesa/vbo/vbo_primitive_restart.c
+++ b/src/mesa/vbo/vbo_primitive_restart.c
@@ -30,8 +30,8 @@
 
 #include "main/imports.h"
 #include "main/bufferobj.h"
+#include "main/draw.h"
 #include "main/macros.h"
-#include "main/varray.h"
 
 #include "vbo.h"
 #include "vbo_context.h"
-- 
1.7.10.4



More information about the mesa-dev mailing list