[Mesa-dev] [PATCH 04/33] intel: Return error value from intel_batchbuffer_flush().

Eric Anholt eric at anholt.net
Mon Oct 24 14:16:51 PDT 2011


This will let the caller do something sensible on error, if it cares.
---
 src/mesa/drivers/dri/intel/intel_batchbuffer.c |   14 ++++++++++----
 src/mesa/drivers/dri/intel/intel_batchbuffer.h |    4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 2d99eec..6991db8 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -120,7 +120,7 @@ intel_batchbuffer_free(struct intel_context *intel)
 
 /* TODO: Push this whole function into bufmgr.
  */
-static void
+static int
 do_flush_locked(struct intel_context *intel)
 {
    struct intel_batchbuffer *batch = &intel->batch;
@@ -163,12 +163,16 @@ do_flush_locked(struct intel_context *intel)
       exit(1);
    }
    intel->vtbl.new_batch(intel);
+
+   return ret;
 }
 
-void
+int
 _intel_batchbuffer_flush(struct intel_context *intel,
 			 const char *file, int line)
 {
+   int ret;
+
    /* No batch should be emitted that uses a mapped region, because that would
     * cause the map to be incoherent with GPU rendering done by the
     * batchbuffer. To ensure that condition, we assert a condition that is
@@ -177,7 +181,7 @@ _intel_batchbuffer_flush(struct intel_context *intel,
    assert(intel->num_mapped_regions == 0);
 
    if (intel->batch.used == 0)
-      return;
+      return 0;
 
    if (intel->first_post_swapbuffers_batch == NULL) {
       intel->first_post_swapbuffers_batch = intel->batch.bo;
@@ -205,7 +209,7 @@ _intel_batchbuffer_flush(struct intel_context *intel,
    /* Check that we didn't just wrap our batchbuffer at a bad time. */
    assert(!intel->no_batch_wrap);
 
-   do_flush_locked(intel);
+   ret = do_flush_locked(intel);
 
    if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
       fprintf(stderr, "waiting for idle\n");
@@ -215,6 +219,8 @@ _intel_batchbuffer_flush(struct intel_context *intel,
    /* Reset the buffer:
     */
    intel_batchbuffer_reset(intel);
+
+   return ret;
 }
 
 
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index 228c32d..e5e5bd4 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -15,8 +15,8 @@ void intel_batchbuffer_free(struct intel_context *intel);
 void intel_batchbuffer_save_state(struct intel_context *intel);
 void intel_batchbuffer_reset_to_saved(struct intel_context *intel);
 
-void _intel_batchbuffer_flush(struct intel_context *intel,
-			      const char *file, int line);
+int _intel_batchbuffer_flush(struct intel_context *intel,
+			     const char *file, int line);
 
 #define intel_batchbuffer_flush(intel) \
 	_intel_batchbuffer_flush(intel, __FILE__, __LINE__)
-- 
1.7.7



More information about the mesa-dev mailing list