[gegl] opencl: Add use-opencl to nodes and call gegl_operation_use_opencl
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] opencl: Add use-opencl to nodes and call gegl_operation_use_opencl
- Date: Fri, 18 Oct 2013 01:34:19 +0000 (UTC)
commit f92128ed07eda7f560678a07a8ab686cee88e95d
Author: Daniel Sabo <DanielSabo gmail com>
Date: Tue Sep 17 02:17:08 2013 -0700
opencl: Add use-opencl to nodes and call gegl_operation_use_opencl
This allows OpenCL to be controlled per node, which
is useful to avoid jumping into OpenCL mode for simple
operations in CPU based graphs.
gegl/graph/gegl-node.c | 22 +++++++++++++++++++++-
gegl/graph/gegl-node.h | 2 ++
gegl/operation/gegl-operation-point-composer.c | 3 ++-
gegl/operation/gegl-operation-point-filter.c | 3 ++-
gegl/operation/gegl-operation.c | 7 +++++++
gegl/operation/gegl-operation.h | 2 ++
operations/common/bilateral-filter-fast.c | 3 ++-
operations/common/bilateral-filter.c | 2 +-
operations/common/box-blur.c | 10 +++-------
operations/common/c2g.c | 2 +-
operations/common/edge-laplace.c | 2 +-
operations/common/edge-sobel.c | 2 +-
operations/common/gaussian-blur.c | 2 +-
operations/common/motion-blur-linear.c | 2 +-
operations/common/noise-reduction.c | 2 +-
operations/common/oilify.c | 2 +-
operations/common/pixelize.c | 2 +-
operations/common/snn-mean.c | 2 +-
operations/common/write-buffer.c | 2 +-
19 files changed, 52 insertions(+), 22 deletions(-)
---
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 4b6cd82..68c9599 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -51,7 +51,8 @@ enum
PROP_OP_CLASS,
PROP_OPERATION,
PROP_NAME,
- PROP_DONT_CACHE
+ PROP_DONT_CACHE,
+ PROP_USE_OPENCL
};
enum
@@ -153,6 +154,14 @@ gegl_node_class_init (GeglNodeClass *klass)
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_USE_OPENCL,
+ g_param_spec_boolean ("use-opencl",
+ "Use OpenCL",
+ "Use the OpenCL version of this operation if
available, this property is inherited by children created from a node.",
+ TRUE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_class, PROP_NAME,
g_param_spec_string ("name",
@@ -289,6 +298,10 @@ gegl_node_local_set_property (GObject *gobject,
node->dont_cache = g_value_get_boolean (value);
break;
+ case PROP_USE_OPENCL:
+ node->use_opencl = g_value_get_boolean (value);
+ break;
+
case PROP_OP_CLASS:
{
va_list null; /* dummy to pass along, it's not used anyways since
@@ -330,6 +343,11 @@ gegl_node_local_get_property (GObject *gobject,
case PROP_DONT_CACHE:
g_value_set_boolean (value, node->dont_cache);
break;
+
+ case PROP_USE_OPENCL:
+ g_value_set_boolean (value, node->use_opencl);
+ break;
+
case PROP_NAME:
g_value_set_string (value, gegl_node_get_name (node));
break;
@@ -1875,6 +1893,7 @@ gegl_node_add_child (GeglNode *self,
child->priv->parent = self;
child->dont_cache = self->dont_cache;
+ child->use_opencl = self->use_opencl;
return child;
}
@@ -1984,6 +2003,7 @@ gegl_node_create_child (GeglNode *self,
if (ret && self)
{
ret->dont_cache = self->dont_cache;
+ ret->use_opencl = self->use_opencl;
}
return ret;
}
diff --git a/gegl/graph/gegl-node.h b/gegl/graph/gegl-node.h
index e69c6a1..2430350 100644
--- a/gegl/graph/gegl-node.h
+++ b/gegl/graph/gegl-node.h
@@ -75,6 +75,8 @@ struct _GeglNode
/* Whether result is cached or not, inherited by children */
gboolean dont_cache;
+ gboolean use_opencl;
+
GMutex mutex;
/*< private >*/
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index b501351..610d235 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -249,7 +249,8 @@ gegl_operation_point_composer_process (GeglOperation *operation,
if ((result->width > 0) && (result->height > 0))
{
- if (gegl_cl_is_accelerated () && (operation_class->cl_data || point_composer_class->cl_process))
+ if (gegl_operation_use_opencl (operation) &&
+ (operation_class->cl_data || point_composer_class->cl_process))
{
if (gegl_operation_point_composer_cl_process (operation, input, aux, output, result, level))
return TRUE;
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 39dd1ed..d9497df 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -174,7 +174,8 @@ gegl_operation_point_filter_process (GeglOperation *operation,
if ((result->width > 0) && (result->height > 0))
{
- if (gegl_cl_is_accelerated () && (operation_class->cl_data || point_filter_class->cl_process))
+ if (gegl_operation_use_opencl (operation) &&
+ (operation_class->cl_data || point_filter_class->cl_process))
{
if (gegl_operation_point_filter_cl_process (operation, input, output, result, level))
return TRUE;
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index 3ff4212..806137f 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -744,6 +744,13 @@ gegl_operation_get_key (const gchar *operation_name,
return ret;
}
+gboolean
+gegl_operation_use_opencl (const GeglOperation *operation)
+{
+ g_return_val_if_fail (operation->node, FALSE);
+ return operation->node->use_opencl && gegl_cl_is_accelerated ();
+}
+
const Babl *
gegl_operation_get_source_format (GeglOperation *operation,
const gchar *padname)
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index 4a796b6..8a476f8 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -247,6 +247,8 @@ void gegl_operation_set_key (const gchar *operation_type,
const gchar * gegl_operation_get_key (const gchar *operation_type,
const gchar *key_name);
+gboolean gegl_operation_use_opencl (const GeglOperation *operation);
+
/* invalidate a specific rectangle, indicating the any computation depending
* on this roi is now invalid.
*
diff --git a/operations/common/bilateral-filter-fast.c b/operations/common/bilateral-filter-fast.c
index 1266a58..3ef3723 100644
--- a/operations/common/bilateral-filter-fast.c
+++ b/operations/common/bilateral-filter-fast.c
@@ -102,7 +102,8 @@ bilateral_process (GeglOperation *operation,
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- if (gegl_cl_is_accelerated () && bilateral_cl_process (operation, input, output, result, o->s_sigma,
o->r_sigma/100))
+ if (gegl_operation_use_opencl (operation))
+ if (bilateral_cl_process (operation, input, output, result, o->s_sigma, o->r_sigma/100))
return TRUE;
bilateral_filter (input, result, output, result, o->s_sigma, o->r_sigma/100);
diff --git a/operations/common/bilateral-filter.c b/operations/common/bilateral-filter.c
index d2f4392..416adb8 100644
--- a/operations/common/bilateral-filter.c
+++ b/operations/common/bilateral-filter.c
@@ -162,7 +162,7 @@ process (GeglOperation *operation,
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglRectangle compute;
- if (o->blur_radius >= 1.0 && gegl_cl_is_accelerated ())
+ if (o->blur_radius >= 1.0 && gegl_operation_use_opencl (operation))
if (cl_process (operation, input, output, result))
return TRUE;
diff --git a/operations/common/box-blur.c b/operations/common/box-blur.c
index 9ea43b8..11449c7 100644
--- a/operations/common/box-blur.c
+++ b/operations/common/box-blur.c
@@ -320,13 +320,9 @@ process (GeglOperation *operation,
GeglOperationAreaFilter *op_area;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
- if (gegl_cl_is_accelerated ())
- {
- if (cl_process (operation, input, output, result))
- return TRUE;
- else
- gegl_cl_disable();
- }
+ if (gegl_operation_use_opencl (operation))
+ if (cl_process (operation, input, output, result))
+ return TRUE;
rect = *result;
tmprect = *result;
diff --git a/operations/common/c2g.c b/operations/common/c2g.c
index b330bee..8d2b6c6 100644
--- a/operations/common/c2g.c
+++ b/operations/common/c2g.c
@@ -313,7 +313,7 @@ process (GeglOperation *operation,
GeglRectangle compute;
compute = gegl_operation_get_required_for_output (operation, "input",result);
- if (o->radius < 500 && gegl_cl_is_accelerated ())
+ if (o->radius < 500 && gegl_operation_use_opencl (operation))
if(cl_process(operation, input, output, result))
return TRUE;
diff --git a/operations/common/edge-laplace.c b/operations/common/edge-laplace.c
index 9b513d5..769da99 100644
--- a/operations/common/edge-laplace.c
+++ b/operations/common/edge-laplace.c
@@ -75,7 +75,7 @@ process (GeglOperation *operation,
gint i, j;
gfloat *buf1, *buf2, *buf3;
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if (cl_process (operation, input, output, result))
return TRUE;
diff --git a/operations/common/edge-sobel.c b/operations/common/edge-sobel.c
index 3007e60..8c76866 100644
--- a/operations/common/edge-sobel.c
+++ b/operations/common/edge-sobel.c
@@ -195,7 +195,7 @@ process (GeglOperation *operation,
compute = gegl_operation_get_required_for_output (operation, "input", result);
has_alpha = babl_format_has_alpha (gegl_operation_get_format (operation, "output"));
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if (cl_process (operation, input, output, result, has_alpha))
return TRUE;
diff --git a/operations/common/gaussian-blur.c b/operations/common/gaussian-blur.c
index 14f73db..df96702 100644
--- a/operations/common/gaussian-blur.c
+++ b/operations/common/gaussian-blur.c
@@ -649,7 +649,7 @@ process (GeglOperation *operation,
force_iir = (o->filter == GEGL_GAUSSIAN_BLUR_FILTER_IIR);
force_fir = (o->filter == GEGL_GAUSSIAN_BLUR_FILTER_FIR);
- if (gegl_cl_is_accelerated () && !force_iir)
+ if (gegl_operation_use_opencl (operation) && !force_iir)
if (cl_process(operation, input, output, result))
return TRUE;
diff --git a/operations/common/motion-blur-linear.c b/operations/common/motion-blur-linear.c
index 1ee715d..833a602 100644
--- a/operations/common/motion-blur-linear.c
+++ b/operations/common/motion-blur-linear.c
@@ -220,7 +220,7 @@ process (GeglOperation *operation,
src_rect.width += op_area->left + op_area->right;
src_rect.height += op_area->top + op_area->bottom;
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if (cl_process (operation, input, output, roi, &src_rect))
return TRUE;
diff --git a/operations/common/noise-reduction.c b/operations/common/noise-reduction.c
index 500adbf..469507c 100644
--- a/operations/common/noise-reduction.c
+++ b/operations/common/noise-reduction.c
@@ -325,7 +325,7 @@ process (GeglOperation *operation,
#endif
GeglRectangle rect;
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if(cl_process(operation, input, output, result))
return TRUE;
diff --git a/operations/common/oilify.c b/operations/common/oilify.c
index 77fd317..bbdf9d3 100644
--- a/operations/common/oilify.c
+++ b/operations/common/oilify.c
@@ -398,7 +398,7 @@ process (GeglOperation *operation,
GeglRectangle src_rect;
gint total_pixels;
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if(cl_process(operation, input, output, result))
return TRUE;
diff --git a/operations/common/pixelize.c b/operations/common/pixelize.c
index a53c952..c14f550 100644
--- a/operations/common/pixelize.c
+++ b/operations/common/pixelize.c
@@ -364,7 +364,7 @@ process (GeglOperation *operation,
whole_region = gegl_operation_source_get_bounding_box (operation, "input");
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if (cl_process (operation, input, output, roi))
return TRUE;
diff --git a/operations/common/snn-mean.c b/operations/common/snn-mean.c
index 86c41ee..90a051b 100644
--- a/operations/common/snn-mean.c
+++ b/operations/common/snn-mean.c
@@ -71,7 +71,7 @@ process (GeglOperation *operation,
GeglBuffer *temp_in;
GeglRectangle compute;
- if (gegl_cl_is_accelerated ())
+ if (gegl_operation_use_opencl (operation))
if (cl_process (operation, input, output, result))
return TRUE;
diff --git a/operations/common/write-buffer.c b/operations/common/write-buffer.c
index a5a81f2..19a91ff 100644
--- a/operations/common/write-buffer.c
+++ b/operations/common/write-buffer.c
@@ -48,7 +48,7 @@ process (GeglOperation *operation,
{
GeglBuffer *output = GEGL_BUFFER (o->buffer);
- if (gegl_cl_is_accelerated ()
+ if (gegl_operation_use_opencl (operation)
&& gegl_cl_color_supported (input->soft_format, output->soft_format) == GEGL_CL_COLOR_CONVERT)
{
size_t size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]