[Mesa-dev] [PATCH] Make generation of framebuffer and renderbuffer id's threadsafe

Samuel Maroy samuel.maroy at barco.com
Fri Nov 13 02:57:19 PST 2015


This should fix the issue described in
https://bugs.freedesktop.org/show_bug.cgi?id=92633

---
 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

This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>


More information about the mesa-dev mailing list