[Mesa-dev] [PATCH 3/3] mesa: use internal function when deleting buffers
Nicolai Hähnle
nhaehnle at gmail.com
Wed Apr 5 09:52:13 UTC 2017
On 05.04.2017 03:41, Timothy Arceri wrote:
> This avoids validation and looking up the buffer for a second time.
s/buffer/buffer target/? The buffer itself isn't looked up. Apart from
this, the series is
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
> ---
> src/mesa/main/bufferobj.c | 32 ++++++++++++++++----------------
> 1 file changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 9669f8a..d9aee58 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -1300,111 +1300,111 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
> assert(bufObj->Name == ids[i] || bufObj == &DummyBufferObject);
>
> _mesa_buffer_unmap_all_mappings(ctx, bufObj);
>
> /* unbind any vertex pointers bound to this buffer */
> for (j = 0; j < ARRAY_SIZE(vao->BufferBinding); j++) {
> unbind(ctx, vao, j, bufObj);
> }
>
> if (ctx->Array.ArrayBufferObj == bufObj) {
> - _mesa_BindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
> + bind_buffer_object(ctx, &ctx->Array.ArrayBufferObj, 0);
> }
> if (vao->IndexBufferObj == bufObj) {
> - _mesa_BindBuffer( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
> + bind_buffer_object(ctx, &vao->IndexBufferObj, 0);
> }
>
> /* unbind ARB_draw_indirect binding point */
> if (ctx->DrawIndirectBuffer == bufObj) {
> - _mesa_BindBuffer( GL_DRAW_INDIRECT_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->DrawIndirectBuffer, 0);
> }
>
> /* unbind ARB_indirect_parameters binding point */
> if (ctx->ParameterBuffer == bufObj) {
> - _mesa_BindBuffer(GL_PARAMETER_BUFFER_ARB, 0);
> + bind_buffer_object(ctx, &ctx->ParameterBuffer, 0);
> }
>
> /* unbind ARB_compute_shader binding point */
> if (ctx->DispatchIndirectBuffer == bufObj) {
> - _mesa_BindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0);
> + bind_buffer_object(ctx, &ctx->DispatchIndirectBuffer, 0);
> }
>
> /* unbind ARB_copy_buffer binding points */
> if (ctx->CopyReadBuffer == bufObj) {
> - _mesa_BindBuffer( GL_COPY_READ_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->CopyReadBuffer, 0);
> }
> if (ctx->CopyWriteBuffer == bufObj) {
> - _mesa_BindBuffer( GL_COPY_WRITE_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->CopyWriteBuffer, 0);
> }
>
> /* unbind transform feedback binding points */
> if (ctx->TransformFeedback.CurrentBuffer == bufObj) {
> - _mesa_BindBuffer( GL_TRANSFORM_FEEDBACK_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, 0);
> }
> for (j = 0; j < MAX_FEEDBACK_BUFFERS; j++) {
> if (ctx->TransformFeedback.CurrentObject->Buffers[j] == bufObj) {
> _mesa_BindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, j, 0 );
> }
> }
>
> /* unbind UBO binding points */
> for (j = 0; j < ctx->Const.MaxUniformBufferBindings; j++) {
> if (ctx->UniformBufferBindings[j].BufferObject == bufObj) {
> _mesa_BindBufferBase( GL_UNIFORM_BUFFER, j, 0 );
> }
> }
>
> if (ctx->UniformBuffer == bufObj) {
> - _mesa_BindBuffer( GL_UNIFORM_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->UniformBuffer, 0);
> }
>
> /* unbind SSBO binding points */
> for (j = 0; j < ctx->Const.MaxShaderStorageBufferBindings; j++) {
> if (ctx->ShaderStorageBufferBindings[j].BufferObject == bufObj) {
> _mesa_BindBufferBase(GL_SHADER_STORAGE_BUFFER, j, 0);
> }
> }
>
> if (ctx->ShaderStorageBuffer == bufObj) {
> - _mesa_BindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
> + bind_buffer_object(ctx, &ctx->ShaderStorageBuffer, 0);
> }
>
> /* unbind Atomci Buffer binding points */
> for (j = 0; j < ctx->Const.MaxAtomicBufferBindings; j++) {
> if (ctx->AtomicBufferBindings[j].BufferObject == bufObj) {
> _mesa_BindBufferBase( GL_ATOMIC_COUNTER_BUFFER, j, 0 );
> }
> }
>
> if (ctx->AtomicBuffer == bufObj) {
> - _mesa_BindBuffer( GL_ATOMIC_COUNTER_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->AtomicBuffer, 0);
> }
>
> /* unbind any pixel pack/unpack pointers bound to this buffer */
> if (ctx->Pack.BufferObj == bufObj) {
> - _mesa_BindBuffer( GL_PIXEL_PACK_BUFFER_EXT, 0 );
> + bind_buffer_object(ctx, &ctx->Pack.BufferObj, 0);
> }
> if (ctx->Unpack.BufferObj == bufObj) {
> - _mesa_BindBuffer( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
> + bind_buffer_object(ctx, &ctx->Unpack.BufferObj, 0);
> }
>
> if (ctx->Texture.BufferObject == bufObj) {
> - _mesa_BindBuffer( GL_TEXTURE_BUFFER, 0 );
> + bind_buffer_object(ctx, &ctx->Texture.BufferObject, 0);
> }
>
> if (ctx->ExternalVirtualMemoryBuffer == bufObj) {
> - _mesa_BindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
> + bind_buffer_object(ctx, &ctx->ExternalVirtualMemoryBuffer, 0);
> }
>
> /* unbind query buffer binding point */
> if (ctx->QueryBuffer == bufObj) {
> - _mesa_BindBuffer(GL_QUERY_BUFFER, 0);
> + bind_buffer_object(ctx, &ctx->QueryBuffer, 0);
> }
>
> /* The ID is immediately freed for re-use */
> _mesa_HashRemoveLocked(ctx->Shared->BufferObjects, ids[i]);
> /* Make sure we do not run into the classic ABA problem on bind.
> * We don't want to allow re-binding a buffer object that's been
> * "deleted" by glDeleteBuffers().
> *
> * The explicit rebinding to the default object in the current context
> * prevents the above in the current context, but another context
>
--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
More information about the mesa-dev
mailing list