summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2013-02-11 11:55:44 -0700
committerAndreas Boll <andreas.boll.dev@gmail.com>2013-02-13 18:46:40 +0100
commit9d4ab9a663d4088ec553edaae0eeafb746d2490d (patch)
treee8170b8e05cb70f3081cc21dade497b2424e0ae6
parentdca04373c2efb177dbb7dca3ad2b57cb36b2ebe6 (diff)
mesa: pass context parameter to gl_renderbuffer::Delete()
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. Reviewed-by: Jose Fonseca <jfonseca@vmware.com> (cherry picked from commit c73245882c7ff1277b190b97f093f7b423a22f10) Conflicts: src/mesa/swrast/s_renderbuffer.c
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c4
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fbo.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_fbo.c4
-rw-r--r--src/mesa/drivers/dri/swrast/swrast.c4
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c4
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c4
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c2
-rw-r--r--src/mesa/main/fbobject.c2
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/renderbuffer.c8
-rw-r--r--src/mesa/main/renderbuffer.h2
-rw-r--r--src/mesa/main/shared.c3
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c4
-rw-r--r--src/mesa/swrast/s_renderbuffer.c10
-rw-r--r--src/mesa/swrast/s_texrender.c2
15 files changed, 31 insertions, 28 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index ba360c5bf6..65494a2d50 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 3be958bbca..e95240f229 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 2267a10b64..f597f35c0f 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 f0ff0b0aaf..46219d1483 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -261,14 +261,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 0e770f9dd6..fa3b84e4f4 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -387,9 +387,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 93da05fe70..7e78013b33 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -900,9 +900,9 @@ static void read_rgba_pixels_16(struct gl_context *ctx,
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 eb68f940f8..31419eab93 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 b4054a242a..e9997ccb77 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -77,7 +77,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 6fce70f17a..355933d189 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2618,7 +2618,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 26f53d1009..2f28443299 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");
}
*ptr = NULL;
diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h
index 0934d85df0..5495ae1505 100644
--- a/src/mesa/main/renderbuffer.h
+++ b/src/mesa/main/renderbuffer.h
@@ -40,7 +40,7 @@ extern struct gl_renderbuffer *
_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name);
extern void
-_mesa_delete_renderbuffer(struct gl_renderbuffer *rb);
+_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
extern void
_mesa_add_renderbuffer(struct gl_framebuffer *fb,
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 58cbc52506..1eea6e742f 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -271,10 +271,11 @@ delete_framebuffer_cb(GLuint id, void *data, void *userData)
static void
delete_renderbuffer_cb(GLuint id, void *data, void *userData)
{
+ struct gl_context *ctx = (struct gl_context *) userData;
struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data;
rb->RefCount = 0; /* see comment for FBOs above */
if (rb->Delete)
- rb->Delete(rb);
+ rb->Delete(ctx, rb);
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 01aba8eaff..a4da89e974 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -225,14 +225,14 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
* gl_renderbuffer::Delete()
*/
static void
-st_renderbuffer_delete(struct gl_renderbuffer *rb)
+st_renderbuffer_delete(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
struct st_renderbuffer *strb = st_renderbuffer(rb);
ASSERT(strb);
pipe_surface_reference(&strb->surface, NULL);
pipe_resource_reference(&strb->texture, NULL);
free(strb->data);
- _mesa_delete_renderbuffer(rb);
+ _mesa_delete_renderbuffer(ctx, rb);
}
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index e468bdb16b..eae7f47371 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -166,15 +166,13 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
* Called via gl_renderbuffer::Delete()
*/
static void
-soft_renderbuffer_delete(struct gl_renderbuffer *rb)
+soft_renderbuffer_delete(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
- if (srb->Buffer) {
- free(srb->Buffer);
- srb->Buffer = NULL;
- }
- _mesa_delete_renderbuffer(rb);
+ free(srb->Buffer);
+ srb->Buffer = NULL;
+ _mesa_delete_renderbuffer(ctx, rb);
}
diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c
index 140e4b50f7..7b25a7b7d8 100644
--- a/src/mesa/swrast/s_texrender.c
+++ b/src/mesa/swrast/s_texrender.c
@@ -16,7 +16,7 @@
static void
-delete_texture_wrapper(struct gl_renderbuffer *rb)
+delete_texture_wrapper(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
ASSERT(rb->RefCount == 0);
free(rb);