diff options
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common.h | 19 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common_context.c | 114 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_lock.c | 9 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texstate.c | 2 |
8 files changed, 71 insertions, 80 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index 4937b0665d1..058e0ee5bec 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -806,7 +806,7 @@ void r200SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void*)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer; + rb = rfb->color_rb[0]; if (rb->bo == NULL) { /* Failed to BO for the buffer */ return; diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index 2d7f392e7c8..14d470a11c0 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -425,7 +425,7 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void*)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer; + rb = rfb->color_rb[0]; if (rb->bo == NULL) { /* Failed to BO for the buffer */ return; diff --git a/src/mesa/drivers/dri/radeon/radeon_common.h b/src/mesa/drivers/dri/radeon/radeon_common.h index 95b718184b7..814da1b4f5b 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.h +++ b/src/mesa/drivers/dri/radeon/radeon_common.h @@ -30,6 +30,23 @@ void radeonDrawBuffer( GLcontext *ctx, GLenum mode ); void radeonReadBuffer( GLcontext *ctx, GLenum mode ); void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height); +static inline struct radeon_renderbuffer *radeon_renderbuffer(struct gl_renderbuffer *rb) +{ + struct radeon_renderbuffer *rrb = (struct radeon_renderbuffer *)rb; + if (rrb && rrb->base.ClassID == RADEON_RB_CLASS) + return rrb; + else + return NULL; +} + +static inline struct radeon_renderbuffer *radeon_get_renderbuffer(struct gl_framebuffer *fb, int att_index) +{ + if (att_index >= 0) + return radeon_renderbuffer(fb->Attachment[att_index].Renderbuffer); + else + return NULL; +} + static inline struct radeon_renderbuffer *radeon_get_depthbuffer(radeonContextPtr rmesa) { struct radeon_renderbuffer *rrb; @@ -47,7 +64,7 @@ static inline struct radeon_renderbuffer *radeon_get_colorbuffer(radeonContextPt rrb = rmesa->state.color.rrb; if (rmesa->radeonScreen->driScreen->dri2.enabled) { - rrb = (struct radeon_renderbuffer *)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer; + rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_BACK_LEFT); } if (!rrb) return NULL; diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c index b63aba2f894..a818440faf8 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c @@ -183,33 +183,33 @@ void radeonCleanupContext(radeonContextPtr radeon) _mesa_destroy_context(radeon->glCtx); rfb = (void*)radeon->dri.drawable->driverPrivate; - rb = (void *)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer; + rb = rfb->color_rb[0]; if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void *)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer; + rb = rfb->color_rb[1]; if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void *)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer; + rb = radeon_get_renderbuffer(&rfb->base, BUFFER_DEPTH); if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } rfb = (void*)radeon->dri.readable->driverPrivate; - rb = (void *)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer; + rb = rfb->color_rb[0]; if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void *)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer; + rb = rfb->color_rb[1]; if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void *)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer; + rb = radeon_get_renderbuffer(&rfb->base, BUFFER_DEPTH); if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; @@ -391,6 +391,7 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) int i, count; struct radeon_framebuffer *draw; radeonContextPtr radeon; + char *regname; if (RADEON_DEBUG & DEBUG_DRI) fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable); @@ -399,15 +400,14 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) screen = context->driScreenPriv; radeon = (radeonContextPtr) context->driverPrivate; i = 0; - if ((rb = (void *)draw->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) { + if (draw->color_rb[0]) attachments[i++] = __DRI_BUFFER_FRONT_LEFT; - } - if ((rb = (void *)draw->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer)) { + if (draw->color_rb[1]) attachments[i++] = __DRI_BUFFER_BACK_LEFT; - } - if ((rb = (void *)draw->base.Attachment[BUFFER_DEPTH].Renderbuffer)) { + if (radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH)) attachments[i++] = __DRI_BUFFER_DEPTH; - } + if (radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL)) + attachments[i++] = __DRI_BUFFER_STENCIL; buffers = (*screen->dri2.loader->getBuffers)(drawable, &drawable->w, @@ -436,64 +436,20 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) for (i = 0; i < count; i++) { switch (buffers[i].attachment) { case __DRI_BUFFER_FRONT_LEFT: - rb = (void *)draw->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer; - if (rb->bo) { - radeon_bo_unref(rb->bo); - rb->bo = NULL; - } - rb->cpp = buffers[i].cpp; - rb->pitch = buffers[i].pitch; - rb->width = drawable->w; - rb->height = drawable->h; - rb->has_surface = 0; - rb->bo = radeon_bo_open(radeon->radeonScreen->bom, - buffers[i].name, - 0, - 0, - RADEON_GEM_DOMAIN_VRAM, - buffers[i].flags); - if (rb->bo == NULL) { - fprintf(stderr, "failled to attach front %d\n", - buffers[i].name); - } + rb = draw->color_rb[0]; + regname = "dri2 front buffer"; break; case __DRI_BUFFER_BACK_LEFT: - rb = (void *)draw->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer; - if (rb->bo) { - radeon_bo_unref(rb->bo); - rb->bo = NULL; - } - rb->cpp = buffers[i].cpp; - rb->pitch = buffers[i].pitch; - rb->width = drawable->w; - rb->height = drawable->h; - rb->has_surface = 0; - rb->bo = radeon_bo_open(radeon->radeonScreen->bom, - buffers[i].name, - 0, - 0, - RADEON_GEM_DOMAIN_VRAM, - buffers[i].flags); + rb = draw->color_rb[1]; + regname = "dri2 back buffer"; break; case __DRI_BUFFER_DEPTH: - rb = (void *)draw->base.Attachment[BUFFER_DEPTH].Renderbuffer; - if (rb->bo) { - radeon_bo_unref(rb->bo); - rb->bo = NULL; - } - rb->cpp = buffers[i].cpp; - rb->pitch = buffers[i].pitch; - rb->width = drawable->w; - rb->height = drawable->h; - rb->has_surface = 0; - rb->bo = radeon_bo_open(radeon->radeonScreen->bom, - buffers[i].name, - 0, - 0, - RADEON_GEM_DOMAIN_VRAM, - buffers[i].flags); + rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH); + regname = "dri2 depth buffer"; break; case __DRI_BUFFER_STENCIL: + rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH); + regname = "dri2 stencil buffer"; break; case __DRI_BUFFER_ACCUM: default: @@ -502,8 +458,32 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) buffers[i].attachment); return; } + + if (rb == NULL) + continue; + + if (rb->bo) { + radeon_bo_unref(rb->bo); + rb->bo = NULL; + } + rb->cpp = buffers[i].cpp; + rb->pitch = buffers[i].pitch; + rb->width = drawable->w; + rb->height = drawable->h; + rb->has_surface = 0; + rb->bo = radeon_bo_open(radeon->radeonScreen->bom, + buffers[i].name, + 0, + 0, + RADEON_GEM_DOMAIN_VRAM, + buffers[i].flags); + if (rb->bo == NULL) { + fprintf(stderr, "failed to attach %s %d\n", + regname, buffers[i].name); + + } } - radeon = (radeonContextPtr) context->driverPrivate; + driUpdateFramebufferSize(radeon->glCtx, drawable); } @@ -534,9 +514,9 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv, if (driDrawPriv != driReadPriv) radeon_update_renderbuffers(driContextPriv, driReadPriv); radeon->state.color.rrb = - (void *)drfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer; + radeon_get_renderbuffer(&drfb->base, BUFFER_BACK_LEFT); radeon->state.depth.rrb = - (void *)drfb->base.Attachment[BUFFER_DEPTH].Renderbuffer; + radeon_get_renderbuffer(&drfb->base, BUFFER_DEPTH); } else { radeon_make_renderbuffer_current(radeon, drfb); } diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h index 4aeb50fe68e..e5ada622b0f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h @@ -70,6 +70,8 @@ typedef struct radeon_context *radeonContextPtr; #include "tnl_dd/t_dd_vertex.h" #undef TAG +#define RADEON_RB_CLASS 0xdeadbeef + struct radeon_renderbuffer { struct gl_renderbuffer base; diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.c b/src/mesa/drivers/dri/radeon/radeon_lock.c index fb9e5e025ea..e1bb2cd6e21 100644 --- a/src/mesa/drivers/dri/radeon/radeon_lock.c +++ b/src/mesa/drivers/dri/radeon/radeon_lock.c @@ -90,15 +90,6 @@ void radeonGetLock(radeonContextPtr rmesa, GLuint flags) rmesa->lost_context = GL_TRUE; } -static INLINE struct radeon_renderbuffer * -radeon_get_renderbuffer(struct gl_framebuffer *fb, int attIndex) -{ - if (attIndex >= 0) - return (struct radeon_renderbuffer *)fb->Attachment[attIndex].Renderbuffer; - else - return NULL; -} - void radeon_lock_hardware(radeonContextPtr radeon) { __DRIdrawable *dPriv = radeon->dri.drawable; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index e90dffd7669..02101978ac4 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -1197,6 +1197,7 @@ radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv) return NULL; _mesa_init_renderbuffer(&ret->base, 0); + ret->base.ClassID = RADEON_RB_CLASS; /* XXX format junk */ switch (format) { diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index 06771a359b9..b9adab18d49 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -678,7 +678,7 @@ void radeonSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPri radeon_bo_unref(rb->bo); rb->bo = NULL; } - rb = (void*)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer; + rb = rfb->color_rb[0]; if (rb->bo == NULL) { /* Failed to BO for the buffer */ return; |