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 */
}
+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;
{
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;
}
}
-/* 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;
}
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
if (t) {
- if (t->bound) {
- FLUSH_BATCH(imesa);
- }
+ if (t->bound)
+ savageTimestampTextures(imesa);
driDestroyTextureObject(t);
}