[Mesa-dev] [PATCH] mesa: rename _mesa_add_renderbuffer* functions

Brian Paul brianp at vmware.com
Fri Apr 14 15:44:57 UTC 2017


Looks ok, just minor formatting nit-picks below.

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


On 04/13/2017 09:42 PM, Timothy Arceri wrote:
> These names so make is easier to understand what is going on in
> regards to references.
>
> Cc: Brian Paul <brianp at vmware.com>
> ---
>   src/mesa/drivers/dri/i915/intel_screen.c      | 10 +++++-----
>   src/mesa/drivers/dri/i965/intel_screen.c      | 14 +++++++-------
>   src/mesa/drivers/dri/nouveau/nouveau_screen.c | 12 ++++++------
>   src/mesa/drivers/dri/radeon/radeon_screen.c   | 12 ++++++------
>   src/mesa/drivers/dri/swrast/swrast.c          |  4 ++--
>   src/mesa/drivers/osmesa/osmesa.c              | 10 +++++-----
>   src/mesa/drivers/x11/xm_api.c                 |  4 ++--
>   src/mesa/main/renderbuffer.c                  |  4 ++--
>   src/mesa/main/renderbuffer.h                  |  4 ++--
>   src/mesa/state_tracker/st_manager.c           |  8 ++++----
>   src/mesa/swrast/s_renderbuffer.c              | 14 +++++++-------
>   11 files changed, 48 insertions(+), 48 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
> index 7e17e95..ecbc47f 100644
> --- a/src/mesa/drivers/dri/i915/intel_screen.c
> +++ b/src/mesa/drivers/dri/i915/intel_screen.c
> @@ -868,48 +868,48 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
>         rgbFormat = MESA_FORMAT_B5G6R5_UNORM;
>      else if (mesaVis->sRGBCapable)
>         rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;
>      else if (mesaVis->alphaBits == 0)
>         rgbFormat = MESA_FORMAT_B8G8R8X8_UNORM;
>      else
>         rgbFormat = MESA_FORMAT_B8G8R8A8_UNORM;
>
>      /* setup the hardware-based renderbuffers */
>      rb = intel_create_renderbuffer(rgbFormat);
> -   _mesa_add_renderbuffer_without_ref(fb, BUFFER_FRONT_LEFT, &rb->Base.Base);
> +   _mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, &rb->Base.Base);
>
>      if (mesaVis->doubleBufferMode) {
>         rb = intel_create_renderbuffer(rgbFormat);
> -      _mesa_add_renderbuffer_without_ref(fb, BUFFER_BACK_LEFT,
> +      _mesa_attach_and_own_rb(fb, BUFFER_BACK_LEFT,
>                                               &rb->Base.Base);

I think that call could fit on one line now.

>      }
>
>      /*
>       * Assert here that the gl_config has an expected depth/stencil bit
>       * combination: one of d24/s8, d16/s0, d0/s0. (See intelInitScreen2(),
>       * which constructs the advertised configs.)
>       */
>      if (mesaVis->depthBits == 24) {
>         assert(mesaVis->stencilBits == 8);
>
>         /*
>          * Use combined depth/stencil. Note that the renderbuffer is
>          * attached to two attachment points.
>          */
>         rb = intel_create_private_renderbuffer(MESA_FORMAT_Z24_UNORM_S8_UINT);
> -      _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, &rb->Base.Base);
> -      _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base.Base);
> +      _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
> +      _mesa_attach_and_reference_rb(fb, BUFFER_STENCIL, &rb->Base.Base);
>      }
>      else if (mesaVis->depthBits == 16) {
>         assert(mesaVis->stencilBits == 0);
>         rb = intel_create_private_renderbuffer(MESA_FORMAT_Z_UNORM16);
> -      _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, &rb->Base.Base);
> +      _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
>      }
>      else {
>         assert(mesaVis->depthBits == 0);
>         assert(mesaVis->stencilBits == 0);
>      }
>
>      /* now add any/all software-based renderbuffers we may need */
>      _swrast_add_soft_renderbuffers(fb,
>                                     false, /* never sw color */
>                                     false, /* never sw depth */
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index 76e82b0..63db4ec 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -1157,59 +1157,59 @@ intelCreateBuffer(__DRIscreen *dri_screen,
>         rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8X8_UNORM
>                                              : MESA_FORMAT_B8G8R8X8_UNORM;
>      } else {
>         rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_SRGB
>                                              : MESA_FORMAT_B8G8R8A8_SRGB;
>         fb->Visual.sRGBCapable = true;
>      }
>
>      /* setup the hardware-based renderbuffers */
>      rb = intel_create_renderbuffer(rgbFormat, num_samples);
> -   _mesa_add_renderbuffer_without_ref(fb, BUFFER_FRONT_LEFT, &rb->Base.Base);
> +   _mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, &rb->Base.Base);
>
>      if (mesaVis->doubleBufferMode) {
>         rb = intel_create_renderbuffer(rgbFormat, num_samples);
> -      _mesa_add_renderbuffer_without_ref(fb, BUFFER_BACK_LEFT, &rb->Base.Base);
> +      _mesa_attach_and_own_rb(fb, BUFFER_BACK_LEFT, &rb->Base.Base);
>      }
>
>      /*
>       * Assert here that the gl_config has an expected depth/stencil bit
>       * combination: one of d24/s8, d16/s0, d0/s0. (See intelInitScreen2(),
>       * which constructs the advertised configs.)
>       */
>      if (mesaVis->depthBits == 24) {
>         assert(mesaVis->stencilBits == 8);
>
>         if (screen->devinfo.has_hiz_and_separate_stencil) {
>            rb = intel_create_private_renderbuffer(MESA_FORMAT_Z24_UNORM_X8_UINT,
>                                                   num_samples);
> -         _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, &rb->Base.Base);
> +         _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
>            rb = intel_create_private_renderbuffer(MESA_FORMAT_S_UINT8,
>                                                   num_samples);
> -         _mesa_add_renderbuffer_without_ref(fb, BUFFER_STENCIL,
> +         _mesa_attach_and_own_rb(fb, BUFFER_STENCIL,
>                                               &rb->Base.Base);

Here too.

>         } else {
>            /*
>             * Use combined depth/stencil. Note that the renderbuffer is
>             * attached to two attachment points.
>             */
>            rb = intel_create_private_renderbuffer(MESA_FORMAT_Z24_UNORM_S8_UINT,
>                                                   num_samples);
> -         _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, &rb->Base.Base);
> -         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base.Base);
> +         _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
> +         _mesa_attach_and_reference_rb(fb, BUFFER_STENCIL, &rb->Base.Base);
>         }
>      }
>      else if (mesaVis->depthBits == 16) {
>         assert(mesaVis->stencilBits == 0);
>         rb = intel_create_private_renderbuffer(MESA_FORMAT_Z_UNORM16,
>                                                num_samples);
> -      _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, &rb->Base.Base);
> +      _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
>      }
>      else {
>         assert(mesaVis->depthBits == 0);
>         assert(mesaVis->stencilBits == 0);
>      }
>
>      /* now add any/all software-based renderbuffers we may need */
>      _swrast_add_soft_renderbuffers(fb,
>                                     false, /* never sw color */
>                                     false, /* never sw depth */
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
> index 2dbd9d1..375f640 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
> @@ -252,41 +252,41 @@ nouveau_create_buffer(__DRIscreen *dri_screen,
>   		color_format = GL_RGB8;
>   	else
>   		color_format = GL_RGBA8;
>
>   	fb = nouveau_framebuffer_dri_new(visual);
>   	if (!fb)
>   		return GL_FALSE;
>
>   	/* Front buffer. */
>   	rb = nouveau_renderbuffer_dri_new(color_format, drawable);
> -	_mesa_add_renderbuffer_without_ref(fb, BUFFER_FRONT_LEFT, rb);
> +	_mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, rb);
>
>   	/* Back buffer */
>   	if (visual->doubleBufferMode) {
>   		rb = nouveau_renderbuffer_dri_new(color_format, drawable);
> -		_mesa_add_renderbuffer_without_ref(fb, BUFFER_BACK_LEFT, rb);
> +		_mesa_attach_and_own_rb(fb, BUFFER_BACK_LEFT, rb);
>   	}
>
>   	/* Depth/stencil buffer. */
>   	if (visual->depthBits == 24 && visual->stencilBits == 8) {
>   		rb = nouveau_renderbuffer_dri_new(GL_DEPTH24_STENCIL8_EXT, drawable);
> -		_mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, rb);
> -		_mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
> +		_mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
> +		_mesa_attach_and_reference_rb(fb, BUFFER_STENCIL, rb);
>
>   	} else if (visual->depthBits == 24) {
>   		rb = nouveau_renderbuffer_dri_new(GL_DEPTH_COMPONENT24, drawable);
> -		_mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, rb);
> +		_mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
>
>   	} else if (visual->depthBits == 16) {
>   		rb = nouveau_renderbuffer_dri_new(GL_DEPTH_COMPONENT16, drawable);
> -		_mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, rb);
> +		_mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
>   	}
>
>   	/* Software renderbuffers. */
>   	_swrast_add_soft_renderbuffers(fb, GL_FALSE, GL_FALSE, GL_FALSE,
>                                          visual->accumRedBits > 0,
>                                          GL_FALSE, GL_FALSE);
>
>   	drawable->driverPrivate = fb;
>
>   	return GL_TRUE;
> diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
> index fab2eea..79e3889 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_screen.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
> @@ -670,49 +670,49 @@ radeonCreateBuffer( __DRIscreen *driScrnPriv,
>
>       if (mesaVis->redBits == 5)
>           rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B5G6R5_UNORM : MESA_FORMAT_R5G6B5_UNORM;
>       else if (mesaVis->alphaBits == 0)
>           rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B8G8R8X8_UNORM : MESA_FORMAT_X8R8G8B8_UNORM;
>       else
>           rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B8G8R8A8_UNORM : MESA_FORMAT_A8R8G8B8_UNORM;
>
>       /* front color renderbuffer */
>       rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
> -    _mesa_add_renderbuffer_without_ref(&rfb->base, BUFFER_FRONT_LEFT, &rfb->color_rb[0]->base.Base);
> +    _mesa_attach_and_own_rb(&rfb->base, BUFFER_FRONT_LEFT, &rfb->color_rb[0]->base.Base);
>       rfb->color_rb[0]->has_surface = 1;
>
>       /* back color renderbuffer */
>       if (mesaVis->doubleBufferMode) {
>         rfb->color_rb[1] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
> -	_mesa_add_renderbuffer_without_ref(&rfb->base, BUFFER_BACK_LEFT, &rfb->color_rb[1]->base.Base);
> +	_mesa_attach_and_own_rb(&rfb->base, BUFFER_BACK_LEFT, &rfb->color_rb[1]->base.Base);
>   	rfb->color_rb[1]->has_surface = 1;
>       }
>
>       if (mesaVis->depthBits == 24) {
>         if (mesaVis->stencilBits == 8) {
>   	struct radeon_renderbuffer *depthStencilRb =
>              radeon_create_renderbuffer(MESA_FORMAT_Z24_UNORM_S8_UINT, driDrawPriv);
> -	_mesa_add_renderbuffer_without_ref(&rfb->base, BUFFER_DEPTH, &depthStencilRb->base.Base);
> -	_mesa_add_renderbuffer(&rfb->base, BUFFER_STENCIL, &depthStencilRb->base.Base);
> +	_mesa_attach_and_own_rb(&rfb->base, BUFFER_DEPTH, &depthStencilRb->base.Base);
> +	_mesa_attach_and_reference_rb(&rfb->base, BUFFER_STENCIL, &depthStencilRb->base.Base);
>   	depthStencilRb->has_surface = screen->depthHasSurface;
>         } else {
>   	/* depth renderbuffer */
>   	struct radeon_renderbuffer *depth =
>              radeon_create_renderbuffer(MESA_FORMAT_Z24_UNORM_X8_UINT, driDrawPriv);
> -	_mesa_add_renderbuffer_without_ref(&rfb->base, BUFFER_DEPTH, &depth->base.Base);
> +	_mesa_attach_and_own_rb(&rfb->base, BUFFER_DEPTH, &depth->base.Base);
>   	depth->has_surface = screen->depthHasSurface;
>         }
>       } else if (mesaVis->depthBits == 16) {
>           /* just 16-bit depth buffer, no hw stencil */
>   	struct radeon_renderbuffer *depth =
>              radeon_create_renderbuffer(MESA_FORMAT_Z_UNORM16, driDrawPriv);
> -	_mesa_add_renderbuffer_without_ref(&rfb->base, BUFFER_DEPTH, &depth->base.Base);
> +	_mesa_attach_and_own_rb(&rfb->base, BUFFER_DEPTH, &depth->base.Base);
>   	depth->has_surface = screen->depthHasSurface;
>       }
>
>       _swrast_add_soft_renderbuffers(&rfb->base,
>   	    GL_FALSE, /* color */
>   	    swDepth,
>   	    swStencil,
>   	    swAccum,
>   	    swAlpha,
>   	    GL_FALSE /* aux */);
> diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
> index f43ac60..fd3a2d9 100644
> --- a/src/mesa/drivers/dri/swrast/swrast.c
> +++ b/src/mesa/drivers/dri/swrast/swrast.c
> @@ -562,27 +562,27 @@ dri_create_buffer(__DRIscreen * sPriv,
>       if (drawable->row == NULL)
>   	goto drawable_fail;
>
>       fb = &drawable->Base;
>
>       /* basic framebuffer setup */
>       _mesa_initialize_window_framebuffer(fb, visual);
>
>       /* add front renderbuffer */
>       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
> -    _mesa_add_renderbuffer_without_ref(fb, BUFFER_FRONT_LEFT,
> +    _mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT,
>                                          &frontrb->Base.Base);

and here.

>
>       /* add back renderbuffer */
>       if (visual->doubleBufferMode) {
>   	backrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE);
> -        _mesa_add_renderbuffer_without_ref(fb, BUFFER_BACK_LEFT,
> +        _mesa_attach_and_own_rb(fb, BUFFER_BACK_LEFT,
>                                              &backrb->Base.Base);

and here?


>       }
>
>       /* add software renderbuffers */
>       _swrast_add_soft_renderbuffers(fb,
>                                      GL_FALSE, /* color */
>                                      visual->haveDepthBuffer,
>                                      visual->haveStencilBuffer,
>                                      visual->haveAccumBuffer,
>                                      GL_FALSE, /* alpha */
> diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
> index 68fca3e..325fc7f 100644
> --- a/src/mesa/drivers/osmesa/osmesa.c
> +++ b/src/mesa/drivers/osmesa/osmesa.c
> @@ -1013,28 +1013,28 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
>      /* Call this periodically to detect when the user has begun using
>       * GL rendering from multiple threads.
>       */
>      _glapi_check_multithread();
>
>
>      /* Create a front/left color buffer which wraps the user-provided buffer.
>       * There is no back color buffer.
>       * If the user tries to use a 8, 16 or 32-bit/channel buffer that
>       * doesn't match what Mesa was compiled for (CHAN_BITS) the
> -    * _mesa_add_renderbuffer() function will create a "wrapper" renderbuffer
> -    * that converts rendering from CHAN_BITS to the user-requested channel
> -    * size.
> +    * _mesa_attach_and_reference_rb() function will create a "wrapper"
> +    * renderbuffer that converts rendering from CHAN_BITS to the
> +    * user-requested channel size.
>       */
>      if (!osmesa->srb) {
>         osmesa->srb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
>         _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
> -      _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
> +      _mesa_attach_and_reference_rb(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
>                                &osmesa->srb->Base);
>         assert(osmesa->srb->Base.RefCount == 2);
>      }
>
>      osmesa->DataType = type;
>
>      /* Set renderbuffer fields.  Set width/height = 0 to force
>       * osmesa_renderbuffer_storage() being called by _mesa_resize_framebuffer()
>       */
>      osmesa->srb->Buffer = buffer;
> @@ -1044,21 +1044,21 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
>       * osmesa_renderbuffer_storage() function to get called.
>       */
>      _mesa_resize_framebuffer(&osmesa->mesa, osmesa->gl_buffer, width, height);
>
>      _mesa_make_current( &osmesa->mesa, osmesa->gl_buffer, osmesa->gl_buffer );
>
>      /* Remove renderbuffer attachment, then re-add.  This installs the
>       * renderbuffer adaptor/wrapper if needed (for bpp conversion).
>       */
>      _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
> -   _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
> +   _mesa_attach_and_reference_rb(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
>                             &osmesa->srb->Base);
>
>
>      /* this updates the visual's red/green/blue/alphaBits fields */
>      _mesa_update_framebuffer_visual(&osmesa->mesa, osmesa->gl_buffer);
>
>      /* update the framebuffer size */
>      _mesa_resize_framebuffer(&osmesa->mesa, osmesa->gl_buffer, width, height);
>
>      return GL_TRUE;
> diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
> index 5be8aa9..4966561 100644
> --- a/src/mesa/drivers/x11/xm_api.c
> +++ b/src/mesa/drivers/x11/xm_api.c
> @@ -304,38 +304,38 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
>       * Front renderbuffer
>       */
>      b->frontxrb = xmesa_new_renderbuffer(NULL, 0, vis, GL_FALSE);
>      if (!b->frontxrb) {
>         free(b);
>         return NULL;
>      }
>      b->frontxrb->Parent = b;
>      b->frontxrb->drawable = d;
>      b->frontxrb->pixmap = (XMesaPixmap) d;
> -   _mesa_add_renderbuffer_without_ref(&b->mesa_buffer, BUFFER_FRONT_LEFT,
> +   _mesa_attach_and_own_rb(&b->mesa_buffer, BUFFER_FRONT_LEFT,
>                                         &b->frontxrb->Base.Base);
>
>      /*
>       * Back renderbuffer
>       */
>      if (vis->mesa_visual.doubleBufferMode) {
>         b->backxrb = xmesa_new_renderbuffer(NULL, 0, vis, GL_TRUE);
>         if (!b->backxrb) {
>            /* XXX free front xrb too */
>            free(b);
>            return NULL;
>         }
>         b->backxrb->Parent = b;
>         /* determine back buffer implementation */
>         b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP;
>
> -      _mesa_add_renderbuffer_without_ref(&b->mesa_buffer, BUFFER_BACK_LEFT,
> +      _mesa_attach_and_own_rb(&b->mesa_buffer, BUFFER_BACK_LEFT,
>                                            &b->backxrb->Base.Base);
>      }
>
>      /*
>       * Other renderbuffer (depth, stencil, etc)
>       */
>      _swrast_add_soft_renderbuffers(&b->mesa_buffer,
>                                     GL_FALSE,  /* color */
>                                     vis->mesa_visual.haveDepthBuffer,
>                                     vis->mesa_visual.haveStencilBuffer,
> diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
> index b58b3f3..4300620 100644
> --- a/src/mesa/main/renderbuffer.c
> +++ b/src/mesa/main/renderbuffer.c
> @@ -137,39 +137,39 @@ validate_and_init_renderbuffer_attachment(struct gl_framebuffer *fb,
>
>
>   /**
>    * Attach a renderbuffer to a framebuffer.
>    * \param bufferName  one of the BUFFER_x tokens
>    *
>    * This function avoids adding a reference and is therefore intended to be
>    * used with a freshly created renderbuffer.
>    */
>   void
> -_mesa_add_renderbuffer_without_ref(struct gl_framebuffer *fb,
> +_mesa_attach_and_own_rb(struct gl_framebuffer *fb,
>                                      gl_buffer_index bufferName,
>                                      struct gl_renderbuffer *rb)
>   {
>      assert(rb->RefCount == 1);
>
>      validate_and_init_renderbuffer_attachment(fb, bufferName, rb);
>
>      _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer,
>                                   NULL);
>      fb->Attachment[bufferName].Renderbuffer = rb;
>   }
>
>   /**
>    * Attach a renderbuffer to a framebuffer.
>    * \param bufferName  one of the BUFFER_x tokens
>    */
>   void
> -_mesa_add_renderbuffer(struct gl_framebuffer *fb,
> +_mesa_attach_and_reference_rb(struct gl_framebuffer *fb,
>                          gl_buffer_index bufferName, struct gl_renderbuffer *rb)
>   {
>      validate_and_init_renderbuffer_attachment(fb, bufferName, rb);
>      _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb);
>   }
>
>
>   /**
>    * Remove the named renderbuffer from the given framebuffer.
>    * \param bufferName  one of the BUFFER_x tokens
> diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h
> index a6f1439..3071e6b 100644
> --- a/src/mesa/main/renderbuffer.h
> +++ b/src/mesa/main/renderbuffer.h
> @@ -40,26 +40,26 @@ struct gl_renderbuffer;
>   extern void
>   _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name);
>
>   extern struct gl_renderbuffer *
>   _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name);
>
>   extern void
>   _mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
>
>   extern void
> -_mesa_add_renderbuffer_without_ref(struct gl_framebuffer *fb,
> +_mesa_attach_and_own_rb(struct gl_framebuffer *fb,
>                                      gl_buffer_index bufferName,
>                                      struct gl_renderbuffer *rb);
>
>   extern void
> -_mesa_add_renderbuffer(struct gl_framebuffer *fb,
> +_mesa_attach_and_reference_rb(struct gl_framebuffer *fb,
>                          gl_buffer_index bufferName, struct gl_renderbuffer *rb);
>
>   extern void
>   _mesa_remove_renderbuffer(struct gl_framebuffer *fb,
>                             gl_buffer_index bufferName);
>
>   extern void
>   _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
>                                 struct gl_renderbuffer *rb);
>
> diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
> index a91dc76..a49fb5e 100644
> --- a/src/mesa/state_tracker/st_manager.c
> +++ b/src/mesa/state_tracker/st_manager.c
> @@ -305,35 +305,35 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
>      }
>
>      if (format == PIPE_FORMAT_NONE)
>         return FALSE;
>
>      rb = st_new_renderbuffer_fb(format, stfb->iface->visual->samples, sw);
>      if (!rb)
>         return FALSE;
>
>      if (idx != BUFFER_DEPTH) {
> -      _mesa_add_renderbuffer_without_ref(&stfb->Base, idx, rb);
> +      _mesa_attach_and_own_rb(&stfb->Base, idx, rb);
>         return TRUE;
>      }
>
>      bool rb_ownership_taken = false;
>      if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)) {
> -      _mesa_add_renderbuffer_without_ref(&stfb->Base, BUFFER_DEPTH, rb);
> +      _mesa_attach_and_own_rb(&stfb->Base, BUFFER_DEPTH, rb);
>         rb_ownership_taken = true;
>      }
>
>      if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) {
>         if (rb_ownership_taken)
> -         _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb);
> +         _mesa_attach_and_reference_rb(&stfb->Base, BUFFER_STENCIL, rb);
>         else
> -         _mesa_add_renderbuffer_without_ref(&stfb->Base, BUFFER_STENCIL, rb);
> +         _mesa_attach_and_own_rb(&stfb->Base, BUFFER_STENCIL, rb);
>      }
>
>      return TRUE;
>   }
>
>   /**
>    * Intialize a struct gl_config from a visual.
>    */
>   static void
>   st_visual_to_context_mode(const struct st_visual *visual,
> diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
> index 940c7b7..66a823d 100644
> --- a/src/mesa/swrast/s_renderbuffer.c
> +++ b/src/mesa/swrast/s_renderbuffer.c
> @@ -267,21 +267,21 @@ add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
>
>         rb = ctx->Driver.NewRenderbuffer(ctx, 0);
>         if (!rb) {
>            _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
>            return GL_FALSE;
>         }
>
>         rb->InternalFormat = GL_RGBA;
>
>         rb->AllocStorage = soft_renderbuffer_storage;
> -      _mesa_add_renderbuffer_without_ref(fb, b, rb);
> +      _mesa_attach_and_own_rb(fb, b, rb);
>      }
>
>      return GL_TRUE;
>   }
>
>
>   /**
>    * Add a software-based depth renderbuffer to the given framebuffer.
>    * This is a helper routine for device drivers when creating a
>    * window system framebuffer (not a user-created render/framebuffer).
> @@ -313,21 +313,21 @@ add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
>         rb->InternalFormat = GL_DEPTH_COMPONENT16;
>      }
>      else if (depthBits <= 24) {
>         rb->InternalFormat = GL_DEPTH_COMPONENT24;
>      }
>      else {
>         rb->InternalFormat = GL_DEPTH_COMPONENT32;
>      }
>
>      rb->AllocStorage = soft_renderbuffer_storage;
> -   _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, rb);
> +   _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
>
>      return GL_TRUE;
>   }
>
>
>   /**
>    * Add a software-based stencil renderbuffer to the given framebuffer.
>    * This is a helper routine for device drivers when creating a
>    * window system framebuffer (not a user-created render/framebuffer).
>    * Once this function is called, you can basically forget about this
> @@ -351,21 +351,21 @@ add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
>      rb = _swrast_new_soft_renderbuffer(ctx, 0);
>      if (!rb) {
>         _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
>         return GL_FALSE;
>      }
>
>      assert(stencilBits <= 8);
>      rb->InternalFormat = GL_STENCIL_INDEX8;
>
>      rb->AllocStorage = soft_renderbuffer_storage;
> -   _mesa_add_renderbuffer_without_ref(fb, BUFFER_STENCIL, rb);
> +   _mesa_attach_and_own_rb(fb, BUFFER_STENCIL, rb);
>
>      return GL_TRUE;
>   }
>
>
>   static GLboolean
>   add_depth_stencil_renderbuffer(struct gl_context *ctx,
>                                  struct gl_framebuffer *fb)
>   {
>      struct gl_renderbuffer *rb;
> @@ -375,22 +375,22 @@ add_depth_stencil_renderbuffer(struct gl_context *ctx,
>
>      rb = _swrast_new_soft_renderbuffer(ctx, 0);
>      if (!rb) {
>         _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth+stencil buffer");
>         return GL_FALSE;
>      }
>
>      rb->InternalFormat = GL_DEPTH_STENCIL;
>
>      rb->AllocStorage = soft_renderbuffer_storage;
> -   _mesa_add_renderbuffer_without_ref(fb, BUFFER_DEPTH, rb);
> -   _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
> +   _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
> +   _mesa_attach_and_reference_rb(fb, BUFFER_STENCIL, rb);
>
>      return GL_TRUE;
>   }
>
>
>   /**
>    * Add a software-based accumulation renderbuffer to the given framebuffer.
>    * This is a helper routine for device drivers when creating a
>    * window system framebuffer (not a user-created render/framebuffer).
>    * Once this function is called, you can basically forget about this
> @@ -413,21 +413,21 @@ add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
>      assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
>
>      rb = _swrast_new_soft_renderbuffer(ctx, 0);
>      if (!rb) {
>         _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
>         return GL_FALSE;
>      }
>
>      rb->InternalFormat = GL_RGBA16_SNORM;
>      rb->AllocStorage = soft_renderbuffer_storage;
> -   _mesa_add_renderbuffer_without_ref(fb, BUFFER_ACCUM, rb);
> +   _mesa_attach_and_own_rb(fb, BUFFER_ACCUM, rb);
>
>      return GL_TRUE;
>   }
>
>
>
>   /**
>    * Add a software-based aux renderbuffer to the given framebuffer.
>    * This is a helper routine for device drivers when creating a
>    * window system framebuffer (not a user-created render/framebuffer).
> @@ -458,21 +458,21 @@ add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
>
>         if (!rb) {
>            _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer");
>            return GL_FALSE;
>         }
>
>         assert (colorBits <= 8);
>         rb->InternalFormat = GL_RGBA;
>
>         rb->AllocStorage = soft_renderbuffer_storage;
> -      _mesa_add_renderbuffer_without_ref(fb, BUFFER_AUX0 + i, rb);
> +      _mesa_attach_and_own_rb(fb, BUFFER_AUX0 + i, rb);
>      }
>      return GL_TRUE;
>   }
>
>
>   /**
>    * Create/attach software-based renderbuffers to the given framebuffer.
>    * This is a helper routine for device drivers.  Drivers can just as well
>    * call the individual _mesa_add_*_renderbuffer() routines directly.
>    */
>



More information about the mesa-dev mailing list