[gegl/gsoc2009-gpu] Add mechanisms to enable or disable GPU support on runtime
- From: Jerson Michael Perpetua <jperpetua src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl/gsoc2009-gpu] Add mechanisms to enable or disable GPU support on runtime
- Date: Thu, 27 Aug 2009 00:28:40 +0000 (UTC)
commit 23c1f703f7f87944a4563cd7cde89cbfe3cab21b
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date: Thu Aug 27 07:27:27 2009 +0800
Add mechanisms to enable or disable GPU support on runtime
Add two mechanisms to enable or disable GPU support on runtime (or at
least during GEGL initialization): an environment variable,
GEGL_ENABLE_GPU, whose presence will enable GPU support and a
command-line option, gegl-enable-gpu, requiring a value of either "true"
or "false". GPU support is disabled by default.
gegl/gegl-config.c | 17 ++++++++++++++++-
gegl/gegl-config.h | 2 ++
gegl/gegl-init.c | 30 +++++++++++++++++++++++-------
3 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index 5f61a02..3cad0b2 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -37,7 +37,9 @@ enum
PROP_SWAP,
PROP_BABL_TOLERANCE,
PROP_TILE_WIDTH,
- PROP_TILE_HEIGHT
+ PROP_TILE_HEIGHT,
+
+ PROP_GPU_ENABLED
};
static void
@@ -78,6 +80,9 @@ get_property (GObject *gobject,
g_value_set_string (value, config->swap);
break;
+ case PROP_GPU_ENABLED:
+ g_value_set_boolean (value, config->gpu_enabled);
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
break;
@@ -126,6 +131,9 @@ set_property (GObject *gobject,
g_free (config->swap);
config->swap = g_value_dup_string (value);
break;
+ case PROP_GPU_ENABLED:
+ config->gpu_enabled = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
break;
@@ -190,6 +198,11 @@ gegl_config_class_init (GeglConfigClass *klass)
g_object_class_install_property (gobject_class, PROP_SWAP,
g_param_spec_string ("swap", "Swap", "where gegl stores it's swap files", NULL,
G_PARAM_READWRITE));
+
+
+ g_object_class_install_property (gobject_class, PROP_GPU_ENABLED,
+ g_param_spec_string ("gpu-enabled", "GPU-support enabled", "whether or not GPU support is enabled", FALSE,
+ G_PARAM_READWRITE));
}
static void
@@ -201,4 +214,6 @@ gegl_config_init (GeglConfig *self)
self->chunk_size = 512 * 512;
self->tile_width = 64;
self->tile_height = 128;
+
+ self->gpu_enabled = FALSE;
}
diff --git a/gegl/gegl-config.h b/gegl/gegl-config.h
index 4ec92d1..bf07209 100644
--- a/gegl/gegl-config.h
+++ b/gegl/gegl-config.h
@@ -44,6 +44,8 @@ struct _GeglConfig
gdouble babl_tolerance;
gint tile_width;
gint tile_height;
+
+ gboolean gpu_enabled;
};
struct _GeglConfigClass
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index b08c9f9..a1f49a4 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -190,12 +190,13 @@ gegl_init (gint *argc,
#endif
}
-static gchar *cmd_gegl_swap=NULL;
-static gchar *cmd_gegl_cache_size=NULL;
-static gchar *cmd_gegl_chunk_size=NULL;
-static gchar *cmd_gegl_quality=NULL;
-static gchar *cmd_gegl_tile_size=NULL;
-static gchar *cmd_babl_tolerance =NULL;
+static gchar *cmd_gegl_swap = NULL;
+static gchar *cmd_gegl_cache_size = NULL;
+static gchar *cmd_gegl_chunk_size = NULL;
+static gchar *cmd_gegl_quality = NULL;
+static gchar *cmd_gegl_tile_size = NULL;
+static gchar *cmd_babl_tolerance = NULL;
+static gchar *cmd_gegl_enable_gpu = NULL;
static const GOptionEntry cmd_entries[]=
{
@@ -229,6 +230,11 @@ static const GOptionEntry cmd_entries[]=
G_OPTION_ARG_STRING, &cmd_gegl_quality,
N_("The quality of rendering a value between 0.0(fast) and 1.0(reference)"), "<quality>"
},
+ {
+ "gegl-enable-gpu", 0, 0,
+ G_OPTION_ARG_STRING, &cmd_gegl_enable_gpu,
+ N_("Whether or not GPU support is enabled"), "<true|false>"
+ },
{ NULL }
};
@@ -277,6 +283,8 @@ GeglConfig *gegl_config (void)
}
if (gegl_swap_dir())
config->swap = g_strdup(gegl_swap_dir ());
+ if (g_getenv ("GEGL_ENABLE_GPU") != NULL)
+ config->gpu_enabled = TRUE;
}
return GEGL_CONFIG (config);
}
@@ -455,7 +463,7 @@ gegl_post_parse_hook (GOptionContext *context,
g_type_init ();
gegl_instrument ("gegl", "gegl_init", 0);
- config = (void*)gegl_config ();
+ config = (gpointer) gegl_config ();
if (cmd_gegl_swap)
g_object_set (config, "swap", cmd_gegl_swap, NULL);
@@ -477,6 +485,14 @@ gegl_post_parse_hook (GOptionContext *context,
if (cmd_babl_tolerance)
g_object_set (config, "babl-tolerance", atof(cmd_babl_tolerance), NULL);
+ if (cmd_gegl_enable_gpu != NULL)
+ {
+ if (g_str_equal (cmd_gegl_enable_gpu, "true"))
+ config->gpu_enabled = TRUE;
+ else if (g_str_equal (cmd_gegl_enable_gpu, "false"))
+ config->gpu_enabled = FALSE;
+ }
+
#ifdef GEGL_ENABLE_DEBUG
{
const char *env_string;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]