[gegl] merge buffer's opencl cache in a sink operation
- From: Victor Matheus de Araujo Oliveira <vmaolive src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] merge buffer's opencl cache in a sink operation
- Date: Wed, 21 Mar 2012 18:02:01 +0000 (UTC)
commit ea9e56168a10ba7542f77c59b07e20646b44c690
Author: Victor Oliveira <victormatheus gmail com>
Date: Wed Mar 21 14:25:07 2012 -0300
merge buffer's opencl cache in a sink operation
gegl/buffer/gegl-buffer-cl-cache.c | 15 +++++++++------
gegl/buffer/gegl-buffer-iterator.c | 2 ++
gegl/operation/gegl-operation-sink.c | 3 +++
3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-cl-cache.c b/gegl/buffer/gegl-buffer-cl-cache.c
index 049ffdc..675139b 100644
--- a/gegl/buffer/gegl-buffer-cl-cache.c
+++ b/gegl/buffer/gegl-buffer-cl-cache.c
@@ -70,6 +70,8 @@ gegl_buffer_cl_cache_new (GeglBuffer *buffer,
g_static_mutex_unlock (&cache_mutex);
}
+#define CL_ERROR {g_printf("[OpenCL] Error in %s:%d %s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(cl_err)); goto error;}
+
gboolean
gegl_buffer_cl_cache_merge (GeglBuffer *buffer,
const GeglRectangle *roi)
@@ -79,6 +81,9 @@ gegl_buffer_cl_cache_merge (GeglBuffer *buffer,
GeglRectangle tmp;
cl_int cl_err = 0;
+ if (!roi)
+ roi = &buffer->extent;
+
gegl_cl_color_babl (buffer->format, &size);
for (elem=cache_entries; elem; elem=elem->next)
@@ -86,21 +91,21 @@ gegl_buffer_cl_cache_merge (GeglBuffer *buffer,
CacheEntry *entry = elem->data;
if (entry->valid && entry->buffer == buffer
- && (!roi || gegl_rectangle_intersect (&tmp, roi, &entry->roi)))
+ && (gegl_rectangle_intersect (&tmp, roi, &entry->roi)))
{
gpointer data;
data = gegl_clEnqueueMapBuffer(gegl_cl_get_command_queue(), entry->tex, CL_TRUE,
- CL_MAP_READ, 0, roi->width * roi->height * size,
+ CL_MAP_READ, 0, entry->roi.width * entry->roi.height * size,
0, NULL, NULL, &cl_err);
- if (cl_err != CL_SUCCESS) goto error;
+ if (cl_err != CL_SUCCESS) CL_ERROR;
/* tile-ize */
gegl_buffer_set (entry->buffer, &entry->roi, entry->buffer->format, data, GEGL_AUTO_ROWSTRIDE);
cl_err = gegl_clEnqueueUnmapMemObject (gegl_cl_get_command_queue(), entry->tex, data,
0, NULL, NULL);
- if (cl_err != CL_SUCCESS) goto error;
+ if (cl_err != CL_SUCCESS) CL_ERROR;
}
}
@@ -217,8 +222,6 @@ gegl_buffer_cl_cache_invalidate (GeglBuffer *buffer,
gegl_buffer_cl_cache_remove (buffer, roi);
}
-#define CL_ERROR {g_printf("[OpenCL] Error in %s:%d %s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(cl_err)); goto error;}
-
gboolean
gegl_buffer_cl_cache_from (GeglBuffer *buffer,
const GeglRectangle *roi,
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 55575c2..d05fd2d 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -430,6 +430,8 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
}
if (!found)
gegl_buffer_lock (i->buffer[no]);
+
+ gegl_buffer_cl_cache_invalidate (i->buffer[no], &i->rect[no]);
}
}
else
diff --git a/gegl/operation/gegl-operation-sink.c b/gegl/operation/gegl-operation-sink.c
index 5c6dc64..a018e06 100644
--- a/gegl/operation/gegl-operation-sink.c
+++ b/gegl/operation/gegl-operation-sink.c
@@ -132,6 +132,9 @@ gegl_operation_sink_process (GeglOperation *operation,
input = gegl_operation_context_get_source (context, "input");
if (input)
{
+ if (cl_state.is_accelerated)
+ gegl_buffer_cl_cache_invalidate (input, NULL);
+
success = klass->process (operation, input, result);
g_object_unref (input);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]