intel: Implement glFinish() correctly by waiting on all previous rendering.
authorEric Anholt <eric@anholt.net>
Tue, 31 May 2011 19:32:06 +0000 (12:32 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 7 Jun 2011 17:46:04 +0000 (10:46 -0700)
Before, we were waiting for (most of) the current framebuffer to be
done, which is not quite the same thing.

src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_context.h

index 377989bcc149efb94463c68c0d4b5883539fc0cf..77edc3a6bfe8a5d5aac61792f4353ed5820c5b3e 100644 (file)
@@ -55,10 +55,12 @@ static void clear_cache( struct intel_context *intel )
 void
 intel_batchbuffer_reset(struct intel_context *intel)
 {
-   if (intel->batch.bo != NULL) {
-      drm_intel_bo_unreference(intel->batch.bo);
-      intel->batch.bo = NULL;
+   if (intel->batch.last_bo != NULL) {
+      drm_intel_bo_unreference(intel->batch.last_bo);
+      intel->batch.last_bo = NULL;
    }
+   intel->batch.last_bo = intel->batch.bo;
+
    clear_cache(intel);
 
    intel->batch.bo = drm_intel_bo_alloc(intel->bufmgr, "batchbuffer",
@@ -72,6 +74,7 @@ intel_batchbuffer_reset(struct intel_context *intel)
 void
 intel_batchbuffer_free(struct intel_context *intel)
 {
+   drm_intel_bo_unreference(intel->batch.last_bo);
    drm_intel_bo_unreference(intel->batch.bo);
    clear_cache(intel);
 }
index 2ea52c26106974abd26f032a4d49a09bac93a3fe..b6a017a876c10a5bd86e2a731e43a93fbabced30 100644 (file)
@@ -579,23 +579,13 @@ intel_glFlush(struct gl_context *ctx)
 void
 intelFinish(struct gl_context * ctx)
 {
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-   int i;
+   struct intel_context *intel = intel_context(ctx);
 
    intel_flush(ctx);
    intel_flush_front(ctx);
 
-   for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
-       struct intel_renderbuffer *irb;
-
-       irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
-
-       if (irb && irb->region && irb->region->buffer)
-         drm_intel_bo_wait_rendering(irb->region->buffer);
-   }
-   if (fb->_DepthBuffer) {
-      /* XXX: Wait on buffer idle */
-   }
+   if (intel->batch.last_bo)
+      drm_intel_bo_wait_rendering(intel->batch.last_bo);
 }
 
 void
index f599861cba8caf27d4810b843a2244bd1da80e5a..80dee4ef38e9743d3d287da24eb50ce138aededa 100644 (file)
@@ -177,7 +177,11 @@ struct intel_context
    int urb_size;
 
    struct intel_batchbuffer {
+      /** Current batchbuffer being queued up. */
       drm_intel_bo *bo;
+      /** Last BO submitted to the hardware.  Used for glFinish(). */
+      drm_intel_bo *last_bo;
+
       struct cached_batch_item *cached_items;
 
       uint16_t emit, total;