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.
parent 6f5df0c0
......@@ -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,
......
......@@ -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
......
......@@ -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++)
......
......@@ -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++)
......
......@@ -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);
......
......@@ -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))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment