From d8c828816e830f75b446b41569edddf7abe4c455 Mon Sep 17 00:00:00 2001 From: Barco User Date: Mon, 26 Oct 2015 14:15:13 +0100 Subject: [PATCH] Make generation of framebuffer and renderbuffer id's threadsafe --- src/mesa/main/fbobject.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index fe6bdc2..6398ff6 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1637,6 +1637,8 @@ create_render_buffers(struct gl_context *ctx, GLsizei n, GLuint *renderbuffers, if (!renderbuffers) return; + mtx_lock(&ctx->Shared->Mutex); + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); for (i = 0; i < n; i++) { @@ -1647,11 +1649,10 @@ create_render_buffers(struct gl_context *ctx, GLsizei n, GLuint *renderbuffers, allocate_renderbuffer(ctx, name, func); } else { /* insert a dummy renderbuffer into the hash table */ - mtx_lock(&ctx->Shared->Mutex); _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); - mtx_unlock(&ctx->Shared->Mutex); } } + mtx_unlock(&ctx->Shared->Mutex); } @@ -2650,6 +2651,7 @@ create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa) if (!framebuffers) return; + mtx_lock(&ctx->Shared->Mutex); first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); for (i = 0; i < n; i++) { @@ -2660,16 +2662,17 @@ create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa) fb = ctx->Driver.NewFramebuffer(ctx, framebuffers[i]); if (!fb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); - return; + goto beach; } } else fb = &DummyFramebuffer; - mtx_lock(&ctx->Shared->Mutex); _mesa_HashInsert(ctx->Shared->FrameBuffers, name, fb); - mtx_unlock(&ctx->Shared->Mutex); } + +beach: + mtx_unlock(&ctx->Shared->Mutex); } -- 2.1.4