mesa: Add binding point for indirect buffer
authorChris Forbes <chrisf@ijw.co.nz>
Wed, 6 Nov 2013 07:03:21 +0000 (20:03 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Mon, 25 Nov 2013 09:01:35 +0000 (22:01 +1300)
Based on part of Patch 2 of Christoph Bumiller's ARB_draw_indirect series.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/bufferobj.c
src/mesa/main/get.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h

index b27f592e842373685f7bc54e3b2b9d2023175ea7..8b5ebc48904337dbe033274dbd6b42af085ecb6b 100644 (file)
@@ -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 );
index 6e6b7b79e209712a5a864be07d9e2d72dffa8989..7f233409ea977b513d21c05d58b7ed7bd081eff7 100644 (file)
@@ -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;
    }
 }
 
index c961feeeeedca32eb82d758b2068b750bddb96cc..781b796ee2ad18b92d430d3e9248ee9f04f41708 100644 (file)
@@ -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" ],
 ]}
 
 ]
index 0e525af9ddaa3fa828524cc42bf4e88e902e8d91..b4b432f4023735bed2854498f5595c503409b4e4 100644 (file)
@@ -3903,6 +3903,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 */