mesa/vbo: Move _vbo_draw_indirect -> _mesa_draw_indirect
authorMathias Fröhlich <mathias.froehlich@web.de>
Mon, 29 Oct 2018 05:13:20 +0000 (06:13 +0100)
committerMathias Fröhlich <mathias.froehlich@web.de>
Thu, 1 Nov 2018 05:08:49 +0000 (06:08 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/drivers/common/driverfuncs.c
src/mesa/main/draw.c
src/mesa/main/draw.h
src/mesa/vbo/vbo.h
src/mesa/vbo/vbo_context.c

index e783262773e1f8139d1f43c2443b2941841df998..bdfac61f3440091503c0c5a6e386d3f5373586aa 100644 (file)
@@ -28,6 +28,7 @@
 #include "main/accum.h"
 #include "main/arrayobj.h"
 #include "main/context.h"
+#include "main/draw.h"
 #include "main/formatquery.h"
 #include "main/framebuffer.h"
 #include "main/mipmap.h"
@@ -55,7 +56,6 @@
 #include "tnl/tnl.h"
 #include "swrast/swrast.h"
 #include "swrast/s_renderbuffer.h"
-#include "vbo/vbo.h"
 
 #include "driverfuncs.h"
 #include "meta.h"
@@ -122,7 +122,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
 
    /* Draw functions */
    driver->Draw = NULL;
-   driver->DrawIndirect = _vbo_draw_indirect;
+   driver->DrawIndirect = _mesa_draw_indirect;
 
    /* simple state commands */
    driver->AlphaFunc = NULL;
index 7729a860d02578fb39c0fb03e365b0827a672327..85a9eedbc3225574a1c4c770cdbd9e599b603131 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include "arrayobj.h"
 #include "glheader.h"
+#include "c99_alloca.h"
 #include "context.h"
 #include "state.h"
 #include "draw.h"
@@ -2143,3 +2144,76 @@ _mesa_DrawTransformFeedback(GLenum mode, GLuint name)
 {
    _mesa_exec_DrawTransformFeedback(mode, name);
 }
+
+
+/*
+ * Helper function for _mesa_draw_indirect below that additionally takes a zero
+ * initialized array of _mesa_prim scratch space memory as the last argument.
+ */
+static void
+draw_indirect(struct gl_context *ctx, GLuint mode,
+              struct gl_buffer_object *indirect_data,
+              GLsizeiptr indirect_offset, unsigned draw_count,
+              unsigned stride,
+              struct gl_buffer_object *indirect_draw_count_buffer,
+              GLsizeiptr indirect_draw_count_offset,
+              const struct _mesa_index_buffer *ib,
+              struct _mesa_prim *prim)
+{
+   prim[0].begin = 1;
+   prim[draw_count - 1].end = 1;
+   for (unsigned i = 0; i < draw_count; ++i, indirect_offset += stride) {
+      prim[i].mode = mode;
+      prim[i].indexed = !!ib;
+      prim[i].indirect_offset = indirect_offset;
+      prim[i].is_indirect = 1;
+      prim[i].draw_id = i;
+   }
+
+   /* This should always be true at this time */
+   assert(indirect_data == ctx->DrawIndirectBuffer);
+
+   ctx->Driver.Draw(ctx, prim, draw_count, ib, false, 0u, ~0u,
+                    NULL, 0, indirect_data);
+}
+
+
+/*
+ * Function to be put into dd_function_table::DrawIndirect as fallback.
+ * Calls into dd_function_table::Draw past adapting call arguments.
+ * See dd_function_table::DrawIndirect for call argument documentation.
+ */
+void
+_mesa_draw_indirect(struct gl_context *ctx, GLuint mode,
+                    struct gl_buffer_object *indirect_data,
+                    GLsizeiptr indirect_offset, unsigned draw_count,
+                    unsigned stride,
+                    struct gl_buffer_object *indirect_draw_count_buffer,
+                    GLsizeiptr indirect_draw_count_offset,
+                    const struct _mesa_index_buffer *ib)
+{
+   /* Use alloca for the prim space if we are somehow in bounds. */
+   if (draw_count*sizeof(struct _mesa_prim) < 1024) {
+      struct _mesa_prim *space = alloca(draw_count*sizeof(struct _mesa_prim));
+      memset(space, 0, draw_count*sizeof(struct _mesa_prim));
+
+      draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
+                    stride, indirect_draw_count_buffer,
+                    indirect_draw_count_offset, ib, space);
+   } else {
+      struct _mesa_prim *space = calloc(draw_count, sizeof(struct _mesa_prim));
+      if (space == NULL) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
+                     (draw_count > 1) ? "Multi" : "",
+                     ib ? "Elements" : "Arrays",
+                     indirect_data ? "CountARB" : "");
+         return;
+      }
+
+      draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
+                    stride, indirect_draw_count_buffer,
+                    indirect_draw_count_offset, ib, space);
+
+      free(space);
+   }
+}
index 0200af6797ff036236554b6a8c4d9a759962d6cc..57b3ec9e7db6ac4205c7e416b84bfd46f030859d 100644 (file)
@@ -76,6 +76,17 @@ void
 _mesa_initialize_exec_dispatch(const struct gl_context *ctx,
                                struct _glapi_table *exec);
 
+
+void
+_mesa_draw_indirect(struct gl_context *ctx, GLuint mode,
+                    struct gl_buffer_object *indirect_data,
+                    GLsizeiptr indirect_offset, unsigned draw_count,
+                    unsigned stride,
+                    struct gl_buffer_object *indirect_draw_count_buffer,
+                    GLsizeiptr indirect_draw_count_offset,
+                    const struct _mesa_index_buffer *ib);
+
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index cab01dcf478d86edf8e112daf0f8b92ba94228e4..3399fcdea466f88bd0e5e6243ddb4addfa74ade6 100644 (file)
@@ -84,16 +84,6 @@ void
 vbo_save_EndCallList(struct gl_context *ctx);
 
 
-void
-_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
-                        struct gl_buffer_object *indirect_data,
-                        GLsizeiptr indirect_offset, unsigned draw_count,
-                        unsigned stride,
-                        struct gl_buffer_object *indirect_draw_count_buffer,
-                        GLsizeiptr indirect_draw_count_offset,
-                        const struct _mesa_index_buffer *ib);
-
-
 void
 vbo_delete_minmax_cache(struct gl_buffer_object *bufferObj);
 
index cf9405df3dc9b81566c3e33b1d1741556edcf41a..364de2c507e009c9f6c260bbdef82e0d7ba5d810 100644 (file)
@@ -25,7 +25,6 @@
  *    Keith Whitwell <keithw@vmware.com>
  */
 
-#include "c99_alloca.h"
 #include "main/errors.h"
 #include "main/bufferobj.h"
 #include "math/m_eval.h"
@@ -249,76 +248,3 @@ _vbo_current_binding(const struct gl_context *ctx)
    const struct vbo_context *vbo = vbo_context_const(ctx);
    return &vbo->binding;
 }
-
-
-/*
- * Helper function for _vbo_draw_indirect below that additionally takes a zero
- * initialized array of _mesa_prim scratch space memory as the last argument.
- */
-static void
-draw_indirect(struct gl_context *ctx, GLuint mode,
-              struct gl_buffer_object *indirect_data,
-              GLsizeiptr indirect_offset, unsigned draw_count,
-              unsigned stride,
-              struct gl_buffer_object *indirect_draw_count_buffer,
-              GLsizeiptr indirect_draw_count_offset,
-              const struct _mesa_index_buffer *ib,
-              struct _mesa_prim *prim)
-{
-   prim[0].begin = 1;
-   prim[draw_count - 1].end = 1;
-   for (unsigned i = 0; i < draw_count; ++i, indirect_offset += stride) {
-      prim[i].mode = mode;
-      prim[i].indexed = !!ib;
-      prim[i].indirect_offset = indirect_offset;
-      prim[i].is_indirect = 1;
-      prim[i].draw_id = i;
-   }
-
-   /* This should always be true at this time */
-   assert(indirect_data == ctx->DrawIndirectBuffer);
-
-   ctx->Driver.Draw(ctx, prim, draw_count, ib, false, 0u, ~0u,
-                    NULL, 0, indirect_data);
-}
-
-
-/*
- * Function to be put into dd_function_table::DrawIndirect as fallback.
- * Calls into dd_function_table::Draw past adapting call arguments.
- * See dd_function_table::DrawIndirect for call argument documentation.
- */
-void
-_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
-                   struct gl_buffer_object *indirect_data,
-                   GLsizeiptr indirect_offset, unsigned draw_count,
-                   unsigned stride,
-                   struct gl_buffer_object *indirect_draw_count_buffer,
-                   GLsizeiptr indirect_draw_count_offset,
-                   const struct _mesa_index_buffer *ib)
-{
-   /* Use alloca for the prim space if we are somehow in bounds. */
-   if (draw_count*sizeof(struct _mesa_prim) < 1024) {
-      struct _mesa_prim *space = alloca(draw_count*sizeof(struct _mesa_prim));
-      memset(space, 0, draw_count*sizeof(struct _mesa_prim));
-
-      draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
-                    stride, indirect_draw_count_buffer,
-                    indirect_draw_count_offset, ib, space);
-   } else {
-      struct _mesa_prim *space = calloc(draw_count, sizeof(struct _mesa_prim));
-      if (space == NULL) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
-                     (draw_count > 1) ? "Multi" : "",
-                     ib ? "Elements" : "Arrays",
-                     indirect_data ? "CountARB" : "");
-         return;
-      }
-
-      draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
-                    stride, indirect_draw_count_buffer,
-                    indirect_draw_count_offset, ib, space);
-
-      free(space);
-   }
-}