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>
/** 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);
intel_miptree_release(&irb->mt);
- _mesa_delete_renderbuffer(rb);
+ _mesa_delete_renderbuffer(ctx, 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 *
}
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);
if (rrb && rrb->bo) {
radeon_bo_unref(rrb->bo);
}
- _mesa_delete_renderbuffer(rb);
+ _mesa_delete_renderbuffer(ctx, rb);
}
#if defined(RADEON_R100)
}
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 */
* 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);
}
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);
}
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
static void
-delete_dummy_renderbuffer(struct gl_renderbuffer *rb)
+delete_dummy_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
/* no op */
}
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,
* 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);
_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;
_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,
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);
}
* 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);
}
* 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);
free(srb->Buffer);
srb->Buffer = NULL;
- _mesa_delete_renderbuffer(rb);
+ _mesa_delete_renderbuffer(ctx, rb);
}
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);