[gegl] buffer: add gegl_buffer_flush_ext



commit e3b29ef5fa3d38a9f04747434ea077ee8719ee1b
Author: Øyvind Kolås <pippin gimp org>
Date:   Mon Sep 10 15:12:44 2018 +0200

    buffer: add gegl_buffer_flush_ext
    
    This is the call to be used externally where the explicit opencl cache
    flushing was used before. In code that uses opencl existing checks for
    opencl can be used around it - but do not have to, since it is a no-op
    with no flush_ext vfuncs set, like it is with no opencl in operation.

 gegl/buffer/gegl-buffer-access.c                |  9 +++++++++
 gegl/buffer/gegl-buffer.h                       | 14 ++++++++++++++
 gegl/operation/gegl-operation-point-composer.c  |  4 ++--
 gegl/operation/gegl-operation-point-composer3.c |  6 +++---
 gegl/operation/gegl-operation-point-filter.c    |  2 +-
 operations/transform/transform-core.c           |  3 +--
 6 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 76335ab7f..73eed6649 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -332,6 +332,15 @@ gegl_buffer_flush (GeglBuffer *buffer)
     g_rec_mutex_unlock (&buffer->tile_storage->mutex);
 }
 
+void
+gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglRectangle *rect)
+{
+  if (gegl_buffer_ext_flush)
+    gegl_buffer_ext_flush (buffer, rect);
+}
+
+
+
 static inline void
 gegl_buffer_iterate_write (GeglBuffer          *buffer,
                            const GeglRectangle *roi,
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index a7d502fe0..ff67b6737 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -699,6 +699,20 @@ glong gegl_buffer_signal_connect (GeglBuffer *buffer,
                                   GCallback   c_handler,
                                   gpointer    data);
 
+/**
+ * gegl_buffer_flush_ext:
+ * @buffer: a GeglBuffer
+ * @rect: rectangle
+ *
+ * Invokes the external flush function, if any is set on the provided buffer -
+ * this ensures that data pending - in the current implementation only OpenCL -
+ * externally to be synchronized with the buffer. Multi threaded code should
+ * call such a synchronization before branching out to avoid each of the
+ * threads having an implicit synchronization of its own.
+ */
+void
+gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglRectangle *rect);
+
 #include <gegl-buffer-iterator.h>
 
 G_END_DECLS
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index 86d550581..ddf64561c 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -370,9 +370,9 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
         if (gegl_cl_is_accelerated ())
         {
           if (input)
-            gegl_buffer_cl_cache_flush (input, result);
+            gegl_buffer_flush_ext (input, result);
           if (aux)
-            gegl_buffer_cl_cache_flush (aux, result);
+            gegl_buffer_flush_ext (aux, result);
         }
 
         for (gint j = 1; j < threads; j++)
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index 578d58d93..f54d2ace4 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -290,11 +290,11 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
         if (gegl_cl_is_accelerated ())
         {
           if (input)
-            gegl_buffer_cl_cache_flush (input, result);
+            gegl_buffer_flush_ext (input, result);
           if (aux)
-            gegl_buffer_cl_cache_flush (aux, result);
+            gegl_buffer_flush_ext (aux, result);
           if (aux2)
-            gegl_buffer_cl_cache_flush (aux2, result);
+            gegl_buffer_flush_ext (aux2, result);
         }
 
         for (gint j = 1; j < threads; j++)
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index c252b222b..399e6f39a 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -332,7 +332,7 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
         pending = threads;
 
         if (gegl_cl_is_accelerated () && input)
-          gegl_buffer_cl_cache_flush (input, result);
+          gegl_buffer_flush_ext (input, result);
 
         for (gint j = 1; j < threads; j++)
           g_thread_pool_push (pool, &thread_data[j], NULL);
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index 062a05813..aa67d46e4 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -1672,8 +1672,7 @@ gegl_transform_process (GeglOperation        *operation,
 
       /* flush opencl caches, to avoid racy flushing
        */
-      if (gegl_cl_is_accelerated ())
-        gegl_buffer_cl_cache_flush (input, NULL);
+      gegl_buffer_flush_ext (input, NULL);
 
       if (gegl_operation_use_threading (operation, result))
       {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]