[Mesa-dev] [PATCH 3/9] mesa: Add QueryBuffer to context
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jan 11 11:06:17 PST 2016
On Mon, Jan 11, 2016 at 2:07 PM, Nanley Chery <nanleychery at gmail.com> wrote:
> On Sun, Jan 10, 2016 at 12:14:51AM -0500, Ilia Mirkin wrote:
>> From: Rafal Mielniczuk <rafal.mielniczuk2 at gmail.com>
>>
>> Add QueryBuffer and initialise it to NullBufferObj on start
>>
>> Signed-off-by: Rafal Mielniczuk <rafal.mielniczuk2 at gmail.com>
>> [imirkin: also release QueryBuffer on free]
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>> src/mesa/main/bufferobj.c | 14 ++++++++++++++
>> src/mesa/main/mtypes.h | 2 ++
>> 2 files changed, 16 insertions(+)
>>
>> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
>> index 14ee8c8..abaa892 100644
>> --- a/src/mesa/main/bufferobj.c
>> +++ b/src/mesa/main/bufferobj.c
>> @@ -120,6 +120,10 @@ 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)
>
> Please replace this expression and lookups of the Extensions struct in
> the following patches with _mesa_has_ARB_query_buffer_object(ctx).
> Open-coding checks for extension support is error-prone.
Will do. This patch is from early 2014, well before your changes :)
>
> - Nanley
>
>> + return &ctx->QueryBuffer;
>> + break;
>> case GL_DRAW_INDIRECT_BUFFER:
>> if ((ctx->API == API_OPENGL_CORE &&
>> ctx->Extensions.ARB_draw_indirect) ||
>> @@ -877,6 +881,9 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
>> _mesa_reference_buffer_object(ctx, &ctx->DispatchIndirectBuffer,
>> 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,
>> @@ -925,6 +932,8 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
>>
>> _mesa_reference_buffer_object(ctx, &ctx->DispatchIndirectBuffer, NULL);
>>
>> + _mesa_reference_buffer_object(ctx, &ctx->QueryBuffer, NULL);
>> +
>> for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) {
>> _mesa_reference_buffer_object(ctx,
>> &ctx->UniformBufferBindings[i].BufferObject,
>> @@ -1348,6 +1357,11 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
>> _mesa_BindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
>> }
>>
>> + /* unbind query buffer binding point */
>> + if (ctx->QueryBuffer == bufObj) {
>> + _mesa_BindBuffer(GL_QUERY_BUFFER, 0);
>> + }
>> +
>> /* The ID is immediately freed for re-use */
>> _mesa_HashRemove(ctx->Shared->BufferObjects, ids[i]);
>> /* Make sure we do not run into the classic ABA problem on bind.
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index 372bce8..4e96bc2 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -4367,6 +4367,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.
>> --
>> 2.4.10
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list