[Mesa-dev] [PATCH V3 04/13] mesa: Add binding point for indirect buffer

Chris Forbes chrisf at ijw.co.nz
Sat Nov 9 01:02:30 PST 2013


Based on part of Patch 2 of Christoph Bumiller's ARB_draw_indirect series.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/main/bufferobj.c        | 14 ++++++++++++++
 src/mesa/main/get.c              |  4 ++++
 src/mesa/main/get_hash_params.py |  2 ++
 src/mesa/main/mtypes.h           |  2 ++
 4 files changed, 22 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b27f592..8b5ebc4 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -86,6 +86,12 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
       return &ctx->CopyReadBuffer;
    case GL_COPY_WRITE_BUFFER:
       return &ctx->CopyWriteBuffer;
+   case GL_DRAW_INDIRECT_BUFFER:
+      if (ctx->API == API_OPENGL_CORE &&
+          ctx->Extensions.ARB_draw_indirect) {
+         return &ctx->DrawIndirectBuffer;
+      }
+      break;
    case GL_TRANSFORM_FEEDBACK_BUFFER:
       if (ctx->Extensions.EXT_transform_feedback) {
          return &ctx->TransformFeedback.CurrentBuffer;
@@ -626,6 +632,9 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
    _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer,
 				 ctx->Shared->NullBufferObj);
 
+   _mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer,
+				 ctx->Shared->NullBufferObj);
+
    for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) {
       _mesa_reference_buffer_object(ctx,
 				    &ctx->UniformBufferBindings[i].BufferObject,
@@ -875,6 +884,11 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
             _mesa_BindBuffer( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
          }
 
+         /* unbind ARB_draw_indirect binding point */
+         if (ctx->DrawIndirectBuffer == bufObj) {
+            _mesa_BindBuffer( GL_DRAW_INDIRECT_BUFFER, 0 );
+         }
+
          /* unbind ARB_copy_buffer binding points */
          if (ctx->CopyReadBuffer == bufObj) {
             _mesa_BindBuffer( GL_COPY_READ_BUFFER, 0 );
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 6e6b7b7..7f23340 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -914,6 +914,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
    case GL_ATOMIC_COUNTER_BUFFER_BINDING:
       v->value_int = ctx->AtomicBuffer->Name;
       break;
+   /* GL_ARB_draw_indirect */
+   case GL_DRAW_INDIRECT_BUFFER_BINDING:
+      v->value_int = ctx->DrawIndirectBuffer->Name;
+      break;
    }
 }
 
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index c961fee..781b796 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -747,6 +747,8 @@ descriptor=[
 { "apis": ["GL_CORE"], "params": [
 # GL_ARB_texture_buffer_range
   [ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ],
+# GL_ARB_draw_indirect
+  [ "DRAW_INDIRECT_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_draw_indirect" ],
 ]}
 
 ]
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d5744e7..e2891b4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3865,6 +3865,8 @@ struct gl_context
 
    struct gl_perf_monitor_state PerfMonitor;
 
+   struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */
+
    struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
    struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
 
-- 
1.8.4.2



More information about the mesa-dev mailing list