[Mesa-dev] [PATCH] st/mesa: add support for indirect drawing v2

Christoph Bumiller e0425955 at student.tuwien.ac.at
Fri Apr 5 05:46:11 PDT 2013


v2:
Fix for constness of indirect buffer argument.
Remove separate extension enable for multi_draw_indirect.
---
 src/mesa/state_tracker/st_cb_bufferobjects.c |    3 +++
 src/mesa/state_tracker/st_cb_bufferobjects.h |    6 ++++++
 src/mesa/state_tracker/st_draw.c             |   11 ++++++++++-
 src/mesa/state_tracker/st_extensions.c       |    3 ++-
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 8ff32c8..2e719cc 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -205,6 +205,9 @@ st_bufferobj_data(struct gl_context *ctx,
    case GL_UNIFORM_BUFFER:
       bind = PIPE_BIND_CONSTANT_BUFFER;
       break;
+   case GL_DRAW_INDIRECT_BUFFER:
+      bind = PIPE_BIND_COMMAND_ARGS_BUFFER;
+      break;
    default:
       bind = 0;
    }
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h
index 1c991d2..05cc0fa 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -54,6 +54,12 @@ st_buffer_object(struct gl_buffer_object *obj)
    return (struct st_buffer_object *) obj;
 }
 
+static INLINE const struct st_buffer_object *
+st_const_buffer_object(const struct gl_buffer_object *obj)
+{
+   return (const struct st_buffer_object *) obj;
+}
+
 
 extern void
 st_bufferobj_validate_usage(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 82a4bcd..a07f8be 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -256,6 +256,14 @@ st_draw_vbo(struct gl_context *ctx,
       }
    }
 
+   if (indirect) {
+      info.indirect = st_const_buffer_object(indirect)->buffer;
+
+      /* Primitive restart is not handled by the VBO module in this case. */
+      info.primitive_restart = ctx->Array._PrimitiveRestart;
+      info.restart_index = ctx->Array._RestartIndex;
+   }
+
    /* do actual drawing */
    for (i = 0; i < nr_prims; i++) {
       info.mode = translate_prim( ctx, prims[i].mode );
@@ -268,6 +276,7 @@ st_draw_vbo(struct gl_context *ctx,
          info.min_index = info.start;
          info.max_index = info.start + info.count - 1;
       }
+      info.indirect_offset = prims[i].indirect_offset;
 
       if (ST_DEBUG & DEBUG_DRAW) {
          debug_printf("st/draw: mode %s  start %u  count %u  indexed %d\n",
@@ -277,7 +286,7 @@ st_draw_vbo(struct gl_context *ctx,
                       info.indexed);
       }
 
-      if (info.count_from_stream_output) {
+      if (info.count_from_stream_output || info.indirect) {
          cso_draw_vbo(st->cso_context, &info);
       }
       else if (info.primitive_restart) {
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 11db9d3..0488755 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -398,7 +398,8 @@ void st_init_extensions(struct st_context *st)
       { o(MESA_texture_array),               PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS         },
 
       { o(OES_standard_derivatives),         PIPE_CAP_SM3                              },
-      { o(ARB_texture_cube_map_array),       PIPE_CAP_CUBE_MAP_ARRAY                   }
+      { o(ARB_texture_cube_map_array),       PIPE_CAP_CUBE_MAP_ARRAY                   },
+      { o(ARB_draw_indirect),                PIPE_CAP_DRAW_INDIRECT                    },
    };
 
    /* Required: render target and sampler support */
-- 
1.7.3.4



More information about the mesa-dev mailing list