From d348a48ac353d7c646a0c4f976f23a764990e779 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 10 Jul 2007 18:07:38 +0200 Subject: First attempt at using private back/z buffers. Allocate and use private back and z/stencil buffers. This is still very broken. --- src/mesa/drivers/dri/i915tex/intel_blit.c | 8 +++-- src/mesa/drivers/dri/i915tex/intel_context.c | 11 ++++++ src/mesa/drivers/dri/i915tex/intel_context.h | 2 +- src/mesa/drivers/dri/i915tex/intel_fbo.c | 25 +++++++++++++- src/mesa/drivers/dri/i915tex/intel_screen.c | 51 +++++++++++++++++++++++++--- src/mesa/drivers/dri/i915tex/intel_screen.h | 1 + 6 files changed, 89 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index dbe4ba2ac5e..5dcb0ddebbb 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -88,6 +88,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, const int nbox = dPriv->numClipRects; const drm_clip_rect_t *pbox = dPriv->pClipRects; const int pitch = frontRegion->pitch; + const int srcpitch = backRegion->pitch; const int cpp = frontRegion->cpp; int BR13, CMD; int i; @@ -96,9 +97,12 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, ASSERT(intel_fb->Base.Name == 0); /* Not a user-created FBO */ ASSERT(frontRegion); ASSERT(backRegion); - ASSERT(frontRegion->pitch == backRegion->pitch); +// ASSERT(frontRegion->pitch == backRegion->pitch); ASSERT(frontRegion->cpp == backRegion->cpp); + DBG("copy buffer, front pitch %d back pitch %d\n", + frontRegion->pitch, backRegion->pitch); + if (cpp == 2) { BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24); CMD = XY_SRC_COPY_BLT_CMD; @@ -142,7 +146,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, OUT_RELOC(frontRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); OUT_BATCH((pbox->y1 << 16) | pbox->x1); - OUT_BATCH(BR13 & 0xffff); + OUT_BATCH((srcpitch * cpp) & 0xffff); OUT_RELOC(backRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0); diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index c927dca8e5a..028e57e5ab6 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -569,6 +569,13 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, __DRIdrawablePrivate * driReadPriv) { +#if 0 + if (driDrawPriv) { + fprintf(stderr, "x %d, y %d, width %d, height %d\n", + driDrawPriv->x, driDrawPriv->y, driDrawPriv->w, driDrawPriv->h); + } +#endif + if (driContextPriv) { struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; @@ -576,6 +583,9 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, (struct intel_framebuffer *) driDrawPriv->driverPrivate; GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate; + /* this is a hack so we have a valid context when the region allocation + 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 */ @@ -613,6 +623,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, } _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: */ diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 9d060eb866f..7a9af1b5fda 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -353,7 +353,7 @@ __memcpy(void *to, const void *from, size_t n) /* ================================================================ * Debugging: */ -#define DO_DEBUG 0 +#define DO_DEBUG 1 #if DO_DEBUG extern int INTEL_DEBUG; #else diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index 349912ffecd..d3f14bcd258 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -257,7 +257,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, break; default: _mesa_problem(ctx, - "Unexpected format in intel_alloc_renderbuffer_storage"); + "Unexpected format (%x) in intel_alloc_renderbuffer_storage", internalFormat); return GL_FALSE; } @@ -453,6 +453,29 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, return irb; } +struct gl_renderbuffer * +intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat) +{ + struct intel_renderbuffer *irb; + + irb = CALLOC_STRUCT(intel_renderbuffer); + if (!irb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer"); + return NULL; + } + + _mesa_init_renderbuffer(&irb->Base, 0); + irb->Base.ClassID = INTEL_RB_CLASS; + irb->Base.InternalFormat = intFormat; + + /* intel-specific methods */ + irb->Base.Delete = intel_delete_renderbuffer; + irb->Base.AllocStorage = intel_alloc_renderbuffer_storage; + irb->Base.GetPointer = intel_get_pointer; + /* span routines set in alloc_storage function */ + + return &irb->Base; +} /** * Create a new renderbuffer object. diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index 2acdead63d5..a5a9c796254 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -156,7 +156,7 @@ intel_recreate_static(intelScreenPrivate *intelScreen, } return region; } - + /* Create intel_region structs to describe the static front,back,depth * buffers created by the xserver. @@ -192,7 +192,7 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen) intelScreen->rotated.pitch / intelScreen->cpp, intelScreen->height); - +#if 0 intelScreen->back_region = intel_recreate_static(intelScreen, intelScreen->back_region, @@ -226,6 +226,7 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen) intelScreen->cpp, intelScreen->depth.pitch / intelScreen->cpp, intelScreen->height); +#endif } /** @@ -382,7 +383,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->rotatedWidth = sarea->virtualX; intelScreen->rotatedHeight = sarea->virtualY; - if (0) + if (1) intelPrintSAREA(sarea); } @@ -614,6 +615,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, &intel_fb->color_rb[0]->Base); } +#if 0 if (mesaVis->doubleBufferMode) { intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat, @@ -640,7 +642,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, _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 @@ -670,6 +671,39 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base); } +#else + if (mesaVis->doubleBufferMode) { + intel_fb->color_rb[1] + = intel_new_renderbuffer_fb(NULL, rgbFormat); + _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_new_renderbuffer_fb(NULL, 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); + /* 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_new_renderbuffer_fb(NULL, GL_DEPTH_COMPONENT16); + _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, GL_FALSE, /* never sw color */ @@ -939,11 +973,18 @@ 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; } return intel_context(ctx); +*/ + if (intelScreen->dummyctxptr == NULL) { + _mesa_problem(NULL, "No current context in intelScreenContext\n"); + return NULL; + } + return intelScreen->dummyctxptr; + } diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.h b/src/mesa/drivers/dri/i915tex/intel_screen.h index bac43aadddf..783ee35524b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.h +++ b/src/mesa/drivers/dri/i915tex/intel_screen.h @@ -96,6 +96,7 @@ typedef struct struct _DriBufferPool *staticPool; unsigned int maxBatchSize; GLboolean havePools; + struct intel_context *dummyctxptr; } intelScreenPrivate; -- cgit v1.2.3 From 1278514ff48b262ee0a4f2ac698c6df648b326a0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 10 Jul 2007 19:56:44 +0200 Subject: copybuffer/cliprect fixups --- src/mesa/drivers/dri/i915tex/intel_blit.c | 6 ++++- src/mesa/drivers/dri/i915tex/intel_buffers.c | 40 ++++++++++++++++++++++++++-- src/mesa/drivers/dri/i915tex/intel_context.h | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index 5dcb0ddebbb..b4fc1691e6b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -115,6 +115,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, for (i = 0; i < nbox; i++, pbox++) { drm_clip_rect_t box; + drm_clip_rect_t sbox; if (pbox->x1 > pbox->x2 || pbox->y1 > pbox->y2 || @@ -137,6 +138,9 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, continue; } + 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); @@ -145,7 +149,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, OUT_RELOC(frontRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); - OUT_BATCH((pbox->y1 << 16) | pbox->x1); + OUT_BATCH((sbox.y1 << 16) | sbox.x1); OUT_BATCH((srcpitch * cpp) & 0xffff); OUT_RELOC(backRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0); diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 62ff54b0075..e8dd7cd5240 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -146,6 +146,27 @@ intelSetRenderbufferClipRects(struct intel_context *intel) intel->drawY = 0; } +/** + * As above, but for rendering private front/back buffer of a window. + * \sa intelSetPrivbufClipRects + */ + +static void +intelSetPrivbufClipRects(struct intel_context *intel) +{ + __DRIdrawablePrivate *dPriv = intel->driDrawable; + if (!dPriv) + return; + + intel->fakeClipRect.x1 = 0; + intel->fakeClipRect.y1 = 0; + intel->fakeClipRect.x2 = dPriv->w; + intel->fakeClipRect.y2 = dPriv->h; + intel->pClipRects = &intel->fakeClipRect; + intel->numClipRects = 1; + intel->drawX = 0; + intel->drawY = 0; +} /** * As above, but for rendering to front buffer of a window. @@ -212,7 +233,7 @@ intelWindowMoved(struct intel_context *intel) /* when would this happen? -BP */ intelSetFrontClipRects(intel); } - else if (intel->ctx.DrawBuffer->Name != 0) { + else if (1 || intel->ctx.DrawBuffer->Name != 0) { /* drawing to user-created FBO - do nothing */ /* Cliprects would be set from intelDrawBuffer() */ } @@ -953,10 +974,17 @@ 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 + rect.x1 = x; + rect.y1 = dPriv->h - y; + rect.x2 = rect.x1 + w; + rect.y2 = rect.y1 + h; +#endif _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ intelCopyBuffer(dPriv, &rect); } @@ -991,7 +1019,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) return; } - /* Do this here, note core Mesa, since this function is called from + /* Do this here, not core Mesa, since this function is called from * many places within the driver. */ if (ctx->NewState & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) { @@ -1042,11 +1070,19 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) if (fb->Name == 0) { /* drawing to window system buffer */ if (front) { +#if 0 intelSetFrontClipRects(intel); +#else + intelSetPrivbufClipRects(intel); +#endif colorRegion = intel_get_rb_region(fb, BUFFER_FRONT_LEFT); } else { +#if 0 intelSetBackClipRects(intel); +#else + intelSetPrivbufClipRects(intel); +#endif colorRegion = intel_get_rb_region(fb, BUFFER_BACK_LEFT); } } diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 7a9af1b5fda..d05b20abbd4 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -254,6 +254,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 */ int perf_boxes; -- cgit v1.2.3 From 43e24ff50773575d28763d899a4f25bb430418b5 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 11 Jul 2007 14:20:39 +0200 Subject: some fixes, fake frontbuffer still doesn't work quite right (resize). Fake frontbuffer doesn't copy in real frontbuffer. Don't even think about doing rotation/page flip/triple buffering for now... More cleanups needed (fake cliprects etc.) --- src/mesa/drivers/dri/i915tex/i915_vtbl.c | 2 ++ src/mesa/drivers/dri/i915tex/intel_blit.c | 18 ++++++++++++------ src/mesa/drivers/dri/i915tex/intel_buffers.c | 23 ++++++++++++----------- src/mesa/drivers/dri/i915tex/intel_context.c | 18 ++++++++++++------ src/mesa/drivers/dri/i915tex/intel_screen.c | 14 +++++++++++++- src/mesa/drivers/dri/i915tex/intel_state.c | 24 ++++++++---------------- 6 files changed, 59 insertions(+), 40 deletions(-) diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index f80e8d6327f..51aff688402 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -463,6 +463,7 @@ i915_state_draw_region(struct intel_context *intel, * Set stride/cpp values */ if (color_region) { +// fprintf(stderr, "color pitch %d\n", color_region->pitch); state->Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; state->Buffer[I915_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | @@ -471,6 +472,7 @@ i915_state_draw_region(struct intel_context *intel, } if (depth_region) { +// fprintf(stderr, "depth pitch %d\n", depth_region->pitch); state->Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; state->Buffer[I915_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index b4fc1691e6b..d6651f62be1 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -82,9 +82,11 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, if (dPriv && dPriv->numClipRects) { struct intel_framebuffer *intel_fb = dPriv->driverPrivate; const struct intel_region *frontRegion - = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT); + = intelScreen->front_region; const struct intel_region *backRegion - = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT); + = 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 nbox = dPriv->numClipRects; const drm_clip_rect_t *pbox = dPriv->pClipRects; const int pitch = frontRegion->pitch; @@ -100,7 +102,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, // ASSERT(frontRegion->pitch == backRegion->pitch); ASSERT(frontRegion->cpp == backRegion->cpp); - DBG("copy buffer, front pitch %d back pitch %d\n", + DBG("front pitch %d back pitch %d\n", frontRegion->pitch, backRegion->pitch); if (cpp == 2) { @@ -138,6 +140,11 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, continue; } + 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; @@ -417,9 +424,8 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask) b = *box; } - if (0) - _mesa_printf("clear %d,%d..%d,%d, mask %x\n", - b.x1, b.y1, b.x2, b.y2, mask); + DBG("clear %d,%d..%d,%d, mask %x\n", + b.x1, b.y1, b.x2, b.y2, mask); /* Loop over all renderbuffers */ for (buf = 0; buf < BUFFER_COUNT && clearMask; buf++) { diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index e8dd7cd5240..fbaa4ee4f31 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -930,7 +930,7 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) 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 || @@ -956,6 +956,16 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) intel_fb->swap_ust = ust; } + if (dPriv && intel->lastStamp != dPriv->lastStamp) { + /* XXX this doesn't appear to work quite right. + And in any case, it will never get called with single buffered + rendering here... + And if it's only a window move (not resize), don't need to do anything. */ + if (INTEL_DEBUG & DEBUG_LOCK) + _mesa_printf("doing defered drawable update\n"); + intelWindowMoved(intel); + intel->lastStamp = dPriv->lastStamp; + } } else { /* XXX this shouldn't be an error but we can't handle it for now */ @@ -1068,21 +1078,12 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) * And set up cliprects. */ if (fb->Name == 0) { + intelSetPrivbufClipRects(intel); /* drawing to window system buffer */ if (front) { -#if 0 - intelSetFrontClipRects(intel); -#else - intelSetPrivbufClipRects(intel); -#endif colorRegion = intel_get_rb_region(fb, BUFFER_FRONT_LEFT); } else { -#if 0 - intelSetBackClipRects(intel); -#else - intelSetPrivbufClipRects(intel); -#endif colorRegion = intel_get_rb_region(fb, BUFFER_BACK_LEFT); } } diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 028e57e5ab6..76426e3c882 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -282,18 +282,22 @@ intelFlush(GLcontext * ctx) * Check if we need to rotate/warp the front color buffer to the * rotated screen. We generally need to do this when we get a glFlush * or glFinish after drawing to the front color buffer. + * If no rotation, just copy the private fake front buffer to the real one. */ static void -intelCheckFrontRotate(GLcontext * ctx) +intelCheckFrontUpdate(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { intelScreenPrivate *screen = intel->intelScreen; + __DRIdrawablePrivate *dPriv = intel->driDrawable; if (screen->current_rotation != 0) { - __DRIdrawablePrivate *dPriv = intel->driDrawable; intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT); } + else { + intelCopyBuffer(dPriv, NULL); + } } } @@ -305,7 +309,7 @@ static void intelglFlush(GLcontext * ctx) { intelFlush(ctx); - intelCheckFrontRotate(ctx); + intelCheckFrontUpdate(ctx); } void @@ -319,7 +323,7 @@ intelFinish(GLcontext * ctx) driFenceUnReference(intel->batch->last_fence); intel->batch->last_fence = NULL; } - intelCheckFrontRotate(ctx); + intelCheckFrontUpdate(ctx); } @@ -724,8 +728,10 @@ intelContendedLock(struct intel_context *intel, GLuint flags) /* Drawable changed? */ if (dPriv && intel->lastStamp != dPriv->lastStamp) { - intelWindowMoved(intel); - intel->lastStamp = dPriv->lastStamp; + if (INTEL_DEBUG & DEBUG_LOCK) + _mesa_printf("drawable change detected but defering update\n"); +/* intelWindowMoved(intel); + intel->lastStamp = dPriv->lastStamp;*/ } } diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index a5a9c796254..82b65ea8420 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -172,6 +172,7 @@ intel_recreate_static(intelScreenPrivate *intelScreen, static void intel_recreate_static_regions(intelScreenPrivate *intelScreen) { +/* this is the real front buffer which is only used for blitting to */ intelScreen->front_region = intel_recreate_static(intelScreen, intelScreen->front_region, @@ -601,6 +602,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis); +#if 0 /* setup the hardware-based renderbuffers */ { intel_fb->color_rb[0] @@ -615,7 +617,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, &intel_fb->color_rb[0]->Base); } -#if 0 if (mesaVis->doubleBufferMode) { intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat, @@ -672,11 +673,22 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, } #else + { + /* fake frontbuffer */ + /* XXX allocation should only happen in the unusual case + it's actually needed */ + intel_fb->color_rb[0] + = intel_new_renderbuffer_fb(NULL, 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); _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; diff --git a/src/mesa/drivers/dri/i915tex/intel_state.c b/src/mesa/drivers/dri/i915tex/intel_state.c index 271511037e9..b2773990e4b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_state.c +++ b/src/mesa/drivers/dri/i915tex/intel_state.c @@ -205,25 +205,17 @@ intelCalcViewport(GLcontext * ctx) GLfloat *m = intel->ViewportMatrix.m; GLfloat yScale, yBias; - if (ctx->DrawBuffer->Name) { - /* User created FBO */ - struct intel_renderbuffer *irb + struct intel_renderbuffer *irb = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); - if (irb && !irb->RenderToTexture) { - /* y=0=top */ - yScale = -1.0; - yBias = irb->Base.Height; - } - else { - /* y=0=bottom */ - yScale = 1.0; - yBias = 0.0; - } + if (irb && !irb->RenderToTexture) { + /* y=0=top */ + yScale = -1.0; + yBias = irb->Base.Height; } else { - /* window buffer, y=0=top */ - yScale = -1.0; - yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F; + /* y=0=bottom */ + yScale = 1.0; + yBias = 0.0; } m[MAT_SX] = v[MAT_SX]; -- cgit v1.2.3 From eb2a896f68e5402764955a30b949d8408d435e73 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 11 Jul 2007 16:08:14 +0200 Subject: drop some more code no longer needed --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 1 + src/mesa/drivers/dri/i915tex/intel_context.c | 2 ++ src/mesa/drivers/dri/i915tex/intel_screen.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index fbaa4ee4f31..4e4f0d14c65 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -500,6 +500,7 @@ void intelRotateWindow(struct intel_context *intel, __DRIdrawablePrivate * dPriv, GLuint srcBuf) { + intelScreenPrivate *screen = intel->intelScreen; drm_clip_rect_t fullRect; struct intel_framebuffer *intel_fb; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 76426e3c882..4b96cd7b7ec 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -682,6 +682,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) intelUpdateScreenRotation(sPriv, sarea); } +#if 0 if (sarea->width != intel->width || sarea->height != intel->height || sarea->rotation != intel->current_rotation) { @@ -724,6 +725,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) intel->height = sarea->height; intel->current_rotation = sarea->rotation; } +#endif /* Drawable changed? */ diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index 82b65ea8420..08057a66006 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -88,6 +88,7 @@ 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, @@ -119,6 +120,7 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv) intelUnmapScreenRegions(intelScreen); return GL_FALSE; } +#endif #if 0 _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle); -- cgit v1.2.3 From fb67b1609e211ed16828e10ffc1c36e54f655112 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 11 Jul 2007 17:30:01 +0200 Subject: remove bogus assertion, change drawable updates don't update driDrawable information until later at all (blit needs fixing). --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 17 ++++++++++++----- src/mesa/drivers/dri/i915tex/intel_context.c | 5 ++++- src/mesa/drivers/dri/i915tex/intel_context.h | 1 + src/mesa/drivers/dri/i915tex/intel_fbo.c | 4 +--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 4e4f0d14c65..67f992e4a21 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -957,15 +957,22 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) intel_fb->swap_ust = ust; } - if (dPriv && intel->lastStamp != dPriv->lastStamp) { + if (intel->revalidateDrawable) { + __DRIscreenPrivate *sPriv = intel->driScreen; + LOCK_HARDWARE(intel); + DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); + intel->revalidateDrawable = GL_FALSE; + UNLOCK_HARDWARE(intel); + if (dPriv && intel->lastStamp != dPriv->lastStamp) { /* XXX this doesn't appear to work quite right. And in any case, it will never get called with single buffered rendering here... And if it's only a window move (not resize), don't need to do anything. */ - if (INTEL_DEBUG & DEBUG_LOCK) - _mesa_printf("doing defered drawable update\n"); - intelWindowMoved(intel); - intel->lastStamp = dPriv->lastStamp; + if (INTEL_DEBUG & DEBUG_LOCK) + _mesa_printf("doing defered drawable update\n"); + intelWindowMoved(intel); + intel->lastStamp = dPriv->lastStamp; + } } } else { diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 4b96cd7b7ec..aa2078e762a 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -673,7 +673,8 @@ intelContendedLock(struct intel_context *intel, GLuint flags) * checking must be done *after* this call: */ if (dPriv) - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); + intel->revalidateDrawable = GL_TRUE; +// DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); if (sarea->width != intelScreen->width || sarea->height != intelScreen->height || @@ -727,6 +728,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) } #endif +#if 0 /* Drawable changed? */ if (dPriv && intel->lastStamp != dPriv->lastStamp) { @@ -735,6 +737,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) /* intelWindowMoved(intel); intel->lastStamp = dPriv->lastStamp;*/ } +#endif } diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index d05b20abbd4..7b97c564a3e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -273,6 +273,7 @@ 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 d3f14bcd258..2dd3617f93a 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -176,7 +176,7 @@ intel_get_pointer(GLcontext * ctx, struct gl_renderbuffer *rb, /** * Called via glRenderbufferStorageEXT() to set the format and allocate - * storage for a user-created renderbuffer. + * storage for a user-created (or priv buffer) renderbuffer. */ static GLboolean intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, @@ -188,8 +188,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, GLboolean softwareBuffer = GL_FALSE; int cpp; - ASSERT(rb->Name != 0); - switch (internalFormat) { case GL_R3_G3_B2: case GL_RGB4: -- cgit v1.2.3 From 20cf13e03b1703937b4228aba8355b34d664aafb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 11 Jul 2007 17:01:30 +0100 Subject: Fix screen corruption on resize. Move buffer resize check to immediately after swapbuffers. Update cliprects inside the locked region of swapbuffers. --- src/mesa/drivers/dri/i915tex/intel_blit.c | 13 ++++ src/mesa/drivers/dri/i915tex/intel_buffers.c | 95 ++-------------------------- src/mesa/drivers/dri/i915tex/intel_context.c | 11 ---- 3 files changed, 17 insertions(+), 102 deletions(-) diff --git a/src/mesa/drivers/dri/i915tex/intel_blit.c b/src/mesa/drivers/dri/i915tex/intel_blit.c index d6651f62be1..c755eac6b2c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_blit.c +++ b/src/mesa/drivers/dri/i915tex/intel_blit.c @@ -79,6 +79,13 @@ intelCopyBuffer(const __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 @@ -171,6 +178,12 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, } UNLOCK_HARDWARE(intel); + + if (intel->revalidateDrawable) { + intel->revalidateDrawable = GL_FALSE; + intelWindowMoved(intel); + } + } diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 67f992e4a21..5aed3ad0ecc 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -162,60 +162,12 @@ intelSetPrivbufClipRects(struct intel_context *intel) intel->fakeClipRect.y1 = 0; intel->fakeClipRect.x2 = dPriv->w; intel->fakeClipRect.y2 = dPriv->h; - intel->pClipRects = &intel->fakeClipRect; intel->numClipRects = 1; + intel->pClipRects = &intel->fakeClipRect; intel->drawX = 0; intel->drawY = 0; } -/** - * As above, but for rendering to front buffer of a window. - * \sa intelSetRenderbufferClipRects - */ -static void -intelSetFrontClipRects(struct intel_context *intel) -{ - __DRIdrawablePrivate *dPriv = intel->driDrawable; - - if (!dPriv) - return; - - intel->numClipRects = dPriv->numClipRects; - intel->pClipRects = dPriv->pClipRects; - intel->drawX = dPriv->x; - intel->drawY = dPriv->y; -} - - -/** - * As above, but for rendering to back buffer of a window. - */ -static void -intelSetBackClipRects(struct intel_context *intel) -{ - __DRIdrawablePrivate *dPriv = intel->driDrawable; - struct intel_framebuffer *intel_fb; - - if (!dPriv) - return; - - intel_fb = dPriv->driverPrivate; - - if (intel_fb->pf_active || dPriv->numBackClipRects == 0) { - /* use the front clip rects */ - intel->numClipRects = dPriv->numClipRects; - intel->pClipRects = dPriv->pClipRects; - intel->drawX = dPriv->x; - intel->drawY = dPriv->y; - } - else { - /* use the back clip rects */ - intel->numClipRects = dPriv->numBackClipRects; - intel->pClipRects = dPriv->pBackClipRects; - intel->drawX = dPriv->backX; - intel->drawY = dPriv->backY; - } -} /** @@ -231,27 +183,10 @@ intelWindowMoved(struct intel_context *intel) if (!intel->ctx.DrawBuffer) { /* when would this happen? -BP */ - intelSetFrontClipRects(intel); - } - else if (1 || intel->ctx.DrawBuffer->Name != 0) { - /* drawing to user-created FBO - do nothing */ - /* Cliprects would be set from intelDrawBuffer() */ - } - else { - /* drawing to a window */ - switch (intel_fb->Base._ColorDrawBufferMask[0]) { - case BUFFER_BIT_FRONT_LEFT: - intelSetFrontClipRects(intel); - break; - case BUFFER_BIT_BACK_LEFT: - intelSetBackClipRects(intel); - break; - default: - /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */ - intelSetFrontClipRects(intel); - } + intel->numClipRects = 0; } + if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) { drmI830Sarea *sarea = intel->sarea; drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, @@ -957,23 +892,6 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv) intel_fb->swap_ust = ust; } - if (intel->revalidateDrawable) { - __DRIscreenPrivate *sPriv = intel->driScreen; - LOCK_HARDWARE(intel); - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); - intel->revalidateDrawable = GL_FALSE; - UNLOCK_HARDWARE(intel); - if (dPriv && intel->lastStamp != dPriv->lastStamp) { - /* XXX this doesn't appear to work quite right. - And in any case, it will never get called with single buffered - rendering here... - And if it's only a window move (not resize), don't need to do anything. */ - if (INTEL_DEBUG & DEBUG_LOCK) - _mesa_printf("doing defered drawable update\n"); - intelWindowMoved(intel); - intel->lastStamp = dPriv->lastStamp; - } - } } else { /* XXX this shouldn't be an error but we can't handle it for now */ @@ -1061,12 +979,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) /* * How many color buffers are we drawing into? */ - if (fb->_NumColorDrawBuffers[0] != 1 -#if 0 - /* XXX FBO temporary - always use software rendering */ - || 1 -#endif - ) { + if (fb->_NumColorDrawBuffers[0] != 1) { /* writing to 0 or 2 or 4 color buffers */ /*_mesa_debug(ctx, "Software rendering\n");*/ FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE); diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index aa2078e762a..531b4adde80 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -727,17 +727,6 @@ intelContendedLock(struct intel_context *intel, GLuint flags) intel->current_rotation = sarea->rotation; } #endif - -#if 0 - /* Drawable changed? - */ - if (dPriv && intel->lastStamp != dPriv->lastStamp) { - if (INTEL_DEBUG & DEBUG_LOCK) - _mesa_printf("drawable change detected but defering update\n"); -/* intelWindowMoved(intel); - intel->lastStamp = dPriv->lastStamp;*/ - } -#endif } -- cgit v1.2.3