+ via_release_pending_textures(vmesa);
+}
+
+
+void viaWaitIdleLocked( struct via_context *vmesa, GLboolean light )
+{
+ if (vmesa->dmaLow)
+ viaFlushDmaLocked(vmesa, 0);
+
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n",
+ __FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite);
+
+ /* Need to emit a new breadcrumb?
+ */
+ if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) {
+ viaEmitBreadcrumbLocked( vmesa );
+ }
+
+ /* Need to wait?
+ */
+ if (vmesa->lastDma >= vmesa->lastBreadcrumbRead)
+ viaWaitBreadcrumb( vmesa, vmesa->lastDma );
+
+ if (light) return;
+
+ while(!viaCheckIdle(vmesa))
+ ;
+
+ via_release_pending_textures(vmesa);
+}
+
+
+
+/* Wait for command stream to be processed *and* the next vblank to
+ * occur. Equivalent to calling WAIT_IDLE() and then WaitVBlank,
+ * except that WAIT_IDLE() will spin the CPU polling, while this is
+ * IRQ driven.
+ */
+static void viaWaitIdleVBlank( __DRIdrawablePrivate *dPriv,
+ struct via_context *vmesa,
+ GLuint value )
+{
+ GLboolean missed_target;
+ __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+
+ VIA_FLUSH_DMA(vmesa);
+
+ if (!value)
+ return;
+
+ do {
+ if (value < vmesa->lastBreadcrumbRead ||
+ vmesa->thrashing)
+ viaSwapOutWork(vmesa);
+
+ driWaitForVBlank( dPriv, & missed_target );
+ if ( missed_target ) {
+ vmesa->swap_missed_count++;
+ (*psp->systemTime->getUST)( &vmesa->swap_missed_ust );
+ }
+ }
+ while (!viaCheckBreadcrumb(vmesa, value));
+
+ vmesa->thrashing = 0; /* reset flag on swap */
+ vmesa->swap_count++;
+ via_release_pending_textures( vmesa );