- Flush before updating the timestamp of a texture heap from a bound texture.
authorFelix Kuehling <fxkuehl@gmx.de>
Thu, 10 Mar 2005 22:45:00 +0000 (22:45 +0000)
committerFelix Kuehling <fxkuehl@gmx.de>
Thu, 10 Mar 2005 22:45:00 +0000 (22:45 +0000)
- Flush before using a new texture or before disabling a texture unit,
  because savageFlushCmdBuf can only update the timestamp of the last
  used texture. This fixes corruption in quake2 with single-textured
  lighting.

src/mesa/drivers/dri/savage/savagetex.c

index 1b5b7901b584b642c21ade014e710b188dd3ca0f..568b5c4e7a5966511b6b447aab74cc852b3d8eb8 100644 (file)
@@ -1407,6 +1407,15 @@ static void savageUpdateTexState_s3d( GLcontext *ctx )
 static void savageUpdateTextureState_s4( GLcontext *ctx )
 {
    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+   if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled &&
+       ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) ||
+       (imesa->CurrentTexObj[1] && ctx->Texture.Unit[1]._ReallyEnabled &&
+       ctx->Texture.Unit[1]._Current->DriverData != imesa->CurrentTexObj[1]) ||
+       (imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled) ||
+       (imesa->CurrentTexObj[1] && !ctx->Texture.Unit[1]._ReallyEnabled))
+       FLUSH_BATCH(imesa);
+
    if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
    if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound &= ~2;
    imesa->CurrentTexObj[0] = 0;
@@ -1419,6 +1428,12 @@ static void savageUpdateTextureState_s4( GLcontext *ctx )
 static void savageUpdateTextureState_s3d( GLcontext *ctx )
 {
     savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+    if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled &&
+        ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) ||
+       (imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled))
+       FLUSH_BATCH(imesa);
+
     if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
     imesa->CurrentTexObj[0] = 0;
     savageUpdateTexState_s3d( ctx );
@@ -1472,13 +1487,16 @@ static void savageTexEnv( GLcontext *ctx, GLenum target,
 
 /* Update a heap's timestamp when a texture image is modified, so the
  * new image is not uploaded while the old one is still in use.
- * FIXME: this should be moved to ../common/texmem.c 
  */
 static void savageTexImageChanged (savageTexObjPtr t) {
     /* Update the heap's time stamp, so the new image is not uploaded
      * while the old one is still in use. */
-    if (t->base.heap && t->base.timestamp > t->base.heap->timestamp)
-       t->base.heap->timestamp = t->base.timestamp;
+    if (t->base.heap) {
+       if (t->base.bound)
+           FLUSH_BATCH((savageContextPtr)t->base.heap->driverContext);
+       if (t->base.timestamp > t->base.heap->timestamp)
+           t->base.heap->timestamp = t->base.timestamp;
+    }
 }
 
 static void savageTexImage1D( GLcontext *ctx, GLenum target, GLint level,