app: add "Use OpenCL" toggle to Prefs -> Environment

and configure GEGL accordingly. Let's see if it's really runtime
switchable :)
This commit is contained in:
Michael Natterer 2013-06-01 23:02:42 +02:00
parent 47cb8fbcc0
commit 1cc9d7d7aa
5 changed files with 41 additions and 3 deletions

View File

@ -51,6 +51,7 @@ enum
PROP_SWAP_PATH,
PROP_NUM_PROCESSORS,
PROP_TILE_CACHE_SIZE,
PROP_USE_OPENCL,
/* ignored, only for backward compatibility: */
PROP_STINGY_MEMORY_USE
@ -158,6 +159,11 @@ gimp_gegl_config_class_init (GimpGeglConfigClass *klass)
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_CONFIRM);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_OPENCL,
"use-opencl", USE_OPENCL_BLURB,
TRUE,
GIMP_PARAM_STATIC_STRINGS);
/* only for backward compatibility: */
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_STINGY_MEMORY_USE,
"stingy-memory-use", NULL,
@ -209,6 +215,9 @@ gimp_gegl_config_set_property (GObject *object,
case PROP_TILE_CACHE_SIZE:
gegl_config->tile_cache_size = g_value_get_uint64 (value);
break;
case PROP_USE_OPENCL:
gegl_config->use_opencl = g_value_get_boolean (value);
break;
case PROP_STINGY_MEMORY_USE:
/* ignored */
@ -242,6 +251,9 @@ gimp_gegl_config_get_property (GObject *object,
case PROP_TILE_CACHE_SIZE:
g_value_set_uint64 (value, gegl_config->tile_cache_size);
break;
case PROP_USE_OPENCL:
g_value_set_boolean (value, gegl_config->use_opencl);
break;
case PROP_STINGY_MEMORY_USE:
/* ignored */

View File

@ -39,6 +39,7 @@ struct _GimpGeglConfig
gchar *swap_path;
guint num_processors;
guint64 tile_cache_size;
gboolean use_opencl;
};
struct _GimpGeglConfigClass

View File

@ -453,10 +453,13 @@ N_("Sets an upper limit to the memory that is used per image to keep " \
#define UNDO_PREVIEW_SIZE_BLURB \
N_("Sets the size of the previews in the Undo History.")
#define USE_HELP_BLURB \
#define USE_HELP_BLURB \
N_("When enabled, pressing F1 will open the help browser.")
#define USER_MANUAL_ONLINE_BLURB \
#define USE_OPENCL_BLURB \
N_("When enabled, uses OpenCL for some operations.")
#define USER_MANUAL_ONLINE_BLURB \
"When enabled, the online user manual will be used by the help system. " \
"Otherwise the locally installed copy is used."

View File

@ -1337,6 +1337,14 @@ prefs_dialog_new (Gimp *gimp,
GTK_TABLE (table), 4, size_group);
#endif /* ENABLE_MP */
/* Hardware Acceleration */
vbox2 = prefs_frame_new (_("Hardware Acceleration"), GTK_CONTAINER (vbox),
FALSE);
prefs_check_button_add (object, "use-opencl",
_("Use OpenCL"),
GTK_BOX (vbox2));
/* Image Thumbnails */
vbox2 = prefs_frame_new (_("Image Thumbnails"), GTK_CONTAINER (vbox), FALSE);

View File

@ -36,6 +36,7 @@
static void gimp_gegl_notify_tile_cache_size (GimpGeglConfig *config);
static void gimp_gegl_notify_num_processors (GimpGeglConfig *config);
static void gimp_gegl_notify_use_opencl (GimpGeglConfig *config);
void
@ -57,8 +58,9 @@ gimp_gegl_init (Gimp *gimp)
g_object_set (gegl_config (),
"tile-cache-size", (guint64) config->tile_cache_size,
#if 0
"threads", config->num_processors,
"threads", config->num_processors,
#endif
"use-opencl", config->use_opencl,
NULL);
}
else
@ -72,6 +74,7 @@ gimp_gegl_init (Gimp *gimp)
#if 0
"threads", config->num_processors,
#endif
"use-opencl", config->use_opencl,
NULL);
}
@ -89,6 +92,9 @@ gimp_gegl_init (Gimp *gimp)
g_signal_connect (config, "notify::num-processors",
G_CALLBACK (gimp_gegl_notify_num_processors),
NULL);
g_signal_connect (config, "notify::use-opencl",
G_CALLBACK (gimp_gegl_notify_use_opencl),
NULL);
gimp_babl_init ();
@ -122,3 +128,11 @@ gimp_gegl_notify_num_processors (GimpGeglConfig *config)
NULL);
#endif
}
static void
gimp_gegl_notify_use_opencl (GimpGeglConfig *config)
{
g_object_set (gegl_config (),
"use-opencl", config->use_opencl,
NULL);
}