Proper fence reference counting.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Fri, 16 Nov 2007 17:36:35 +0000 (17:36 +0000)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Sat, 17 Nov 2007 15:39:36 +0000 (15:39 +0000)
src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
src/mesa/pipe/i915simple/i915_batch.h
src/mesa/pipe/i915simple/i915_context.c
src/mesa/pipe/i915simple/i915_winsys.h

index 7713d6e48d0838a0a80751a9cb5ccefd830ac0c3..eea8c0be1819ba19f8295e58f48c0f9291edf321 100644 (file)
@@ -111,12 +111,19 @@ static void intel_i915_batch_reloc( struct i915_winsys *sws,
 
 
 
-static struct pipe_fence *
-intel_i915_batch_flush( struct i915_winsys *sws )
+static void
+intel_i915_batch_flush( struct i915_winsys *sws, 
+                        struct pipe_fence **fence )
 {
    struct intel_context *intel = intel_i915_winsys(sws)->intel;
-
-   return pipe_fo(intel_batchbuffer_flush( intel->batch ));
+   struct pipe_fence *tmp_fence;
+   
+   tmp_fence = pipe_fo(intel_batchbuffer_flush( intel->batch ));
+   
+   /* this also increases the fence reference count, which is not done inside
+    * intel_batchbuffer_flush call above
+    */
+   sws->fence_reference(sws, fence, tmp_fence);
 }
 
 
@@ -143,14 +150,10 @@ intel_i915_fence_is_signalled( struct i915_winsys *sws,
                                struct pipe_fence *fence )
 {
    struct _DriFenceObject *dri_fence = dri_fo(fence);
-   int ret = 1;
-   if (fence) {
-      driFenceReference(dri_fence);
-      ret = driFenceSignaled(dri_fence,
+   if (fence)
+      return driFenceSignaled(dri_fence,
                        DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW);
-      driFenceUnReference(dri_fence);
-   }
-   return ret;
+   return 1;
 }
 
 
@@ -159,13 +162,10 @@ intel_i915_fence_wait( struct i915_winsys *sws,
                        struct pipe_fence *fence )
 {
    struct _DriFenceObject *dri_fence = dri_fo(fence);
-   if (fence) {
-      driFenceReference(dri_fence);
+   if (fence)
       driFenceFinish(dri_fence,
                      DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW,
                      GL_FALSE);
-      driFenceUnReference(dri_fence);
-   }
    return 1;
 }
 
index 99b03c37db15e05f49f1aa791f0151216929a119..603d193f626327b78acd45922286dce5833c972e 100644 (file)
@@ -46,7 +46,7 @@
 
 #define FLUSH_BATCH() do {                                             \
    if (0) i915_dump_batchbuffer( i915 );                               \
-   i915->last_fence = i915->winsys->batch_flush( i915->winsys );       \
+   i915->winsys->batch_flush( i915->winsys, &i915->last_fence );       \
    i915->batch_start = NULL;                                           \
    i915->hardware_dirty = ~0;                                          \
 } while (0)
index e43274dc6674539131ef280a135c110a45aa5139..f5d770ce0dfd1d184b73ad78b1f7beba0a7b4180 100644 (file)
@@ -175,6 +175,8 @@ static void i915_destroy( struct pipe_context *pipe )
 
    draw_destroy( i915->draw );
 
+   i915->winsys->fence_reference( i915->winsys, &i915->last_fence, NULL );
+   
    free( i915 );
 }
 
index 03457c1d61c3b0d154a8de92fb64082703a59fd6..386ed745d373e6fffc6758ce1f5a1b6eae703930 100644 (file)
@@ -98,7 +98,14 @@ struct i915_winsys {
                        unsigned access_flags,
                        unsigned delta );
    
-   struct pipe_fence *(*batch_flush)( struct i915_winsys *sws );
+   /**
+    * Flush the batch buffer.
+    * 
+    * Fence argument must point to NULL or to a previous fence, and the caller 
+    * must call fence_reference when done with the fence.
+    */
+   void (*batch_flush)( struct i915_winsys *sws,
+                        struct pipe_fence **fence );
 
 
    /* Fence