[Mesa-dev] [PATCH 1/3] mesa: pass context parameter to gl_renderbuffer::Delete()

Matt Turner mattst88 at gmail.com
Mon Dec 3 10:05:12 PST 2012


On Fri, Nov 30, 2012 at 10:19 AM, Brian Paul <brianp at vmware.com> wrote:
> We sometimes need a rendering context when deleting renderbuffers.
> Pass it explicitly instead of trying to grab a current context
> (which might be NULL).  The next patch will make use of this.
>
> Note: this is a candidate for the stable branches.
> ---
>  src/mesa/drivers/dri/intel/intel_fbo.c     |    4 ++--
>  src/mesa/drivers/dri/nouveau/nouveau_fbo.c |    4 ++--
>  src/mesa/drivers/dri/radeon/radeon_fbo.c   |    4 ++--
>  src/mesa/drivers/dri/swrast/swrast.c       |    4 ++--
>  src/mesa/drivers/osmesa/osmesa.c           |    4 ++--
>  src/mesa/drivers/windows/gdi/wmesa.c       |    4 ++--
>  src/mesa/drivers/x11/xm_buffer.c           |    2 +-
>  src/mesa/main/fbobject.c                   |    2 +-
>  src/mesa/main/mtypes.h                     |    2 +-
>  src/mesa/main/renderbuffer.c               |    8 ++++++--
>  src/mesa/main/renderbuffer.h               |    2 +-
>  src/mesa/main/shared.c                     |    3 ++-
>  src/mesa/state_tracker/st_cb_fbo.c         |    4 ++--
>  src/mesa/swrast/s_renderbuffer.c           |    4 ++--
>  src/mesa/swrast/s_texrender.c              |    2 +-
>  15 files changed, 29 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
> index 96f6c32..6a66521 100644
> --- a/src/mesa/drivers/dri/intel/intel_fbo.c
> +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
> @@ -87,7 +87,7 @@ intel_new_framebuffer(struct gl_context * ctx, GLuint name)
>
>  /** Called by gl_renderbuffer::Delete() */
>  static void
> -intel_delete_renderbuffer(struct gl_renderbuffer *rb)
> +intel_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>     struct intel_renderbuffer *irb = intel_renderbuffer(rb);
>
> @@ -95,7 +95,7 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
>
>     intel_miptree_release(&irb->mt);
>
> -   _mesa_delete_renderbuffer(rb);
> +   _mesa_delete_renderbuffer(ctx, rb);
>  }
>
>  /**
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
> index c3e2341..c47bce8 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
> @@ -102,12 +102,12 @@ nouveau_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
>  }
>
>  static void
> -nouveau_renderbuffer_del(struct gl_renderbuffer *rb)
> +nouveau_renderbuffer_del(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>         struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
>
>         nouveau_surface_ref(NULL, s);
> -       _mesa_delete_renderbuffer(rb);
> +       _mesa_delete_renderbuffer(ctx, rb);
>  }
>
>  static struct gl_renderbuffer *
> diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
> index 291f2b7..9ab74c4 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
> @@ -54,7 +54,7 @@ radeon_new_framebuffer(struct gl_context *ctx, GLuint name)
>  }
>
>  static void
> -radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
> +radeon_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>    struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
>
> @@ -67,7 +67,7 @@ radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
>    if (rrb && rrb->bo) {
>      radeon_bo_unref(rrb->bo);
>    }
> -  _mesa_delete_renderbuffer(rb);
> +  _mesa_delete_renderbuffer(ctx, rb);
>  }
>
>  #if defined(RADEON_R100)
> diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
> index 3a47cdb..2474ed8 100644
> --- a/src/mesa/drivers/dri/swrast/swrast.c
> +++ b/src/mesa/drivers/dri/swrast/swrast.c
> @@ -251,14 +251,14 @@ choose_pixel_format(const struct gl_config *v)
>  }
>
>  static void
> -swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
> +swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>      struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
>
>      TRACE;
>
>      free(xrb->Base.Buffer);
> -    _mesa_delete_renderbuffer(rb);
> +    _mesa_delete_renderbuffer(ctx, rb);
>  }
>
>  /* see bytes_per_line in libGL */
> diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
> index e02b2f3..c206d64 100644
> --- a/src/mesa/drivers/osmesa/osmesa.c
> +++ b/src/mesa/drivers/osmesa/osmesa.c
> @@ -386,9 +386,9 @@ compute_row_addresses( OSMesaContext osmesa )
>   * Don't use _mesa_delete_renderbuffer since we can't free rb->Buffer.
>   */
>  static void
> -osmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
> +osmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
> -   free(rb);
> +   _mesa_delete_renderbuffer(ctx, rb);
>  }
>
>
> diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
> index 9f6f750..50347cf 100644
> --- a/src/mesa/drivers/windows/gdi/wmesa.c
> +++ b/src/mesa/drivers/windows/gdi/wmesa.c
> @@ -426,9 +426,9 @@ static void clear(struct gl_context *ctx, GLbitfield mask)
>
>
>  static void
> -wmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
> +wmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
> -    free(rb);
> +    _mesa_delete_renderbuffer(ctx, rb);
>  }
>
>
> diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
> index 1820d76..dc9a3be 100644
> --- a/src/mesa/drivers/x11/xm_buffer.c
> +++ b/src/mesa/drivers/x11/xm_buffer.c
> @@ -235,7 +235,7 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height)
>
>
>  static void
> -xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
> +xmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>     /* XXX Note: the ximage or Pixmap attached to this renderbuffer
>      * should probably get freed here, but that's currently done in
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 2e2fc2c..9eec61d 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -78,7 +78,7 @@ static struct gl_framebuffer IncompleteFramebuffer;
>
>
>  static void
> -delete_dummy_renderbuffer(struct gl_renderbuffer *rb)
> +delete_dummy_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>     /* no op */
>  }
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index f34b342..5bfae69 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2605,7 +2605,7 @@ struct gl_renderbuffer
>     gl_format Format;      /**< The actual renderbuffer memory format */
>
>     /** Delete this renderbuffer */
> -   void (*Delete)(struct gl_renderbuffer *rb);
> +   void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
>
>     /** Allocate new storage for this renderbuffer */
>     GLboolean (*AllocStorage)(struct gl_context *ctx,
> diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
> index 26f53d1..2f28443 100644
> --- a/src/mesa/main/renderbuffer.c
> +++ b/src/mesa/main/renderbuffer.c
> @@ -80,7 +80,7 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
>   * free the object in the end.
>   */
>  void
> -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
> +_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
>  {
>     _glthread_DESTROY_MUTEX(rb->Mutex);
>     free(rb);
> @@ -159,7 +159,11 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
>        _glthread_UNLOCK_MUTEX(oldRb->Mutex);
>
>        if (deleteFlag) {
> -         oldRb->Delete(oldRb);
> +         GET_CURRENT_CONTEXT(ctx);
> +         if (ctx)
> +            oldRb->Delete(ctx, oldRb);
> +         else
> +            _mesa_problem(NULL, "Unable to delete renderbuffer, no context");

I'm seeing this message printed for all of the es3 conformance tests
I'm doing on i965. Any idea what's up?


More information about the mesa-dev mailing list