Mesa (master): intel: Implement glFinish() correctly by waiting on all previous rendering.
Eric Anholt
anholt at kemper.freedesktop.org
Tue Jun 7 17:46:33 UTC 2011
Module: Mesa
Branch: master
Commit: 23b6f9606dc247488835745668b3686218612536
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=23b6f9606dc247488835745668b3686218612536
Author: Eric Anholt <eric at anholt.net>
Date: Tue May 31 12:32:06 2011 -0700
intel: Implement glFinish() correctly by waiting on all previous rendering.
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 | 9 ++++++---
src/mesa/drivers/dri/intel/intel_context.c | 16 +++-------------
src/mesa/drivers/dri/intel/intel_context.h | 4 ++++
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 377989b..77edc3a 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -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);
}
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 2ea52c2..b6a017a 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -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
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index f599861..80dee4e 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -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;
More information about the mesa-commit
mailing list