[Mesa-dev] [PATCH] mesa: tidy up renderbuffer RefCount initialisation

Brian Paul brianp at vmware.com
Wed Apr 5 17:21:17 UTC 2017


On 04/05/2017 05:06 AM, Timothy Arceri wrote:
> 42aaa548 changed the renderbuffer initialisation of RefCount from
> 1 to 0.
>
> This is inconsitent with how we use RefCount elsewhere. Also every
> driver implementation of NewRenderbuffer() calls
> _mesa_init_renderbuffer() so its safe to set it there.
> ---
>   src/mesa/drivers/common/meta.c | 2 --
>   src/mesa/main/fbobject.c       | 1 -
>   src/mesa/main/renderbuffer.c   | 2 +-
>   3 files changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index efbc934..f4c91ac 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -3037,22 +3037,20 @@ decompress_texture_image(struct gl_context *ctx,
>                                     ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler);
>
>      /* Create/bind FBO/renderbuffer */
>      if (decompress_fbo->fb == NULL) {
>         decompress_fbo->rb = ctx->Driver.NewRenderbuffer(ctx, 0xDEADBEEF);
>         if (decompress_fbo->rb == NULL) {
>            _mesa_meta_end(ctx);
>            return false;
>         }
>
> -      decompress_fbo->rb->RefCount = 1;
> -
>         decompress_fbo->fb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
>         if (decompress_fbo->fb == NULL) {
>            _mesa_meta_end(ctx);
>            return false;
>         }
>
>         _mesa_bind_framebuffers(ctx, decompress_fbo->fb, decompress_fbo->fb);
>         _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, GL_COLOR_ATTACHMENT0,
>                                        decompress_fbo->rb);
>      }
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 4d9a7b8..e52c1e3 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -1309,21 +1309,20 @@ allocate_renderbuffer_locked(struct gl_context *ctx, GLuint renderbuffer,
>      struct gl_renderbuffer *newRb;
>
>      /* create new renderbuffer object */
>      newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer);
>      if (!newRb) {
>         _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
>         return NULL;
>      }
>      assert(newRb->AllocStorage);
>      _mesa_HashInsertLocked(ctx->Shared->RenderBuffers, renderbuffer, newRb);
> -   newRb->RefCount = 1; /* referenced by hash table */
>
>      return newRb;
>   }
>
>
>   static void
>   bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
>   {
>      struct gl_renderbuffer *newRb;
>      GET_CURRENT_CONTEXT(ctx);
> diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
> index 53e0b74..1d24e9c 100644
> --- a/src/mesa/main/renderbuffer.c
> +++ b/src/mesa/main/renderbuffer.c
> @@ -36,21 +36,21 @@
>   /**
>    * Initialize the fields of a gl_renderbuffer to default values.
>    */
>   void
>   _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
>   {
>      GET_CURRENT_CONTEXT(ctx);
>
>      rb->ClassID = 0;
>      rb->Name = name;
> -   rb->RefCount = 0;
> +   rb->RefCount = 1;
>      rb->Delete = _mesa_delete_renderbuffer;
>
>      /* The rest of these should be set later by the caller of this function or
>       * the AllocStorage method:
>       */
>      rb->AllocStorage = NULL;
>
>      rb->Width = 0;
>      rb->Height = 0;
>      rb->Depth = 0;
>

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list