From 9327e2d312e5da58f1cf4dbb806c67fcefd892f5 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Thu, 31 Dec 2015 15:47:17 -0500 Subject: [PATCH] mesa: add parameter buffer, used for ARB_indirect_parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Ilia Mirkin Reviewed-by: Marek Olšák --- src/mesa/main/bufferobj.c | 15 +++++++++++++++ src/mesa/main/get.c | 5 +++++ src/mesa/main/get_hash_params.py | 4 ++++ src/mesa/main/mtypes.h | 1 + 4 files changed, 25 insertions(+) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index a1e47d62773..d7c5680661b 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -127,6 +127,11 @@ get_buffer_target(struct gl_context *ctx, GLenum target) return &ctx->DrawIndirectBuffer; } break; + case GL_PARAMETER_BUFFER_ARB: + if (_mesa_has_ARB_indirect_parameters(ctx)) { + return &ctx->ParameterBuffer; + } + break; case GL_DISPATCH_INDIRECT_BUFFER: if (_mesa_has_compute_shaders(ctx)) { return &ctx->DispatchIndirectBuffer; @@ -866,6 +871,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->ParameterBuffer, + ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->DispatchIndirectBuffer, ctx->Shared->NullBufferObj); @@ -913,6 +921,8 @@ _mesa_free_buffer_objects( struct gl_context *ctx ) _mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer, NULL); + _mesa_reference_buffer_object(ctx, &ctx->ParameterBuffer, NULL); + _mesa_reference_buffer_object(ctx, &ctx->DispatchIndirectBuffer, NULL); for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) { @@ -1261,6 +1271,11 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids) _mesa_BindBuffer( GL_DRAW_INDIRECT_BUFFER, 0 ); } + /* unbind ARB_indirect_parameters binding point */ + if (ctx->ParameterBuffer == bufObj) { + _mesa_BindBuffer(GL_PARAMETER_BUFFER_ARB, 0); + } + /* unbind ARB_compute_shader binding point */ if (ctx->DispatchIndirectBuffer == bufObj) { _mesa_BindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0); diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index c6a2e5b912c..95cb18c8ee8 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -423,6 +423,7 @@ EXTRA_EXT(ARB_framebuffer_no_attachments); EXTRA_EXT(ARB_tessellation_shader); EXTRA_EXT(ARB_shader_subroutine); EXTRA_EXT(ARB_shader_storage_buffer_object); +EXTRA_EXT(ARB_indirect_parameters); static const int extra_ARB_color_buffer_float_or_glcore[] = { @@ -1032,6 +1033,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu case GL_DRAW_INDIRECT_BUFFER_BINDING: v->value_int = ctx->DrawIndirectBuffer->Name; break; + /* GL_ARB_indirect_parameters */ + case GL_PARAMETER_BUFFER_BINDING_ARB: + v->value_int = ctx->ParameterBuffer->Name; + break; /* GL_ARB_separate_shader_objects */ case GL_PROGRAM_PIPELINE_BINDING: if (ctx->Pipeline.Current) { diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index 7a48ed2f414..af7a8f4a906 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -887,6 +887,10 @@ descriptor=[ # GL_ARB_shader_subroutine [ "MAX_SUBROUTINES", "CONST(MAX_SUBROUTINES), extra_ARB_shader_subroutine" ], [ "MAX_SUBROUTINE_UNIFORM_LOCATIONS", "CONST(MAX_SUBROUTINE_UNIFORM_LOCATIONS), extra_ARB_shader_subroutine" ], + +# GL_ARB_indirect_parameters + [ "PARAMETER_BUFFER_BINDING_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_indirect_parameters" ], + ]} ] diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5cd2e8eb3af..dd52368ef65 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4349,6 +4349,7 @@ struct gl_context struct gl_perf_monitor_state PerfMonitor; struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */ + struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */ struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */ struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ -- 2.30.2