From 9870f7bccc55f9b1728fa8b9ed78a72ab15d7f4f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 11 Jul 2007 20:18:51 +0200 Subject: restrict blitted area to size of rendered area --- src/mesa/drivers/dri/i915tex/intel_blit.c | 38 ++++++++++++++++++---------- src/mesa/drivers/dri/i915tex/intel_blit.h | 2 +- src/mesa/drivers/dri/i915tex/intel_buffers.c | 14 +++------- 3 files changed, 30 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index c755eac6b2c..3e42d799808 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -49,7 +49,7 @@ * Used for SwapBuffers(). */ void -intelCopyBuffer(const __DRIdrawablePrivate * dPriv, +intelCopyBuffer(__DRIdrawablePrivate * dPriv, const drm_clip_rect_t * rect) { @@ -94,6 +94,8 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, = intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT ? intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT) : intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT); + const int backWidth = intel_fb->Base.Width; + const int backHeight = intel_fb->Base.Height; const int nbox = dPriv->numClipRects; const drm_clip_rect_t *pbox = dPriv->pClipRects; const int pitch = frontRegion->pitch; @@ -134,32 +136,42 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, box = *pbox; if (rect) { - if (rect->x1 > box.x1) - box.x1 = rect->x1; - if (rect->y1 > box.y1) - box.y1 = rect->y1; - if (rect->x2 < box.x2) - box.x2 = rect->x2; - if (rect->y2 < box.y2) - box.y2 = rect->y2; + drm_clip_rect_t rrect; + + rrect.x1 = dPriv->x + rect->x1; + rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y; + rrect.x2 = rect->x2 + rrect.x1; + rrect.y2 = rect->y2 + rrect.y1; + if (rrect.x1 > box.x1) + box.x1 = rrect.x1; + if (rrect.y1 > box.y1) + box.y1 = rrect.y1; + if (rrect.x2 < box.x2) + box.x2 = rrect.x2; + if (rrect.y2 < box.y2) + box.y2 = rrect.y2; if (box.x1 > box.x2 || box.y1 > box.y2) continue; } + /* restrict blit to size of actually rendered area */ + if (box.x2 - box.x1 > backWidth) + box.x2 = backWidth + box.x1; + if (box.y2 - box.y1 > backHeight) + box.y2 = backHeight + box.y1; + DBG("box x1 x2 y1 y2 %d %d %d %d\n", box.x1, box.x2, box.y1, box.y2); - /* XXX should make sure only the minimum area based on - old draw buffer and new front clip rects is copied */ sbox.x1 = box.x1 - dPriv->x; sbox.y1 = box.y1 - dPriv->y; BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS); OUT_BATCH(CMD); OUT_BATCH(BR13); - OUT_BATCH((pbox->y1 << 16) | pbox->x1); - OUT_BATCH((pbox->y2 << 16) | pbox->x2); + OUT_BATCH((box.y1 << 16) | box.x1); + OUT_BATCH((box.y2 << 16) | box.x2); OUT_RELOC(frontRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.h b/src/mesa/drivers/dri/i915tex/intel_blit.h index e7bc280f58a..77686444fa0 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.h +++ b/src/mesa/drivers/dri/i915tex/intel_blit.h @@ -32,7 +32,7 @@ #include "intel_ioctl.h" #include "dri_bufmgr.h" -extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv, +extern void intelCopyBuffer(__DRIdrawablePrivate * dpriv, const drm_clip_rect_t * rect); extern void intelClearWithBlit(GLcontext * ctx, GLbitfield mask); diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 5aed3ad0ecc..20e9521105d 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -910,17 +910,11 @@ intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) if (ctx->Visual.doubleBufferMode) { drm_clip_rect_t rect; -#if 1 - rect.x1 = x + dPriv->x; - rect.y1 = (dPriv->h - y - h) + dPriv->y; - rect.x2 = rect.x1 + w; - rect.y2 = rect.y1 + h; -#else + /* fixup cliprect (driDrawable may have changed?) later */ rect.x1 = x; - rect.y1 = dPriv->h - y; - rect.x2 = rect.x1 + w; - rect.y2 = rect.y1 + h; -#endif + rect.y1 = y; + rect.x2 = w; + rect.y2 = h; _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ intelCopyBuffer(dPriv, &rect); } -- cgit v1.2.3 From 8b6517abfc20dc508c2a4cb1f6f22f34a8a70805 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 12 Jul 2007 21:52:02 +0200 Subject: don't use driDrawable information directly, don't resize at makecurrent driDrawable information now isn't used in most parts of the driver. makecurrent only updates fb information when the context is new (driDrawable is still updated by the dri common code). --- src/mesa/drivers/dri/i915tex/intel_blit.c | 9 +++---- src/mesa/drivers/dri/i915tex/intel_buffers.c | 22 ++++----------- src/mesa/drivers/dri/i915tex/intel_context.c | 18 ++++++++----- src/mesa/drivers/dri/i915tex/intel_context.h | 1 - src/mesa/drivers/dri/i915tex/intel_fbo.c | 2 ++ src/mesa/drivers/dri/i915tex/intel_ioctl.c | 3 +-- src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c | 18 ++++++------- src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 33 +++++++++-------------- src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 27 ++++++++++--------- src/mesa/drivers/dri/i915tex/intel_pixel_read.c | 26 +++++++----------- src/mesa/drivers/dri/i915tex/intel_span.c | 15 +++++------ src/mesa/drivers/dri/i915tex/intel_tex_copy.c | 17 +++--------- 12 files changed, 77 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index 3e42d799808..2a0a6393152 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -91,7 +91,7 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv, const struct intel_region *frontRegion = intelScreen->front_region; const struct intel_region *backRegion - = intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT ? + = intel_fb->Base._ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT ? intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT) : intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT); const int backWidth = intel_fb->Base.Width; @@ -108,7 +108,6 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv, ASSERT(intel_fb->Base.Name == 0); /* Not a user-created FBO */ ASSERT(frontRegion); ASSERT(backRegion); -// ASSERT(frontRegion->pitch == backRegion->pitch); ASSERT(frontRegion->cpp == backRegion->cpp); DBG("front pitch %d back pitch %d\n", @@ -405,6 +404,7 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask) LOCK_HARDWARE(intel); if (intel->numClipRects) { + assert(intel->numClipRects == 1); GLint cx, cy, cw, ch; drm_clip_rect_t clear; int i; @@ -417,10 +417,9 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask) if (fb->Name == 0) { /* clearing a window */ - /* flip top to bottom */ - clear.x1 = cx + intel->drawX; - clear.y1 = intel->driDrawable->y + intel->driDrawable->h - cy - ch; + clear.x1 = cx; + clear.y1 = intel->pClipRects->y2 - cy - ch; clear.x2 = clear.x1 + cw; clear.y2 = clear.y1 + ch; } diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 20e9521105d..59b291a709d 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -128,8 +128,6 @@ intel_readbuf_region(struct intel_context *intel) * Update the following fields for rendering to a user-created FBO: * intel->numClipRects * intel->pClipRects - * intel->drawX - * intel->drawY */ static void intelSetRenderbufferClipRects(struct intel_context *intel) @@ -142,8 +140,6 @@ intelSetRenderbufferClipRects(struct intel_context *intel) intel->fboRect.y2 = intel->ctx.DrawBuffer->Height; intel->numClipRects = 1; intel->pClipRects = &intel->fboRect; - intel->drawX = 0; - intel->drawY = 0; } /** @@ -154,18 +150,17 @@ intelSetRenderbufferClipRects(struct intel_context *intel) static void intelSetPrivbufClipRects(struct intel_context *intel) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; - if (!dPriv) + if (!intel->ctx.DrawBuffer) { + fprintf(stderr, "%s: DrawBuffer not set!\n", __FUNCTION__); return; + } intel->fakeClipRect.x1 = 0; intel->fakeClipRect.y1 = 0; - intel->fakeClipRect.x2 = dPriv->w; - intel->fakeClipRect.y2 = dPriv->h; + intel->fakeClipRect.x2 = intel->ctx.DrawBuffer->Width; + intel->fakeClipRect.y2 = intel->ctx.DrawBuffer->Height; intel->numClipRects = 1; intel->pClipRects = &intel->fakeClipRect; - intel->drawX = 0; - intel->drawY = 0; } @@ -445,7 +440,6 @@ intelRotateWindow(struct intel_context *intel, int i; GLenum format, type; - int xOrig, yOrig; int origNumClipRects; drm_clip_rect_t *origRects; @@ -469,8 +463,6 @@ intelRotateWindow(struct intel_context *intel, /* save current drawing origin and cliprects (restored at end) */ - xOrig = intel->drawX; - yOrig = intel->drawY; origNumClipRects = intel->numClipRects; origRects = intel->pClipRects; @@ -481,8 +473,6 @@ intelRotateWindow(struct intel_context *intel, fullRect.y1 = 0; fullRect.x2 = screen->rotatedWidth; fullRect.y2 = screen->rotatedHeight; - intel->drawX = 0; - intel->drawY = 0; intel->numClipRects = 1; intel->pClipRects = &fullRect; @@ -565,8 +555,6 @@ intelRotateWindow(struct intel_context *intel, intel_batchbuffer_flush(intel->batch); /* restore original drawing origin and cliprects */ - intel->drawX = xOrig; - intel->drawY = yOrig; intel->numClipRects = origNumClipRects; intel->pClipRects = origRects; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 531b4adde80..451c7fd1ba5 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -370,7 +370,7 @@ intelInitContext(struct intel_context *intel, if (!havePools) return GL_FALSE; - + if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx, functions, (void *) intel)) @@ -572,6 +572,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, __DRIdrawablePrivate * driDrawPriv, __DRIdrawablePrivate * driReadPriv) { + GLuint updatebufsize = GL_FALSE; #if 0 if (driDrawPriv) { @@ -619,19 +620,22 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, } } - /* set GLframebuffer size to match window, if needed */ - driUpdateFramebufferSize(&intel->ctx, driDrawPriv); + /* only update GLframebuffer size to match window + if here for the first time */ + if (intel->ctx.FirstTimeCurrent) { + updatebufsize = GL_TRUE; + driUpdateFramebufferSize(&intel->ctx, driDrawPriv); - if (driReadPriv != driDrawPriv) { - driUpdateFramebufferSize(&intel->ctx, driReadPriv); + if (driReadPriv != driDrawPriv) { + driUpdateFramebufferSize(&intel->ctx, driReadPriv); + } } _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb); - intel->intelScreen->dummyctxptr = &intel->ctx; /* The drawbuffer won't always be updated by _mesa_make_current: */ - if (intel->ctx.DrawBuffer == &intel_fb->Base) { + if (updatebufsize && intel->ctx.DrawBuffer == &intel_fb->Base) { if (intel->driDrawable != driDrawPriv) { intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 7b97c564a3e..f85b3a63627 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -250,7 +250,6 @@ struct intel_context /* These refer to the current drawing buffer: */ - int drawX, drawY; /**< origin of drawing area within region */ GLuint numClipRects; /**< cliprects for drawing */ drm_clip_rect_t *pClipRects; drm_clip_rect_t fboRect; /**< cliprect for FBO rendering */ diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index 2dd3617f93a..aeb909cce17 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -146,6 +146,8 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb) ASSERT(irb); + DBG("freeing renderbuffer\n"); + if (irb->PairedStencil || irb->PairedDepth) { intel_unpair_depth_stencil(ctx, irb); } diff --git a/src/mesa/drivers/dri/i915tex/intel_ioctl.c b/src/mesa/drivers/dri/i915tex/intel_ioctl.c index 3250c6b3a9c..54721c78ab1 100644 --- a/src/mesa/drivers/dri/i915tex/intel_ioctl.c +++ b/src/mesa/drivers/dri/i915tex/intel_ioctl.c @@ -116,8 +116,7 @@ intel_batch_ioctl(struct intel_context *intel, batch.cliprects = intel->pClipRects; batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects; batch.DR1 = 0; - batch.DR4 = ((((GLuint) intel->drawX) & 0xffff) | - (((GLuint) intel->drawY) << 16)); + batch.DR4 = 0; /* still need this ? */ DBG("%s: 0x%x..0x%x DR4: %x cliprects: %d\n", __FUNCTION__, diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c index 65bf338589e..96d3cbef5f2 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c @@ -195,18 +195,18 @@ do_blit_bitmap( GLcontext *ctx, LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; - drm_clip_rect_t *box = dPriv->pClipRects; + if (intel->numClipRects) { + assert(intel->numClipRects == 1); + drm_clip_rect_t *box = intel->pClipRects; drm_clip_rect_t dest_rect; - GLint nbox = dPriv->numClipRects; + GLint nbox = intel->numClipRects; GLint srcx = 0, srcy = 0; GLint orig_screen_x1, orig_screen_y2; GLuint i; - orig_screen_x1 = dPriv->x + dstx; - orig_screen_y2 = dPriv->y + (dPriv->h - dsty); + orig_screen_x1 = dstx; + orig_screen_y2 = box->y2 - dsty; /* Do scissoring in GL coordinates: */ @@ -223,8 +223,8 @@ x if (ctx->Scissor.Enabled) /* Convert from GL to hardware coordinates: */ - dsty = dPriv->y + (dPriv->h - dsty - height); - dstx = dPriv->x + dstx; + dsty = box->y2 - dsty - height; + dstx = dstx; dest_rect.x1 = dstx; dest_rect.y1 = dsty; @@ -235,7 +235,7 @@ x if (ctx->Scissor.Enabled) drm_clip_rect_t rect; int box_w, box_h; GLint px, py; - GLuint stipple[32]; + GLuint stipple[32]; if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) continue; diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index 9d478283e47..03c7353ee15 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -191,14 +191,10 @@ do_texture_copypixels(GLcontext * ctx, LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; - - - srcy = dPriv->h - srcy - height; /* convert from gl to hardware coords */ - - srcx += dPriv->x; - srcy += dPriv->y; + if (intel->numClipRects) { + int bufHeight = intel->pClipRects->y2; + assert (intel->numClipRects == 1); + srcy = bufHeight - srcy - height; /* convert from gl to hardware coords */ /* Clip against the source region. This is the only source * clipping we do. XXX: Just set the texcord wrap mode to clamp @@ -223,8 +219,8 @@ do_texture_copypixels(GLcontext * ctx, intel_meta_draw_quad(intel, dstx, dstx + width * ctx->Pixel.ZoomX, - dPriv->h - (dsty + height * ctx->Pixel.ZoomY), - dPriv->h - (dsty), 0, /* XXX: what z value? */ + bufHeight - (dsty + height * ctx->Pixel.ZoomY), + bufHeight - (dsty), 0, /* XXX: what z value? */ 0x00ff00ff, srcx, srcx + width, srcy, srcy + height); @@ -271,11 +267,11 @@ do_blit_copypixels(GLcontext * ctx, LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; - drm_clip_rect_t *box = dPriv->pClipRects; + if (intel->numClipRects) { + assert(intel->numClipRects == 1); + drm_clip_rect_t *box = intel->pClipRects; drm_clip_rect_t dest_rect; - GLint nbox = dPriv->numClipRects; + GLint nbox = intel->numClipRects; GLint delta_x = 0; GLint delta_y = 0; GLuint i; @@ -299,13 +295,10 @@ do_blit_copypixels(GLcontext * ctx, } /* Convert from GL to hardware coordinates: + * cliprect should be size of buffer */ - dsty = dPriv->h - dsty - height; - srcy = dPriv->h - srcy - height; - dstx += dPriv->x; - dsty += dPriv->y; - srcx += dPriv->x; - srcy += dPriv->y; + dsty = box->y2 - dsty - height; + srcy = box->y2 - srcy - height; /* Clip against the source region. This is the only source * clipping we do. Dst is clipped with cliprects below. diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index 77c67c821eb..2d46c4b8c0e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -138,13 +138,15 @@ do_texture_drawpixels(GLcontext * ctx, LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; + if (intel->numClipRects) { + assert(intel->numClipRects == 1); + int bufHeight = intel->pClipRects->y2; + GLint srcx, srcy; GLint dstx, dsty; dstx = x; - dsty = dPriv->h - (y + height); + dsty = bufHeight - (y + height); srcx = 0; /* skiprows/pixels already done */ srcy = 0; @@ -172,8 +174,8 @@ do_texture_drawpixels(GLcontext * ctx, */ intel_meta_draw_quad(intel, dstx, dstx + width * ctx->Pixel.ZoomX, - dPriv->h - (y + height * ctx->Pixel.ZoomY), - dPriv->h - (y), + bufHeight - (y + height * ctx->Pixel.ZoomY), + bufHeight - (y), -ctx->Current.RasterPos[2] * .5, 0x00ff00ff, srcx, srcx + width, srcy + height, srcy); @@ -289,21 +291,21 @@ do_blit_drawpixels(GLcontext * ctx, src_offset = (GLuint) _mesa_image_address(2, unpack, pixels, width, height, format, type, 0, 0, 0); + /* don't need a lock as cliprects shouldn't change */ intelFlush(&intel->ctx); - LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; - int nbox = dPriv->numClipRects; - drm_clip_rect_t *box = dPriv->pClipRects; + if (intel->numClipRects) { + assert(intel->numClipRects == 1); + int nbox = intel->numClipRects; + drm_clip_rect_t *box = intel->pClipRects; drm_clip_rect_t rect; drm_clip_rect_t dest_rect; struct _DriBufferObject *src_buffer = intel_bufferobj_buffer(intel, src, INTEL_READ); int i; - dest_rect.x1 = dPriv->x + x; - dest_rect.y1 = dPriv->y + dPriv->h - (y + height); + dest_rect.x1 = x; + dest_rect.y1 = box->y2 - (y + height); dest_rect.x2 = dest_rect.x1 + width; dest_rect.y2 = dest_rect.y1 + height; @@ -327,7 +329,6 @@ do_blit_drawpixels(GLcontext * ctx, fence = intel_batchbuffer_flush(intel->batch); driFenceReference(fence); } - UNLOCK_HARDWARE(intel); if (fence) { driFenceFinish(fence, DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, GL_FALSE); diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c index 24e49ae0663..9481cb4800f 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c @@ -77,7 +77,6 @@ do_texture_readpixels(GLcontext * ctx, struct intel_context *intel = intel_context(ctx); intelScreenPrivate *screen = intel->intelScreen; GLint pitch = pack->RowLength ? pack->RowLength : width; - __DRIdrawablePrivate *dPriv = intel->driDrawable; int textureFormat; GLenum glTextureFormat; int destFormat, depthFormat, destPitch; @@ -107,7 +106,7 @@ do_texture_readpixels(GLcontext * ctx, LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { + if (intel->numClipRects) { intel->vtbl.install_meta_state(intel); intel->vtbl.meta_no_depth_write(intel); intel->vtbl.meta_no_stencil_write(intel); @@ -120,9 +119,7 @@ do_texture_readpixels(GLcontext * ctx, return GL_TRUE; } - y = dPriv->h - y - height; - x += dPriv->x; - y += dPriv->y; + y = intel->pClipRects->y2 - y - height; /* Set the frontbuffer up as a large rectangular texture. @@ -230,29 +227,25 @@ do_blit_readpixels(GLcontext * ctx, dst_offset = (GLuint) _mesa_image_address(2, pack, pixels, width, height, format, type, 0, 0, 0); - - /* Although the blits go on the command buffer, need to do this and - * fire with lock held to guarentee cliprects are correct. - */ + /* reading from priv buffer, cliprects should not change */ intelFlush(&intel->ctx); - LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) { + if (intel->numClipRects) { + assert (intel->numClipRects == 1); GLboolean all = (width * height * src->cpp == dst->Base.Size && x == 0 && dst_offset == 0); struct _DriBufferObject *dst_buffer = intel_bufferobj_buffer(intel, dst, all ? INTEL_WRITE_FULL : INTEL_WRITE_PART); - __DRIdrawablePrivate *dPriv = intel->driDrawable; - int nbox = dPriv->numClipRects; - drm_clip_rect_t *box = dPriv->pClipRects; + int nbox = intel->numClipRects; + drm_clip_rect_t *box = intel->pClipRects; drm_clip_rect_t rect; drm_clip_rect_t src_rect; int i; - src_rect.x1 = dPriv->x + x; - src_rect.y1 = dPriv->y + dPriv->h - (y + height); + src_rect.x1 = x; + src_rect.y1 = box->y2 - (y + height); src_rect.x2 = src_rect.x1 + width; src_rect.y2 = src_rect.y1 + height; @@ -279,7 +272,6 @@ do_blit_readpixels(GLcontext * ctx, driFenceReference(fence); } - UNLOCK_HARDWARE(intel); if (fence) { driFenceFinish(fence, DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, diff --git a/src/mesa/drivers/dri/i915tex/intel_span.c b/src/mesa/drivers/dri/i915tex/intel_span.c index ab0874e4fd6..368e0ec3c09 100644 --- a/src/mesa/drivers/dri/i915tex/intel_span.c +++ b/src/mesa/drivers/dri/i915tex/intel_span.c @@ -51,8 +51,7 @@ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ const GLint yScale = irb->RenderToTexture ? 1 : -1; \ const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \ - GLubyte *buf = (GLubyte *) irb->pfMap \ - + (intel->drawY * irb->pfPitch + intel->drawX) * irb->region->cpp;\ + GLubyte *buf = (GLubyte *) irb->pfMap; \ GLuint p; \ assert(irb->pfMap);\ (void) p; @@ -65,10 +64,10 @@ do { \ int _nc = intel->numClipRects; \ while ( _nc-- ) { \ - int minx = intel->pClipRects[_nc].x1 - intel->drawX; \ - int miny = intel->pClipRects[_nc].y1 - intel->drawY; \ - int maxx = intel->pClipRects[_nc].x2 - intel->drawX; \ - int maxy = intel->pClipRects[_nc].y2 - intel->drawY; + int minx = intel->pClipRects[_nc].x1; \ + int miny = intel->pClipRects[_nc].y1; \ + int maxx = intel->pClipRects[_nc].x2; \ + int maxy = intel->pClipRects[_nc].y2; @@ -106,9 +105,7 @@ const GLuint pitch = irb->pfPitch/***XXX region->pitch*/; /* in pixels */ \ const GLint yScale = irb->RenderToTexture ? 1 : -1; \ const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \ - char *buf = (char *) irb->pfMap/*XXX use region->map*/ + \ - (intel->drawY * pitch + intel->drawX) * irb->region->cpp; - + char *buf = (char *) irb->pfMap/*XXX use region->map*/ ; #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_copy.c b/src/mesa/drivers/dri/i915tex/intel_tex_copy.c index b85a25642a2..90c2b9ebb51 100644 --- a/src/mesa/drivers/dri/i915tex/intel_tex_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_tex_copy.c @@ -101,6 +101,7 @@ do_copy_texsubimage(struct intel_context *intel, } intelFlush(ctx); + /* XXX still need the lock ? */ LOCK_HARDWARE(intel); { GLuint image_offset = intel_miptree_image_offset(intelImage->mt, @@ -117,20 +118,8 @@ do_copy_texsubimage(struct intel_context *intel, dstx += x - orig_x; dsty += y - orig_y; - if (ctx->ReadBuffer->Name == 0) { - /* reading from a window, adjust x, y */ - __DRIdrawablePrivate *dPriv = intel->driDrawable; - GLuint window_y; - /* window_y = position of window on screen if y=0=bottom */ - window_y = intel->intelScreen->height - (dPriv->y + dPriv->h); - y = window_y + y; - x += dPriv->x; - } - else { - /* reading from a FBO */ - /* invert Y */ - y = ctx->ReadBuffer->Height - y - 1; - } + /* invert Y */ + y = ctx->ReadBuffer->Height - y - 1; /* A bit of fiddling to get the blitter to work with -ve -- cgit v1.2.3 From f022bff5aa828cfdbb4749f672fc51c345f9cb33 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 13 Jul 2007 20:47:17 +0200 Subject: bugfixes (wrt fb updates), cleanups move drawable validation back to where it was now that the driDrawable information isn't used directly anymore. Fix bogus fb updates (the context we get for SwapBuffer processing may not have the drawable being processed attached!) glthreads behaves a bit better but still not correct. --- src/mesa/drivers/dri/i915tex/intel_blit.c | 18 ++++++++--------- src/mesa/drivers/dri/i915tex/intel_context.c | 24 ++++++++++------------- src/mesa/drivers/dri/i915tex/intel_context.h | 1 - src/mesa/drivers/dri/i915tex/intel_fbo.c | 14 ++++++++------ src/mesa/drivers/dri/i915tex/intel_fbo.h | 4 +++- src/mesa/drivers/dri/i915tex/intel_screen.c | 29 ++++++++++++++-------------- 6 files changed, 44 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index 2a0a6393152..db72f59a2c7 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -79,13 +79,6 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv, */ LOCK_HARDWARE(intel); - if (intel->revalidateDrawable) { - __DRIscreenPrivate *sPriv = intel->driScreen; - if (dPriv) { - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); - } - } - if (dPriv && dPriv->numClipRects) { struct intel_framebuffer *intel_fb = dPriv->driverPrivate; const struct intel_region *frontRegion @@ -190,9 +183,14 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv, UNLOCK_HARDWARE(intel); - if (intel->revalidateDrawable) { - intel->revalidateDrawable = GL_FALSE; - intelWindowMoved(intel); + /* XXX this is bogus. The context here may not even be bound to this drawable! */ + if (intel->lastStamp != dPriv->lastStamp) { + GET_CURRENT_CONTEXT(currctx); + struct intel_context *intelcurrent = intel_context(currctx); + if (intelcurrent == intel && intelcurrent->driDrawable == dPriv) { + intelWindowMoved(intel); + intel->lastStamp = dPriv->lastStamp; + } } } diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 451c7fd1ba5..41eaafece23 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -572,7 +572,6 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, __DRIdrawablePrivate * driDrawPriv, __DRIdrawablePrivate * driReadPriv) { - GLuint updatebufsize = GL_FALSE; #if 0 if (driDrawPriv) { @@ -620,22 +619,18 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, } } - /* only update GLframebuffer size to match window - if here for the first time */ - if (intel->ctx.FirstTimeCurrent) { - updatebufsize = GL_TRUE; - driUpdateFramebufferSize(&intel->ctx, driDrawPriv); + /* update GLframebuffer size to match window if needed */ + driUpdateFramebufferSize(&intel->ctx, driDrawPriv); - if (driReadPriv != driDrawPriv) { - driUpdateFramebufferSize(&intel->ctx, driReadPriv); - } + if (driReadPriv != driDrawPriv) { + driUpdateFramebufferSize(&intel->ctx, driReadPriv); } _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb); /* The drawbuffer won't always be updated by _mesa_make_current: */ - if (updatebufsize && intel->ctx.DrawBuffer == &intel_fb->Base) { + if (intel->ctx.DrawBuffer == &intel_fb->Base) { if (intel->driDrawable != driDrawPriv) { intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) @@ -646,9 +641,11 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, &intel_fb->vbl_seq); intel->driDrawable = driDrawPriv; intelWindowMoved(intel); + intel->lastStamp = driDrawPriv->lastStamp; + } + else if (intel->lastStamp != driDrawPriv->lastStamp) { + intel_draw_buffer(&intel->ctx, &intel_fb->Base); } - - intel_draw_buffer(&intel->ctx, &intel_fb->Base); } } else { @@ -677,8 +674,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) * checking must be done *after* this call: */ if (dPriv) - intel->revalidateDrawable = GL_TRUE; -// DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); + DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); if (sarea->width != intelScreen->width || sarea->height != intelScreen->height || diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index f85b3a63627..b5defdc47e4 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -272,7 +272,6 @@ struct intel_context drmI830Sarea *sarea; GLuint lastStamp; - GLuint revalidateDrawable; /** * Configuration cache diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index aeb909cce17..afee07c6898 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -299,7 +299,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, } - +#if 0 /** * Called for each hardware renderbuffer when a _window_ is resized. * Just update fields. @@ -316,6 +316,7 @@ intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb, return GL_TRUE; } +#endif static void intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb, @@ -352,7 +353,7 @@ intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, } - +#if 0 /** * Create a new intel_renderbuffer which corresponds to an on-screen window, * not a user-created renderbuffer. @@ -452,15 +453,16 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, return irb; } +#endif -struct gl_renderbuffer * -intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat) +struct intel_renderbuffer * +intel_new_renderbuffer_fb(GLuint intFormat) { struct intel_renderbuffer *irb; irb = CALLOC_STRUCT(intel_renderbuffer); if (!irb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer"); + _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer"); return NULL; } @@ -474,7 +476,7 @@ intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat) irb->Base.GetPointer = intel_get_pointer; /* span routines set in alloc_storage function */ - return &irb->Base; + return irb; } /** diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h index 963f5e706f4..762aac594e8 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.h +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h @@ -84,7 +84,7 @@ struct intel_renderbuffer GLuint vbl_pending; /**< vblank sequence number of pending flip */ }; - +#if 0 extern struct intel_renderbuffer *intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, @@ -92,7 +92,9 @@ extern struct intel_renderbuffer *intel_create_renderbuffer(GLenum intFormat, int pitch, int cpp, void *map); +#endif +extern struct intel_renderbuffer *intel_new_renderbuffer_fb(GLuint intFormat); extern void intel_fbo_init(struct intel_context *intel); diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index 08057a66006..dcc29923834 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -680,14 +680,14 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, /* XXX allocation should only happen in the unusual case it's actually needed */ intel_fb->color_rb[0] - = intel_new_renderbuffer_fb(NULL, rgbFormat); + = intel_new_renderbuffer_fb(rgbFormat); _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT, &intel_fb->color_rb[0]->Base); } if (mesaVis->doubleBufferMode) { intel_fb->color_rb[1] - = intel_new_renderbuffer_fb(NULL, rgbFormat); + = intel_new_renderbuffer_fb(rgbFormat); _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, &intel_fb->color_rb[1]->Base); @@ -695,14 +695,14 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, struct gl_renderbuffer *tmp_rb = NULL; intel_fb->color_rb[2] - = intel_new_renderbuffer_fb(NULL, rgbFormat); + = intel_new_renderbuffer_fb(rgbFormat); _mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base); } } if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { /* combined depth/stencil buffer */ struct intel_renderbuffer *depthStencilRb - = intel_new_renderbuffer_fb(NULL, GL_DEPTH24_STENCIL8_EXT); + = intel_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT); /* note: bind RB to two attachment points */ _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthStencilRb->Base); @@ -712,7 +712,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, else if (mesaVis->depthBits == 16) { /* just 16-bit depth buffer, no hw stencil */ struct intel_renderbuffer *depthRb - = intel_new_renderbuffer_fb(NULL, GL_DEPTH_COMPONENT16); + = intel_new_renderbuffer_fb(GL_DEPTH_COMPONENT16); _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base); } @@ -987,18 +987,19 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen) * context at screen creation. For now just use the current context. */ -/* GET_CURRENT_CONTEXT(ctx); + GET_CURRENT_CONTEXT(ctx); if (ctx == NULL) { - _mesa_problem(NULL, "No current context in intelScreenContext\n"); - return NULL; +/* _mesa_problem(NULL, "No current context in intelScreenContext\n"); + return NULL; */ + /* need a context for the first time makecurrent is called (for hw lock + when allocating priv buffers) */ + if (intelScreen->dummyctxptr == NULL) { + _mesa_problem(NULL, "No current context in intelScreenContext\n"); + return NULL; + } + return intelScreen->dummyctxptr; } return intel_context(ctx); -*/ - if (intelScreen->dummyctxptr == NULL) { - _mesa_problem(NULL, "No current context in intelScreenContext\n"); - return NULL; - } - return intelScreen->dummyctxptr; } -- cgit v1.2.3 From a04056d313a8346dc9e6e1b062762a6f115d1b46 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sat, 14 Jul 2007 14:24:20 +0200 Subject: fix assertion, z/stencil swarst readback, (still looks suspicious) copyTexSubimage --- src/mesa/drivers/dri/common/drirenderbuffer.c | 4 ++++ src/mesa/drivers/dri/i915tex/intel_pixel_read.c | 2 +- src/mesa/drivers/dri/i915tex/intel_span.c | 4 ++-- src/mesa/drivers/dri/i915tex/intel_tex_copy.c | 8 +++++--- 4 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c b/src/mesa/drivers/dri/common/drirenderbuffer.c index d36af3e5bee..d4f7f2527bb 100644 --- a/src/mesa/drivers/dri/common/drirenderbuffer.c +++ b/src/mesa/drivers/dri/common/drirenderbuffer.c @@ -209,7 +209,11 @@ driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawablePrivate *dPriv) struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate; if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) { ctx->Driver.ResizeBuffers(ctx, fb, dPriv->w, dPriv->h); +#if 0 + /* if the driver needs the hw lock for ResizeBuffers, the drawable + might have changed again by now */ assert(fb->Width == dPriv->w); assert(fb->Height == dPriv->h); +#endif } } diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c index 9481cb4800f..c7bdb6bc855 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c @@ -183,7 +183,7 @@ do_blit_readpixels(GLcontext * ctx, */ if (!_mesa_validate_pbo_access(2, pack, width, height, 1, format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels"); + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels"); return GL_TRUE; } } diff --git a/src/mesa/drivers/dri/i915tex/intel_span.c b/src/mesa/drivers/dri/i915tex/intel_span.c index 368e0ec3c09..74f118121c1 100644 --- a/src/mesa/drivers/dri/i915tex/intel_span.c +++ b/src/mesa/drivers/dri/i915tex/intel_span.c @@ -264,7 +264,7 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) /* depth buffer (Note wrapper!) */ if (ctx->DrawBuffer->_DepthBuffer) { irb = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); - if (irb && irb->region && irb->Base.Name != 0) { + if (irb && irb->region) { if (map) { intel_region_map(intel->intelScreen, irb->region); irb->pfMap = irb->region->map; @@ -281,7 +281,7 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) /* stencil buffer (Note wrapper!) */ if (ctx->DrawBuffer->_StencilBuffer) { irb = intel_renderbuffer(ctx->DrawBuffer->_StencilBuffer->Wrapped); - if (irb && irb->region && irb->Base.Name != 0) { + if (irb && irb->region) { if (map) { intel_region_map(intel->intelScreen, irb->region); irb->pfMap = irb->region->map; diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_copy.c b/src/mesa/drivers/dri/i915tex/intel_tex_copy.c index 90c2b9ebb51..8d7f8f9d91b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_tex_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_tex_copy.c @@ -118,9 +118,11 @@ do_copy_texsubimage(struct intel_context *intel, dstx += x - orig_x; dsty += y - orig_y; - /* invert Y */ - y = ctx->ReadBuffer->Height - y - 1; - + if (!(ctx->ReadBuffer->Name == 0)) { + /* XXX this looks bogus ? */ + /* FBO: invert Y */ + y = ctx->ReadBuffer->Height - y - 1; + } /* A bit of fiddling to get the blitter to work with -ve * pitches. But we get a nice inverted blit this way, so it's -- cgit v1.2.3 From cd3afa2a952a9ec05fb9fa959dfe90d620bd2d88 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 15 Jul 2007 18:17:36 +0200 Subject: begin getting rid of fake clip rects (copy_pixel) --- src/mesa/drivers/dri/i915tex/intel_context.c | 1 + src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 133 ++++++++++++++---------- 2 files changed, 80 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 41eaafece23..146426fd371 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -192,6 +192,7 @@ const struct dri_extension card_extensions[] = { #if 1 /* XXX FBO temporary? */ {"GL_EXT_packed_depth_stencil", NULL}, #endif + {"GL_EXT_pixel_buffer_object", NULL}, {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, {"GL_EXT_stencil_wrap", NULL}, {"GL_EXT_texture_edge_clamp", NULL}, diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index 03c7353ee15..77d0e24f001 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -42,21 +42,25 @@ #include "intel_regions.h" #include "intel_tris.h" #include "intel_pixel.h" +#include "intel_fbo.h" #define FILE_DEBUG_FLAG DEBUG_PIXEL static struct intel_region * copypix_src_region(struct intel_context *intel, GLenum type) { + struct intel_renderbuffer *irb; + switch (type) { case GL_COLOR: return intel_readbuf_region(intel); case GL_DEPTH: /* Don't think this is really possible execpt at 16bpp, when we have no stencil. */ - if (intel->intelScreen->depth_region && - intel->intelScreen->depth_region->cpp == 2) - return intel->intelScreen->depth_region; + irb = intel_renderbuffer(intel->ctx.ReadBuffer->_DepthBuffer->Wrapped); + if (irb && irb->region && irb->region->cpp == 2) + return irb->region; + break; case GL_STENCIL: /* Don't think this is really possible. */ @@ -64,7 +68,10 @@ copypix_src_region(struct intel_context *intel, GLenum type) case GL_DEPTH_STENCIL_EXT: /* Does it matter whether it is stencil/depth or depth/stencil? */ - return intel->intelScreen->depth_region; + irb = intel_renderbuffer(intel->ctx.ReadBuffer->_DepthBuffer->Wrapped); + if (irb && irb->region) + return irb->region; + break; default: break; } @@ -164,7 +171,8 @@ do_texture_copypixels(GLcontext * ctx, /* Set the 3d engine to draw into the destination region: */ - intel->vtbl.meta_draw_region(intel, dst, intel->intelScreen->depth_region); + intel->vtbl.meta_draw_region(intel, dst, + (intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped))->region); intel->vtbl.meta_import_pixel_state(intel); @@ -191,9 +199,8 @@ do_texture_copypixels(GLcontext * ctx, LOCK_HARDWARE(intel); - if (intel->numClipRects) { - int bufHeight = intel->pClipRects->y2; - assert (intel->numClipRects == 1); + { + int bufHeight = ctx->DrawBuffer->Height; srcy = bufHeight - srcy - height; /* convert from gl to hardware coords */ /* Clip against the source region. This is the only source @@ -205,7 +212,8 @@ do_texture_copypixels(GLcontext * ctx, GLint orig_x = srcx; GLint orig_y = srcy; - if (!_mesa_clip_to_region(0, 0, src->pitch, src->height, + if (!_mesa_clip_to_region(0, 0, ctx->ReadBuffer->Width - 1, + ctx->ReadBuffer->Height - 1, &srcx, &srcy, &width, &height)) goto out; @@ -248,8 +256,10 @@ do_blit_copypixels(GLcontext * ctx, GLint dstx, GLint dsty, GLenum type) { struct intel_context *intel = intel_context(ctx); - struct intel_region *dst = intel_drawbuf_region(intel); - struct intel_region *src = copypix_src_region(intel, type); + struct intel_renderbuffer *irbread; + struct intel_renderbuffer *irbdraw; + struct intel_region *dst; + struct intel_region *src; /* Copypixels can be more than a straight copy. Ensure all the * extra operations are disabled: @@ -258,23 +268,43 @@ do_blit_copypixels(GLcontext * ctx, ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) return GL_FALSE; - if (!src || !dst) - return GL_FALSE; - - - intelFlush(&intel->ctx); - LOCK_HARDWARE(intel); + if (type == GL_COLOR) { + irbread = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); + irbdraw = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + if (!irbread || !irbread->region || !irbdraw || !irbdraw->region) + return GL_FALSE; + } + else if (type == GL_DEPTH) { + /* Don't think this is really possible execpt at 16bpp, when we have no stencil. + */ + irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped); + irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + if (!irbread || !irbread->region || !irbdraw || !irbdraw->region + || !(irbread->region->cpp == 2)) + return GL_FALSE; + } + else if (GL_DEPTH_STENCIL_EXT) { + /* Does it matter whether it is stencil/depth or depth/stencil? + */ + irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped); + irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + if (!irbread || !irbread->region || !irbdraw || !irbdraw->region) + return GL_FALSE; + } + else if (GL_STENCIL) { + /* Don't think this is really possible. + */ + return GL_FALSE; + } + + src = irbread->region; + dst = irbdraw->region; - if (intel->numClipRects) { - assert(intel->numClipRects == 1); - drm_clip_rect_t *box = intel->pClipRects; - drm_clip_rect_t dest_rect; - GLint nbox = intel->numClipRects; + { GLint delta_x = 0; GLint delta_y = 0; - GLuint i; /* Do scissoring in GL coordinates: */ @@ -289,58 +319,54 @@ do_blit_copypixels(GLcontext * ctx, if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height)) goto out; - + srcx = dstx - dx; srcy = dsty - dy; } /* Convert from GL to hardware coordinates: - * cliprect should be size of buffer */ - dsty = box->y2 - dsty - height; - srcy = box->y2 - srcy - height; + dsty = irbdraw->Base.Height - dsty - height; + srcy = irbread->Base.Height - srcy - height; - /* Clip against the source region. This is the only source - * clipping we do. Dst is clipped with cliprects below. + /* Clip against the source region: */ { delta_x = srcx - dstx; delta_y = srcy - dsty; - if (!_mesa_clip_to_region(0, 0, src->pitch, src->height, - &srcx, &srcy, &width, &height)) + if (!_mesa_clip_to_region(0, 0, irbread->Base.Width - 1, + irbread->Base.Height - 1, + &srcx, &srcy, &width, &height)) goto out; dstx = srcx - delta_x; dsty = srcy - delta_y; } - dest_rect.x1 = dstx; - dest_rect.y1 = dsty; - dest_rect.x2 = dstx + width; - dest_rect.y2 = dsty + height; - - /* Could do slightly more clipping: Eg, take the intersection of - * the existing set of cliprects and those cliprects translated - * by delta_x, delta_y: - * - * This code will not overwrite other windows, but will - * introduce garbage when copying from obscured window regions. + /* Clip against the dest region: */ - for (i = 0; i < nbox; i++) { - drm_clip_rect_t rect; + { + delta_x = dstx - srcx; + delta_y = dsty - srcy; - if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) - continue; + if (!_mesa_clip_to_region(0, 0, irbdraw->Base.Width - 1, + irbdraw->Base.Height - 1, + &dstx, &dsty, &width, &height)) + goto out; + srcx = dstx - delta_x; + srcy = dsty - delta_y; + } - intelEmitCopyBlit(intel, dst->cpp, - src->pitch, src->buffer, 0, - dst->pitch, dst->buffer, 0, - rect.x1 + delta_x, - rect.y1 + delta_y, /* srcx, srcy */ - rect.x1, rect.y1, /* dstx, dsty */ - rect.x2 - rect.x1, rect.y2 - rect.y1, + { + + intelEmitCopyBlit(intel, dst->cpp, + src->pitch, src->buffer, 0, + dst->pitch, dst->buffer, 0, + srcx, srcy, + dstx, dsty, + width, height, ctx->Color.ColorLogicOpEnabled ? ctx->Color.LogicOp : GL_COPY); } @@ -348,7 +374,6 @@ do_blit_copypixels(GLcontext * ctx, out: intel_batchbuffer_flush(intel->batch); } - UNLOCK_HARDWARE(intel); DBG("%s: success\n", __FUNCTION__); return GL_TRUE; -- cgit v1.2.3 From 8172f50419b370c4608d1bbc6cac4d77e3e45804 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 15 Jul 2007 20:15:19 +0200 Subject: fix the texture copypixels path --- src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index 77d0e24f001..57e746ae22f 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -119,6 +119,7 @@ do_texture_copypixels(GLcontext * ctx, struct intel_context *intel = intel_context(ctx); struct intel_region *dst = intel_drawbuf_region(intel); struct intel_region *src = copypix_src_region(intel, type); + struct intel_region *depthreg = NULL; GLenum src_format; GLenum src_type; @@ -171,8 +172,11 @@ do_texture_copypixels(GLcontext * ctx, /* Set the 3d engine to draw into the destination region: */ - intel->vtbl.meta_draw_region(intel, dst, - (intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped))->region); + if (ctx->DrawBuffer->_DepthBuffer && + ctx->DrawBuffer->_DepthBuffer->Wrapped) + depthreg = (intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped))->region; + + intel->vtbl.meta_draw_region(intel, dst, depthreg); intel->vtbl.meta_import_pixel_state(intel); @@ -200,8 +204,9 @@ do_texture_copypixels(GLcontext * ctx, LOCK_HARDWARE(intel); { - int bufHeight = ctx->DrawBuffer->Height; - srcy = bufHeight - srcy - height; /* convert from gl to hardware coords */ + int dstbufHeight = ctx->DrawBuffer->Height; + /* convert from gl to hardware coords */ + srcy = ctx->ReadBuffer->Height - srcy - height; /* Clip against the source region. This is the only source * clipping we do. XXX: Just set the texcord wrap mode to clamp @@ -224,11 +229,11 @@ do_texture_copypixels(GLcontext * ctx, /* Just use the regular cliprect mechanism... Does this need to * even hold the lock??? */ - intel_meta_draw_quad(intel, - dstx, - dstx + width * ctx->Pixel.ZoomX, - bufHeight - (dsty + height * ctx->Pixel.ZoomY), - bufHeight - (dsty), 0, /* XXX: what z value? */ + intel_meta_draw_quad(intel, + dstx, + dstx + width * ctx->Pixel.ZoomX, + dstbufHeight - (dsty + height * ctx->Pixel.ZoomY), + dstbufHeight - (dsty), 0, /* XXX: what z value? */ 0x00ff00ff, srcx, srcx + width, srcy, srcy + height); -- cgit v1.2.3 From a1ec23a30f3ff9583b32428c2c357b9ef66f3a50 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 15 Jul 2007 22:47:42 +0200 Subject: fix bogus fb/drawable information (fixes xdemos/wincopy) the framebuffer objects attached to drawables can have invalidate state associated with them, since for the window framebuffer this is per-context state and not per-fbo state. Since drivers may rely on that information (otherwise would need to check if currently the window-framebuffer is bound in a lot of places) fix it up in _mesa_make_current (ugly). --- src/mesa/drivers/dri/i915tex/intel_context.c | 5 +++-- src/mesa/main/context.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 146426fd371..cb3ec4ccfad 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -289,8 +289,9 @@ static void intelCheckFrontUpdate(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); - if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == - BUFFER_BIT_FRONT_LEFT) { + /* can't use _ColorDrawBufferMask as its value + might change if a different drawable is bound! */ + if (ctx->Color.DrawBuffer[0] == GL_FRONT_LEFT) { intelScreenPrivate *screen = intel->intelScreen; __DRIdrawablePrivate *dPriv = intel->driDrawable; if (screen->current_rotation != 0) { diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 255023c0fa9..183a552d406 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1495,9 +1495,20 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); + /* fix up the fb fields - these will end up wrong otherwise + if the DRIdrawable changes, and someone may rely on them. + */ + /* What a mess!?! */ + int i; + GLenum buffers[MAX_DRAW_BUFFERS]; + for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { + buffers[i] = newCtx->Color.DrawBuffer[i]; + } + _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL); } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); + _mesa_ReadBuffer(newCtx->Pixel.ReadBuffer); } newCtx->NewState |= _NEW_BUFFERS; -- cgit v1.2.3 From 99c7e38d8363eafe2fc079ed6e7bad289d65e965 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 15 Jul 2007 22:53:59 +0200 Subject: change back driver change from previous commit --- src/mesa/drivers/dri/i915tex/intel_context.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index cb3ec4ccfad..ec4a7a746d4 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -289,9 +289,12 @@ static void intelCheckFrontUpdate(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); - /* can't use _ColorDrawBufferMask as its value - might change if a different drawable is bound! */ - if (ctx->Color.DrawBuffer[0] == GL_FRONT_LEFT) { + /* rely on _ColorDrawBufferMask being kept up to date by mesa + even for window-fbos. */ + /* not sure. Might need that for all masks including + BUFFER_BIT_FRONT_LEFT maybe? */ + if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == + BUFFER_BIT_FRONT_LEFT) { intelScreenPrivate *screen = intel->intelScreen; __DRIdrawablePrivate *dPriv = intel->driDrawable; if (screen->current_rotation != 0) { -- cgit v1.2.3 From d69cae95a072d3641bd8340a5216662e0365ed6f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 11:51:08 +0200 Subject: allow blit path for read pixels if pack->alignment isn't 1. pack->alignment doesn't matter usually if the image is sufficiently aligned anyway. Speeds up some tests/readrate cases by a factor of 100 (since the pack->alignment default which noone ever bothers to change is 4). --- src/mesa/drivers/dri/i915tex/intel_pixel_read.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c index c7bdb6bc855..c41ca33f8f5 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c @@ -203,17 +203,18 @@ do_blit_readpixels(GLcontext * ctx, return GL_FALSE; } - if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) { - if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: bad packing params\n", __FUNCTION__); - return GL_FALSE; - } - if (pack->RowLength > 0) rowLength = pack->RowLength; else rowLength = width; + if (((rowLength * src->cpp) % pack->Alignment) || + pack->SwapBytes || pack->LsbFirst) { + if (INTEL_DEBUG & DEBUG_PIXEL) + _mesa_printf("%s: bad packing params\n", __FUNCTION__); + return GL_FALSE; + } + if (pack->Invert) { if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__); -- cgit v1.2.3 From 8b93d9238e4dd51acaf95c4744d5f6a795d9d35c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 13:57:49 +0200 Subject: get rid of more cliprects (readpixel)... --- src/mesa/drivers/dri/i915tex/intel_pixel_read.c | 167 +++++++++++++----------- 1 file changed, 91 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c index c41ca33f8f5..76a6959625e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_read.c @@ -42,6 +42,8 @@ #include "intel_regions.h" #include "intel_pixel.h" #include "intel_buffer_objects.h" +#include "intel_fbo.h" +#include "intel_tris.h" /* For many applications, the new ability to pull the source buffers * back out of the GTT and then do the packing/conversion operations @@ -54,6 +56,8 @@ * an argument for blit/texture readpixels, or for blitting to a * temporary and then pulling that back. * + * XXX this is not true for fake frontbuffers... + * When the destination is a pbo, however, it's not clear if it is * ever going to be pulled to main memory (though the access param * will be a good hint). So it sounds like we do want to be able to @@ -68,88 +72,105 @@ static GLboolean do_texture_readpixels(GLcontext * ctx, - GLint x, GLint y, GLsizei width, GLsizei height, + GLint srcx, GLint srcy, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *pack, struct intel_region *dest_region) { #if 0 struct intel_context *intel = intel_context(ctx); - intelScreenPrivate *screen = intel->intelScreen; - GLint pitch = pack->RowLength ? pack->RowLength : width; - int textureFormat; - GLenum glTextureFormat; - int destFormat, depthFormat, destPitch; - drm_clip_rect_t tmp; + struct intel_region *depthreg = NULL; + struct intel_region *src = intel_readbuf_region(intel); +// struct intel_region *src = copypix_src_region(intel, type); + GLenum src_format; + GLenum src_type; if (INTEL_DEBUG & DEBUG_PIXEL) fprintf(stderr, "%s\n", __FUNCTION__); - - if (ctx->_ImageTransferState || - pack->SwapBytes || pack->LsbFirst || !pack->Invert) { - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: check_color failed\n", __FUNCTION__); - return GL_FALSE; - } - - intel->vtbl.meta_texrect_source(intel, intel_readbuf_region(intel)); - - if (!intel->vtbl.meta_render_dest(intel, dest_region, type, format)) { - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: couldn't set dest %s/%s\n", - __FUNCTION__, - _mesa_lookup_enum_by_nr(type), - _mesa_lookup_enum_by_nr(format)); + if (!src || type != GL_COLOR) return GL_FALSE; - } - LOCK_HARDWARE(intel); + intelFlush(&intel->ctx); - if (intel->numClipRects) { - intel->vtbl.install_meta_state(intel); - intel->vtbl.meta_no_depth_write(intel); - intel->vtbl.meta_no_stencil_write(intel); + intel->vtbl.install_meta_state(intel); - if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) { - UNLOCK_HARDWARE(intel); - SET_STATE(i830, state); - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__); - return GL_TRUE; - } + /* Is this true? Also will need to turn depth testing on according + * to state: + */ + intel->vtbl.meta_no_stencil_write(intel); + intel->vtbl.meta_no_depth_write(intel); - y = intel->pClipRects->y2 - y - height; + /* Set the 3d engine to draw into the destination region: + */ + if (ctx->DrawBuffer->_DepthBuffer && + ctx->DrawBuffer->_DepthBuffer->Wrapped) + depthreg = (intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped))->region; + intel->vtbl.meta_draw_region(intel, dest_region, depthreg); - /* Set the frontbuffer up as a large rectangular texture. - */ - intel->vtbl.meta_tex_rect_source(intel, src_region, textureFormat); + intel->vtbl.meta_import_pixel_state(intel); + if (src->cpp == 2) { + src_format = GL_RGB; + src_type = GL_UNSIGNED_SHORT_5_6_5; + } + else { + src_format = GL_BGRA; + src_type = GL_UNSIGNED_BYTE; + } - intel->vtbl.meta_texture_blend_replace(i830, glTextureFormat); + /* Set the frontbuffer up as a large rectangular texture. + */ + if (!intel->vtbl.meta_tex_rect_source(intel, src->buffer, 0, + src->pitch, + src->height, src_format, src_type)) { + intel->vtbl.leave_meta_state(intel); + return GL_FALSE; + } - /* Set the 3d engine to draw into the destination region: - */ + intel->vtbl.meta_texture_blend_replace(intel); - intel->vtbl.meta_draw_region(intel, dest_region); - intel->vtbl.meta_draw_format(intel, destFormat, depthFormat); /* ?? */ + LOCK_HARDWARE(intel); + { + int dstbufHeight = height * ctx->Pixel.ZoomY; /* ? */ + /* convert from gl to hardware coords */ + srcy = ctx->ReadBuffer->Height - srcy - height; - /* Draw a single quad, no cliprects: + /* Clip against the source region. This is the only source + * clipping we do. XXX: Just set the texcord wrap mode to clamp + * or similar. + * */ - intel->vtbl.meta_disable_cliprects(intel); + if (0) { + if (!_mesa_clip_to_region(0, 0, ctx->ReadBuffer->Width - 1, + ctx->ReadBuffer->Height - 1, + &srcx, &srcy, &width, &height)) + goto out; - intel->vtbl.draw_quad(intel, - 0, width, 0, height, - 0x00ff00ff, x, x + width, y, y + height); + } + /* Just use the regular cliprect mechanism... Does this need to + * even hold the lock??? + */ + intel_meta_draw_quad(intel, + 0, + width * ctx->Pixel.ZoomX, + dstbufHeight - (height * ctx->Pixel.ZoomY), + dstbufHeight, 0, /* XXX: what z value? */ + 0x00ff00ff, + srcx, srcx + width, srcy, srcy + height); + + out: intel->vtbl.leave_meta_state(intel); + intel_batchbuffer_flush(intel->batch); } UNLOCK_HARDWARE(intel); - intel_region_wait_fence(ctx, dest_region); /* required by GL */ + if (INTEL_DEBUG & DEBUG_PIXEL) + _mesa_printf("%s: success\n", __FUNCTION__); return GL_TRUE; #endif @@ -166,7 +187,8 @@ do_blit_readpixels(GLcontext * ctx, const struct gl_pixelstore_attrib *pack, GLvoid * pixels) { struct intel_context *intel = intel_context(ctx); - struct intel_region *src = intel_readbuf_region(intel); + struct intel_renderbuffer *irbread; + struct intel_region *src; struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj); GLuint dst_offset; GLuint rowLength; @@ -175,8 +197,10 @@ do_blit_readpixels(GLcontext * ctx, if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); - if (!src) + irbread = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); + if (!irbread || !irbread->region) return GL_FALSE; + src = irbread->region; if (dst) { /* XXX This validation should be done by core mesa: @@ -228,44 +252,35 @@ do_blit_readpixels(GLcontext * ctx, dst_offset = (GLuint) _mesa_image_address(2, pack, pixels, width, height, format, type, 0, 0, 0); - /* reading from priv buffer, cliprects should not change */ intelFlush(&intel->ctx); - if (intel->numClipRects) { - assert (intel->numClipRects == 1); + { + GLint srcx = x; + GLint srcy = irbread->Base.Height - (y + height); + GLint srcwidth = width; + GLint srcheight = height; + GLboolean all = (width * height * src->cpp == dst->Base.Size && x == 0 && dst_offset == 0); struct _DriBufferObject *dst_buffer = intel_bufferobj_buffer(intel, dst, all ? INTEL_WRITE_FULL : INTEL_WRITE_PART); - int nbox = intel->numClipRects; - drm_clip_rect_t *box = intel->pClipRects; - drm_clip_rect_t rect; - drm_clip_rect_t src_rect; - int i; - - src_rect.x1 = x; - src_rect.y1 = box->y2 - (y + height); - src_rect.x2 = src_rect.x1 + width; - src_rect.y2 = src_rect.y1 + height; - - - for (i = 0; i < nbox; i++) { - if (!intel_intersect_cliprects(&rect, &src_rect, &box[i])) - continue; + /* clip to src region */ + if (_mesa_clip_to_region(0, 0, irbread->Base.Width - 1, + irbread->Base.Height - 1, + &srcx, &srcy, &srcwidth, &srcheight)); + { intelEmitCopyBlit(intel, src->cpp, src->pitch, src->buffer, 0, rowLength, dst_buffer, dst_offset, - rect.x1, - rect.y1, - rect.x1 - src_rect.x1, - rect.y2 - src_rect.y2, - rect.x2 - rect.x1, rect.y2 - rect.y1, + srcx, srcy, + 0, 0, + width, height, GL_COPY); } -- cgit v1.2.3 From 6104044f6bd9464b5972234f95801ca6ba5db510 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 15:33:09 +0200 Subject: get rid of more fake cliprects (drawpixel), and enable blit draw with scissor --- src/mesa/drivers/dri/i915tex/intel_pixel.c | 3 +- src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c | 15 ++-- src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 29 +----- src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 104 ++++++++++++++++------ 4 files changed, 87 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel.c b/src/mesa/drivers/dri/i915tex/intel_pixel.c index 9018e3daef4..8e61cc81848 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel.c @@ -44,13 +44,12 @@ intel_check_blit_fragment_ops(GLcontext * ctx) if (ctx->NewState) _mesa_update_state(ctx); - /* XXX Note: Scissor could be done with the blitter: + /* XXX Note: Scissor done with blitter: */ return !(ctx->_ImageTransferState || ctx->Color.AlphaEnabled || ctx->Depth.Test || ctx->Fog.Enabled || - ctx->Scissor.Enabled || ctx->Stencil.Enabled || !ctx->Color.ColorMask[0] || !ctx->Color.ColorMask[1] || diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c index 96d3cbef5f2..c205c6a715f 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_bitmap.c @@ -195,16 +195,17 @@ do_blit_bitmap( GLcontext *ctx, LOCK_HARDWARE(intel); - if (intel->numClipRects) { - assert(intel->numClipRects == 1); - drm_clip_rect_t *box = intel->pClipRects; + { + drm_clip_rect_t box; drm_clip_rect_t dest_rect; - GLint nbox = intel->numClipRects; GLint srcx = 0, srcy = 0; GLint orig_screen_x1, orig_screen_y2; GLuint i; - + box.x1 = 0; + box.y1 = 0; + box.x2 = ctx->DrawBuffer->Width; + box.y2 = ctx->DrawBuffer->Height; orig_screen_x1 = dstx; orig_screen_y2 = box->y2 - dsty; @@ -231,13 +232,13 @@ x if (ctx->Scissor.Enabled) dest_rect.x2 = dstx + width; dest_rect.y2 = dsty + height; - for (i = 0; i < nbox; i++) { + for (i = 0; i < 1; i++) { drm_clip_rect_t rect; int box_w, box_h; GLint px, py; GLuint stipple[32]; - if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) + if (!intel_intersect_cliprects(&rect, &dest_rect, &box[0])) continue; /* Now go back to GL coordinates to figure out what subset of diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index 57e746ae22f..3148a2b0d42 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -80,33 +80,6 @@ copypix_src_region(struct intel_context *intel, GLenum type) } -/** - * Check if any fragment operations are in effect which might effect - * glCopyPixels. Differs from intel_check_blit_fragment_ops in that - * we allow Scissor. - */ -static GLboolean -intel_check_copypixel_blit_fragment_ops(GLcontext * ctx) -{ - if (ctx->NewState) - _mesa_update_state(ctx); - - /* Could do logicop with the blitter: - */ - return !(ctx->_ImageTransferState || - ctx->Color.AlphaEnabled || - ctx->Depth.Test || - ctx->Fog.Enabled || - ctx->Stencil.Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || - ctx->Texture._EnabledUnits || - ctx->FragmentProgram._Enabled || - ctx->Color.BlendEnabled); -} - /* Doesn't work for overlapping regions. Could do a double copy or * just fallback. */ @@ -269,7 +242,7 @@ do_blit_copypixels(GLcontext * ctx, /* Copypixels can be more than a straight copy. Ensure all the * extra operations are disabled: */ - if (!intel_check_copypixel_blit_fragment_ops(ctx) || + if (!intel_check_blit_fragment_ops(ctx) || ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index 2d46c4b8c0e..b1ecf2b0ce3 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -43,7 +43,7 @@ #include "intel_pixel.h" #include "intel_buffer_objects.h" #include "intel_tris.h" - +#include "intel_fbo.h" static GLboolean @@ -138,9 +138,8 @@ do_texture_drawpixels(GLcontext * ctx, LOCK_HARDWARE(intel); - if (intel->numClipRects) { - assert(intel->numClipRects == 1); - int bufHeight = intel->pClipRects->y2; + { + int bufHeight = ctx->DrawBuffer->Height; GLint srcx, srcy; GLint dstx, dsty; @@ -208,22 +207,50 @@ do_texture_drawpixels(GLcontext * ctx, */ static GLboolean do_blit_drawpixels(GLcontext * ctx, - GLint x, GLint y, + GLint dstx, GLint dsty, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid * pixels) { struct intel_context *intel = intel_context(ctx); - struct intel_region *dest = intel_drawbuf_region(intel); + struct intel_renderbuffer *irbdraw; + struct intel_region *dest; struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj); GLuint src_offset; GLuint rowLength; + GLuint height_orig = height; struct _DriFenceObject *fence = NULL; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); + if (type == GL_COLOR) { + irbdraw = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + if (!irbdraw || !irbdraw->region) + return GL_FALSE; + } + else if (type == GL_DEPTH) { + /* Don't think this is really possible execpt at 16bpp, when we have no stencil. + */ + irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + if (!irbdraw || !irbdraw->region || !(irbdraw->region->cpp == 2)) + return GL_FALSE; + } + else if (GL_DEPTH_STENCIL_EXT) { + /* Does it matter whether it is stencil/depth or depth/stencil? + */ + irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + if (!irbdraw || !irbdraw->region) + return GL_FALSE; + } + else if (GL_STENCIL) { + /* Don't think this is really possible. + */ + return GL_FALSE; + } + + dest = irbdraw->region; if (!dest) { if (INTEL_DEBUG & DEBUG_PIXEL) @@ -277,7 +304,7 @@ do_blit_drawpixels(GLcontext * ctx, if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__); return GL_FALSE; /* later */ - y -= height; + dsty -= height; } else if (ctx->Pixel.ZoomY == 1.0F) { rowLength = -rowLength; @@ -291,38 +318,59 @@ do_blit_drawpixels(GLcontext * ctx, src_offset = (GLuint) _mesa_image_address(2, unpack, pixels, width, height, format, type, 0, 0, 0); - /* don't need a lock as cliprects shouldn't change */ + /* don't need a lock as we have no cliprects ? */ intelFlush(&intel->ctx); - if (intel->numClipRects) { - assert(intel->numClipRects == 1); - int nbox = intel->numClipRects; - drm_clip_rect_t *box = intel->pClipRects; - drm_clip_rect_t rect; - drm_clip_rect_t dest_rect; + { + GLuint srcx = 0; + GLuint srcy = 0; + GLint dx = dstx; + GLint dy = dsty; + + /* Do scissoring in GL coordinates: + */ + if (ctx->Scissor.Enabled) + { + GLint x = ctx->Scissor.X; + GLint y = ctx->Scissor.Y; + GLuint w = ctx->Scissor.Width; + GLuint h = ctx->Scissor.Height; + height_orig = height; + + + if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height)) + goto out; + + } + + /* no need to clip against pbo src region, but clip against dest */ + { + if (!_mesa_clip_to_region(0, 0, irbdraw->Base.Width - 1, + irbdraw->Base.Height - 1, + &dstx, &dsty, &width, &height)) + goto out; + + srcx = dstx - dx; + srcy = dsty - dy; + } + struct _DriBufferObject *src_buffer = intel_bufferobj_buffer(intel, src, INTEL_READ); - int i; - dest_rect.x1 = x; - dest_rect.y1 = box->y2 - (y + height); - dest_rect.x2 = dest_rect.x1 + width; - dest_rect.y2 = dest_rect.y1 + height; - - for (i = 0; i < nbox; i++) { - if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) - continue; + /* Convert from GL to hardware coordinates: + */ + dsty = irbdraw->Base.Height - dsty - height; + srcy = height_orig - srcy - height; + { intelEmitCopyBlit(intel, dest->cpp, rowLength, src_buffer, src_offset, dest->pitch, dest->buffer, 0, - rect.x1 - dest_rect.x1, - rect.y2 - dest_rect.y2, - rect.x1, - rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1, + srcx, srcy, + dstx, dsty, width, height, ctx->Color.ColorLogicOpEnabled ? ctx->Color.LogicOp : GL_COPY); } @@ -335,6 +383,8 @@ do_blit_drawpixels(GLcontext * ctx, driFenceUnReference(fence); } + out: + if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s - DONE\n", __FUNCTION__); -- cgit v1.2.3 From 56cbdfd7d541e5d99b7e7c4fb7b03ac6ac1536a1 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 15:53:23 +0200 Subject: more cliprect elimination (swrast span) --- src/mesa/drivers/dri/i915tex/intel_span.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_span.c b/src/mesa/drivers/dri/i915tex/intel_span.c index 74f118121c1..5a978d9ce26 100644 --- a/src/mesa/drivers/dri/i915tex/intel_span.c +++ b/src/mesa/drivers/dri/i915tex/intel_span.c @@ -47,7 +47,6 @@ #define DBG 0 #define LOCAL_VARS \ - struct intel_context *intel = intel_context(ctx); \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ const GLint yScale = irb->RenderToTexture ? 1 : -1; \ const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \ @@ -56,20 +55,17 @@ assert(irb->pfMap);\ (void) p; -/* XXX FBO: this is identical to the macro in spantmp2.h except we get - * the cliprect info from the context, not the driDrawable. - * Move this into spantmp2.h someday. +/* There is just a single cliploop! */ #define HW_CLIPLOOP() \ do { \ - int _nc = intel->numClipRects; \ - while ( _nc-- ) { \ - int minx = intel->pClipRects[_nc].x1; \ - int miny = intel->pClipRects[_nc].y1; \ - int maxx = intel->pClipRects[_nc].x2; \ - int maxy = intel->pClipRects[_nc].y2; - + int minx = 0; \ + int miny = 0; \ + int maxx = irb->Base.Width - 1; \ + int maxy = irb->Base.Height - 1; +#define HW_ENDCLIPLOOP() \ + } while (0) #define Y_FLIP(_y) ((_y) * yScale + yBias) @@ -100,7 +96,6 @@ #define LOCAL_DEPTH_VARS \ - struct intel_context *intel = intel_context(ctx); \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ const GLuint pitch = irb->pfPitch/***XXX region->pitch*/; /* in pixels */ \ const GLint yScale = irb->RenderToTexture ? 1 : -1; \ -- cgit v1.2.3 From 894557d625b6813dfb23602b96fde6a59d3db54e Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 17:41:22 +0200 Subject: get rid of more cliprects... --- src/mesa/drivers/dri/i915tex/intel_blit.c | 33 ++++++++----------------- src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 7 ++++++ 2 files changed, 17 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index db72f59a2c7..3ecd2e8e481 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -402,10 +402,8 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask) LOCK_HARDWARE(intel); if (intel->numClipRects) { - assert(intel->numClipRects == 1); GLint cx, cy, cw, ch; - drm_clip_rect_t clear; - int i; + drm_clip_rect_t b; /* Get clear bounds after locking */ cx = fb->_Xmin; @@ -416,36 +414,25 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask) if (fb->Name == 0) { /* clearing a window */ /* flip top to bottom */ - clear.x1 = cx; - clear.y1 = intel->pClipRects->y2 - cy - ch; - clear.x2 = clear.x1 + cw; - clear.y2 = clear.y1 + ch; + b.x1 = cx; + b.y1 = fb->Height - cy - ch; + b.x2 = b.x1 + cw; + b.y2 = b.y1 + ch; } else { /* clearing FBO */ - assert(intel->numClipRects == 1); - assert(intel->pClipRects == &intel->fboRect); - clear.x1 = cx; - clear.y1 = cy; - clear.x2 = clear.x1 + cw; - clear.y2 = clear.y1 + ch; + b.x1 = cx; + b.y1 = cy; + b.x2 = b.x1 + cw; + b.y2 = b.y1 + ch; /* no change to mask */ } - for (i = 0; i < intel->numClipRects; i++) { - const drm_clip_rect_t *box = &intel->pClipRects[i]; - drm_clip_rect_t b; + { GLuint buf; GLuint clearMask = mask; /* use copy, since we modify it below */ GLboolean all = (cw == fb->Width && ch == fb->Height); - if (!all) { - intel_intersect_cliprects(&b, &clear, box); - } - else { - b = *box; - } - DBG("clear %d,%d..%d,%d, mask %x\n", b.x1, b.y1, b.x2, b.y2, mask); diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index b1ecf2b0ce3..1c83028d8ab 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -421,10 +421,17 @@ intelDrawPixels(GLcontext * ctx, * wise happily run the fragment program on each pixel in the image). */ struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current; + /* can't just set current frag prog to 0 here as on buffer resize + we'll get new state checks which will segfault (actually don't get them + with current priv buffers). Remains a hack. */ ctx->FragmentProgram._Current = NULL; + ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE; + ctx->FragmentProgram._Active = GL_FALSE; _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels ); ctx->FragmentProgram._Current = fpSave; + ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; + ctx->FragmentProgram._Active = GL_TRUE; } else { _swrast_DrawPixels( ctx, x, y, width, height, format, type, -- cgit v1.2.3 From 5fc7973d5493039e4b3037eae10e9a005d4cf717 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 19:01:47 +0200 Subject: small cleanups --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 44 ++-------------------------- src/mesa/drivers/dri/i915tex/intel_context.h | 3 +- 2 files changed, 4 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 59b291a709d..d3d97f8df0a 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -125,13 +125,14 @@ intel_readbuf_region(struct intel_context *intel) /** - * Update the following fields for rendering to a user-created FBO: + * Update the following fields for rendering: * intel->numClipRects * intel->pClipRects */ static void intelSetRenderbufferClipRects(struct intel_context *intel) { + /* zero-sized buffers might be legal? */ assert(intel->ctx.DrawBuffer->Width > 0); assert(intel->ctx.DrawBuffer->Height > 0); intel->fboRect.x1 = 0; @@ -142,28 +143,6 @@ intelSetRenderbufferClipRects(struct intel_context *intel) intel->pClipRects = &intel->fboRect; } -/** - * As above, but for rendering private front/back buffer of a window. - * \sa intelSetPrivbufClipRects - */ - -static void -intelSetPrivbufClipRects(struct intel_context *intel) -{ - if (!intel->ctx.DrawBuffer) { - fprintf(stderr, "%s: DrawBuffer not set!\n", __FUNCTION__); - return; - } - - intel->fakeClipRect.x1 = 0; - intel->fakeClipRect.y1 = 0; - intel->fakeClipRect.x2 = intel->ctx.DrawBuffer->Width; - intel->fakeClipRect.y2 = intel->ctx.DrawBuffer->Height; - intel->numClipRects = 1; - intel->pClipRects = &intel->fakeClipRect; -} - - /** * This will be called whenever the currently bound window is moved/resized. @@ -327,7 +306,6 @@ intelClearWithTris(struct intel_context *intel, GLbitfield mask) LOCK_HARDWARE(intel); - /* XXX FBO: was: intel->driDrawable->numClipRects */ if (intel->numClipRects) { GLint cx, cy, cw, ch; GLuint buf; @@ -930,7 +908,6 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) struct intel_context *intel = intel_context(ctx); struct intel_region *colorRegion, *depthRegion = NULL; struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL; - int front = 0; /* drawing to front color buffer? */ if (!fb) { /* this can happen during the initial context initialization */ @@ -965,33 +942,18 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) /* writing to 0 or 2 or 4 color buffers */ /*_mesa_debug(ctx, "Software rendering\n");*/ FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE); - front = 1; /* might not have back color buffer */ } else { /* draw to exactly one color buffer */ /*_mesa_debug(ctx, "Hardware rendering\n");*/ FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE); - if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { - front = 1; - } } /* * Get the intel_renderbuffer for the colorbuffer we're drawing into. * And set up cliprects. */ - if (fb->Name == 0) { - intelSetPrivbufClipRects(intel); - /* drawing to window system buffer */ - if (front) { - colorRegion = intel_get_rb_region(fb, BUFFER_FRONT_LEFT); - } - else { - colorRegion = intel_get_rb_region(fb, BUFFER_BACK_LEFT); - } - } - else { - /* drawing to user-created FBO */ + { struct intel_renderbuffer *irb; intelSetRenderbufferClipRects(intel); irb = intel_renderbuffer(fb->_ColorDrawBuffers[0][0]); diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index b5defdc47e4..e2008c4e18d 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -252,8 +252,7 @@ struct intel_context */ GLuint numClipRects; /**< cliprects for drawing */ drm_clip_rect_t *pClipRects; - drm_clip_rect_t fboRect; /**< cliprect for FBO rendering */ - drm_clip_rect_t fakeClipRect; /**< cliprect for priv back/fake front buffers rendering */ + drm_clip_rect_t fboRect; /**< cliprect for rendering */ int perf_boxes; -- cgit v1.2.3 From cc9cf90b090b80e51ac03af6fe113287e083accd Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 20:53:33 +0200 Subject: fix resize bugs (fb size updated too late), fix typos, cleanups... --- src/mesa/drivers/dri/i915tex/i915_state.c | 2 ++ src/mesa/drivers/dri/i915tex/intel_buffers.c | 10 ++++++---- src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 4 ++-- src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 4 ++-- src/mesa/drivers/dri/i915tex/intel_screen.c | 2 ++ 5 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c index e5d8d279936..f523206befc 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state.c +++ b/src/mesa/drivers/dri/i915tex/i915_state.c @@ -904,6 +904,7 @@ i915_init_packets(struct i915_context *i915) { I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS); +#if 0 /* color buffer offset/stride */ i915->state.Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ @@ -914,6 +915,7 @@ i915_init_packets(struct i915_context *i915) /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ i915->state.Buffer[I915_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ BUF_3D_USE_FENCE); +#endif i915->state.Buffer[I915_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index d3d97f8df0a..74e2bfd769c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -160,6 +160,9 @@ intelWindowMoved(struct intel_context *intel) intel->numClipRects = 0; } + /* Update Mesa's notion of window size */ + driUpdateFramebufferSize(ctx, dPriv); + intel_fb->Base.Initialized = GL_TRUE; /* XXX remove someday */ if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) { drmI830Sarea *sarea = intel->sarea; @@ -277,10 +280,6 @@ intelWindowMoved(struct intel_context *intel) intel_fb->vblank_flags &= ~VBLANK_FLAG_SECONDARY; } - /* Update Mesa's notion of window size */ - driUpdateFramebufferSize(ctx, dPriv); - intel_fb->Base.Initialized = GL_TRUE; /* XXX remove someday */ - /* Update hardware scissor */ ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, ctx->Scissor.Width, ctx->Scissor.Height); @@ -707,6 +706,9 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv) intel_flip_renderbuffers(intel_fb); intel_draw_buffer(&intel->ctx, &intel_fb->Base); + if (INTEL_DEBUG & DEBUG_IOCTL) + fprintf(stderr, "%s: success\n", __FUNCTION__); + return GL_TRUE; } diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index 3148a2b0d42..ad111d4d721 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -263,7 +263,7 @@ do_blit_copypixels(GLcontext * ctx, || !(irbread->region->cpp == 2)) return GL_FALSE; } - else if (GL_DEPTH_STENCIL_EXT) { + else if (type == GL_DEPTH_STENCIL_EXT) { /* Does it matter whether it is stencil/depth or depth/stencil? */ irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped); @@ -271,7 +271,7 @@ do_blit_copypixels(GLcontext * ctx, if (!irbread || !irbread->region || !irbdraw || !irbdraw->region) return GL_FALSE; } - else if (GL_STENCIL) { + else if (type == GL_STENCIL) { /* Don't think this is really possible. */ return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index 1c83028d8ab..eebd63ec014 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -237,14 +237,14 @@ do_blit_drawpixels(GLcontext * ctx, if (!irbdraw || !irbdraw->region || !(irbdraw->region->cpp == 2)) return GL_FALSE; } - else if (GL_DEPTH_STENCIL_EXT) { + else if (type == GL_DEPTH_STENCIL_EXT) { /* Does it matter whether it is stencil/depth or depth/stencil? */ irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); if (!irbdraw || !irbdraw->region) return GL_FALSE; } - else if (GL_STENCIL) { + else if (type == GL_STENCIL) { /* Don't think this is really possible. */ return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index dcc29923834..f0d1439dd70 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -355,6 +355,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->front.handle = sarea->front_handle; intelScreen->front.size = sarea->front_size; +#if 0 intelScreen->back.offset = sarea->back_offset; intelScreen->back.pitch = sarea->pitch * intelScreen->cpp; intelScreen->back.handle = sarea->back_handle; @@ -376,6 +377,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->logTextureGranularity = sarea->log_tex_granularity; intelScreen->tex.handle = sarea->tex_handle; intelScreen->tex.size = sarea->tex_size; +#endif intelScreen->rotated.offset = sarea->rotated_offset; intelScreen->rotated.pitch = sarea->rotated_pitch * intelScreen->cpp; -- cgit v1.2.3 From 4dd8e2648d7ec8634d1005aae2da562b57b0267f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 12:56:30 +0200 Subject: increase MAX_RELOCS so never run out before batch buffer is full (fixes xdemos/shape) --- src/mesa/drivers/dri/i915tex/intel_batchbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h index 59261f72741..212f1301012 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h @@ -9,7 +9,7 @@ struct intel_context; #define BATCH_SZ 16384 #define BATCH_RESERVED 16 -#define MAX_RELOCS 400 +#define MAX_RELOCS 4096 #define INTEL_BATCH_NO_CLIPRECTS 0x1 #define INTEL_BATCH_CLIPRECTS 0x2 -- cgit v1.2.3 From 04d49ff24d0f9c7c3a99c45b50f62aa32b0a28ed Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 15:56:43 +0200 Subject: remove old code, remaining bits of static handles, disable (no longer functional anyway) rotation code --- src/mesa/drivers/dri/i915tex/i830_state.c | 10 - src/mesa/drivers/dri/i915tex/intel_buffers.c | 12 +- src/mesa/drivers/dri/i915tex/intel_buffers.h | 2 + src/mesa/drivers/dri/i915tex/intel_context.c | 34 +-- src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 2 +- src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 9 +- src/mesa/drivers/dri/i915tex/intel_screen.c | 266 +----------------------- src/mesa/drivers/dri/i915tex/intel_screen.h | 9 - src/mesa/main/framebuffer.c | 2 + 9 files changed, 32 insertions(+), 314 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i830_state.c b/src/mesa/drivers/dri/i915tex/i830_state.c index 3c149e69055..490d6814295 100644 --- a/src/mesa/drivers/dri/i915tex/i830_state.c +++ b/src/mesa/drivers/dri/i915tex/i830_state.c @@ -879,7 +879,6 @@ i830Enable(GLcontext * ctx, GLenum cap, GLboolean state) static void i830_init_packets(struct i830_context *i830) { - intelScreenPrivate *screen = i830->intel.intelScreen; /* Zero all state */ memset(&i830->state, 0, sizeof(i830->state)); @@ -1033,15 +1032,6 @@ i830_init_packets(struct i830_context *i830) i830->state.Stipple[I830_STPREG_ST0] = _3DSTATE_STIPPLE; - i830->state.Buffer[I830_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i830->state.Buffer[I830_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(screen->front.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); - - - i830->state.Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i830->state.Buffer[I830_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); - i830->state.Buffer[I830_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; #if 0 diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 74e2bfd769c..d06fc0eaeae 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -193,7 +193,7 @@ intelWindowMoved(struct intel_context *intel) intel_fb->pf_current_page = (intel->sarea->pf_current_page >> (intel_fb->pf_pipes & 0x2)) & 0x3; - intel_fb->pf_num_pages = intel->intelScreen->third.handle ? 3 : 2; + intel_fb->pf_num_pages = 2 /*intel->intelScreen->third.handle ? 3 : 2*/; pf_active = pf_pipes && (pf_pipes & intel->sarea->pf_active) == pf_pipes; @@ -396,8 +396,9 @@ intelClearWithTris(struct intel_context *intel, GLbitfield mask) } - - +#if 0 +/* Xorg seems to handle that nowadays, and this code here no longer works with priv + buffers */ /** * Copy the window contents named by dPriv to the rotated (or reflected) * color buffer. @@ -537,7 +538,7 @@ intelRotateWindow(struct intel_context *intel, UNLOCK_HARDWARE(intel); } - +#endif /** * Called by ctx->Driver.Clear. @@ -845,10 +846,11 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) if (screen->current_rotation != 0 || !intelPageFlip(dPriv)) { intelCopyBuffer(dPriv, NULL); } - +#if 0 if (screen->current_rotation != 0) { intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT); } +#endif } intel_fb->swap_count++; diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.h b/src/mesa/drivers/dri/i915tex/intel_buffers.h index 3b686cb5c18..3c7a9cf139c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.h +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.h @@ -52,8 +52,10 @@ extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb); extern void intelInitBufferFuncs(struct dd_function_table *functions); +#if 0 extern void intelRotateWindow(struct intel_context *intel, __DRIdrawablePrivate * dPriv, GLuint srcBuf); +#endif #endif /* INTEL_BUFFERS_H */ diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index ec4a7a746d4..ea2b7e5277b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -295,14 +295,18 @@ intelCheckFrontUpdate(GLcontext * ctx) BUFFER_BIT_FRONT_LEFT maybe? */ if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { - intelScreenPrivate *screen = intel->intelScreen; __DRIdrawablePrivate *dPriv = intel->driDrawable; +#if 0 + intelScreenPrivate *screen = intel->intelScreen; if (screen->current_rotation != 0) { intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT); } else { intelCopyBuffer(dPriv, NULL); } +#else + intelCopyBuffer(dPriv, NULL); +#endif } } @@ -596,34 +600,6 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, is done. Need a per-screen context? */ intel->intelScreen->dummyctxptr = intel; - /* XXX FBO temporary fix-ups! */ - /* if the renderbuffers don't have regions, init them from the context */ - { - struct intel_renderbuffer *irbDepth - = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH); - struct intel_renderbuffer *irbStencil - = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL); - - if (intel_fb->color_rb[0] && !intel_fb->color_rb[0]->region) { - intel_region_reference(&intel_fb->color_rb[0]->region, - intel->intelScreen->front_region); - } - if (intel_fb->color_rb[1] && !intel_fb->color_rb[1]->region) { - intel_region_reference(&intel_fb->color_rb[1]->region, - intel->intelScreen->back_region); - } - if (intel_fb->color_rb[2] && !intel_fb->color_rb[2]->region) { - intel_region_reference(&intel_fb->color_rb[2]->region, - intel->intelScreen->third_region); - } - if (irbDepth && !irbDepth->region) { - intel_region_reference(&irbDepth->region, intel->intelScreen->depth_region); - } - if (irbStencil && !irbStencil->region) { - intel_region_reference(&irbStencil->region, intel->intelScreen->depth_region); - } - } - /* update GLframebuffer size to match window if needed */ driUpdateFramebufferSize(&intel->ctx, driDrawPriv); diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index ad111d4d721..58c415215e7 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -271,7 +271,7 @@ do_blit_copypixels(GLcontext * ctx, if (!irbread || !irbread->region || !irbdraw || !irbdraw->region) return GL_FALSE; } - else if (type == GL_STENCIL) { + else /* GL_STENCIL */ { /* Don't think this is really possible. */ return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index eebd63ec014..4d6b4af5898 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -57,6 +57,7 @@ do_texture_drawpixels(GLcontext * ctx, struct intel_context *intel = intel_context(ctx); struct intel_region *dst = intel_drawbuf_region(intel); struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj); + struct intel_region *depthreg = NULL; GLuint rowLength = unpack->RowLength ? unpack->RowLength : width; GLuint src_offset; @@ -112,7 +113,11 @@ do_texture_drawpixels(GLcontext * ctx, /* Set the 3d engine to draw into the destination region: */ - intel->vtbl.meta_draw_region(intel, dst, intel->intelScreen->depth_region); + if (ctx->DrawBuffer->_DepthBuffer && + ctx->DrawBuffer->_DepthBuffer->Wrapped) + depthreg = (intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped))->region; + + intel->vtbl.meta_draw_region(intel, dst, depthreg); intel->vtbl.meta_import_pixel_state(intel); @@ -244,7 +249,7 @@ do_blit_drawpixels(GLcontext * ctx, if (!irbdraw || !irbdraw->region) return GL_FALSE; } - else if (type == GL_STENCIL) { + else /* GL_STENCIL */ { /* Don't think this is really possible. */ return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index f0d1439dd70..4cabc222251 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -88,55 +88,8 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv) _mesa_warning(NULL, "no front buffer handle in intelMapScreenRegions!"); } -#if 0 - if (0) - _mesa_printf("Back 0x%08x ", intelScreen->back.handle); - if (drmMap(sPriv->fd, - intelScreen->back.handle, - intelScreen->back.size, - (drmAddress *) & intelScreen->back.map) != 0) { - intelUnmapScreenRegions(intelScreen); - return GL_FALSE; - } - - if (intelScreen->third.handle) { - if (0) - _mesa_printf("Third 0x%08x ", intelScreen->third.handle); - if (drmMap(sPriv->fd, - intelScreen->third.handle, - intelScreen->third.size, - (drmAddress *) & intelScreen->third.map) != 0) { - intelUnmapScreenRegions(intelScreen); - return GL_FALSE; - } - } - - if (0) - _mesa_printf("Depth 0x%08x ", intelScreen->depth.handle); - if (drmMap(sPriv->fd, - intelScreen->depth.handle, - intelScreen->depth.size, - (drmAddress *) & intelScreen->depth.map) != 0) { - intelUnmapScreenRegions(intelScreen); - return GL_FALSE; - } -#endif - -#if 0 - _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle); - if (drmMap(sPriv->fd, - intelScreen->tex.handle, - intelScreen->tex.size, - (drmAddress *) & intelScreen->tex.map) != 0) { - intelUnmapScreenRegions(intelScreen); - return GL_FALSE; - } -#endif if (0) - printf("Mappings: front: %p back: %p third: %p depth: %p tex: %p\n", - intelScreen->front.map, - intelScreen->back.map, intelScreen->third.map, - intelScreen->depth.map, intelScreen->tex.map); + printf("Mappings: front: %p\n", intelScreen->front.map); return GL_TRUE; } @@ -161,12 +114,8 @@ intel_recreate_static(intelScreenPrivate *intelScreen, /* Create intel_region structs to describe the static front,back,depth - * buffers created by the xserver. - * - * Although FBO's mean we now no longer use these as render targets in - * all circumstances, they won't go away until the back and depth - * buffers become private, and the front and rotated buffers will - * remain even then. + * buffers created by the xserver. + * Only used for real front buffer now. * * Note that these don't allocate video memory, just describe * allocations alread made by the X server. @@ -185,51 +134,6 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen) intelScreen->front.pitch / intelScreen->cpp, intelScreen->height); - intelScreen->rotated_region = - intel_recreate_static(intelScreen, - intelScreen->rotated_region, - DRM_BO_FLAG_MEM_TT, - intelScreen->rotated.offset, - intelScreen->rotated.map, - intelScreen->cpp, - intelScreen->rotated.pitch / - intelScreen->cpp, intelScreen->height); - -#if 0 - intelScreen->back_region = - intel_recreate_static(intelScreen, - intelScreen->back_region, - DRM_BO_FLAG_MEM_TT, - intelScreen->back.offset, - intelScreen->back.map, - intelScreen->cpp, - intelScreen->back.pitch / intelScreen->cpp, - intelScreen->height); - - if (intelScreen->third.handle) { - intelScreen->third_region = - intel_recreate_static(intelScreen, - intelScreen->third_region, - DRM_BO_FLAG_MEM_TT, - intelScreen->third.offset, - intelScreen->third.map, - intelScreen->cpp, - intelScreen->third.pitch / intelScreen->cpp, - intelScreen->height); - } - - /* Still assuming front.cpp == depth.cpp - */ - intelScreen->depth_region = - intel_recreate_static(intelScreen, - intelScreen->depth_region, - DRM_BO_FLAG_MEM_TT, - intelScreen->depth.offset, - intelScreen->depth.map, - intelScreen->cpp, - intelScreen->depth.pitch / intelScreen->cpp, - intelScreen->height); -#endif } /** @@ -261,32 +165,6 @@ intelUnmapScreenRegions(intelScreenPrivate * intelScreen) #endif intelScreen->front.map = NULL; } - if (intelScreen->back.map) { -#if REALLY_UNMAP - if (drmUnmap(intelScreen->back.map, intelScreen->back.size) != 0) - printf("drmUnmap back failed!\n"); -#endif - intelScreen->back.map = NULL; - } - if (intelScreen->third.map) { -#if REALLY_UNMAP - if (drmUnmap(intelScreen->third.map, intelScreen->third.size) != 0) - printf("drmUnmap third failed!\n"); -#endif - intelScreen->third.map = NULL; - } - if (intelScreen->depth.map) { -#if REALLY_UNMAP - drmUnmap(intelScreen->depth.map, intelScreen->depth.size); - intelScreen->depth.map = NULL; -#endif - } - if (intelScreen->tex.map) { -#if REALLY_UNMAP - drmUnmap(intelScreen->tex.map, intelScreen->tex.size); - intelScreen->tex.map = NULL; -#endif - } } @@ -297,17 +175,6 @@ intelPrintDRIInfo(intelScreenPrivate * intelScreen, fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n", intelScreen->front.size, intelScreen->front.offset, intelScreen->front.pitch); - fprintf(stderr, "*** Back size: 0x%x offset: 0x%x pitch: %d\n", - intelScreen->back.size, intelScreen->back.offset, - intelScreen->back.pitch); - fprintf(stderr, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n", - intelScreen->depth.size, intelScreen->depth.offset, - intelScreen->depth.pitch); - fprintf(stderr, "*** Rotated size: 0x%x offset: 0x%x pitch: %d\n", - intelScreen->rotated.size, intelScreen->rotated.offset, - intelScreen->rotated.pitch); - fprintf(stderr, "*** Texture size: 0x%x offset: 0x%x\n", - intelScreen->tex.size, intelScreen->tex.offset); fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem); } @@ -355,39 +222,6 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->front.handle = sarea->front_handle; intelScreen->front.size = sarea->front_size; -#if 0 - intelScreen->back.offset = sarea->back_offset; - intelScreen->back.pitch = sarea->pitch * intelScreen->cpp; - intelScreen->back.handle = sarea->back_handle; - intelScreen->back.size = sarea->back_size; - - if (intelScreen->driScrnPriv->ddxMinor >= 8) { - intelScreen->third.offset = sarea->third_offset; - intelScreen->third.pitch = sarea->pitch * intelScreen->cpp; - intelScreen->third.handle = sarea->third_handle; - intelScreen->third.size = sarea->third_size; - } - - intelScreen->depth.offset = sarea->depth_offset; - intelScreen->depth.pitch = sarea->pitch * intelScreen->cpp; - intelScreen->depth.handle = sarea->depth_handle; - intelScreen->depth.size = sarea->depth_size; - - intelScreen->tex.offset = sarea->tex_offset; - intelScreen->logTextureGranularity = sarea->log_tex_granularity; - intelScreen->tex.handle = sarea->tex_handle; - intelScreen->tex.size = sarea->tex_size; -#endif - - intelScreen->rotated.offset = sarea->rotated_offset; - intelScreen->rotated.pitch = sarea->rotated_pitch * intelScreen->cpp; - intelScreen->rotated.size = sarea->rotated_size; - intelScreen->current_rotation = sarea->rotation; - matrix23Rotate(&intelScreen->rotMatrix, - sarea->width, sarea->height, sarea->rotation); - intelScreen->rotatedWidth = sarea->virtualX; - intelScreen->rotatedHeight = sarea->virtualY; - if (1) intelPrintSAREA(sarea); } @@ -495,23 +329,6 @@ intelInitDriver(__DRIscreenPrivate * sPriv) return GL_FALSE; } -#if 0 - - /* - * FIXME: Remove this code and its references. - */ - - intelScreen->tex.offset = gDRIPriv->textureOffset; - intelScreen->logTextureGranularity = gDRIPriv->logTextureGranularity; - intelScreen->tex.handle = gDRIPriv->textures; - intelScreen->tex.size = gDRIPriv->textureSize; - -#else - intelScreen->tex.offset = 0; - intelScreen->logTextureGranularity = 0; - intelScreen->tex.handle = 0; - intelScreen->tex.size = 0; -#endif intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; @@ -589,7 +406,9 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, __DRIdrawablePrivate * driDrawPriv, const __GLcontextModes * mesaVis, GLboolean isPixmap) { +#if 0 intelScreenPrivate *screen = (intelScreenPrivate *) driScrnPriv->private; +#endif if (isPixmap) { return GL_FALSE; /* not implemented */ @@ -606,77 +425,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis); -#if 0 - /* setup the hardware-based renderbuffers */ - { - intel_fb->color_rb[0] - = intel_create_renderbuffer(rgbFormat, - screen->width, screen->height, - screen->front.offset, - screen->front.pitch, - screen->cpp, - screen->front.map); - intel_set_span_functions(&intel_fb->color_rb[0]->Base); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT, - &intel_fb->color_rb[0]->Base); - } - - if (mesaVis->doubleBufferMode) { - intel_fb->color_rb[1] - = intel_create_renderbuffer(rgbFormat, - screen->width, screen->height, - screen->back.offset, - screen->back.pitch, - screen->cpp, - screen->back.map); - intel_set_span_functions(&intel_fb->color_rb[1]->Base); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, - &intel_fb->color_rb[1]->Base); - - if (screen->third.handle) { - struct gl_renderbuffer *tmp_rb = NULL; - - intel_fb->color_rb[2] - = intel_create_renderbuffer(rgbFormat, - screen->width, screen->height, - screen->third.offset, - screen->third.pitch, - screen->cpp, - screen->third.map); - intel_set_span_functions(&intel_fb->color_rb[2]->Base); - _mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base); - } - } - if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { - /* combined depth/stencil buffer */ - struct intel_renderbuffer *depthStencilRb - = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT, - screen->width, screen->height, - screen->depth.offset, - screen->depth.pitch, - screen->cpp, /* 4! */ - screen->depth.map); - intel_set_span_functions(&depthStencilRb->Base); - /* note: bind RB to two attachment points */ - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, - &depthStencilRb->Base); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL, - &depthStencilRb->Base); - } - else if (mesaVis->depthBits == 16) { - /* just 16-bit depth buffer, no hw stencil */ - struct intel_renderbuffer *depthRb - = intel_create_renderbuffer(GL_DEPTH_COMPONENT16, - screen->width, screen->height, - screen->depth.offset, - screen->depth.pitch, - screen->cpp, /* 2! */ - screen->depth.map); - intel_set_span_functions(&depthRb->Base); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base); - } - -#else { /* fake frontbuffer */ /* XXX allocation should only happen in the unusual case @@ -693,6 +441,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, &intel_fb->color_rb[1]->Base); +#if 0 if (screen->third.handle) { struct gl_renderbuffer *tmp_rb = NULL; @@ -700,7 +449,9 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, = intel_new_renderbuffer_fb(rgbFormat); _mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base); } +#endif } + if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { /* combined depth/stencil buffer */ struct intel_renderbuffer *depthStencilRb @@ -718,7 +469,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base); } -#endif /* now add any/all software-based renderbuffers we may need */ _mesa_add_soft_renderbuffers(&intel_fb->Base, diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.h b/src/mesa/drivers/dri/i915tex/intel_screen.h index 783ee35524b..89671e12c9b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.h +++ b/src/mesa/drivers/dri/i915tex/intel_screen.h @@ -50,17 +50,8 @@ typedef struct typedef struct { intelRegion front; - intelRegion back; - intelRegion third; - intelRegion rotated; - intelRegion depth; - intelRegion tex; struct intel_region *front_region; - struct intel_region *back_region; - struct intel_region *third_region; - struct intel_region *depth_region; - struct intel_region *rotated_region; int deviceID; int width; diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 1fd31a53211..a95e44c5133 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -668,7 +668,9 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) void _mesa_update_framebuffer(GLcontext *ctx) { + /* XXX might not be quite correct for different draw/read buffers ? */ struct gl_framebuffer *fb = ctx->DrawBuffer; +// struct gl_framebuffer *fbread = ctx->ReadBuffer; /* Completeness only matters for user-created framebuffers */ if (fb->Name != 0) { -- cgit v1.2.3 From d9499a151df85fef6bb6f31b58657e44cadba50a Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 17:29:55 +0200 Subject: fix mesa fb binding Make sure that we bind the right buffer (draw or read) when rebinding the window framebuffer (the api doesn't allow binding different draw and read buffers at the same time, but the default window framebuffer is basically 2 fb objects, one for read, one for write, which can be different). Pass both of these two down the driver api (no driver uses this right now). --- src/mesa/drivers/dri/i915tex/intel_fbo.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 7 +++++-- src/mesa/main/dd.h | 2 +- src/mesa/main/fbobject.c | 8 +++++--- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index afee07c6898..b0c243ebe02 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -513,7 +513,7 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name) */ static void intel_bind_framebuffer(GLcontext * ctx, GLenum target, - struct gl_framebuffer *fb) + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { intel_draw_buffer(ctx, fb); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index 857cd30584c..6a2c2013e34 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -395,9 +395,12 @@ nouveauNewRenderbuffer(GLcontext *ctx, GLuint name) } static void -nouveauBindFramebuffer(GLcontext *ctx, GLenum target, struct gl_framebuffer *fb) +nouveauBindFramebuffer(GLcontext *ctx, GLenum target, + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { - nouveau_build_framebuffer(ctx, fb); + if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { + nouveau_build_framebuffer(ctx, fb); + } } static void diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 88f33943b31..caa50dd6826 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -782,7 +782,7 @@ struct dd_function_table { struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name); struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name); void (*BindFramebuffer)(GLcontext *ctx, GLenum target, - struct gl_framebuffer *fb); + struct gl_framebuffer *fb, struct gl_framebuffer *fbread); void (*FramebufferRenderbuffer)(GLcontext *ctx, struct gl_framebuffer *fb, GLenum attachment, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index e3bada5ae89..5345310ca1f 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -924,7 +924,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { - struct gl_framebuffer *newFb; + struct gl_framebuffer *newFb, *newFbread; GLboolean bindReadBuf, bindDrawBuf; GET_CURRENT_CONTEXT(ctx); @@ -984,12 +984,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); } + newFbread = newFb; } else { /* Binding the window system framebuffer (which was originally set * with MakeCurrent). */ newFb = ctx->WinSysDrawBuffer; + newFbread = ctx->WinSysReadBuffer; } ASSERT(newFb); @@ -1000,7 +1002,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) */ if (bindReadBuf) { - _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb); + _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); } if (bindDrawBuf) { @@ -1015,7 +1017,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } if (ctx->Driver.BindFramebuffer) { - ctx->Driver.BindFramebuffer(ctx, target, newFb); + ctx->Driver.BindFramebuffer(ctx, target, newFb, newFbread); } } -- cgit v1.2.3 From a8bf93e00e28031d7e2444f79df2686f262b4420 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 19:22:23 +0200 Subject: fix up mesa's probably bogus framebuffer updates with different read/write fbs --- src/mesa/main/framebuffer.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index a95e44c5133..f8716f30d37 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -652,6 +652,27 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) } +static void +update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) +{ + /* Completeness only matters for user-created framebuffers */ + if (fb->Name != 0) { + /* XXX: EXT_framebuffer_blit: + framebuffer must still be complete wrt read/draw? */ + _mesa_test_framebuffer_completeness(ctx, fb); + _mesa_update_framebuffer_visual(fb); + } + + /* update_color_draw/read_buffers not needed for + read/draw only fb, but shouldn't hurt ??? */ + update_color_draw_buffers(ctx, fb); + update_color_read_buffer(ctx, fb); + _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); + _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); + + compute_depth_max(fb); +} + /** * Update state related to the current draw/read framebuffers. * Specifically, update these framebuffer fields: @@ -668,22 +689,13 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) void _mesa_update_framebuffer(GLcontext *ctx) { - /* XXX might not be quite correct for different draw/read buffers ? */ struct gl_framebuffer *fb = ctx->DrawBuffer; -// struct gl_framebuffer *fbread = ctx->ReadBuffer; - - /* Completeness only matters for user-created framebuffers */ - if (fb->Name != 0) { - _mesa_test_framebuffer_completeness(ctx, fb); - _mesa_update_framebuffer_visual(fb); - } + struct gl_framebuffer *fbread = ctx->ReadBuffer; - update_color_draw_buffers(ctx, fb); - update_color_read_buffer(ctx, fb); - _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); - _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); - - compute_depth_max(fb); + update_framebuffer(ctx, fb); + if (fbread != fb && fbread != NULL /* can happen at make_current - + core/driver circular dependencies, should be fixed up */) + update_framebuffer(ctx, fbread); } -- cgit v1.2.3 From 881d71495b893516d685e3c68b60c0aa2742d2a7 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 19:37:05 +0200 Subject: get rid of more pageflip/rotation code. --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 48 +++------------------------- src/mesa/drivers/dri/i915tex/intel_context.c | 7 +--- src/mesa/drivers/dri/i915tex/intel_context.h | 15 --------- src/mesa/drivers/dri/i915tex/intel_screen.h | 2 -- 4 files changed, 6 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index d06fc0eaeae..5ec8ad0835b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -650,7 +650,7 @@ intel_wait_flips(struct intel_context *intel, GLuint batch_flags) } } - +#if 0 /* Flip the front & back buffers */ static GLboolean @@ -712,35 +712,8 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv) return GL_TRUE; } +#endif -#if 0 -void -intelSwapBuffers(__DRIdrawablePrivate * dPriv) -{ - if (dPriv->driverPrivate) { - const struct gl_framebuffer *fb - = (struct gl_framebuffer *) dPriv->driverPrivate; - if (fb->Visual.doubleBufferMode) { - GET_CURRENT_CONTEXT(ctx); - if (ctx && ctx->DrawBuffer == fb) { - _mesa_notifySwapBuffers(ctx); /* flush pending rendering */ - } - if (intel->doPageFlip) { - intelPageFlip(dPriv); - } - else { - intelCopyBuffer(dPriv); - } - } - } - else { - _mesa_problem(NULL, - "dPriv has no gl_framebuffer pointer in intelSwapBuffers"); - } -} -#else -/* Trunk version: - */ static GLboolean intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) @@ -755,8 +728,7 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) GLboolean ret; if ((intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) || - intelScreen->current_rotation != 0 || - intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6)) + intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6)) return GL_FALSE; swap.seqtype = DRM_VBLANK_ABSOLUTE; @@ -831,26 +803,17 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) intel = intel_context(ctx); if (ctx->Visual.doubleBufferMode) { - intelScreenPrivate *screen = intel->intelScreen; GLboolean missed_target; struct intel_framebuffer *intel_fb = dPriv->driverPrivate; int64_t ust; _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ - if (screen->current_rotation != 0 || - !intelScheduleSwap(dPriv, &missed_target)) { + if (!intelScheduleSwap(dPriv, &missed_target)) { driWaitForVBlank(dPriv, &intel_fb->vbl_seq, intel_fb->vblank_flags, &missed_target); - if (screen->current_rotation != 0 || !intelPageFlip(dPriv)) { - intelCopyBuffer(dPriv, NULL); - } -#if 0 - if (screen->current_rotation != 0) { - intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT); - } -#endif + intelCopyBuffer(dPriv, NULL); } intel_fb->swap_count++; @@ -868,7 +831,6 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__); } } -#endif void intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index ea2b7e5277b..527b33f4af7 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -390,10 +390,6 @@ intelInitContext(struct intel_context *intel, intel->driScreen = sPriv; intel->sarea = saPriv; - intel->width = intelScreen->width; - intel->height = intelScreen->height; - intel->current_rotation = intelScreen->current_rotation; - if (!lockMutexInit) { lockMutexInit = GL_TRUE; _glthread_INIT_MUTEX(lockMutex); @@ -658,8 +654,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); if (sarea->width != intelScreen->width || - sarea->height != intelScreen->height || - sarea->rotation != intelScreen->current_rotation) { + sarea->height != intelScreen->height) { intelUpdateScreenRotation(sPriv, sarea); } diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index e2008c4e18d..5c8e2777996 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -234,13 +234,6 @@ struct intel_context GLuint vertex_size; GLubyte *verts; /* points to tnl->clipspace.vertex_buf */ -#if 0 - struct intel_region *front_region; /* XXX FBO: obsolete */ - struct intel_region *rotated_region; /* XXX FBO: obsolete */ - struct intel_region *back_region; /* XXX FBO: obsolete */ - struct intel_region *draw_region; /* XXX FBO: rename to color_region */ - struct intel_region *depth_region; /**< currently bound depth/Z region */ -#endif /* Fallback rasterization functions */ @@ -276,14 +269,6 @@ struct intel_context * Configuration cache */ driOptionCache optionCache; - - /* Rotation. Need to match that of the - * current screen. - */ - - int width; - int height; - int current_rotation; }; /* These are functions now: diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.h b/src/mesa/drivers/dri/i915tex/intel_screen.h index 89671e12c9b..9a5e3ac76e2 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.h +++ b/src/mesa/drivers/dri/i915tex/intel_screen.h @@ -74,8 +74,6 @@ typedef struct struct matrix23 rotMatrix; - int current_rotation; /* 0, 90, 180 or 270 */ - int rotatedWidth, rotatedHeight; /** * Configuration cache with default values for all contexts -- cgit v1.2.3 From 7664105fc2a27ae0862edff66a0a5a33e4111fe1 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 19:49:25 +0200 Subject: remove some more old stuff --- src/mesa/drivers/dri/i915tex/intel_screen.c | 2 -- src/mesa/drivers/dri/i915tex/intel_screen.h | 4 ---- 2 files changed, 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index 4cabc222251..0b9ba7eda73 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -310,10 +310,8 @@ intelInitDriver(__DRIscreenPrivate * sPriv) switch (gDRIPriv->bitsPerPixel) { case 16: - intelScreen->fbFormat = DV_PF_565; break; case 32: - intelScreen->fbFormat = DV_PF_8888; break; default: exit(1); diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.h b/src/mesa/drivers/dri/i915tex/intel_screen.h index 9a5e3ac76e2..8e4e0b9c12f 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.h +++ b/src/mesa/drivers/dri/i915tex/intel_screen.h @@ -59,10 +59,6 @@ typedef struct int mem; /* unused */ int cpp; /* for front and back buffers */ -/* int bitsPerPixel; */ - int fbFormat; /* XXX FBO: this is obsolete - remove after i830 updates */ - - int logTextureGranularity; __DRIscreenPrivate *driScrnPriv; unsigned int sarea_priv_offset; -- cgit v1.2.3 From c5a8bc712542d24a035aa8fe58cf3c28c7c6fbd1 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 20:06:44 +0200 Subject: get rid of checks for old ddx --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 5 ++--- src/mesa/drivers/dri/i915tex/intel_screen.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 5ec8ad0835b..bcd99106b9e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -157,6 +157,7 @@ intelWindowMoved(struct intel_context *intel) if (!intel->ctx.DrawBuffer) { /* when would this happen? -BP */ + assert(0); intel->numClipRects = 0; } @@ -164,7 +165,7 @@ intelWindowMoved(struct intel_context *intel) driUpdateFramebufferSize(ctx, dPriv); intel_fb->Base.Initialized = GL_TRUE; /* XXX remove someday */ - if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) { + { drmI830Sarea *sarea = intel->sarea; drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h }; @@ -276,8 +277,6 @@ intelWindowMoved(struct intel_context *intel) intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited; } } - } else { - intel_fb->vblank_flags &= ~VBLANK_FLAG_SECONDARY; } /* Update hardware scissor */ diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index 0b9ba7eda73..5ad0932e2eb 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -692,7 +692,7 @@ __driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn, __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; - static const __DRIversion ddx_expected = { 1, 5, 0 }; + static const __DRIversion ddx_expected = { 1, 7, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 1, 7, 0 }; -- cgit v1.2.3 From ccb713cdb8831617880ac71ac357361b586d05c6 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 15:18:43 +0200 Subject: swapbuffers with non-current contexts, cleanups manywin got broken (when intelPageflip got no longer called). Make sure that intelFlush is getting called when a context gets unbound, to handle later swapbuffer calls on that context's drawable better. Related, fix non-current cliprects getting used on unbound drawables. --- src/mesa/drivers/dri/i915tex/intel_blit.c | 6 ++++++ src/mesa/drivers/dri/i915tex/intel_buffers.c | 13 ++----------- src/mesa/drivers/dri/i915tex/intel_context.c | 13 +++++++++---- src/mesa/drivers/dri/i915tex/intel_context.h | 2 -- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index 3ecd2e8e481..28441f4b835 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -78,6 +78,12 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv, * should work regardless. */ LOCK_HARDWARE(intel); + /* if this drawable isn't currently bound the LOCK_HARDWARE done on the + current context (which is what intelScreenContext should return) might + not get a contended lock and thus cliprects not updated (tests/manywin) */ + if ((struct intel_context *)dPriv->driContextPriv->driverPrivate != intel) + DRI_VALIDATE_DRAWABLE_INFO(intel->driScreen, dPriv); + if (dPriv && dPriv->numClipRects) { struct intel_framebuffer *intel_fb = dPriv->driverPrivate; diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index bcd99106b9e..0ecf3aa1d4d 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -356,7 +356,8 @@ intelClearWithTris(struct intel_context *intel, GLbitfield mask) /* XXX: Using INTEL_BATCH_NO_CLIPRECTS here is dangerous as the * drawing origin may not be correctly emitted. */ - intel_meta_draw_quad(intel, clear.x1, clear.x2, clear.y1, clear.y2, intel->ctx.Depth.Clear, clearColor, 0, 0, 0, 0); /* texcoords */ + intel_meta_draw_quad(intel, clear.x1, clear.x2, clear.y1, clear.y2, + intel->ctx.Depth.Clear, clearColor, 0, 0, 0, 0); /* texcoords */ mask &= ~(BUFFER_BIT_BACK_LEFT | BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH); @@ -991,16 +992,6 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) /** ** Release old regions, reference new regions **/ -#if 0 /* XXX FBO: this seems to be redundant with i915_state_draw_region() */ - if (intel->draw_region != colorRegion) { - intel_region_release(&intel->draw_region); - intel_region_reference(&intel->draw_region, colorRegion); - } - if (intel->intelScreen->depth_region != depthRegion) { - intel_region_release(&intel->intelScreen->depth_region); - intel_region_reference(&intel->intelScreen->depth_region, depthRegion); - } -#endif intel->vtbl.set_draw_region(intel, colorRegion, depthRegion); diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 527b33f4af7..5acfd923b99 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -569,6 +569,9 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv) GLboolean intelUnbindContext(__DRIcontextPrivate * driContextPriv) { + struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; + FLUSH_VERTICES((&intel->ctx), 0); + intelFlush(&intel->ctx); return GL_TRUE; } @@ -616,14 +619,16 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, (*dri_interface->getUST) (&intel_fb->swap_ust); driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags, &intel_fb->vbl_seq); + } + } + + if ((intel->driDrawable != driDrawPriv) || + (intel->lastStamp != driDrawPriv->lastStamp)) { intel->driDrawable = driDrawPriv; intelWindowMoved(intel); intel->lastStamp = driDrawPriv->lastStamp; - } - else if (intel->lastStamp != driDrawPriv->lastStamp) { - intel_draw_buffer(&intel->ctx, &intel_fb->Base); - } } + } else { _mesa_make_current(NULL, NULL, NULL); diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 5c8e2777996..628a15f8de5 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -247,8 +247,6 @@ struct intel_context drm_clip_rect_t *pClipRects; drm_clip_rect_t fboRect; /**< cliprect for rendering */ - int perf_boxes; - GLuint do_usleeps; int do_irqs; GLuint irqsEmitted; -- cgit v1.2.3 From 3f318c2eb98cf7216ae7033806fa764ac40192bf Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 18:07:12 +0200 Subject: more fixes for mesa's fbo handling (fixes tests/fbotest1/2) --- src/mesa/main/buffers.c | 5 ++--- src/mesa/main/context.c | 5 +++++ src/mesa/main/fbobject.c | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index c280f89e1d1..68a0575d93d 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -557,9 +557,8 @@ _mesa_ReadBuffer(GLenum buffer) } } - if (fb->Name == 0) { - ctx->Pixel.ReadBuffer = buffer; - } + ctx->Pixel.ReadBuffer = buffer; + fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 183a552d406..5239e739568 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1499,6 +1499,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, if the DRIdrawable changes, and someone may rely on them. */ /* What a mess!?! */ + /* XXX this is still not quite correct. Imagine a user-created fbo + bound on a context. Now rebind with a completely new drawable. + Upon rebinding to the window-framebuffer, we have no idea what + the read and write buffers should be (front, back, ...) - that + information was only available in the previously used drawable... */ int i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 5345310ca1f..f300e481ce0 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1003,13 +1003,20 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); + /* set context value */ + ctx->Pixel.ReadBuffer = newFbread->ColorReadBuffer; } if (bindDrawBuf) { + GLuint i; /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); + /* set context value */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + ctx->Color.DrawBuffer[i] = newFb->ColorDrawBuffer[i]; + } if (newFb->Name != 0) { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); -- cgit v1.2.3 From 131a03631208afb1fce90292eb27115511f58257 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 20:17:14 +0200 Subject: fix mesa's handling of fbo's / window fb (again) Make sure the relevant fields in window fbs get updated at appropriate time (those are NOT the same as fbos!!!), and fix up related code accordingly. This is a bit ugly, but there's a reason the issues section in EXT_fbo is a couple hundred pages long... Hopefully correct now. --- src/mesa/main/attrib.c | 4 +++ src/mesa/main/buffers.c | 72 ++++++++++++++++++++++++++++++--------------- src/mesa/main/buffers.h | 3 ++ src/mesa/main/context.c | 12 ++------ src/mesa/main/fbobject.c | 24 ++++++++++----- src/mesa/main/framebuffer.c | 3 +- 6 files changed, 77 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 1aa0a02fc78..b422198f929 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -98,9 +98,13 @@ _mesa_PushAttrib(GLbitfield mask) } if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; struct gl_colorbuffer_attrib *attr; attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); + /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) + attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; newnode = new_attrib_node( GL_COLOR_BUFFER_BIT ); newnode->data = attr; newnode->next = head; diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 68a0575d93d..7764a5d3b2e 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -370,6 +370,14 @@ _mesa_DrawBuffer(GLenum buffer) /* if we get here, there's no error so set new state */ _mesa_drawbuffers(ctx, 1, &buffer, &destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, 1, &buffer); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffer); } @@ -435,6 +443,14 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) /* OK, if we get here, there were no errors so set the new state */ _mesa_drawbuffers(ctx, n, buffers, destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, n, buffers); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffers[0]); } @@ -463,14 +479,15 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, /* not really needed, will be set later */ fb->_NumColorDrawBuffers[output] = 0; + if (fb->Name == 0) /* Set traditional state var */ - ctx->Color.DrawBuffer[output] = buffer; + ctx->Color.DrawBuffer[output] = buffer; } /** * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and - * _mesa_PopAttrib to set drawbuffer state. + * other places (window fbo fixup) to set fbo (and the old ctx) fields. * All error checking will have been done prior to calling this function * so nothing should go wrong at this point. * \param ctx current context @@ -479,6 +496,7 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param destMask array[n] of BUFFER_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). + * \param callDriver call driver or not (bad idea sometimes this is called) */ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, @@ -509,30 +527,15 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, } ctx->NewState |= _NEW_COLOR; - - /* - * Call device driver function. - */ - if (ctx->Driver.DrawBuffers) - ctx->Driver.DrawBuffers(ctx, n, buffers); - else if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, buffers[0]); } - -/** - * Called by glReadBuffer to set the source renderbuffer for reading pixels. - * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - */ -void GLAPIENTRY -_mesa_ReadBuffer(GLenum buffer) +GLboolean +_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) { struct gl_framebuffer *fb; GLbitfield supportedMask; GLint srcBuffer; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); fb = ctx->ReadBuffer; @@ -548,20 +551,43 @@ _mesa_ReadBuffer(GLenum buffer) srcBuffer = read_buffer_enum_to_index(buffer); if (srcBuffer == -1) { _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer=0x%x)", buffer); - return; + return GL_FALSE; } supportedMask = supported_buffer_bitmask(ctx, fb); if (((1 << srcBuffer) & supportedMask) == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer=0x%x)", buffer); - return; + return GL_FALSE; } } - ctx->Pixel.ReadBuffer = buffer; - + if (fb->Name == 0) { + ctx->Pixel.ReadBuffer = buffer; + } fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; + return GL_TRUE; +} + + + +/** + * Called by glReadBuffer to set the source renderbuffer for reading pixels. + * \param mode color buffer such as GL_FRONT, GL_BACK, etc. + * \param callDriver call driver or not (bad idea sometimes this is called) + */ +void GLAPIENTRY +_mesa_ReadBuffer(GLenum buffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + + if (!_mesa_readbuffer_update_fields(ctx, buffer)) + return; + ctx->NewState |= _NEW_PIXEL; /* diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h index fcc21523421..208e7af2b93 100644 --- a/src/mesa/main/buffers.h +++ b/src/mesa/main/buffers.h @@ -56,6 +56,9 @@ extern void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, const GLbitfield *destMask); +extern GLboolean +_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer); + extern void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 5239e739568..92d8ceda292 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1496,14 +1496,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); /* fix up the fb fields - these will end up wrong otherwise - if the DRIdrawable changes, and someone may rely on them. - */ - /* What a mess!?! */ - /* XXX this is still not quite correct. Imagine a user-created fbo - bound on a context. Now rebind with a completely new drawable. - Upon rebinding to the window-framebuffer, we have no idea what - the read and write buffers should be (front, back, ...) - that - information was only available in the previously used drawable... */ + if the DRIdrawable changes, and everything relies on them. + This is a bit messy (same as needed in _mesa_BindFramebufferEXT) */ int i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { @@ -1513,7 +1507,7 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); - _mesa_ReadBuffer(newCtx->Pixel.ReadBuffer); + _mesa_readbuffer_update_fields(newCtx, newCtx->Pixel.ReadBuffer); } newCtx->NewState |= _NEW_BUFFERS; diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f300e481ce0..6f7effcce70 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -29,6 +29,7 @@ */ +#include "buffers.h" #include "context.h" #include "fbobject.h" #include "framebuffer.h" @@ -1001,23 +1002,32 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) * XXX check if re-binding same buffer and skip some of this code. */ + /* for window-framebuffers, re-initialize the fbo values, as they + could be wrong (makecurrent with a new drawable while still a fbo + was bound will lead to default init fbo values). + note that therefore the context ReadBuffer/DrawBuffer values are not + valid while fbo's are bound!!! */ if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); - /* set context value */ - ctx->Pixel.ReadBuffer = newFbread->ColorReadBuffer; + if (!newFbread->Name) { + _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer); + } } if (bindDrawBuf) { - GLuint i; /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); - /* set context value */ - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - ctx->Color.DrawBuffer[i] = newFb->ColorDrawBuffer[i]; + if (!newFb->Name) { + GLuint i; + GLenum buffers[MAX_DRAW_BUFFERS]; + for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + buffers[i] = ctx->Color.DrawBuffer[i]; + } + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL); } - if (newFb->Name != 0) { + else { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index f8716f30d37..f737c74f357 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -693,8 +693,7 @@ _mesa_update_framebuffer(GLcontext *ctx) struct gl_framebuffer *fbread = ctx->ReadBuffer; update_framebuffer(ctx, fb); - if (fbread != fb && fbread != NULL /* can happen at make_current - - core/driver circular dependencies, should be fixed up */) + if (fbread != fb) update_framebuffer(ctx, fbread); } -- cgit v1.2.3 From da21eff86be088852457cdcb725aed5337c4519d Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 19 Jul 2007 16:41:14 +0200 Subject: fix drawables not getting freed if context is made current with new drawables --- src/mesa/drivers/dri/common/dri_util.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index dd52f7e9151..d785382f39d 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -120,7 +120,7 @@ static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw) * Find drawables in the local hash that have been destroyed on the * server. * - * \param drawHash Hash-table containing all know drawables. + * \param drawHash Hash-table containing all known drawables. */ static void __driGarbageCollectDrawables(void *drawHash) { @@ -235,6 +235,12 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, prp->refcount--; } + /* destroy the drawables if they no longer exist on the server */ + if ((pdp->refcount == 0) || (prp->refcount == 0)) { + /* probably shouldn't need the collector here, + as we know the affected drawables (or could there be others?) */ + __driGarbageCollectDrawables(pdp->driScreenPriv->drawHash); + } /* XXX this is disabled so that if we call SwapBuffers on an unbound * window we can determine the last context bound to the window and -- cgit v1.2.3 From 79ddb7f9a27421089efea090de6c41d2d630bb8f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 19 Jul 2007 17:42:14 +0200 Subject: more cleanups (looks pretty reasonable now) remove some already ifdefed out, no longer functional and used code. Don't do our own scissor clipping in the pixeldraw/copy paths, as meas already does that for us... --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 144 ------------------------ src/mesa/drivers/dri/i915tex/intel_buffers.h | 6 - src/mesa/drivers/dri/i915tex/intel_context.c | 12 +- src/mesa/drivers/dri/i915tex/intel_fbo.c | 120 -------------------- src/mesa/drivers/dri/i915tex/intel_pixel_copy.c | 77 +++++-------- src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 44 +++----- 6 files changed, 45 insertions(+), 358 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 0ecf3aa1d4d..ee3266e09bd 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -396,150 +396,6 @@ intelClearWithTris(struct intel_context *intel, GLbitfield mask) } -#if 0 -/* Xorg seems to handle that nowadays, and this code here no longer works with priv - buffers */ -/** - * Copy the window contents named by dPriv to the rotated (or reflected) - * color buffer. - * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source. - */ -void -intelRotateWindow(struct intel_context *intel, - __DRIdrawablePrivate * dPriv, GLuint srcBuf) -{ - - intelScreenPrivate *screen = intel->intelScreen; - drm_clip_rect_t fullRect; - struct intel_framebuffer *intel_fb; - struct intel_region *src; - const drm_clip_rect_t *clipRects; - int numClipRects; - int i; - GLenum format, type; - - int origNumClipRects; - drm_clip_rect_t *origRects; - - /* - * set up hardware state - */ - intelFlush(&intel->ctx); - - LOCK_HARDWARE(intel); - - if (!intel->numClipRects) { - UNLOCK_HARDWARE(intel); - return; - } - - intel->vtbl.install_meta_state(intel); - - intel->vtbl.meta_no_depth_write(intel); - intel->vtbl.meta_no_stencil_write(intel); - intel->vtbl.meta_color_mask(intel, GL_FALSE); - - - /* save current drawing origin and cliprects (restored at end) */ - origNumClipRects = intel->numClipRects; - origRects = intel->pClipRects; - - /* - * set drawing origin, cliprects for full-screen access to rotated screen - */ - fullRect.x1 = 0; - fullRect.y1 = 0; - fullRect.x2 = screen->rotatedWidth; - fullRect.y2 = screen->rotatedHeight; - intel->numClipRects = 1; - intel->pClipRects = &fullRect; - - intel->vtbl.meta_draw_region(intel, screen->rotated_region, NULL); /* ? */ - - intel_fb = dPriv->driverPrivate; - - if ((srcBuf == BUFFER_BIT_BACK_LEFT && !intel_fb->pf_active)) { - src = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT); - clipRects = dPriv->pBackClipRects; - numClipRects = dPriv->numBackClipRects; - } - else { - src = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT); - clipRects = dPriv->pClipRects; - numClipRects = dPriv->numClipRects; - } - - if (src->cpp == 4) { - format = GL_BGRA; - type = GL_UNSIGNED_BYTE; - } - else { - format = GL_BGR; - type = GL_UNSIGNED_SHORT_5_6_5_REV; - } - - /* set the whole screen up as a texture to avoid alignment issues */ - intel->vtbl.meta_tex_rect_source(intel, - src->buffer, - screen->width, - screen->height, src->pitch, format, type); - - intel->vtbl.meta_texture_blend_replace(intel); - - /* - * loop over the source window's cliprects - */ - for (i = 0; i < numClipRects; i++) { - int srcX0 = clipRects[i].x1; - int srcY0 = clipRects[i].y1; - int srcX1 = clipRects[i].x2; - int srcY1 = clipRects[i].y2; - GLfloat verts[4][2], tex[4][2]; - int j; - - /* build vertices for four corners of clip rect */ - verts[0][0] = srcX0; - verts[0][1] = srcY0; - verts[1][0] = srcX1; - verts[1][1] = srcY0; - verts[2][0] = srcX1; - verts[2][1] = srcY1; - verts[3][0] = srcX0; - verts[3][1] = srcY1; - - /* .. and texcoords */ - tex[0][0] = srcX0; - tex[0][1] = srcY0; - tex[1][0] = srcX1; - tex[1][1] = srcY0; - tex[2][0] = srcX1; - tex[2][1] = srcY1; - tex[3][0] = srcX0; - tex[3][1] = srcY1; - - /* transform coords to rotated screen coords */ - - for (j = 0; j < 4; j++) { - matrix23TransformCoordf(&screen->rotMatrix, - &verts[j][0], &verts[j][1]); - } - - /* draw polygon to map source image to dest region */ - intel_meta_draw_poly(intel, 4, verts, 0, 0, tex); - - } /* cliprect loop */ - - intel->vtbl.leave_meta_state(intel); - intel_batchbuffer_flush(intel->batch); - - /* restore original drawing origin and cliprects */ - intel->numClipRects = origNumClipRects; - intel->pClipRects = origRects; - - UNLOCK_HARDWARE(intel); -} -#endif - /** * Called by ctx->Driver.Clear. */ diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.h b/src/mesa/drivers/dri/i915tex/intel_buffers.h index 3c7a9cf139c..13d1a15ffbf 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.h +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.h @@ -52,10 +52,4 @@ extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb); extern void intelInitBufferFuncs(struct dd_function_table *functions); -#if 0 -extern void -intelRotateWindow(struct intel_context *intel, - __DRIdrawablePrivate * dPriv, GLuint srcBuf); -#endif - #endif /* INTEL_BUFFERS_H */ diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 5acfd923b99..769287ba6a8 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -296,17 +296,7 @@ intelCheckFrontUpdate(GLcontext * ctx) if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { __DRIdrawablePrivate *dPriv = intel->driDrawable; -#if 0 - intelScreenPrivate *screen = intel->intelScreen; - if (screen->current_rotation != 0) { - intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT); - } - else { - intelCopyBuffer(dPriv, NULL); - } -#else intelCopyBuffer(dPriv, NULL); -#endif } } @@ -570,6 +560,8 @@ GLboolean intelUnbindContext(__DRIcontextPrivate * driContextPriv) { struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; + /* XXX UnbindContext is called AFTER the new context is made current. + Hopefully shouldn't be a problem ? */ FLUSH_VERTICES((&intel->ctx), 0); intelFlush(&intel->ctx); return GL_TRUE; diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index b0c243ebe02..399a280c47c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -299,25 +299,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, } -#if 0 -/** - * Called for each hardware renderbuffer when a _window_ is resized. - * Just update fields. - * Not used for user-created renderbuffers! - */ -static GLboolean -intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - ASSERT(rb->Name == 0); - rb->Width = width; - rb->Height = height; - rb->_ActualFormat = internalFormat; - - return GL_TRUE; -} -#endif - static void intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb, GLuint width, GLuint height) @@ -353,107 +334,6 @@ intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, } -#if 0 -/** - * Create a new intel_renderbuffer which corresponds to an on-screen window, - * not a user-created renderbuffer. - * \param width the screen width - * \param height the screen height - */ -struct intel_renderbuffer * -intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, - int offset, int pitch, int cpp, void *map) -{ - GET_CURRENT_CONTEXT(ctx); - - struct intel_renderbuffer *irb; - const GLuint name = 0; - - irb = CALLOC_STRUCT(intel_renderbuffer); - if (!irb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer"); - return NULL; - } - - _mesa_init_renderbuffer(&irb->Base, name); - irb->Base.ClassID = INTEL_RB_CLASS; - - switch (intFormat) { - case GL_RGB5: - irb->Base._ActualFormat = GL_RGB5; - irb->Base._BaseFormat = GL_RGBA; - irb->Base.RedBits = 5; - irb->Base.GreenBits = 6; - irb->Base.BlueBits = 5; - irb->Base.DataType = GL_UNSIGNED_BYTE; - cpp = 2; - break; - case GL_RGBA8: - irb->Base._ActualFormat = GL_RGBA8; - irb->Base._BaseFormat = GL_RGBA; - irb->Base.RedBits = 8; - irb->Base.GreenBits = 8; - irb->Base.BlueBits = 8; - irb->Base.AlphaBits = 8; - irb->Base.DataType = GL_UNSIGNED_BYTE; - cpp = 4; - break; - case GL_STENCIL_INDEX8_EXT: - irb->Base._ActualFormat = GL_STENCIL_INDEX8_EXT; - irb->Base._BaseFormat = GL_STENCIL_INDEX; - irb->Base.StencilBits = 8; - irb->Base.DataType = GL_UNSIGNED_BYTE; - cpp = 1; - break; - case GL_DEPTH_COMPONENT16: - irb->Base._ActualFormat = GL_DEPTH_COMPONENT16; - irb->Base._BaseFormat = GL_DEPTH_COMPONENT; - irb->Base.DepthBits = 16; - irb->Base.DataType = GL_UNSIGNED_SHORT; - cpp = 2; - break; - case GL_DEPTH_COMPONENT24: - irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT; - irb->Base._BaseFormat = GL_DEPTH_COMPONENT; - irb->Base.DepthBits = 24; - irb->Base.DataType = GL_UNSIGNED_INT; - cpp = 4; - break; - case GL_DEPTH24_STENCIL8_EXT: - irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT; - irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT; - irb->Base.DepthBits = 24; - irb->Base.StencilBits = 8; - irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - cpp = 4; - break; - default: - _mesa_problem(NULL, - "Unexpected intFormat in intel_create_renderbuffer"); - return NULL; - } - - irb->Base.InternalFormat = intFormat; - - /* intel-specific methods */ - irb->Base.Delete = intel_delete_renderbuffer; - irb->Base.AllocStorage = intel_alloc_window_storage; - irb->Base.GetPointer = intel_get_pointer; - /* This sets the Get/PutRow/Value functions */ - intel_set_span_functions(&irb->Base); - - irb->pfMap = map; - irb->pfPitch = pitch / cpp; /* in pixels */ - -#if 00 - irb->region = intel_region_create_static(intel, - DRM_MM_TT, - offset, map, cpp, width, height); -#endif - - return irb; -} -#endif struct intel_renderbuffer * intel_new_renderbuffer_fb(GLuint intFormat) diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c index 58c415215e7..2ecacc3c090 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c @@ -234,6 +234,8 @@ do_blit_copypixels(GLcontext * ctx, GLint dstx, GLint dsty, GLenum type) { struct intel_context *intel = intel_context(ctx); + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_framebuffer *fbread = ctx->ReadBuffer; struct intel_renderbuffer *irbread; struct intel_renderbuffer *irbdraw; struct intel_region *dst; @@ -249,16 +251,16 @@ do_blit_copypixels(GLcontext * ctx, intelFlush(&intel->ctx); if (type == GL_COLOR) { - irbread = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); - irbdraw = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + irbread = intel_renderbuffer(fbread->_ColorReadBuffer); + irbdraw = intel_renderbuffer(fb->_ColorDrawBuffers[0][0]); if (!irbread || !irbread->region || !irbdraw || !irbdraw->region) return GL_FALSE; } else if (type == GL_DEPTH) { /* Don't think this is really possible execpt at 16bpp, when we have no stencil. */ - irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped); - irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + irbread = intel_renderbuffer(fbread->_DepthBuffer->Wrapped); + irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped); if (!irbread || !irbread->region || !irbdraw || !irbdraw->region || !(irbread->region->cpp == 2)) return GL_FALSE; @@ -266,8 +268,8 @@ do_blit_copypixels(GLcontext * ctx, else if (type == GL_DEPTH_STENCIL_EXT) { /* Does it matter whether it is stencil/depth or depth/stencil? */ - irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped); - irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + irbread = intel_renderbuffer(fbread->_DepthBuffer->Wrapped); + irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped); if (!irbread || !irbread->region || !irbdraw || !irbdraw->region) return GL_FALSE; } @@ -281,61 +283,38 @@ do_blit_copypixels(GLcontext * ctx, dst = irbdraw->region; { - GLint delta_x = 0; - GLint delta_y = 0; + GLint dx = dstx - srcx; + GLint dy = dsty - srcy; - /* Do scissoring in GL coordinates: + /* Clip against dest, including scissor, in GL coordinates: */ - if (ctx->Scissor.Enabled) - { - GLint x = ctx->Scissor.X; - GLint y = ctx->Scissor.Y; - GLuint w = ctx->Scissor.Width; - GLuint h = ctx->Scissor.Height; - GLint dx = dstx - srcx; - GLint dy = dsty - srcy; - - if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height)) - goto out; - srcx = dstx - dx; - srcy = dsty - dy; - } + if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, + fb->_Xmax - 1, fb->_Ymax - 1, + &dstx, &dsty, &width, &height)) + goto out; + + srcx = dstx - dx; + srcy = dsty - dy; /* Convert from GL to hardware coordinates: */ - dsty = irbdraw->Base.Height - dsty - height; - srcy = irbread->Base.Height - srcy - height; + dsty = fb->Height - dsty - height; + srcy = fbread->Height - srcy - height; /* Clip against the source region: */ - { - delta_x = srcx - dstx; - delta_y = srcy - dsty; + dx = srcx - dstx; + dy = srcy - dsty; - if (!_mesa_clip_to_region(0, 0, irbread->Base.Width - 1, - irbread->Base.Height - 1, - &srcx, &srcy, &width, &height)) - goto out; + if (!_mesa_clip_to_region(0, 0, irbread->Base.Width - 1, + irbread->Base.Height - 1, + &srcx, &srcy, &width, &height)) + goto out; - dstx = srcx - delta_x; - dsty = srcy - delta_y; - } + dstx = srcx - dx; + dsty = srcy - dy; - /* Clip against the dest region: - */ - { - delta_x = dstx - srcx; - delta_y = dsty - srcy; - - if (!_mesa_clip_to_region(0, 0, irbdraw->Base.Width - 1, - irbdraw->Base.Height - 1, - &dstx, &dsty, &width, &height)) - goto out; - - srcx = dstx - delta_x; - srcy = dsty - delta_y; - } { diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index 4d6b4af5898..4139117206e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -219,33 +219,33 @@ do_blit_drawpixels(GLcontext * ctx, const GLvoid * pixels) { struct intel_context *intel = intel_context(ctx); + struct gl_framebuffer *fb = ctx->DrawBuffer; struct intel_renderbuffer *irbdraw; struct intel_region *dest; struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj); GLuint src_offset; GLuint rowLength; - GLuint height_orig = height; struct _DriFenceObject *fence = NULL; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); if (type == GL_COLOR) { - irbdraw = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + irbdraw = intel_renderbuffer(fb->_ColorDrawBuffers[0][0]); if (!irbdraw || !irbdraw->region) return GL_FALSE; } else if (type == GL_DEPTH) { /* Don't think this is really possible execpt at 16bpp, when we have no stencil. */ - irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped); if (!irbdraw || !irbdraw->region || !(irbdraw->region->cpp == 2)) return GL_FALSE; } else if (type == GL_DEPTH_STENCIL_EXT) { /* Does it matter whether it is stencil/depth or depth/stencil? */ - irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); + irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped); if (!irbdraw || !irbdraw->region) return GL_FALSE; } @@ -331,40 +331,26 @@ do_blit_drawpixels(GLcontext * ctx, GLuint srcy = 0; GLint dx = dstx; GLint dy = dsty; + GLuint height_orig = height; - /* Do scissoring in GL coordinates: + /* Do scissoring and clipping in GL coordinates, no need to clip against + * pbo src region (note fbo fields include scissor already): */ - if (ctx->Scissor.Enabled) - { - GLint x = ctx->Scissor.X; - GLint y = ctx->Scissor.Y; - GLuint w = ctx->Scissor.Width; - GLuint h = ctx->Scissor.Height; - height_orig = height; - - - if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height)) - goto out; - - } + height_orig = height; + if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, + fb->_Xmax - 1, fb->_Ymax - 1, + &dstx, &dsty, &width, &height)) + goto out; - /* no need to clip against pbo src region, but clip against dest */ - { - if (!_mesa_clip_to_region(0, 0, irbdraw->Base.Width - 1, - irbdraw->Base.Height - 1, - &dstx, &dsty, &width, &height)) - goto out; - - srcx = dstx - dx; - srcy = dsty - dy; - } + srcx = dstx - dx; + srcy = dsty - dy; struct _DriBufferObject *src_buffer = intel_bufferobj_buffer(intel, src, INTEL_READ); /* Convert from GL to hardware coordinates: */ - dsty = irbdraw->Base.Height - dsty - height; + dsty = fb->Height - dsty - height; srcy = height_orig - srcy - height; { -- cgit v1.2.3 From e0850e52eed52ff4e2acac6b31a7c456eb9716a0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 19 Jul 2007 18:11:48 +0200 Subject: remove some more really old ifdefed out code... --- src/mesa/drivers/dri/i915tex/i915_state.c | 48 ------------------------------- 1 file changed, 48 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c index f523206befc..1fede6a8d8e 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state.c +++ b/src/mesa/drivers/dri/i915tex/i915_state.c @@ -904,44 +904,9 @@ i915_init_packets(struct i915_context *i915) { I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS); -#if 0 - /* color buffer offset/stride */ - i915->state.Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ - i915->state.Buffer[I915_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(screen->front.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); - - i915->state.Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ - i915->state.Buffer[I915_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); -#endif i915->state.Buffer[I915_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; - /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ -#if 0 /* seems we don't need this */ - switch (screen->fbFormat) { - case DV_PF_565: - i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL | - DITHER_FULL_ALWAYS | - screen->fbFormat | - DEPTH_FRMT_16_FIXED); - break; - case DV_PF_8888: - i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL | - screen->fbFormat | - DEPTH_FRMT_24_FIXED_8_OTHER); - break; - } -#endif - /* scissor */ i915->state.Buffer[I915_DESTREG_SENABLE] = @@ -952,19 +917,6 @@ i915_init_packets(struct i915_context *i915) } -#if 0 - { - I915_STATECHANGE(i915, I915_UPLOAD_DEFAULTS); - i915->state.Default[I915_DEFREG_C0] = _3DSTATE_DEFAULT_DIFFUSE; - i915->state.Default[I915_DEFREG_C1] = 0; - i915->state.Default[I915_DEFREG_S0] = _3DSTATE_DEFAULT_SPECULAR; - i915->state.Default[I915_DEFREG_S1] = 0; - i915->state.Default[I915_DEFREG_Z0] = _3DSTATE_DEFAULT_Z; - i915->state.Default[I915_DEFREG_Z1] = 0; - } -#endif - - /* These will be emitted every at the head of every buffer, unless * we get hardware contexts working. */ -- cgit v1.2.3 From 97cd87ef74eb06aa8da52be42871120cca145269 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 20 Jul 2007 11:33:24 +0200 Subject: minor cleanups, disable debugging --- src/mesa/drivers/dri/i915tex/i830_vtbl.c | 19 ------------------- src/mesa/drivers/dri/i915tex/intel_buffers.c | 2 +- src/mesa/drivers/dri/i915tex/intel_context.c | 3 +-- src/mesa/drivers/dri/i915tex/intel_context.h | 2 +- src/mesa/drivers/dri/i915tex/intel_screen.c | 4 ++-- src/mesa/drivers/dri/i915tex/intel_state.c | 2 +- 6 files changed, 6 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c index e432648ada0..03d4788be1a 100644 --- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c @@ -597,25 +597,6 @@ i830_set_draw_region(struct intel_context *intel, i830_state_draw_region(intel, &i830->state, color_region, depth_region); } -#if 0 -static void -i830_update_color_z_regions(intelContextPtr intel, - const intelRegion * colorRegion, - const intelRegion * depthRegion) -{ - i830ContextPtr i830 = I830_CONTEXT(intel); - - i830->state.Buffer[I830_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | - BUF_3D_USE_FENCE); - i830->state.Buffer[I830_DESTREG_CBUFADDR2] = colorRegion->offset; - - i830->state.Buffer[I830_DESTREG_DBUFADDR1] = - (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depthRegion->pitch) | BUF_3D_USE_FENCE); - i830->state.Buffer[I830_DESTREG_DBUFADDR2] = depthRegion->offset; -} -#endif - /* This isn't really handled at the moment. */ diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index ee3266e09bd..4b2a4acaf98 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -645,7 +645,7 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) return ret; } - + void intelSwapBuffers(__DRIdrawablePrivate * dPriv) { diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 769287ba6a8..f032c97dfbb 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -703,8 +703,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) } - -/* Lock the hardware and validate our state. +/* Lock the hardware and validate our state. */ void LOCK_HARDWARE( struct intel_context *intel ) { diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 628a15f8de5..535a93effac 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -335,7 +335,7 @@ __memcpy(void *to, const void *from, size_t n) /* ================================================================ * Debugging: */ -#define DO_DEBUG 1 +#define DO_DEBUG 0 #if DO_DEBUG extern int INTEL_DEBUG; #else diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index 5ad0932e2eb..3c0ae854e46 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -118,7 +118,7 @@ intel_recreate_static(intelScreenPrivate *intelScreen, * Only used for real front buffer now. * * Note that these don't allocate video memory, just describe - * allocations alread made by the X server. + * allocations already made by the X server. */ static void intel_recreate_static_regions(intelScreenPrivate *intelScreen) @@ -222,7 +222,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->front.handle = sarea->front_handle; intelScreen->front.size = sarea->front_size; - if (1) + if (0) intelPrintSAREA(sarea); } diff --git a/src/mesa/drivers/dri/i915tex/intel_state.c b/src/mesa/drivers/dri/i915tex/intel_state.c index b2773990e4b..5c5f2c6de5c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_state.c +++ b/src/mesa/drivers/dri/i915tex/intel_state.c @@ -194,7 +194,7 @@ intelClearColor(GLcontext * ctx, const GLfloat color[4]) * Update the viewport transformation matrix. Depends on: * - viewport pos/size * - depthrange - * - window pos/size or FBO size + * - window size or FBO size */ static void intelCalcViewport(GLcontext * ctx) -- cgit v1.2.3 From 118bd626b10d213eb022ac2618bf2efc5fe734d1 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 20 Jul 2007 11:34:26 +0200 Subject: fix bogus recently introduced function param comments --- src/mesa/main/buffers.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 7764a5d3b2e..0e6ca8ea1c2 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -496,7 +496,6 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param destMask array[n] of BUFFER_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). - * \param callDriver call driver or not (bad idea sometimes this is called) */ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, @@ -574,7 +573,6 @@ _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) /** * Called by glReadBuffer to set the source renderbuffer for reading pixels. * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - * \param callDriver call driver or not (bad idea sometimes this is called) */ void GLAPIENTRY _mesa_ReadBuffer(GLenum buffer) -- cgit v1.2.3 From 36fce66034887009749c3d52587c293da2457820 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sat, 21 Jul 2007 16:51:15 +0200 Subject: set the _BaseFormat for window-framebuffers, could hit some assertion otherwise --- src/mesa/drivers/dri/i915tex/intel_fbo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index 399a280c47c..04ca5ae8ba0 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -350,6 +350,21 @@ intel_new_renderbuffer_fb(GLuint intFormat) irb->Base.ClassID = INTEL_RB_CLASS; irb->Base.InternalFormat = intFormat; + switch (intFormat) { + case GL_RGB5: + case GL_RGBA8: + irb->Base._BaseFormat = GL_RGBA; + break; + case GL_DEPTH_COMPONENT16: + irb->Base._BaseFormat = GL_DEPTH_COMPONENT; + break; + case GL_DEPTH24_STENCIL8_EXT: + irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT; + break; + default: + assert(0); + } + /* intel-specific methods */ irb->Base.Delete = intel_delete_renderbuffer; irb->Base.AllocStorage = intel_alloc_renderbuffer_storage; -- cgit v1.2.3 From 9d2d34b5eabfb7855081ad56fa00b3e0f6b8e631 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 29 Jul 2007 18:04:28 +0200 Subject: Fix crashes when the frag prog can't be handled in hardware (#11131) Must not change to/from swrast after Render.Start or bad things will happen. (Driver will still somewhat incorrectly report an implementation error, and apps can't really figure out if a prog is natively supported as validation is later - could try doing it earlier to give some hint at least, even though native status may still change later due to fog etc.) --- src/mesa/drivers/dri/i915tex/i830_vtbl.c | 6 ++++++ src/mesa/drivers/dri/i915tex/i915_vtbl.c | 8 +++++++- src/mesa/drivers/dri/i915tex/intel_context.h | 1 + src/mesa/drivers/dri/i915tex/intel_render.c | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c index 03d4788be1a..20c6900025e 100644 --- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c @@ -60,6 +60,11 @@ do { \ #define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2)) #define TEXBIND_SET(n, x) ((x)<<((n)*4)) +static void +i830_render_prevalidate(struct intel_context *intel) +{ +} + static void i830_render_start(struct intel_context *intel) { @@ -638,5 +643,6 @@ i830InitVtbl(struct i830_context *i830) i830->intel.vtbl.update_texture_state = i830UpdateTextureState; i830->intel.vtbl.flush_cmd = i830_flush_cmd; i830->intel.vtbl.render_start = i830_render_start; + i830->intel.vtbl.render_prevalidate = i830_render_prevalidate; i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty; } diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index 51aff688402..13ca9aee6bd 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -44,13 +44,18 @@ #include "i915_context.h" static void -i915_render_start(struct intel_context *intel) +i915_render_prevalidate(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); i915ValidateFragmentProgram(i915); } +static void +i915_render_start(struct intel_context *intel) +{ +} + static void i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) @@ -547,6 +552,7 @@ i915InitVtbl(struct i915_context *i915) i915->intel.vtbl.lost_hardware = i915_lost_hardware; i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state; i915->intel.vtbl.render_start = i915_render_start; + i915->intel.vtbl.render_prevalidate = i915_render_prevalidate; i915->intel.vtbl.set_draw_region = i915_set_draw_region; i915->intel.vtbl.update_texture_state = i915UpdateTextureState; i915->intel.vtbl.flush_cmd = i915_flush_cmd; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 535a93effac..ee5be455333 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -131,6 +131,7 @@ struct intel_context void (*update_texture_state) (struct intel_context * intel); void (*render_start) (struct intel_context * intel); + void (*render_prevalidate) (struct intel_context * intel); void (*set_draw_region) (struct intel_context * intel, struct intel_region * draw_region, struct intel_region * depth_region); diff --git a/src/mesa/drivers/dri/i915tex/intel_render.c b/src/mesa/drivers/dri/i915tex/intel_render.c index f9fa55051ea..c8b6d308d96 100644 --- a/src/mesa/drivers/dri/i915tex/intel_render.c +++ b/src/mesa/drivers/dri/i915tex/intel_render.c @@ -202,6 +202,8 @@ intel_run_render(GLcontext * ctx, struct tnl_pipeline_stage *stage) struct vertex_buffer *VB = &tnl->vb; GLuint i; + intel->vtbl.render_prevalidate( intel ); + /* Don't handle clipping or indexed vertices. */ if (intel->RenderIndex != 0 || -- cgit v1.2.3 From 7aefdd518578687f961bb512a2b408857f0b9824 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 29 Jul 2007 19:40:50 +0200 Subject: fix range reduction for sin/cos in i915tex (#11609) --- src/mesa/drivers/dri/i915tex/i915_context.h | 6 ------ src/mesa/drivers/dri/i915tex/i915_fragprog.c | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_context.h b/src/mesa/drivers/dri/i915tex/i915_context.h index d2713e88f96..3a41d66c148 100644 --- a/src/mesa/drivers/dri/i915tex/i915_context.h +++ b/src/mesa/drivers/dri/i915tex/i915_context.h @@ -308,12 +308,6 @@ extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, void *sharedContextPrivate); -/*====================================================================== - * i915_texprog.c - */ -extern void i915ValidateTextureProgram(struct i915_context *i915); - - /*====================================================================== * i915_debug.c */ diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c index a4b22a0c32c..95ec50490a2 100644 --- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c @@ -320,7 +320,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0 / (M_PI)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -329,7 +329,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (M_PI)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 @@ -642,7 +642,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0 / (M_PI)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -651,7 +651,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (M_PI)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 -- cgit v1.2.3