gegl r2210 - in trunk: . gegl gegl/operation operations/common operations/generated
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2210 - in trunk: . gegl gegl/operation operations/common operations/generated
- Date: Mon, 21 Apr 2008 01:09:13 +0100 (BST)
Author: ok
Date: Mon Apr 21 00:09:12 2008
New Revision: 2210
URL: http://svn.gnome.org/viewvc/gegl?rev=2210&view=rev
Log:
* gegl/gegl-plugin.h: enable Gegl4float type when compiling with gcc,
added more macros for working with these vectors including
Gegl4floatR(vector) and GBA versions to access individual components.
* gegl/operation/gegl-operation-processors.c:
(gegl_class_register_alternate_vfunc): enable gcc-vectors for good
setting.
* operations/common/brightness-contrast.c: (process_sse),
(gegl_chant_class_init):
* operations/common/invert.c: (process_sse),
(gegl_chant_class_init):
* operations/generated/other-blend.rb:
* operations/generated/svg-12-porter-duff.rb: Simplified syntax used
gcc vectors.
Modified:
trunk/ChangeLog
trunk/gegl/gegl-plugin.h
trunk/gegl/operation/gegl-operation-processors.c
trunk/operations/common/brightness-contrast.c
trunk/operations/common/invert.c
trunk/operations/generated/other-blend.rb
trunk/operations/generated/svg-12-porter-duff.rb
Modified: trunk/gegl/gegl-plugin.h
==============================================================================
--- trunk/gegl/gegl-plugin.h (original)
+++ trunk/gegl/gegl-plugin.h Mon Apr 21 00:09:12 2008
@@ -100,20 +100,25 @@
#include <operation/gegl-operation-sink.h>
#include <operation/gegl-operation-meta.h>
-#ifdef USE_SSE
+#define USE_GCC_VECTORS defined(__GNUC__) && (__GNUC__ >= 4)
-typedef float v4sf __attribute__ ((vector_size (4*sizeof(float))));
-typedef union
-{
- v4sf v;
- float a[4];
-} GeglV4;
-
-#define GEGL_V4(a,b,c,d) ((GeglV4){{a,b,c,d}})
-#define GEGL_V4_FILL(val) GEGL_V4(val,val,val,val)
-#define GEGL_V4_ZERO GEGL_V4_FILL(0.0)
-#define GEGL_V4_ONE GEGL_V4_FILL(1.0)
-#define GEGL_V4_HALF GEGL_V4_FILL(0.5)
+#if USE_GCC_VECTORS
+
+typedef float Gegl4float __attribute__ ((vector_size (4*sizeof(float))));
+
+#define Gegl4float_a(a) ((float *)(&a))
+#define Gegl4floatR(a) Gegl4float_a(a)[0]
+#define Gegl4floatG(a) Gegl4float_a(a)[0]
+#define Gegl4floatB(a) Gegl4float_a(a)[0]
+#define Gegl4floatA(a) Gegl4float_a(a)[0]
+#define Gegl4float(a,b,c,d) ((Gegl4float){a,b,c,d})
+#define Gegl4float_all(val) Gegl4float(val,val,val,val)
+#define Gegl4float_zero Gegl4float_all(0.0)
+#define Gegl4float_one Gegl4float_all(1.0)
+#define Gegl4float_half Gegl4float_all(0.5)
+
+
+#define Gegl4float_mul(vec,val) ((vec) * Gegl4float_all(val))
#endif
Modified: trunk/gegl/operation/gegl-operation-processors.c
==============================================================================
--- trunk/gegl/operation/gegl-operation-processors.c (original)
+++ trunk/gegl/operation/gegl-operation-processors.c Mon Apr 21 00:09:12 2008
@@ -43,6 +43,7 @@
#include "gegl-operation-point-filter.h"
#include "gegl-operation-sink.h"
#include "gegl-operation-source.h"
+#include "gegl-debug.h"
#include <glib/gprintf.h>
@@ -113,10 +114,11 @@
if (g_getenv ("GEGL_QUALITY"))
#endif
{
- const gchar *quality = g_getenv ("GEGL_QUALITY");
- GCallback fast = NULL;
- GCallback good = NULL;
- GCallback reference = NULL;
+ const gchar *quality = g_getenv ("GEGL_QUALITY");
+ GCallback fast = NULL;
+ GCallback good = NULL;
+ GCallback reference = NULL;
+ GCallback gcc_vectors = NULL;
#ifdef USE_SSE
GCallback sse = NULL;
if (quality == NULL)
@@ -132,6 +134,8 @@
{
if (g_str_equal (string, "fast"))
fast = cb;
+ if (g_str_equal (string, "gcc-vectors"))
+ gcc_vectors = cb;
else if (g_str_equal (string, "good"))
good = cb;
#ifdef USE_SSE
@@ -147,25 +151,25 @@
if (g_str_equal (quality, "fast"))
{
#ifdef USE_SSE
- g_print ("Setting %s callback for %s\n", fast?"fast":sse?"sse":good?"good":"reference",
+ GEGL_NOTE(PROCESSOR, "Setting %s callback for %s", fast?"fast":sse?"sse":gcc_vectors?"gcc-vectors":good?"good":"reference",
g_type_name (G_TYPE_FROM_CLASS (cclass)));
- *vfunc_ptr = fast?fast:sse?sse:good?good:reference;
+ *vfunc_ptr = fast?fast:sse?sse:gcc_vectors?gcc_vectors:good?good:reference;
#else
- g_print ("Setting %s callback for %s\n", fast?"fast":good?"good":"reference",
+ GEGL_NOTE(PROCESSOR, "Setting %s callback for %s", fast?"fast":gcc_vectors?"gcc-vectors":good?"good":"reference",
g_type_name (G_TYPE_FROM_CLASS (cclass)));
- *vfunc_ptr = fast?fast:good?good:reference;
+ *vfunc_ptr = fast?fast:gcc_vectors?gcc_vectors:good?good:reference;
#endif
}
else if (g_str_equal (quality, "good"))
{
#ifdef USE_SSE
- g_print ("Setting %s callback for %s\n", sse?"sse":good?"good":"reference",
+ GEGL_NOTE(PROCESSOR, "Setting %s callback for %s", sse?"sse":gcc_vectors?"gcc-vectors":good?"good":"reference",
g_type_name (G_TYPE_FROM_CLASS (cclass)));
- *vfunc_ptr = sse?sse:good?good:reference;
+ *vfunc_ptr = sse?sse:gcc_vectors?gcc_vectors:good?good:reference;
#else
- g_print ("Setting %s callback for %s\n", good?"good":"reference",
+ GEGL_NOTE(PROCESSOR, "Setting %s callback for %s", gcc_vectors?"gcc-vectors":good?"good":"reference",
g_type_name (G_TYPE_FROM_CLASS (cclass)));
- *vfunc_ptr = good?good:reference;
+ *vfunc_ptr = gcc_vectors?"gcc-vectors":good?good:reference;
#endif
}
else
@@ -173,7 +177,7 @@
/* best */
#ifdef USE_SSE
if (sse && gegl_cpu_accel_get_support () & GEGL_CPU_ACCEL_X86_SSE)
- g_print ("Setting sse processor for %s\n", g_type_name (G_TYPE_FROM_CLASS (cclass)));
+ GEGL_NOTE(PROCESSOR, "Setting sse processor for %s", g_type_name (G_TYPE_FROM_CLASS (cclass)));
*vfunc_ptr = sse?sse:reference;
#else
*vfunc_ptr = reference;
Modified: trunk/operations/common/brightness-contrast.c
==============================================================================
--- trunk/operations/common/brightness-contrast.c (original)
+++ trunk/operations/common/brightness-contrast.c Mon Apr 21 00:09:12 2008
@@ -108,7 +108,8 @@
}
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
+
static gboolean
process_sse (GeglOperation *op,
void *in_buf,
@@ -116,17 +117,19 @@
glong samples)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
- GeglV4 *in = in_buf;
- GeglV4 *out = out_buf;
- GeglV4 brightness = GEGL_V4_FILL(o->brightness + 0.5);
- GeglV4 contrast = GEGL_V4_FILL(o->contrast);
-
- brightness.a[3] = 0.5;
- contrast.a[3] = 1.0;
+ Gegl4float *in = in_buf;
+ Gegl4float *out = out_buf;
+ /* add 0.5 to brightness here to make the logic in the innerloop tighter
+ */
+ Gegl4float brightness = Gegl4float_all(o->brightness + 0.5);
+ Gegl4float contrast = Gegl4float_all(o->contrast);
+ Gegl4float half = Gegl4float_half;
+
while (--samples)
{
- out->v = (in->v - GEGL_V4_HALF.v) * contrast.v + brightness.v;
+ *out = (*in - half) * contrast + brightness;
+ Gegl4floatA(*out)=Gegl4floatA(*in);
in ++;
out ++;
}
@@ -166,9 +169,13 @@
operation_class->description = _("Changes the light level and contrast.");
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
+ /* add conditionally compiled variation of process(), gegl should be able
+ * to determine which is fastest and hopefully if any implementation is
+ * broken and not conforming to the reference implementation.
+ */
gegl_operation_class_add_processor (operation_class,
- G_CALLBACK (process_sse), "sse");
+ G_CALLBACK (process_sse), "gcc-vectors");
#endif
}
Modified: trunk/operations/common/invert.c
==============================================================================
--- trunk/operations/common/invert.c (original)
+++ trunk/operations/common/invert.c Mon Apr 21 00:09:12 2008
@@ -54,21 +54,22 @@
return TRUE;
}
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
static gboolean
process_sse (GeglOperation *op,
void *in_buf,
void *out_buf,
glong samples)
{
- GeglV4 *in = in_buf;
- GeglV4 *out = out_buf;
+ Gegl4float *in = in_buf;
+ Gegl4float *out = out_buf;
+ Gegl4float one = Gegl4float_one;
while (--samples)
{
- gfloat a=in->a[3];
- out->v = GEGL_V4_ONE.v - in->v;
- out->a[3]=a;
+ gfloat a= Gegl4float_a(*in)[3];
+ *out = one - *in;
+ Gegl4float_a(*out)[3]=a;
in ++;
out ++;
}
@@ -93,9 +94,9 @@
"Inverts the components (except alpha), the result is the"
" corresponding \"negative\" image.";
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
gegl_operation_class_add_processor (operation_class,
- G_CALLBACK (process_sse), "sse");
+ G_CALLBACK (process_sse), "gcc-vectors");
#endif
}
Modified: trunk/operations/generated/other-blend.rb
==============================================================================
--- trunk/operations/generated/other-blend.rb (original)
+++ trunk/operations/generated/other-blend.rb Mon Apr 21 00:09:12 2008
@@ -35,11 +35,11 @@
# Alias for porter-duff src-over
['normal', 'cA + cB * (1 - aA)',
'aA + aB - aA * aB',
- 'D->v = A->v + B->v * (GEGL_V4_ONE.v - GEGL_V4_FILL(A->a[3]).v)'],
+ '*D = *A + *B * (Gegl4float_one - Gegl4float_all(Gegl4float_a(*A)[3]))'],
# Alias for porter-duff src-over
['over', 'cA + cB * (1 - aA)',
'aA + aB - aA * aB',
- 'D->v = A->v + B->v * (GEGL_V4_ONE.v - GEGL_V4_FILL(A->a[3]).v)'],
+ '*D = *A + *B * (Gegl4float_one - Gegl4float_all(Gegl4float_a(*A)[3]))'],
]
file_head1 = '
@@ -90,9 +90,9 @@
point_composer_class->process = process;
operation_class->prepare = prepare;
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
gegl_operation_class_add_processor (operation_class,
- G_CALLBACK (process_sse), "sse");
+ G_CALLBACK (process_gegl4float), "gcc-vectors");
#endif
'
@@ -154,18 +154,18 @@
return TRUE;
}
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
static gboolean
-process_sse (GeglOperation *op,
- void *in_buf,
- void *aux_buf,
- void *out_buf,
- glong n_pixels)
+process_gegl4float (GeglOperation *op,
+ void *in_buf,
+ void *aux_buf,
+ void *out_buf,
+ glong n_pixels)
{
- GeglV4 *A = aux_buf;
- GeglV4 *B = in_buf;
- GeglV4 *D = out_buf;
+ Gegl4float *A = aux_buf;
+ Gegl4float *B = in_buf;
+ Gegl4float *D = out_buf;
if (B==NULL)
return TRUE;
Modified: trunk/operations/generated/svg-12-porter-duff.rb
==============================================================================
--- trunk/operations/generated/svg-12-porter-duff.rb (original)
+++ trunk/operations/generated/svg-12-porter-duff.rb Mon Apr 21 00:09:12 2008
@@ -34,41 +34,41 @@
a = [
['clear', '0.0',
'0.0',
- 'D->v = GEGL_V4_ZERO.v'],
+ '*D = Gegl4float_zero'],
['src', 'cA',
'aA',
- 'D->v = A->v'],
+ '*D = *A'],
['dst', 'cB',
'aB',
- 'D->v = B->v'],
+ '*D = *B'],
['src_over', 'cA + cB * (1 - aA)',
'aA + aB - aA * aB',
- 'D->v = A->v + B->v * (GEGL_V4_ONE.v - GEGL_V4_FILL(A->a[3]).v)'],
+ '*D = *A + Gegl4float_mul (*B, 1.0 - Gegl4floatA(*A))'],
['dst_over', 'cB + cA * (1 - aB)',
'aA + aB - aA * aB',
- 'D->v = B->v + A->v * (GEGL_V4_ONE.v - GEGL_V4_FILL(B->a[3]).v)'],
+ '*D = *B + Gegl4float_mul (*A, 1.0 - Gegl4floatA(*B))'],
['src_in', 'cA * aB', # this one had special treatment wrt rectangles in deleted file porter-duff.rb before the svg ops came in, perhaps that was with good reason? /pippin
'aA * aB',
- 'D->v = A->v * GEGL_V4_FILL(B->a[3]).v'],
+ '*D = Gegl4float_mul(*A, Gegl4floatA(*B))'],
['dst_in', 'cB * aA', # <- XXX: typo?
'aA * aB',
- 'D->v = B->v * GEGL_V4_FILL(A->a[3]).v'],
+ '*D = Gegl4float_mul (*B, Gegl4floatA(*A))'],
['src_out', 'cA * (1 - aB)',
'aA * (1 - aB)',
- 'D->v = A->v * GEGL_V4_ONE.v - GEGL_V4_FILL(B->a[3]).v'],
+ '*D = Gegl4float_mul (*A, 1.0 - Gegl4floatA(*B))'],
['dst_out', 'cB * (1 - aA)',
'aB * (1 - aA)',
- 'D->v = B->v * GEGL_V4_ONE.v - GEGL_V4_FILL(A->a[3]).v'],
+ '*D = Gegl4float_mul (*B, 1.0 - Gegl4floatA(*A))'],
['src_atop', 'cA * aB + cB * (1 - aA)',
'aB',
- 'D->v = A->v * (GEGL_V4_FILL(B->a[3])).v + B->v * (GEGL_V4_ONE.v - GEGL_V4_FILL(A->a[3]).v);D->a[3]=B->a[3]'],
+ '*D = Gegl4float_mul (*A, Gegl4floatA(*B)) + Gegl4float_mul (*B, 1.0 - Gegl4floatA(*A));Gegl4floatA(*D)=Gegl4floatA(*B)'],
['dst_atop', 'cB * aA + cA * (1 - aB)',
'aA',
- 'D->v = B->v * (GEGL_V4_FILL(A->a[3])).v + A->v * (GEGL_V4_ONE.v - GEGL_V4_FILL(B->a[3]).v);D->a[3]=A->a[3]'],
+ '*D = Gegl4float_mul (*B, Gegl4floatA(*A)) + Gegl4float_mul (*A, 1.0 - Gegl4floatA(*B));Gegl4floatA(*D)=Gegl4floatA(*A)'],
['xor', 'cA * (1 - aB)+ cB * (1 - aA)',
'aA + aB - 2 * aA * aB',
- 'D->v = A->v * B->v']
+ '*D = *A * *B'] # FIXME this is wrong
]
file_head1 = '
@@ -119,9 +119,9 @@
point_composer_class->process = process;
operation_class->prepare = prepare;
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
gegl_operation_class_add_processor (operation_class,
- G_CALLBACK (process_sse), "sse");
+ G_CALLBACK (process_gegl4float), "gcc-vectors");
#endif
'
@@ -183,18 +183,18 @@
return TRUE;
}
-#ifdef USE_SSE
+#ifdef USE_GCC_VECTORS
static gboolean
-process_sse (GeglOperation *op,
- void *in_buf,
- void *aux_buf,
- void *out_buf,
- glong n_pixels)
+process_gegl4float (GeglOperation *op,
+ void *in_buf,
+ void *aux_buf,
+ void *out_buf,
+ glong n_pixels)
{
- GeglV4 *A = aux_buf;
- GeglV4 *B = in_buf;
- GeglV4 *D = out_buf;
+ Gegl4float *A = aux_buf;
+ Gegl4float *B = in_buf;
+ Gegl4float *D = out_buf;
if (B==NULL)
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]