[gegl] OpenCL cache of a GeglBuffer must be cleaned before editing



commit 967f0f10db9ba4d311a7f88e581f1502e04c2dfc
Author: Victor Oliveira <victormatheus gmail com>
Date:   Fri Feb 17 02:48:04 2012 -0200

    OpenCL cache of a GeglBuffer must be cleaned before editing

 gegl/buffer/gegl-buffer-access.c      |    2 +-
 gegl/buffer/gegl-buffer-cl-cache.c    |   11 ++++-------
 gegl/buffer/gegl-buffer-cl-iterator.c |    3 +++
 3 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 3f2f8c9..7f88646 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1196,7 +1196,7 @@ gegl_buffer_clear (GeglBuffer          *dst,
   pxsize = babl_format_get_bytes_per_pixel (dst->format);
 
   if (cl_state.is_accelerated)
-    gegl_buffer_cl_cache_remove (dst, dst_rect);
+    gegl_buffer_cl_cache_invalidate (dst, dst_rect);
 
   /* FIXME: this can be even further optimized by special casing it so
    * that fully voided tiles are dropped.
diff --git a/gegl/buffer/gegl-buffer-cl-cache.c b/gegl/buffer/gegl-buffer-cl-cache.c
index 5568d4f..876b56a 100644
--- a/gegl/buffer/gegl-buffer-cl-cache.c
+++ b/gegl/buffer/gegl-buffer-cl-cache.c
@@ -184,6 +184,9 @@ void
 gegl_buffer_cl_cache_invalidate (GeglBuffer          *buffer,
                                  const GeglRectangle *roi)
 {
+  if (!roi)
+    roi = &buffer->extent;
+
   if (G_UNLIKELY (!cache_entries))
     {
       cache_entries = g_array_new (TRUE, TRUE, sizeof (CacheEntry));
@@ -227,16 +230,10 @@ gegl_buffer_cl_cache_from (GeglBuffer          *buffer,
   for (i=0; i<cache_entries->len; i++)
     {
       CacheEntry *entry = &g_array_index (cache_entries, CacheEntry, i);
+
       if (entry->buffer == buffer && gegl_rectangle_contains (&entry->roi, roi))
         {
           cl_int cl_err;
-          const size_t origin_buf[3] = {(entry->roi.x - roi->x) * buf_size,  roi->y - entry->roi.y, 0};
-          const size_t region_buf[3] = {(roi->width) * buf_size,  roi->height, 1};
-
-          /* const size_t origin_dest[3] = {(entry->roi.x - roi->x) * dest_size, roi->y - entry->roi.y, 0};
-             const size_t region_dest[3] = {(roi->width) * dest_size, roi->height, 1}; */
-
-          const size_t origin_zero[3] = {0, 0, 0};
 
           switch (conv)
             {
diff --git a/gegl/buffer/gegl-buffer-cl-iterator.c b/gegl/buffer/gegl-buffer-cl-iterator.c
index 037972b..55576e0 100644
--- a/gegl/buffer/gegl-buffer-cl-iterator.c
+++ b/gegl/buffer/gegl-buffer-cl-iterator.c
@@ -154,6 +154,9 @@ gegl_buffer_cl_iterator_next (GeglBufferClIterator *iterator, gboolean *err)
               }
           if (!found)
             gegl_buffer_lock (i->buffer[no]);
+
+          if (i->flags[no] == GEGL_CL_BUFFER_WRITE)
+            gegl_buffer_cl_cache_invalidate (i->buffer[no], &i->rect[no]);
         }
     }
   else



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