aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFelix Kuehling <[email protected]>2005-03-14 21:52:46 +0000
committerFelix Kuehling <[email protected]>2005-03-14 21:52:46 +0000
commitbd5bba84705fd96ebf11493130d54e547a83d0fc (patch)
tree738aedd40b5ea5c325c00e0c9fe57ef426f53190 /src
parente2e4a5c992c7655cdd4374b962d339ec62bb5f5c (diff)
When timestamping textures, need to emit the event with SAVAGE_WAIT_3D
set. Otherwise the 3D engine may still be using a texture that is being overwritten. In order to minimize the cost of waiting, timestamp textures only when needed: when a texture image changes, when a different texture is bound to a texture unit or when a texture unit is disabled. (Used to be after flushing every command buffer.)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/savage/savageioctl.c12
-rw-r--r--src/mesa/drivers/dri/savage/savagetex.c56
2 files changed, 41 insertions, 27 deletions
diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c
index 9f3a028428f..e68f58cccf4 100644
--- a/src/mesa/drivers/dri/savage/savageioctl.c
+++ b/src/mesa/drivers/dri/savage/savageioctl.c
@@ -605,18 +605,6 @@ void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
imesa->cmdBuf.write = imesa->cmdBuf.base;
savageEmitOldState(imesa);
imesa->cmdBuf.start = imesa->cmdBuf.write;
-
- /* Timestamp current texture objects for texture heap aging.
- * Only useful with long-lived 32-bit event tags available
- * with Savage DRM 2.3.x or later. */
- if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) &&
- imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
- unsigned int e = savageEmitEventLocked(imesa, 0);
- if (imesa->CurrentTexObj[0])
- imesa->CurrentTexObj[0]->timestamp = e;
- if (imesa->CurrentTexObj[1])
- imesa->CurrentTexObj[1]->timestamp = e;
- }
}
if (discard) {
diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c
index 568b5c4e7a5..934b6e2b3c5 100644
--- a/src/mesa/drivers/dri/savage/savagetex.c
+++ b/src/mesa/drivers/dri/savage/savagetex.c
@@ -767,17 +767,19 @@ static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t )
if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX)
fprintf(stderr, "Texture upload: |");
- savageFlushVertices (imesa);
- LOCK_HARDWARE(imesa);
- savageFlushCmdBufLocked (imesa, GL_FALSE);
/* Heap timestamps are only reliable with Savage DRM 2.3.x or
* later. Earlier versions had only 16 bit time stamps which
* would wrap too frequently. */
if (imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
unsigned int heap = t->base.heap->heapId;
+ LOCK_HARDWARE(imesa);
savageWaitEvent (imesa, imesa->textureHeaps[heap]->timestamp);
- } else
+ } else {
+ savageFlushVertices (imesa);
+ LOCK_HARDWARE(imesa);
+ savageFlushCmdBufLocked (imesa, GL_FALSE);
WAIT_IDLE_EMPTY_LOCKED(imesa);
+ }
for (i = 0 ; i < numLevels ; i++) {
const GLint j = t->base.firstLevel + i; /* the texObj's level */
@@ -1403,18 +1405,39 @@ static void savageUpdateTexState_s3d( GLcontext *ctx )
}
+static void savageTimestampTextures( savageContextPtr imesa )
+{
+ /* Timestamp current texture objects for texture heap aging.
+ * Only useful with long-lived 32-bit event tags available
+ * with Savage DRM 2.3.x or later. */
+ if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) &&
+ imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
+ unsigned int e;
+ FLUSH_BATCH(imesa);
+ e = savageEmitEvent(imesa, SAVAGE_WAIT_3D);
+ if (imesa->CurrentTexObj[0])
+ imesa->CurrentTexObj[0]->timestamp = e;
+ if (imesa->CurrentTexObj[1])
+ imesa->CurrentTexObj[1]->timestamp = e;
+ }
+}
+
static void savageUpdateTextureState_s4( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ /* When a texture is about to change or be disabled, timestamp the
+ * old texture(s). We'll have to wait for this time stamp before
+ * uploading anything to the same texture heap.
+ */
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);
+ savageTimestampTextures(imesa);
if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound &= ~2;
@@ -1429,10 +1452,14 @@ static void savageUpdateTextureState_s3d( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ /* When a texture is about to change or be disabled, timestamp the
+ * old texture(s). We'll have to wait for this time stamp before
+ * uploading anything to the same texture heap.
+ */
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);
+ savageTimestampTextures(imesa);
if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
imesa->CurrentTexObj[0] = 0;
@@ -1485,15 +1512,15 @@ 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.
- */
+/* Update the heap's time stamp, so the new image is not uploaded
+ * while the old one is still in use. If the texture that is going to
+ * be changed is currently bound, we need to timestamp the texture
+ * first. */
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) {
if (t->base.bound)
- FLUSH_BATCH((savageContextPtr)t->base.heap->driverContext);
+ savageTimestampTextures(
+ (savageContextPtr)t->base.heap->driverContext);
if (t->base.timestamp > t->base.heap->timestamp)
t->base.heap->timestamp = t->base.timestamp;
}
@@ -1662,9 +1689,8 @@ static void savageDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
if (t) {
- if (t->bound) {
- FLUSH_BATCH(imesa);
- }
+ if (t->bound)
+ savageTimestampTextures(imesa);
driDestroyTextureObject(t);
}