[gegl] cl: Fixing more bugs and adding cl support to write-buffer
- From: Victor Matheus de Araujo Oliveira <vmaolive src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] cl: Fixing more bugs and adding cl support to write-buffer
- Date: Sat, 31 Mar 2012 18:26:58 +0000 (UTC)
commit ce5cd83cfec19ea9873a0c1e00921c313c16983c
Author: Victor Oliveira <victormatheus gmail com>
Date: Sat Mar 31 15:25:59 2012 -0300
cl: Fixing more bugs and adding cl support to write-buffer
so we can perform color conversion in the GPU for output
gegl/buffer/gegl-buffer-access.c | 1 +
gegl/buffer/gegl-buffer-cl-iterator.c | 2 +
gegl/buffer/gegl-tile-handler-cache.c | 7 +++--
gegl/opencl/gegl-cl-color.c | 2 +-
operations/common/write-buffer.c | 38 ++++++++++++++++++++++++++++++++-
5 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index d7f4b14..c46da3f 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -25,6 +25,7 @@
#include <gio/gio.h>
#include "gegl.h"
+#include "gegl/gegl-debug.h"
#include "gegl-types-internal.h"
#include "gegl-buffer-types.h"
#include "gegl-buffer.h"
diff --git a/gegl/buffer/gegl-buffer-cl-iterator.c b/gegl/buffer/gegl-buffer-cl-iterator.c
index 51548a2..9dbedea 100644
--- a/gegl/buffer/gegl-buffer-cl-iterator.c
+++ b/gegl/buffer/gegl-buffer-cl-iterator.c
@@ -342,6 +342,8 @@ gegl_buffer_cl_iterator_next (GeglBufferClIterator *iterator, gboolean *err)
case GEGL_CL_COLOR_NOT_SUPPORTED:
{
+ gegl_buffer_cl_cache_flush (i->buffer[no], &i->roi[no][j]);
+
g_assert (i->tex_op[no][j] == NULL);
i->tex_op[no][j] = gegl_clCreateBuffer (gegl_cl_get_context (),
CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_ONLY,
diff --git a/gegl/buffer/gegl-tile-handler-cache.c b/gegl/buffer/gegl-tile-handler-cache.c
index b0b4445..5ad872b 100644
--- a/gegl/buffer/gegl-tile-handler-cache.c
+++ b/gegl/buffer/gegl-tile-handler-cache.c
@@ -219,9 +219,7 @@ gegl_tile_handler_cache_get_tile_command (GeglTileSource *tile_store,
GeglTile *tile = NULL;
if (gegl_cl_is_accelerated ())
- {
- gegl_buffer_cl_cache_flush2 (cache, NULL);
- }
+ gegl_buffer_cl_cache_flush2 (cache, NULL);
tile = gegl_tile_handler_cache_get_tile (cache, x, y, z);
if (tile)
@@ -261,6 +259,9 @@ gegl_tile_handler_cache_command (GeglTileSource *tile_store,
{
GList *link;
+ if (gegl_cl_is_accelerated ())
+ gegl_buffer_cl_cache_flush2 (GEGL_TILE_HANDLER_CACHE (tile_store), NULL);
+
for (link = g_queue_peek_head_link (cache_queue); link; link = link->next)
{
CacheItem *item = link->data;
diff --git a/gegl/opencl/gegl-cl-color.c b/gegl/opencl/gegl-cl-color.c
index fc0fa7f..2f6c4a8 100644
--- a/gegl/opencl/gegl-cl-color.c
+++ b/gegl/opencl/gegl-cl-color.c
@@ -113,7 +113,7 @@ choose_kernel (const Babl *in_format, const Babl *out_format)
{
if (out_format == babl_format ("RGBA u8")) kernel = CL_RGBAF_TO_RGBAU8;
else if (out_format == babl_format ("RaGaBaA float")) kernel = CL_RGBAF_TO_RAGABAF;
- else if (out_format == babl_format ("R'G'B' u8")) kernel = CL_RGBAF_TO_RGB_GAMMA_U8;
+ else if (out_format == babl_format ("R'G'B' u8")) kernel = CL_RGBAF_TO_RGB_GAMMA_U8;
else if (out_format == babl_format ("R'G'B'A u8")) kernel = CL_RGBAF_TO_RGBA_GAMMA_U8;
else if (out_format == babl_format ("R'G'B'A float")) kernel = CL_RGBAF_TO_RGBA_GAMMA_F;
else if (out_format == babl_format ("Y'CbCrA float")) kernel = CL_RGBAF_TO_YCBCRAF;
diff --git a/operations/common/write-buffer.c b/operations/common/write-buffer.c
index 10114d6..80e2591 100644
--- a/operations/common/write-buffer.c
+++ b/operations/common/write-buffer.c
@@ -33,6 +33,9 @@ gegl_chant_object (buffer, _("Buffer location"),
#include "gegl-chant.h"
#include "graph/gegl-node.h"
+#include "gegl/gegl-debug.h"
+#include "opencl/gegl-cl.h"
+
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
@@ -45,7 +48,40 @@ process (GeglOperation *operation,
{
GeglBuffer *output = GEGL_BUFFER (o->buffer);
- gegl_buffer_copy (input, result, output, result);
+ if (gegl_cl_is_accelerated ()
+ && gegl_cl_color_supported (input->soft_format, output->soft_format) == GEGL_CL_COLOR_CONVERT)
+ {
+ GEGL_NOTE (GEGL_DEBUG_OPENCL, "write-buffer: %p %p %s %s {%d %d %d %d}", input, output, babl_get_name(input->soft_format), babl_get_name(output->soft_format),
+ result->x, result->y, result->width, result->height);
+
+ size_t size;
+ gboolean err;
+ cl_int cl_err;
+ gint j;
+ gegl_cl_color_babl (output->soft_format, &size);
+
+ GeglBufferClIterator *i = gegl_buffer_cl_iterator_new (output, result, output->soft_format, GEGL_CL_BUFFER_WRITE, GEGL_ABYSS_NONE);
+ gint read = gegl_buffer_cl_iterator_add (i, input, result, output->soft_format, GEGL_CL_BUFFER_READ, GEGL_ABYSS_NONE);
+
+ while (gegl_buffer_cl_iterator_next (i, &err))
+ {
+ if (err) break;
+ for (j=0; j < i->n; j++)
+ {
+ cl_err = gegl_clEnqueueCopyBuffer (gegl_cl_get_command_queue (),
+ i->tex[read][j], i->tex[0][j], 0, 0, i->size[0][j] * size,
+ 0, NULL, NULL);
+ if (cl_err != CL_SUCCESS)
+ {
+ GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in gegl_buffer_copy: %s", gegl_cl_errstring(cl_err));
+ break;
+ }
+ }
+ }
+ }
+ else
+ gegl_buffer_copy (input, result, output, result);
+
gegl_buffer_flush (output);
gegl_node_emit_computed (operation->node, result);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]