summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorFelix Kuehling <fxkuehl@gmx.de>2005-02-05 21:21:02 +0000
committerFelix Kuehling <fxkuehl@gmx.de>2005-02-05 21:21:02 +0000
commit5bdf2bc6c707f0a815cc46fb0bab7e2a209110a3 (patch)
treee7e44f784eb033ab47c7bba84dcdd99560d7e7a5 /src/mesa/drivers/dri
parentd9d972a944c9953d99ff09deeb2a739386aa0a76 (diff)
- Fixed scissor rectangle not moving with the window (Xorg bug #1731).
- Flush buffered primitives before changing scissors. - Require Savage DRM version 2.1.0, so that the broken single-cliprect code can finally rest in peace. - Removed some more dead code.
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/savage/savage_init.h2
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c13
-rw-r--r--src/mesa/drivers/dri/savage/savagecontext.h13
-rw-r--r--src/mesa/drivers/dri/savage/savageioctl.c17
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.c159
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.h1
6 files changed, 47 insertions, 158 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_init.h b/src/mesa/drivers/dri/savage/savage_init.h
index 74b40d8729..9cf8e66b7c 100644
--- a/src/mesa/drivers/dri/savage/savage_init.h
+++ b/src/mesa/drivers/dri/savage/savage_init.h
@@ -83,8 +83,6 @@ typedef struct {
#include "savagecontext.h"
extern void savageGetLock( savageContextPtr imesa, GLuint flags );
-extern void savageEmitScissorValues( savageContextPtr imesa, int box_nr, int emit );
-extern void savageEmitDrawingRectangle( savageContextPtr imesa );
extern void savageXMesaSetBackClipRects( savageContextPtr imesa );
extern void savageXMesaSetFrontClipRects( savageContextPtr imesa );
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 9abb558471..38f679aee3 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -601,11 +601,10 @@ void savageXMesaSetFrontClipRects( savageContextPtr imesa )
imesa->numClipRects = dPriv->numClipRects;
imesa->pClipRects = dPriv->pClipRects;
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
imesa->drawX = dPriv->x;
imesa->drawY = dPriv->y;
- savageEmitDrawingRectangle( imesa );
+ savageCalcViewport( imesa->glCtx );
}
@@ -630,10 +629,7 @@ void savageXMesaSetBackClipRects( savageContextPtr imesa )
imesa->drawY = dPriv->backY;
}
- savageEmitDrawingRectangle( imesa );
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
-
-
+ savageCalcViewport( imesa->glCtx );
}
@@ -769,8 +765,7 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
SAVAGE_UPLOAD_FOGTBL |
SAVAGE_UPLOAD_TEX0 |
SAVAGE_UPLOAD_TEX1 |
- SAVAGE_UPLOAD_TEXGLOBAL |
- SAVAGE_UPLOAD_CLIPRECTS);
+ SAVAGE_UPLOAD_TEXGLOBAL);
imesa->lostContext = GL_TRUE;
sarea->ctxOwner = me;
}
@@ -929,7 +924,7 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 2, 0, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
- static const __DRIversion drm_expected = { 2, 0, 0 };
+ static const __DRIversion drm_expected = { 2, 1, 0 };
if ( ! driCheckDriDdxDrmVersions2( "Savage",
dri_version, & dri_expected,
diff --git a/src/mesa/drivers/dri/savage/savagecontext.h b/src/mesa/drivers/dri/savage/savagecontext.h
index b2d47a4693..2e9671afd9 100644
--- a/src/mesa/drivers/dri/savage/savagecontext.h
+++ b/src/mesa/drivers/dri/savage/savagecontext.h
@@ -79,7 +79,6 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
#define SAVAGE_UPLOAD_FOGTBL 0x8 /* fog table */
#define SAVAGE_UPLOAD_GLOBAL 0x10 /* most global regs */
#define SAVAGE_UPLOAD_TEXGLOBAL 0x20 /* TexBlendColor (S4 only) */
-#define SAVAGE_UPLOAD_CLIPRECTS 0x1000 /* FIXME: get rid of this */
/*define the max numer of vertex in vertex buf*/
#define SAVAGE_MAX_VERTEXS 0x10000
@@ -263,10 +262,14 @@ struct savage_context_t {
GLuint dirtyAge;
GLuint any_contend; /* throttle me harder */
- GLuint scissor;
- GLboolean scissorChanged;
- drm_clip_rect_t draw_rect;
- drm_clip_rect_t scissor_rect;
+ /* Scissor state needs to be mirrored so buffered commands can be
+ * emitted with the old scissor state when scissor state changes.
+ */
+ struct {
+ GLboolean enabled;
+ GLint x, y;
+ GLsizei w, h;
+ } scissor;
drm_context_t hHWContext;
drm_hw_lock_t *driHwLock;
diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c
index 51faea0295..cd25b620f0 100644
--- a/src/mesa/drivers/dri/savage/savageioctl.c
+++ b/src/mesa/drivers/dri/savage/savageioctl.c
@@ -401,8 +401,6 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
cmd[1].clear1.mask = depthMask;
cmd[1].clear1.value = clearDepth;
}
-
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
}
if (mask)
@@ -562,16 +560,25 @@ void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
cmdbuf.vb_stride = imesa->HwVertexSize;
cmdbuf.cmd_addr = start;
cmdbuf.size = (imesa->cmdBuf.write - start);
- if (!imesa->inSwap && imesa->glCtx->Scissor.Enabled) {
+ if (!imesa->inSwap && imesa->scissor.enabled) {
drm_clip_rect_t *box = dPriv->pClipRects, *ibox;
+ drm_clip_rect_t scissor;
GLuint nbox = dPriv->numClipRects, nibox;
+ /* transform and clip scissor to viewport */
+ scissor.x1 = MAX2(imesa->scissor.x, 0) + dPriv->x;
+ scissor.y1 = MAX2(dPriv->h - imesa->scissor.y - imesa->scissor.h,
+ 0) + dPriv->y;
+ scissor.x2 = MIN2(imesa->scissor.x + imesa->scissor.w,
+ dPriv->w) + dPriv->x;
+ scissor.y2 = MIN2(dPriv->h - imesa->scissor.y,
+ dPriv->h) + dPriv->y;
+ /* intersect cliprects with scissor */
ibox = malloc(dPriv->numClipRects*sizeof(drm_clip_rect_t));
if (!ibox) {
fprintf(stderr, "Out of memory.\n");
exit(1);
}
- nibox = savageIntersectClipRects(ibox, box, nbox,
- &imesa->scissor_rect);
+ nibox = savageIntersectClipRects(ibox, box, nbox, &scissor);
cmdbuf.nbox = nibox;
cmdbuf.box_addr = ibox;
} else {
diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c
index b86586c8b8..b417d1e2aa 100644
--- a/src/mesa/drivers/dri/savage/savagestate.c
+++ b/src/mesa/drivers/dri/savage/savagestate.c
@@ -632,19 +632,18 @@ static void savageDDDepthMask_s3d(GLcontext *ctx, GLboolean flag)
static void savageDDScissor( GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h )
-{
+{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
- imesa->scissor_rect.x1 = MAX2(imesa->drawX+x,imesa->draw_rect.x1);
- imesa->scissor_rect.y1 = MAX2(imesa->drawY+imesa->driDrawable->h -(y+h),
- imesa->draw_rect.y1);
- imesa->scissor_rect.x2 = MIN2(imesa->drawX+x+w,imesa->draw_rect.x2);
- imesa->scissor_rect.y2 = MIN2(imesa->drawY+imesa->driDrawable->h - y,
- imesa->draw_rect.y2);
-
- imesa->scissorChanged=GL_TRUE;
+ /* Emit buffered commands with old scissor state. */
+ FLUSH_BATCH(imesa);
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
+ /* Mirror scissors in private context. */
+ imesa->scissor.enabled = ctx->Scissor.Enabled;
+ imesa->scissor.x = x;
+ imesa->scissor.y = y;
+ imesa->scissor.w = w;
+ imesa->scissor.h = h;
}
@@ -706,7 +705,7 @@ static void savageDDSetColor(GLcontext *ctx,
* Window position and viewport transformation
*/
-static void savageCalcViewport( GLcontext *ctx )
+void savageCalcViewport( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -1196,8 +1195,6 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
savageDDDepthFunc_s4(ctx,ctx->Depth.Func);
break;
case GL_SCISSOR_TEST:
- imesa->scissor = state;
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
savageDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height);
break;
@@ -1288,8 +1285,6 @@ static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
savageDDDepthFunc_s3d(ctx,ctx->Depth.Func);
break;
case GL_SCISSOR_TEST:
- imesa->scissor = state;
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
savageDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height);
break;
@@ -1359,64 +1354,9 @@ void savageDDUpdateHwState( GLcontext *ctx )
}
-void savageEmitDrawingRectangle( savageContextPtr imesa )
-{
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
- savageScreenPrivate *savageScreen = imesa->savageScreen;
- drm_clip_rect_t *pbox;
- int nbox;
-
-
- int x0 = imesa->drawX;
- int y0 = imesa->drawY;
- int x1 = x0 + dPriv->w;
- int y1 = y0 + dPriv->h;
-
- pbox = dPriv->pClipRects;
- nbox = dPriv->numClipRects;
-
-
-
- /* Coordinate origin of the window - may be offscreen.
- */
- /* imesa->BufferSetup[SAVAGE_DESTREG_DR4] = ((y0<<16) |
- (((unsigned)x0)&0xFFFF));*/
-
- /* Clip to screen.
- */
- if (x0 < 0) x0 = 0;
- if (y0 < 0) y0 = 0;
- if (x1 > savageScreen->width) x1 = savageScreen->width;
- if (y1 > savageScreen->height) y1 = savageScreen->height;
-
-
- if(nbox == 1)
- {
- imesa->draw_rect.x1 = MAX2(x0,pbox->x1);
- imesa->draw_rect.y1 = MAX2(y0,pbox->y1);
- imesa->draw_rect.x2 = MIN2(x1,pbox->x2);
- imesa->draw_rect.y2 = MIN2(y1,pbox->y2);
- }
- else
- {
- imesa->draw_rect.x1 = x0;
- imesa->draw_rect.y1 = y0;
- imesa->draw_rect.x2 = x1;
- imesa->draw_rect.y2 = y1;
- }
-
- imesa->scissorChanged = GL_TRUE;
-
- /* imesa->regs.ni.changed.ni.fDrawCtrl0Changed=GL_TRUE;
- imesa->regs.ni.changed.ni.fDrawCtrl1Changed=GL_TRUE;*/
-
- savageCalcViewport (imesa->glCtx);
-}
-
-
static void savageDDPrintDirty( const char *msg, GLuint state )
{
- fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n",
+ fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s\n",
msg,
(unsigned int) state,
(state & SAVAGE_UPLOAD_LOCAL) ? "upload-local, " : "",
@@ -1424,8 +1364,7 @@ static void savageDDPrintDirty( const char *msg, GLuint state )
(state & SAVAGE_UPLOAD_TEX1) ? "upload-tex1, " : "",
(state & SAVAGE_UPLOAD_FOGTBL) ? "upload-fogtbl, " : "",
(state & SAVAGE_UPLOAD_GLOBAL) ? "upload-global, " : "",
- (state & SAVAGE_UPLOAD_TEXGLOBAL) ? "upload-texglobal, " : "",
- (state & SAVAGE_UPLOAD_CLIPRECTS) ? "upload-cliprects, " : ""
+ (state & SAVAGE_UPLOAD_TEXGLOBAL) ? "upload-texglobal, " : ""
);
}
@@ -1504,28 +1443,6 @@ static void savageEmitChangedRegChunk (savageContextPtr imesa,
}
static void savageUpdateRegister_s4(savageContextPtr imesa)
{
- /*
- * Scissors updates drawctrl0 and drawctrl 1
- */
- if (imesa->scissorChanged && imesa->savageScreen->driScrnPriv->drmMinor < 1)
- {
- if(imesa->scissor)
- {
- imesa->regs.s4.drawCtrl0.ni.scissorXStart = imesa->scissor_rect.x1;
- imesa->regs.s4.drawCtrl0.ni.scissorYStart = imesa->scissor_rect.y1;
- imesa->regs.s4.drawCtrl1.ni.scissorXEnd = imesa->scissor_rect.x2-1;
- imesa->regs.s4.drawCtrl1.ni.scissorYEnd = imesa->scissor_rect.y2-1;
- }
- else
- {
- imesa->regs.s4.drawCtrl0.ni.scissorXStart = imesa->draw_rect.x1;
- imesa->regs.s4.drawCtrl0.ni.scissorYStart = imesa->draw_rect.y1;
- imesa->regs.s4.drawCtrl1.ni.scissorXEnd = imesa->draw_rect.x2-1;
- imesa->regs.s4.drawCtrl1.ni.scissorYEnd = imesa->draw_rect.y2-1;
- }
- imesa->scissorChanged = GL_FALSE;
- }
-
/* the savage4 uses the contiguous range of BCI registers 0x1e-0x39
* 0x1e-0x27 are local, no need to check them for global changes */
savageEmitChangedRegs (imesa, 0x1e, 0x39);
@@ -1534,33 +1451,6 @@ static void savageUpdateRegister_s4(savageContextPtr imesa)
}
static void savageUpdateRegister_s3d(savageContextPtr imesa)
{
- if (imesa->scissorChanged && imesa->savageScreen->driScrnPriv->drmMinor < 1)
- {
- if(imesa->scissor)
- {
- imesa->regs.s3d.scissorsStart.ni.scissorXStart =
- imesa->scissor_rect.x1;
- imesa->regs.s3d.scissorsStart.ni.scissorYStart =
- imesa->scissor_rect.y1;
- imesa->regs.s3d.scissorsEnd.ni.scissorXEnd =
- imesa->scissor_rect.x2-1;
- imesa->regs.s3d.scissorsEnd.ni.scissorYEnd =
- imesa->scissor_rect.y2-1;
- }
- else
- {
- imesa->regs.s3d.scissorsStart.ni.scissorXStart =
- imesa->draw_rect.x1;
- imesa->regs.s3d.scissorsStart.ni.scissorYStart =
- imesa->draw_rect.y1;
- imesa->regs.s3d.scissorsEnd.ni.scissorXEnd =
- imesa->draw_rect.x2-1;
- imesa->regs.s3d.scissorsEnd.ni.scissorYEnd =
- imesa->draw_rect.y2-1;
- }
- imesa->scissorChanged = GL_FALSE;
- }
-
/* Some temporary hacks to workaround lockups. Not sure if they are
* still needed. But they work for now. */
imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
@@ -1597,22 +1487,17 @@ void savageEmitChangedState( savageContextPtr imesa )
if (SAVAGE_DEBUG & DEBUG_VERBOSE_API)
savageDDPrintDirty( "\n\n\nsavageEmitHwStateLocked", imesa->dirty );
- if (imesa->dirty & ~SAVAGE_UPLOAD_CLIPRECTS)
+ if (imesa->dirty)
{
- if (imesa->dirty & (SAVAGE_UPLOAD_GLOBAL | SAVAGE_UPLOAD_LOCAL |
- SAVAGE_UPLOAD_TEX0 | SAVAGE_UPLOAD_TEX1 |
- SAVAGE_UPLOAD_FOGTBL | SAVAGE_UPLOAD_TEXGLOBAL))
- {
- if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
- fprintf (stderr, "... emitting state\n");
- if (imesa->savageScreen->chipset >= S3_SAVAGE4)
- savageUpdateRegister_s4(imesa);
- else
- savageUpdateRegister_s3d(imesa);
- }
-
- imesa->dirty &= SAVAGE_UPLOAD_CLIPRECTS;
- }
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "... emitting state\n");
+ if (imesa->savageScreen->chipset >= S3_SAVAGE4)
+ savageUpdateRegister_s4(imesa);
+ else
+ savageUpdateRegister_s3d(imesa);
+ }
+
+ imesa->dirty = 0;
}
diff --git a/src/mesa/drivers/dri/savage/savagestate.h b/src/mesa/drivers/dri/savage/savagestate.h
index b1b402a184..5fe718d7a6 100644
--- a/src/mesa/drivers/dri/savage/savagestate.h
+++ b/src/mesa/drivers/dri/savage/savagestate.h
@@ -28,6 +28,7 @@
#include "savagecontext.h"
+void savageCalcViewport( GLcontext *ctx );
void savageEmitOldState( savageContextPtr imesa );
void savageEmitChangedState( savageContextPtr imesa );