From 179cc373f1ecb4d65a413fdc64c74f98e27dac79 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Dec 2004 17:47:08 +0000 Subject: Get scissor test working again. Passes glean scissor test. --- src/mesa/drivers/dri/unichrome/via_context.c | 12 +++++- src/mesa/drivers/dri/unichrome/via_ioctl.c | 58 ++++++++++++++++++---------- src/mesa/drivers/dri/unichrome/via_state.c | 17 +++++++- src/mesa/drivers/dri/unichrome/via_tris.c | 9 ++++- 4 files changed, 70 insertions(+), 26 deletions(-) (limited to 'src/mesa/drivers/dri') diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 4c70af60c83..2fa1eb4f9cc 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -661,8 +661,16 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv, (GLframebuffer *)driDrawPriv->driverPrivate, (GLframebuffer *)driReadPriv->driverPrivate); if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext); - viaXMesaWindowMoved(vmesa); - + + /* These are probably needed only the first time a context is + * made current: + */ + viaXMesaWindowMoved(vmesa); + ctx->Driver.Scissor(ctx, + ctx->Scissor.X, + ctx->Scissor.Y, + ctx->Scissor.Width, + ctx->Scissor.Height); } else { diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c index d1fa996c0f5..d3d4041b99f 100644 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c @@ -495,11 +495,9 @@ static void via_emit_cliprect(viaContextPtr vmesa, GLuint pitch = buffer->pitch; GLuint offset = buffer->orig; - GLuint clipL = b->x1 - vmesa->drawX; - GLuint clipR = b->x2 - vmesa->drawX; - GLuint clipT = b->y1 - vmesa->drawY; - GLuint clipB = b->y2 - vmesa->drawY; - + if (0) + fprintf(stderr, "emit cliprect for box %d,%d %d,%d\n", b->x1, b->y1, b->x2, b->y2); + vb[0] = HC_HEADER2; vb[1] = (HC_ParaType_NotTex << 16); @@ -508,8 +506,8 @@ static void via_emit_cliprect(viaContextPtr vmesa, vb[3] = (HC_SubA_HClipLR << 24) | 0x0; } else { - vb[2] = (HC_SubA_HClipTB << 24) | (clipT << 12) | clipB; - vb[3] = (HC_SubA_HClipLR << 24) | (clipL << 12) | clipR; + vb[2] = (HC_SubA_HClipTB << 24) | (b->y1 << 12) | b->y2; + vb[3] = (HC_SubA_HClipLR << 24) | (b->x1 << 12) | b->x2; } vb[4] = ((HC_SubA_HDBBasL << 24) | (offset & 0xFFFFFF)); @@ -525,6 +523,11 @@ static int intersect_rect(drm_clip_rect_t *out, drm_clip_rect_t *b) { *out = *a; + + if (0) + fprintf(stderr, "intersect %d,%d %d,%d and %d,%d %d,%d\n", + a->x1, a->y1, a->x2, a->y2, + b->x1, b->y1, b->x2, b->y2); if (b->x1 > out->x1) out->x1 = b->x1; if (b->x2 < out->x2) out->x2 = b->x2; @@ -557,6 +560,9 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags) int i; RING_VARS; + if (VIA_DEBUG) + fprintf(stderr, "%s\n", __FUNCTION__); + if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) && *(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) { fprintf(stderr, "%s called without lock held\n", __FUNCTION__); @@ -622,35 +628,42 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags) dump_dma( vmesa ); if (flags & VIA_NO_CLIPRECTS) { + if (0) fprintf(stderr, "%s VIA_NO_CLIPRECTS\n", __FUNCTION__); assert(vmesa->dmaCliprectAddr == 0); fire_buffer( vmesa ); } else if (!vmesa->dmaCliprectAddr) { /* Contains only state. Could just dump the packet? */ - if (0) fprintf(stderr, "no dmaCliprectAddr\n"); + if (0) fprintf(stderr, "%s: no dmaCliprectAddr\n", __FUNCTION__); if (0) fire_buffer( vmesa ); } else if (vmesa->numClipRects) { - int ret; drm_clip_rect_t *pbox = vmesa->pClipRects; + if (0) fprintf(stderr, "%s: %d cliprects\n", __FUNCTION__, vmesa->numClipRects); for (i = 0; i < vmesa->numClipRects; i++) { - if (vmesa->glCtx->Scissor.Enabled) { - drm_clip_rect_t b; - if (!intersect_rect(&b, &pbox[i], &vmesa->scissorRect)) - continue; - via_emit_cliprect(vmesa, &b); - } - else { - via_emit_cliprect(vmesa, &pbox[i]); - } - - ret = fire_buffer(vmesa); - if (ret) + drm_clip_rect_t b; + + b.x1 = pbox[i].x1 - (vmesa->drawX + vmesa->drawXoff); + b.x2 = pbox[i].x2 - (vmesa->drawX + vmesa->drawXoff); + b.y1 = pbox[i].y1 - vmesa->drawY; + b.y2 = pbox[i].y2 - vmesa->drawY; + + if (vmesa->glCtx->Scissor.Enabled && + !intersect_rect(&b, &b, &vmesa->scissorRect)) + continue; + + b.x1 += vmesa->drawXoff; + b.x2 += vmesa->drawXoff; + + via_emit_cliprect(vmesa, &b); + + if (fire_buffer(vmesa) != 0) goto done; } } else { + if (0) fprintf(stderr, "%s: no cliprects\n", __FUNCTION__); UNLOCK_HARDWARE(vmesa); sched_yield(); LOCK_HARDWARE(vmesa); @@ -742,6 +755,9 @@ GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int li GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes) { + if (0) + fprintf(stderr, "%s %d\n", __FUNCTION__, bytes); + assert(vmesa->dmaLastPrim); if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) { viaWrapPrimitive(vmesa); diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index fe1007bb1a7..dc22d2ceccd 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -615,7 +615,8 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y, if (!vmesa->driDrawable) return; - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); + if (VIA_DEBUG) + fprintf(stderr, "%s %d,%d %dx%d, drawH %d\n", __FUNCTION__, x,y,w,h, vmesa->driDrawable->h); if (ctx->Scissor.Enabled) { VIA_FLUSH_DMA(vmesa); /* don't pipeline cliprect changes */ @@ -628,6 +629,19 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y, if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); } +static void viaEnable(GLcontext *ctx, GLenum cap, GLboolean state) +{ + viaContextPtr vmesa = VIA_CONTEXT(ctx); + + switch (cap) { + case GL_SCISSOR_TEST: + VIA_FLUSH_DMA(vmesa); + break; + default: + break; + } +} + /* Fallback to swrast for select and feedback. @@ -1612,6 +1626,7 @@ void viaInitStateFuncs(GLcontext *ctx) ctx->Driver.Scissor = viaScissor; ctx->Driver.DepthRange = viaDepthRange; ctx->Driver.Viewport = viaViewport; + ctx->Driver.Enable = viaEnable; /* Pixel path fallbacks. */ diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c index 8c16d01000e..5f801748e38 100644 --- a/src/mesa/drivers/dri/unichrome/via_tris.c +++ b/src/mesa/drivers/dri/unichrome/via_tris.c @@ -790,9 +790,11 @@ static void viaRenderPrimitive( GLcontext *ctx, GLuint prim ) void viaFinishPrimitive(viaContextPtr vmesa) { - if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__); + if (VIA_DEBUG) + fprintf(stderr, "%s\n", __FUNCTION__); - if (!vmesa->dmaLastPrim) { + if (!vmesa->dmaLastPrim || !vmesa->dmaCliprectAddr) { + assert(0); } else if (vmesa->dmaLow != vmesa->dmaLastPrim) { GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK; @@ -818,6 +820,9 @@ void viaFinishPrimitive(viaContextPtr vmesa) viaFlushDma( vmesa ); } else { + if (VIA_DEBUG) + fprintf(stderr, "remove empty primitive\n"); + /* Remove the primitive header: */ vmesa->dmaLastPrim = 0; -- cgit v1.2.3