aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/unichrome/via_context.c
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2007-01-16 11:22:57 +0000
committerKeith Whitwell <[email protected]>2007-01-16 11:22:57 +0000
commit6a3fdc3a1ea6c306d9543791bf172dd1052d7382 (patch)
treec372c6daff13e435e79914c2e40dfe9d370c337b /src/mesa/drivers/dri/unichrome/via_context.c
parent0b412f8f156b46b0e7220a2b61e0f41781769f66 (diff)
parenta03fc8277180e2171519165a724849e2254ef0b7 (diff)
Merge branch 'master' of git+ssh://[email protected]/git/mesa/mesa into vbo-0.2
Conflicts: src/mesa/array_cache/sources src/mesa/drivers/dri/i965/brw_context.c src/mesa/drivers/dri/i965/brw_draw.c src/mesa/drivers/dri/i965/brw_fallback.c src/mesa/drivers/dri/i965/brw_vs_emit.c src/mesa/drivers/dri/i965/brw_vs_tnl.c src/mesa/drivers/dri/mach64/mach64_context.c src/mesa/main/extensions.c src/mesa/main/getstring.c src/mesa/tnl/sources src/mesa/tnl/t_save_api.c src/mesa/tnl/t_save_playback.c src/mesa/tnl/t_vtx_api.c src/mesa/tnl/t_vtx_exec.c src/mesa/vbo/vbo_attrib.h src/mesa/vbo/vbo_exec_api.c src/mesa/vbo/vbo_save_api.c src/mesa/vbo/vbo_save_draw.c
Diffstat (limited to 'src/mesa/drivers/dri/unichrome/via_context.c')
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c146
1 files changed, 96 insertions, 50 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index 38dcf458db8..bc5a414df60 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -147,10 +147,13 @@ viaRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb,
static void
-viaInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format)
+viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format,
+ __DRIdrawablePrivate *dPriv)
{
const GLuint name = 0;
+ struct gl_renderbuffer *rb = & vrb->Base;
+ vrb->dPriv = dPriv;
_mesa_init_renderbuffer(rb, name);
/* Make sure we're using a null-valued GetPointer routine */
@@ -198,8 +201,9 @@ viaInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format)
* \sa AllocateBuffer
*/
static GLboolean
-calculate_buffer_parameters( struct via_context *vmesa,
- struct gl_framebuffer *fb )
+calculate_buffer_parameters(struct via_context *vmesa,
+ struct gl_framebuffer *fb,
+ __DRIdrawablePrivate *dPriv)
{
const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
const unsigned extra = 32;
@@ -215,26 +219,28 @@ calculate_buffer_parameters( struct via_context *vmesa,
if (!vmesa->front.Base.InternalFormat) {
/* do one-time init for the renderbuffers */
- viaInitRenderbuffer(&vmesa->front.Base, GL_RGBA);
+ viaInitRenderbuffer(&vmesa->front, GL_RGBA, dPriv);
viaSetSpanFunctions(&vmesa->front, &fb->Visual);
_mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->front.Base);
if (fb->Visual.doubleBufferMode) {
- viaInitRenderbuffer(&vmesa->back.Base, GL_RGBA);
+ viaInitRenderbuffer(&vmesa->back, GL_RGBA, dPriv);
viaSetSpanFunctions(&vmesa->back, &fb->Visual);
_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->back.Base);
}
if (vmesa->glCtx->Visual.depthBits > 0) {
- viaInitRenderbuffer(&vmesa->depth.Base,
+ viaInitRenderbuffer(&vmesa->depth,
(vmesa->glCtx->Visual.depthBits == 16
- ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24));
+ ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24),
+ dPriv);
viaSetSpanFunctions(&vmesa->depth, &fb->Visual);
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depth.Base);
}
if (vmesa->glCtx->Visual.stencilBits > 0) {
- viaInitRenderbuffer(&vmesa->stencil.Base, GL_STENCIL_INDEX8_EXT);
+ viaInitRenderbuffer(&vmesa->stencil, GL_STENCIL_INDEX8_EXT,
+ dPriv);
viaSetSpanFunctions(&vmesa->stencil, &fb->Visual);
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencil.Base);
}
@@ -243,11 +249,9 @@ calculate_buffer_parameters( struct via_context *vmesa,
assert(vmesa->front.Base.InternalFormat);
assert(vmesa->front.Base.AllocStorage);
if (fb->Visual.doubleBufferMode) {
- assert(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
- assert(vmesa->front.Base.AllocStorage);
+ assert(vmesa->back.Base.AllocStorage);
}
if (fb->Visual.depthBits) {
- assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
assert(vmesa->depth.Base.AllocStorage);
}
@@ -352,19 +356,11 @@ void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
{
struct via_context *vmesa = VIA_CONTEXT(ctx);
- calculate_buffer_parameters( vmesa, drawbuffer );
+ calculate_buffer_parameters(vmesa, drawbuffer, vmesa->driDrawable);
_mesa_resize_framebuffer(ctx, drawbuffer, width, height);
}
-static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct via_context *vmesa = VIA_CONTEXT(ctx);
- *width = vmesa->driDrawable->w;
- *height = vmesa->driDrawable->h;
-}
-
/* Extension strings exported by the Unichrome driver.
*/
const struct dri_extension card_extensions[] =
@@ -579,7 +575,6 @@ viaCreateContext(const __GLcontextModes *visual,
ctx->Const.MaxPointSizeAA = 1.0;
ctx->Const.PointSizeGranularity = 1.0;
- ctx->Driver.GetBufferSize = viaBufferSize;
ctx->Driver.GetString = viaGetString;
ctx->DriverCtx = (void *)vmesa;
@@ -734,50 +729,72 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
void viaXMesaWindowMoved(struct via_context *vmesa)
{
- __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ __DRIdrawablePrivate *const drawable = vmesa->driDrawable;
+ __DRIdrawablePrivate *const readable = vmesa->driReadable;
+ struct via_renderbuffer *const draw_buffer =
+ (struct via_renderbuffer *) drawable->driverPrivate;
+ struct via_renderbuffer *const read_buffer =
+ (struct via_renderbuffer *) readable->driverPrivate;
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
- if (!dPriv)
+ if (!drawable)
return;
switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
case BUFFER_BIT_BACK_LEFT:
- if (dPriv->numBackClipRects == 0) {
- vmesa->numClipRects = dPriv->numClipRects;
- vmesa->pClipRects = dPriv->pClipRects;
+ if (drawable->numBackClipRects == 0) {
+ vmesa->numClipRects = drawable->numClipRects;
+ vmesa->pClipRects = drawable->pClipRects;
}
else {
- vmesa->numClipRects = dPriv->numBackClipRects;
- vmesa->pClipRects = dPriv->pBackClipRects;
+ vmesa->numClipRects = drawable->numBackClipRects;
+ vmesa->pClipRects = drawable->pBackClipRects;
}
break;
case BUFFER_BIT_FRONT_LEFT:
- vmesa->numClipRects = dPriv->numClipRects;
- vmesa->pClipRects = dPriv->pClipRects;
+ vmesa->numClipRects = drawable->numClipRects;
+ vmesa->pClipRects = drawable->pClipRects;
break;
default:
vmesa->numClipRects = 0;
break;
}
- if (vmesa->drawW != dPriv->w ||
- vmesa->drawH != dPriv->h)
- calculate_buffer_parameters( vmesa, vmesa->glCtx->DrawBuffer );
+ if ((draw_buffer->drawW != drawable->w)
+ || (draw_buffer->drawH != drawable->h)) {
+ calculate_buffer_parameters(vmesa, vmesa->glCtx->DrawBuffer,
+ drawable);
+ }
- vmesa->drawXoff = (GLuint)(((dPriv->x * bytePerPixel) & 0x1f) /
+ draw_buffer->drawXoff = (GLuint)(((drawable->x * bytePerPixel) & 0x1f) /
bytePerPixel);
- vmesa->drawX = dPriv->x - vmesa->drawXoff;
- vmesa->drawY = dPriv->y;
- vmesa->drawW = dPriv->w;
- vmesa->drawH = dPriv->h;
+ draw_buffer->drawX = drawable->x - draw_buffer->drawXoff;
+ draw_buffer->drawY = drawable->y;
+ draw_buffer->drawW = drawable->w;
+ draw_buffer->drawH = drawable->h;
+
+ if (drawable != readable) {
+ if ((read_buffer->drawW != readable->w)
+ || (read_buffer->drawH != readable->h)) {
+ calculate_buffer_parameters(vmesa, vmesa->glCtx->ReadBuffer,
+ readable);
+ }
+
+ read_buffer->drawXoff = (GLuint)(((readable->x * bytePerPixel) & 0x1f) /
+ bytePerPixel);
+ read_buffer->drawX = readable->x - read_buffer->drawXoff;
+ read_buffer->drawY = readable->y;
+ read_buffer->drawW = readable->w;
+ read_buffer->drawH = readable->h;
+ }
vmesa->front.orig = (vmesa->front.offset +
- vmesa->drawY * vmesa->front.pitch +
- vmesa->drawX * bytePerPixel);
+ draw_buffer->drawY * vmesa->front.pitch +
+ draw_buffer->drawX * bytePerPixel);
vmesa->front.origMap = (vmesa->front.map +
- vmesa->drawY * vmesa->front.pitch +
- vmesa->drawX * bytePerPixel);
+ draw_buffer->drawY * vmesa->front.pitch +
+ draw_buffer->drawX * bytePerPixel);
vmesa->back.orig = vmesa->back.offset;
vmesa->depth.orig = vmesa->depth.offset;
@@ -813,15 +830,41 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
drawBuffer = (GLframebuffer *)driDrawPriv->driverPrivate;
readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
- if ( vmesa->driDrawable != driDrawPriv ) {
- driDrawableInitVBlank( driDrawPriv, vmesa->vblank_flags,
- &vmesa->vbl_seq );
- vmesa->driDrawable = driDrawPriv;
- if ( ! calculate_buffer_parameters( vmesa, drawBuffer ) ) {
- return GL_FALSE;
- }
+ if (vmesa->driDrawable != driDrawPriv) {
+ driDrawableInitVBlank(driDrawPriv, vmesa->vblank_flags,
+ &vmesa->vbl_seq);
}
+ if ((vmesa->driDrawable != driDrawPriv)
+ || (vmesa->driReadable != driReadPriv)) {
+ vmesa->driDrawable = driDrawPriv;
+ vmesa->driReadable = driReadPriv;
+
+ if ((drawBuffer->Width != driDrawPriv->w)
+ || (drawBuffer->Height != driDrawPriv->h)) {
+ _mesa_resize_framebuffer(ctx, drawBuffer,
+ driDrawPriv->w, driDrawPriv->h);
+ drawBuffer->Initialized = GL_TRUE;
+ }
+
+ if (!calculate_buffer_parameters(vmesa, drawBuffer, driDrawPriv)) {
+ return GL_FALSE;
+ }
+
+ if (driDrawPriv != driReadPriv) {
+ if ((readBuffer->Width != driReadPriv->w)
+ || (readBuffer->Height != driReadPriv->h)) {
+ _mesa_resize_framebuffer(ctx, readBuffer,
+ driReadPriv->w, driReadPriv->h);
+ readBuffer->Initialized = GL_TRUE;
+ }
+
+ if (!calculate_buffer_parameters(vmesa, readBuffer, driReadPriv)) {
+ return GL_FALSE;
+ }
+ }
+ }
+
_mesa_make_current(vmesa->glCtx, drawBuffer, readBuffer);
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
@@ -847,7 +890,10 @@ 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);
+ if (dPriv != vmesa->driReadable) {
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, vmesa->driReadable);
+ }
if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
vmesa->sarea->ctxOwner = vmesa->hHWContext;