[Mesa-dev,v3,3/9] mesa: Add QueryBuffer to context

Submitted by Rafal Mielniczuk on April 1, 2014, 9:10 a.m.

Details

Message ID 1396343428-27053-1-git-send-email-rafal.mielniczuk2@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Rafal Mielniczuk April 1, 2014, 9:10 a.m.
v2: Add check for desktop gl and ARB_query_buffer_object extension
    when returning QueryBuffer in get_buffer_target

Add QueryBuffer and initialise it to NullBufferObj
on start
---
 src/mesa/main/bufferobj.c | 8 ++++++++
 src/mesa/main/mtypes.h    | 2 ++
 2 files changed, 10 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 2e9e059..f1dbc7e 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -89,6 +89,11 @@  get_buffer_target(struct gl_context *ctx, GLenum target)
       return &ctx->CopyReadBuffer;
    case GL_COPY_WRITE_BUFFER:
       return &ctx->CopyWriteBuffer;
+   case GL_QUERY_BUFFER:
+      if (_mesa_is_desktop_gl(ctx)
+          && ctx->Extensions.ARB_query_buffer_object)
+         return &ctx->QueryBuffer;
+      break;
    case GL_DRAW_INDIRECT_BUFFER:
       if (ctx->API == API_OPENGL_CORE &&
           ctx->Extensions.ARB_draw_indirect) {
@@ -835,6 +840,9 @@  _mesa_init_buffer_objects( struct gl_context *ctx )
    _mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer,
 				 ctx->Shared->NullBufferObj);
 
+   _mesa_reference_buffer_object(ctx, &ctx->QueryBuffer,
+                                 ctx->Shared->NullBufferObj);
+
    for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) {
       _mesa_reference_buffer_object(ctx,
 				    &ctx->UniformBufferBindings[i].BufferObject,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3e3e6fd..ebb581c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4164,6 +4164,8 @@  struct gl_context
    struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
    struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
 
+   struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */
+
    /**
     * Current GL_ARB_uniform_buffer_object binding referenced by
     * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.