Author: Julien Viard de Galbert Subject: dri/unichrome: fix renderbuffer deallocation assert. As suggested on https://bugs.freedesktop.org/show_bug.cgi?id=26999 This basically changes struct via_renderbuffer in struct via_context to pointer and uses _mesa_reference_renderbuffer to use reference counting. The rest of the driver is just adapted to use pointers instead of direct fields. This patch is not for integration but for the braves to test it. There is a lot of TODO comments where more rework is needed. diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index ff666a3..c278410 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -130,6 +130,9 @@ static void viaDeleteRenderbuffer(struct gl_renderbuffer *rb) { /* Don't free() since we're contained in via_context struct. */ + // TODO: should probably call via_free_draw_buffer here + // instead of inside FreeBuffer + _mesa_free(rb); } static GLboolean @@ -142,6 +145,22 @@ viaRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb, return GL_TRUE; } +static struct via_renderbuffer * +viaCreateRenderbuffer(void) //TODO (GLenum format, __DRIdrawablePrivate *dPriv) +{ + GET_CURRENT_CONTEXT(ctx); + + struct via_renderbuffer *vrb; + vrb = CALLOC_STRUCT(via_renderbuffer); + if (!vrb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer"); + return NULL; + } + // TODO do this call and place the viaCreateRenderbuffer calls at + // the right place + //viaInitRenderbuffer(vrb, format, dPriv); + return vrb; +} static void viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format, @@ -218,42 +237,59 @@ calculate_buffer_parameters(struct via_context *vmesa, * That should be fixed someday. */ - if (!vmesa->front.Base.InternalFormat) { + if (!vmesa->frontBuffer) { /* do one-time init for the renderbuffers */ - viaInitRenderbuffer(&vmesa->front, GL_RGBA, dPriv); - viaSetSpanFunctions(&vmesa->front, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->front.Base); + struct via_renderbuffer *rb; + rb = viaCreateRenderbuffer(); + if(!rb) { return GL_FALSE; } + viaInitRenderbuffer(rb, GL_RGBA, dPriv); + /* TODO kept as frontBuffer is still in the context */ + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->frontBuffer, &rb->Base); + viaSetSpanFunctions(vmesa->frontBuffer, &fb->Visual); + _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->frontBuffer->Base); if (fb->Visual.doubleBufferMode) { - viaInitRenderbuffer(&vmesa->back, GL_RGBA, dPriv); - viaSetSpanFunctions(&vmesa->back, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->back.Base); + rb = viaCreateRenderbuffer(); + if(!rb) { return GL_FALSE; } + viaInitRenderbuffer(rb, GL_RGBA, dPriv); + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->backBuffer, &rb->Base); + viaSetSpanFunctions(vmesa->backBuffer, &fb->Visual); + _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->backBuffer->Base); } if (vmesa->glCtx->Visual.depthBits > 0) { - viaInitRenderbuffer(&vmesa->depth, + rb = viaCreateRenderbuffer(); + if(!rb) { return GL_FALSE; } + viaInitRenderbuffer(rb, (vmesa->glCtx->Visual.depthBits == 16 ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24), dPriv); - viaSetSpanFunctions(&vmesa->depth, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depth.Base); + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->depthBuffer, &rb->Base); + viaSetSpanFunctions(vmesa->depthBuffer, &fb->Visual); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depthBuffer->Base); } if (vmesa->glCtx->Visual.stencilBits > 0) { - viaInitRenderbuffer(&vmesa->stencil, GL_STENCIL_INDEX8_EXT, + rb = viaCreateRenderbuffer(); + if(!rb) { return GL_FALSE; } + viaInitRenderbuffer(rb, GL_STENCIL_INDEX8_EXT, dPriv); - viaSetSpanFunctions(&vmesa->stencil, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencil.Base); + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->stencilBuffer, &rb->Base); + viaSetSpanFunctions(vmesa->stencilBuffer, &fb->Visual); + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencilBuffer->Base); } } - assert(vmesa->front.Base.InternalFormat); - assert(vmesa->front.Base.AllocStorage); + assert(vmesa->frontBuffer); + assert(vmesa->frontBuffer->Base.InternalFormat); + assert(vmesa->frontBuffer->Base.AllocStorage); if (fb->Visual.doubleBufferMode) { - assert(vmesa->back.Base.AllocStorage); + assert(vmesa->backBuffer); + assert(vmesa->backBuffer->Base.AllocStorage); } if (fb->Visual.depthBits) { - assert(vmesa->depth.Base.AllocStorage); + assert(vmesa->depthBuffer); + assert(vmesa->depthBuffer->Base.AllocStorage); } @@ -262,87 +298,93 @@ calculate_buffer_parameters(struct via_context *vmesa, w = vmesa->driDrawable->w; h = vmesa->driDrawable->h; - vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel; - vmesa->front.pitch = buffer_align( w ) << shift; /* bytes, not pixels */ - vmesa->front.size = vmesa->front.pitch * h; + vmesa->frontBuffer->bpp = vmesa->viaScreen->bitsPerPixel; + vmesa->frontBuffer->pitch = buffer_align( w ) << shift; /* bytes, not pixels */ + vmesa->frontBuffer->size = vmesa->frontBuffer->pitch * h; - if (vmesa->front.map) - via_free_draw_buffer(vmesa, &vmesa->front); - if (!via_alloc_draw_buffer(vmesa, &vmesa->front)) + if (vmesa->frontBuffer->map) + via_free_draw_buffer(vmesa, vmesa->frontBuffer); + if (!via_alloc_draw_buffer(vmesa, vmesa->frontBuffer)) return GL_FALSE; } else { w = vmesa->viaScreen->width; h = vmesa->viaScreen->height; - vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel; - vmesa->front.pitch = buffer_align( w ) << shift; /* bytes, not pixels */ - vmesa->front.size = vmesa->front.pitch * h; + vmesa->frontBuffer->bpp = vmesa->viaScreen->bitsPerPixel; + vmesa->frontBuffer->pitch = buffer_align( w ) << shift; /* bytes, not pixels */ + vmesa->frontBuffer->size = vmesa->frontBuffer->pitch * h; if (getenv("ALTERNATE_SCREEN")) - vmesa->front.offset = vmesa->front.size; + vmesa->frontBuffer->offset = vmesa->frontBuffer->size; else - vmesa->front.offset = 0; - vmesa->front.map = (char *) vmesa->driScreen->pFB; + vmesa->frontBuffer->offset = 0; + vmesa->frontBuffer->map = (char *) vmesa->driScreen->pFB; } /* Allocate back-buffer */ if (vmesa->hasBack) { - vmesa->back.bpp = vmesa->viaScreen->bitsPerPixel; - vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift); - vmesa->back.pitch += extra; - vmesa->back.pitch = MIN2(vmesa->back.pitch, vmesa->front.pitch); - vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h; - if (vmesa->back.map) - via_free_draw_buffer(vmesa, &vmesa->back); - if (!via_alloc_draw_buffer(vmesa, &vmesa->back)) + vmesa->backBuffer->bpp = vmesa->viaScreen->bitsPerPixel; + vmesa->backBuffer->pitch = (buffer_align( vmesa->driDrawable->w ) << shift); + vmesa->backBuffer->pitch += extra; + vmesa->backBuffer->pitch = MIN2(vmesa->backBuffer->pitch, vmesa->frontBuffer->pitch); + vmesa->backBuffer->size = vmesa->backBuffer->pitch * vmesa->driDrawable->h; + if (vmesa->backBuffer->map) + via_free_draw_buffer(vmesa, vmesa->backBuffer); + if (!via_alloc_draw_buffer(vmesa, vmesa->backBuffer)) return GL_FALSE; } else { - if (vmesa->back.map) - via_free_draw_buffer(vmesa, &vmesa->back); - (void) memset( &vmesa->back, 0, sizeof( vmesa->back ) ); + if (vmesa->backBuffer) { /* TODO check if we can do cleaner */ + if (vmesa->backBuffer->map) + via_free_draw_buffer(vmesa, vmesa->backBuffer); + (void) memset( vmesa->backBuffer, 0, sizeof( struct via_renderbuffer ) ); + } } /* Allocate depth-buffer */ if ( vmesa->hasStencil || vmesa->hasDepth ) { - vmesa->depth.bpp = vmesa->depthBits; - if (vmesa->depth.bpp == 24) - vmesa->depth.bpp = 32; + vmesa->depthBuffer->bpp = vmesa->depthBits; + if (vmesa->depthBuffer->bpp == 24) + vmesa->depthBuffer->bpp = 32; - vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) * - (vmesa->depth.bpp/8)) + extra; - vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h; + vmesa->depthBuffer->pitch = (buffer_align( vmesa->driDrawable->w ) * + (vmesa->depthBuffer->bpp/8)) + extra; + vmesa->depthBuffer->size = vmesa->depthBuffer->pitch * vmesa->driDrawable->h; - if (vmesa->depth.map) - via_free_draw_buffer(vmesa, &vmesa->depth); - if (!via_alloc_draw_buffer(vmesa, &vmesa->depth)) { + if (vmesa->depthBuffer->map) + via_free_draw_buffer(vmesa, vmesa->depthBuffer); + if (!via_alloc_draw_buffer(vmesa, vmesa->depthBuffer)) { return GL_FALSE; } } else { - if (vmesa->depth.map) - via_free_draw_buffer(vmesa, &vmesa->depth); - (void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) ); + if (vmesa->depthBuffer) { /* TODO check if we can do cleaner */ + if (vmesa->depthBuffer->map) + via_free_draw_buffer(vmesa, vmesa->depthBuffer); + (void) memset( vmesa->depthBuffer, 0, sizeof( struct via_renderbuffer ) ); + } } + if (vmesa->stencilBuffer) { /* TODO check if we can do cleaner */ /* stencil buffer is same as depth buffer */ - vmesa->stencil.handle = vmesa->depth.handle; - vmesa->stencil.size = vmesa->depth.size; - vmesa->stencil.offset = vmesa->depth.offset; - vmesa->stencil.index = vmesa->depth.index; - vmesa->stencil.pitch = vmesa->depth.pitch; - vmesa->stencil.bpp = vmesa->depth.bpp; - vmesa->stencil.map = vmesa->depth.map; - vmesa->stencil.orig = vmesa->depth.orig; - vmesa->stencil.origMap = vmesa->depth.origMap; + vmesa->stencilBuffer->handle = vmesa->depthBuffer->handle; + vmesa->stencilBuffer->size = vmesa->depthBuffer->size; + vmesa->stencilBuffer->offset = vmesa->depthBuffer->offset; + vmesa->stencilBuffer->index = vmesa->depthBuffer->index; + vmesa->stencilBuffer->pitch = vmesa->depthBuffer->pitch; + vmesa->stencilBuffer->bpp = vmesa->depthBuffer->bpp; + vmesa->stencilBuffer->map = vmesa->depthBuffer->map; + vmesa->stencilBuffer->orig = vmesa->depthBuffer->orig; + vmesa->stencilBuffer->origMap = vmesa->depthBuffer->origMap; + } if( vmesa->viaScreen->width == vmesa->driDrawable->w && vmesa->viaScreen->height == vmesa->driDrawable->h ) { vmesa->doPageFlip = vmesa->allowPageFlip; if (vmesa->hasBack) { - assert(vmesa->back.pitch == vmesa->front.pitch); + assert(vmesa->backBuffer->pitch == vmesa->frontBuffer->pitch); } } else @@ -438,17 +480,18 @@ AllocateDmaBuffer(struct via_context *vmesa) static void FreeBuffer(struct via_context *vmesa) { - if (vmesa->front.map && vmesa->drawType == GLX_PBUFFER_BIT) - via_free_draw_buffer(vmesa, &vmesa->front); + // TODO should be cleared by destructing buffers ? + if (vmesa->frontBuffer && vmesa->frontBuffer->map && vmesa->drawType == GLX_PBUFFER_BIT) + via_free_draw_buffer(vmesa, vmesa->frontBuffer); - if (vmesa->back.map) - via_free_draw_buffer(vmesa, &vmesa->back); + if (vmesa->backBuffer && vmesa->backBuffer->map) + via_free_draw_buffer(vmesa, vmesa->backBuffer); - if (vmesa->depth.map) - via_free_draw_buffer(vmesa, &vmesa->depth); + if (vmesa->depthBuffer && vmesa->depthBuffer->map) + via_free_draw_buffer(vmesa, vmesa->depthBuffer); - if (vmesa->breadcrumb.map) - via_free_draw_buffer(vmesa, &vmesa->breadcrumb); + if (vmesa->breadcrumbBuffer && vmesa->breadcrumbBuffer->map) + via_free_draw_buffer(vmesa, vmesa->breadcrumbBuffer); if (vmesa->dma) via_free_dma_buffer(vmesa); @@ -632,11 +675,17 @@ viaCreateContext(const __GLcontextModes *visual, /* Allocate a small piece of fb memory for synchronization: */ - vmesa->breadcrumb.bpp = 32; - vmesa->breadcrumb.pitch = buffer_align( 64 ) << 2; - vmesa->breadcrumb.size = vmesa->breadcrumb.pitch; + vmesa->breadcrumbBuffer = viaCreateRenderbuffer(); + if(!vmesa->breadcrumbBuffer) { + FreeBuffer(vmesa); + FREE(vmesa); + return GL_FALSE; + } + vmesa->breadcrumbBuffer->bpp = 32; + vmesa->breadcrumbBuffer->pitch = buffer_align( 64 ) << 2; + vmesa->breadcrumbBuffer->size = vmesa->breadcrumbBuffer->pitch; - if (!via_alloc_draw_buffer(vmesa, &vmesa->breadcrumb)) { + if (!via_alloc_draw_buffer(vmesa, vmesa->breadcrumbBuffer)) { fprintf(stderr ,"AllocateDmaBuffer fail\n"); FreeBuffer(vmesa); FREE(vmesa); @@ -720,6 +769,17 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv) driDestroyOptionCache(&vmesa->optionCache); + + // unreference render buffers + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->frontBuffer, NULL); + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->backBuffer, NULL); + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->depthBuffer, NULL); + _mesa_reference_renderbuffer((struct gl_renderbuffer **)&vmesa->stencilBuffer, NULL); + // breadcrumbBuffer is not initialysed as a real renderbuffer + // ie _mesa_init_renderbuffer is never called to fill the struct + // so the reference counting does not work... + FREE(vmesa->breadcrumbBuffer); + FREE(vmesa); } @@ -782,29 +842,33 @@ void viaXMesaWindowMoved(struct via_context *vmesa) read_buffer->drawH = readable->h; } - vmesa->front.orig = (vmesa->front.offset + - draw_buffer->drawY * vmesa->front.pitch + + vmesa->frontBuffer->orig = (vmesa->frontBuffer->offset + + draw_buffer->drawY * vmesa->frontBuffer->pitch + draw_buffer->drawX * bytePerPixel); - vmesa->front.origMap = (vmesa->front.map + - draw_buffer->drawY * vmesa->front.pitch + + vmesa->frontBuffer->origMap = (vmesa->frontBuffer->map + + draw_buffer->drawY * vmesa->frontBuffer->pitch + draw_buffer->drawX * bytePerPixel); - vmesa->back.orig = (vmesa->back.offset + - draw_buffer->drawY * vmesa->back.pitch + + if (vmesa->hasBack) { + vmesa->backBuffer->orig = (vmesa->backBuffer->offset + + draw_buffer->drawY * vmesa->backBuffer->pitch + draw_buffer->drawX * bytePerPixel); - vmesa->back.origMap = (vmesa->back.map + - draw_buffer->drawY * vmesa->back.pitch + + vmesa->backBuffer->origMap = (vmesa->backBuffer->map + + draw_buffer->drawY * vmesa->backBuffer->pitch + draw_buffer->drawX * bytePerPixel); + } - vmesa->depth.orig = (vmesa->depth.offset + - draw_buffer->drawY * vmesa->depth.pitch + + if (vmesa->glCtx->Visual.depthBits > 0) { + vmesa->depthBuffer->orig = (vmesa->depthBuffer->offset + + draw_buffer->drawY * vmesa->depthBuffer->pitch + draw_buffer->drawX * bytePerPixel); - vmesa->depth.origMap = (vmesa->depth.map + - draw_buffer->drawY * vmesa->depth.pitch + + vmesa->depthBuffer->origMap = (vmesa->depthBuffer->map + + draw_buffer->drawY * vmesa->depthBuffer->pitch + draw_buffer->drawX * bytePerPixel); + } viaCalcViewport(vmesa->glCtx); } @@ -899,7 +963,7 @@ void viaGetLock(struct via_context *vmesa, GLuint flags) drmGetLock(vmesa->driFd, vmesa->hHWContext, flags); - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); + DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); // segfault on exit inside this if (dPriv != vmesa->driReadable) { DRI_VALIDATE_DRAWABLE_INFO(sPriv, vmesa->driReadable); } diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h index 4cc9e47..96c4054 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.h +++ b/src/mesa/drivers/dri/unichrome/via_context.h @@ -157,11 +157,11 @@ struct via_context { GLcontext *shareCtx; /* XXX These don't belong here. They should be per-drawable state. */ - struct via_renderbuffer front; - struct via_renderbuffer back; - struct via_renderbuffer depth; - struct via_renderbuffer stencil; /* mirrors depth */ - struct via_renderbuffer breadcrumb; + struct via_renderbuffer *frontBuffer; + struct via_renderbuffer *backBuffer; + struct via_renderbuffer *depthBuffer; + struct via_renderbuffer *stencilBuffer; /* mirrors depth */ + struct via_renderbuffer *breadcrumbBuffer; GLboolean hasBack; GLboolean hasDepth; diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c index 69eac44..be6e18d 100644 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c @@ -315,17 +315,17 @@ static void viaClear(GLcontext *ctx, GLbitfield mask) } if (flag & VIA_FRONT) { - viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, + viaFillBuffer(vmesa, vmesa->frontBuffer, boxes, nr, vmesa->ClearColor, vmesa->ClearMask); } if (flag & VIA_BACK) { - viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, + viaFillBuffer(vmesa, vmesa->backBuffer, boxes, nr, vmesa->ClearColor, vmesa->ClearMask); } if (flag & VIA_DEPTH) { - viaFillBuffer(vmesa, &vmesa->depth, boxes, nr, clear_depth, + viaFillBuffer(vmesa, vmesa->depthBuffer, boxes, nr, clear_depth, clear_depth_mask); } @@ -348,8 +348,8 @@ static void viaDoSwapBuffers(struct via_context *vmesa, GLuint nbox) { GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; - struct via_renderbuffer *front = &vmesa->front; - struct via_renderbuffer *back = &vmesa->back; + struct via_renderbuffer *front = vmesa->frontBuffer; + struct via_renderbuffer *back = vmesa->backBuffer; GLuint i; for (i = 0; i < nbox; i++, b++) { @@ -375,7 +375,7 @@ static void viaDoSwapBuffers(struct via_context *vmesa, static void viaEmitBreadcrumbLocked( struct via_context *vmesa ) { - struct via_renderbuffer *buffer = &vmesa->breadcrumb; + struct via_renderbuffer *buffer = vmesa->breadcrumbBuffer; GLuint value = vmesa->lastBreadcrumbWrite + 1; if (VIA_DEBUG & DEBUG_IOCTL) @@ -415,7 +415,7 @@ static GLboolean viaCheckIdle( struct via_context *vmesa ) GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value ) { - GLuint *buf = (GLuint *)vmesa->breadcrumb.map; + GLuint *buf = (GLuint *)vmesa->breadcrumbBuffer->map; vmesa->lastBreadcrumbRead = *buf; if (VIA_DEBUG & DEBUG_IOCTL) @@ -575,14 +575,14 @@ void viaResetPageFlippingLocked(struct via_context *vmesa) viaDoPageFlipLocked( vmesa, 0 ); - if (vmesa->front.offset != 0) { + if (vmesa->frontBuffer->offset != 0) { struct via_renderbuffer buffer_tmp; - memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_renderbuffer)); + memcpy(&buffer_tmp, vmesa->backBuffer, sizeof(struct via_renderbuffer)); + memcpy(vmesa->backBuffer, vmesa->frontBuffer, sizeof(struct via_renderbuffer)); + memcpy(vmesa->frontBuffer, &buffer_tmp, sizeof(struct via_renderbuffer)); } - assert(vmesa->front.offset == 0); + assert(vmesa->frontBuffer->offset == 0); vmesa->doPageFlip = vmesa->allowPageFlip = 0; } @@ -649,7 +649,7 @@ void viaPageFlip(__DRIdrawablePrivate *dPriv) viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[0]); LOCK_HARDWARE(vmesa); - viaDoPageFlipLocked(vmesa, vmesa->back.offset); + viaDoPageFlipLocked(vmesa, vmesa->backBuffer->offset); vmesa->lastSwap[1] = vmesa->lastSwap[0]; vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite; viaEmitBreadcrumbLocked(vmesa); @@ -661,9 +661,9 @@ void viaPageFlip(__DRIdrawablePrivate *dPriv) /* KW: FIXME: When buffers are freed, could free frontbuffer by * accident: */ - memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_renderbuffer)); + memcpy(&buffer_tmp, vmesa->backBuffer, sizeof(struct via_renderbuffer)); + memcpy(vmesa->backBuffer, vmesa->frontBuffer, sizeof(struct via_renderbuffer)); + memcpy(vmesa->frontBuffer, &buffer_tmp, sizeof(struct via_renderbuffer)); } diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index e65f5fd..f2092ce 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -97,8 +97,8 @@ void viaEmitState(struct via_context *vmesa) GLuint pitch, format, offset; format = HC_HZWBFM_24; - offset = vmesa->depth.offset; - pitch = vmesa->depth.pitch; + offset = vmesa->depthBuffer->offset; + pitch = vmesa->depthBuffer->pitch; BEGIN_RING(6); OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) ); @@ -121,8 +121,8 @@ void viaEmitState(struct via_context *vmesa) } - offset = vmesa->depth.offset; - pitch = vmesa->depth.pitch; + offset = vmesa->depthBuffer->offset; + pitch = vmesa->depthBuffer->pitch; BEGIN_RING(4); OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) ); @@ -661,12 +661,12 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode) switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { case BUFFER_FRONT_LEFT: VIA_FLUSH_DMA(vmesa); - vmesa->drawBuffer = &vmesa->front; + vmesa->drawBuffer = vmesa->frontBuffer; FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE); break; case BUFFER_BACK_LEFT: VIA_FLUSH_DMA(vmesa); - vmesa->drawBuffer = &vmesa->back; + vmesa->drawBuffer = vmesa->backBuffer; FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE); break; default: