Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Victor Oliveira
You can use OpenCL in the CPU, just install the AMD OpenCL SDK. GEGL
looks for libOpenCL.so in /usr/lib.

You should use GEGL_ENABLE_OPENCL=yes

On Tue, Jan 29, 2013 at 1:24 AM, Alexander Rabtchevich
 wrote:
> I have embedded AMD 4290 graphics, which does not support OpenCL. So trying
> ENABLE_OPENCL=yes doesn't make any difference. And the processor is 6-cores
> Phenom II 1075T.
>
>
> With respect,
> Alexander Rabtchevich
>
>
>
>
> Victor Oliveira wrote:
>>
>> You could try the OpenCL support in GEGL, it should use all of your cores.
>>
>> ps: there are bugs still, but I'm solving them.
>>
>> Victor
>>
>> On Mon, Jan 28, 2013 at 4:27 PM, Alexander Rabtchevich
>>  wrote:
>>>
>>> Hello
>>>
>>> Is there a way to make 2.9 git master to use more than one core? Changing
>>> in
>>> GIMP settings doesn't make effect.
>>>
>>> With respect,
>>> Alexander Rabtchevich
>>>
>>> ___
>>> gimp-developer-list mailing list
>>> gimp-developer-list@gnome.org
>>> https://mail.gnome.org/mailman/listinfo/gimp-developer-list
>
>
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


[Gimp-developer] [PATCH] app: Use SHM transport for data transfer for display

2013-01-29 Thread Chris Wilson
Recent Cairo uses SHM transports when available, and exposes the ability
for its users to manage images shared between it and the display.
This allows us to eliminate copies, and if the architecture supports it
even to upload directly into GPU addressable memory without any copies
(all in normal system memory so we suffer no performance penalty when
applying the filters). The caveat is that we need to be aware of the
synchronize requirements, the cairo_surface_flush and
cairo_surface_mark_dirty, around access to the transport image. To
reduce the frequency of these barriers, we can subdivide the transport
image into small chunks as to satisfy individual updates and delay the
synchronisation barrier until we are forced to reuse earlier pixels.

Note this bumps the required Cairo version to 1.12, and please be aware
that the XSHM transport requires bug fixes from cairo.git (will be
1.12.12)

Cc: Michael Natterer 
---
 app/display/gimpdisplayshell-callbacks.c |3 +
 app/display/gimpdisplayshell-render.c|  223 +++---
 app/display/gimpdisplayshell-render.h|3 +
 app/display/gimpdisplayshell.c   |   16 +--
 app/display/gimpdisplayshell.h   |7 +
 configure.ac |2 +-
 6 files changed, 220 insertions(+), 34 deletions(-)

diff --git a/app/display/gimpdisplayshell-callbacks.c 
b/app/display/gimpdisplayshell-callbacks.c
index e8cf44d..4aa25f7 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -38,6 +38,7 @@
 #include "gimpdisplayshell-appearance.h"
 #include "gimpdisplayshell-callbacks.h"
 #include "gimpdisplayshell-draw.h"
+#include "gimpdisplayshell-render.h"
 #include "gimpdisplayshell-scroll.h"
 #include "gimpdisplayshell-selection.h"
 #include "gimpdisplayshell-title.h"
@@ -109,6 +110,8 @@ gimp_display_shell_canvas_realize (GtkWidget*canvas,
 
   /*  allow shrinking  */
   gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
+
+  gimp_display_shell_xfer_realize (shell);
 }
 
 void
diff --git a/app/display/gimpdisplayshell-render.c 
b/app/display/gimpdisplayshell-render.c
index 67d1c50..38eec27 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -42,6 +42,199 @@
 #include "gimpdisplayshell-render.h"
 #include "gimpdisplayshell-scroll.h"
 
+static struct rtree_node *
+rtree_node_create (struct rtree *rtree, struct rtree_node **prev,
+  int x, int y, int w, int h)
+{
+struct rtree_node *node;
+
+node = g_slice_alloc (sizeof (*node));
+if (node == NULL)
+   return NULL;
+
+node->children[0] = NULL;
+node->x = x;
+node->y = y;
+node->w = w;
+node->h = h;
+
+node->next = *prev;
+*prev = node;
+
+return node;
+}
+
+static void
+rtree_node_destroy (struct rtree *rtree, struct rtree_node *node)
+{
+int i;
+
+for (i = 0; i < 4 && node->children[i] != NULL; i++)
+   rtree_node_destroy (rtree, node->children[i]);
+
+g_slice_free (struct rtree_node, node);
+}
+
+static struct rtree_node *
+rtree_node_insert (struct rtree *rtree, struct rtree_node **prev,
+  struct rtree_node *node, int w, int h)
+{
+*prev = node->next;
+
+if (((node->w - w) | (node->h - h)) > 1) {
+   int ww = node->w - w;
+   int hh = node->h - h;
+   int i = 0;
+
+   node->children[i] = rtree_node_create (rtree, prev,
+  node->x, node->y,
+  w, h);
+   if (node->children[i] == NULL)
+   return node;
+   i++;
+
+   if (ww > 1) {
+   node->children[i] = rtree_node_create (rtree, prev,
+  node->x + w, node->y,
+  ww, h);
+   if (node->children[i])
+   i++;
+   }
+
+   if (hh > 1) {
+   node->children[i] = rtree_node_create (rtree, prev,
+  node->x, node->y + h,
+  ww, hh);
+   if (node->children[i])
+   i++;
+
+   if (w > 1) {
+   node->children[i] = rtree_node_create (rtree, prev,
+  node->x + w,
+  node->y + h,
+  ww, hh);
+   if (node->children[i])
+   i++;
+   }
+   }
+
+   if (i < 4)
+   node->children[i] = NULL;
+
+   node = node->children[0];
+}
+
+return node;
+}
+
+static struct rtree_node *
+rtree_insert (struct rtree *rtree, int w, int h)
+{
+struct rtree_node *node, **prev;
+
+for (prev = &rtree->available; (node = *prev); prev = &node->next)
+   if (node->w >= w && w < 2 * node->w && node->h >= h && h < 2 * node->h)
+   re

Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Paka
* Victor Oliveira  [01-29-13 07:39]:
> You can use OpenCL in the CPU, just install the AMD OpenCL SDK. GEGL
> looks for libOpenCL.so in /usr/lib.
> 
> You should use GEGL_ENABLE_OPENCL=yes

export as environment varible or ??

tks,
-- 
(paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
http://en.opensuse.org   openSUSE Community Member
Registered Linux User #207535@ http://linuxcounter.net
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


[Gimp-developer] [PATCH] app: Use SHM transport for data transfer for display

2013-01-29 Thread Chris Wilson
Recent Cairo uses SHM transports when available, and exposes the ability
for its users to manage images shared between it and the display.
This allows us to eliminate copies, and if the architecture supports it
even to upload directly into GPU addressable memory without any copies
(all in normal system memory so we suffer no performance penalty when
applying the filters). The caveat is that we need to be aware of the
synchronize requirements, the cairo_surface_flush and
cairo_surface_mark_dirty, around access to the transport image. To
reduce the frequency of these barriers, we can subdivide the transport
image into small chunks as to satisfy individual updates and delay the
synchronisation barrier until we are forced to reuse earlier pixels.

Note this bumps the required Cairo version to 1.12, and please be aware
that the XSHM transport requires bug fixes from cairo.git (will be
1.12.12)

v2: After further reflections with Mitch, we realized we share the
transport surface between all canvases by attaching it to the common
screen.

Cc: Michael Natterer 
---
 app/display/Makefile.am  |2 +
 app/display/gimpdisplay-transport.c  |  256 ++
 app/display/gimpdisplay-transport.h  |   42 +
 app/display/gimpdisplayshell-callbacks.c |3 +
 app/display/gimpdisplayshell-render.c|   33 ++--
 app/display/gimpdisplayshell-render.h|   14 --
 app/display/gimpdisplayshell.c   |   12 --
 app/display/gimpdisplayshell.h   |3 +-
 configure.ac |2 +-
 9 files changed, 315 insertions(+), 52 deletions(-)
 create mode 100644 app/display/gimpdisplay-transport.c
 create mode 100644 app/display/gimpdisplay-transport.h

diff --git a/app/display/Makefile.am b/app/display/Makefile.am
index d0b5413..3756b5b 100644
--- a/app/display/Makefile.am
+++ b/app/display/Makefile.am
@@ -75,6 +75,8 @@ libappdisplay_a_sources = \
gimpdisplay-foreach.h   \
gimpdisplay-handlers.c  \
gimpdisplay-handlers.h  \
+   gimpdisplay-transport.c \
+   gimpdisplay-transport.h \
gimpdisplayshell.c  \
gimpdisplayshell.h  \
gimpdisplayshell-appearance.c   \
diff --git a/app/display/gimpdisplay-transport.c 
b/app/display/gimpdisplay-transport.c
new file mode 100644
index 000..79709db
--- /dev/null
+++ b/app/display/gimpdisplay-transport.c
@@ -0,0 +1,256 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include "config.h"
+
+#include 
+#include 
+
+#include "display-types.h"
+
+#include "core/gimp.h"
+#include "core/gimpcontainer.h"
+#include "core/gimpcontext.h"
+#include "core/gimpimage.h"
+#include "core/gimplist.h"
+
+#include "gimpdisplay.h"
+#include "gimpdisplay-transport.h"
+
+struct GimpDisplayXfer {
+  struct rtree {
+  struct rtree_node {
+ struct rtree_node *children[4];
+ struct rtree_node *next;
+ int x, y, w, h;
+  } root, *available;
+  } rtree; /* track subregions of render_surface for efficient uploads */
+  cairo_surface_t *render_surface;   /*  buffer for rendering the image */
+};
+
+static struct rtree_node *
+rtree_node_create (struct rtree *rtree, struct rtree_node **prev,
+  int x, int y, int w, int h)
+{
+  struct rtree_node *node;
+
+  node = g_slice_alloc (sizeof (*node));
+  if (node == NULL)
+return NULL;
+
+  node->children[0] = NULL;
+  node->x = x;
+  node->y = y;
+  node->w = w;
+  node->h = h;
+
+  node->next = *prev;
+  *prev = node;
+
+  return node;
+}
+
+static void
+rtree_node_destroy (struct rtree *rtree, struct rtree_node *node)
+{
+  int i;
+
+  for (i = 0; i < 4 && node->children[i] != NULL; i++)
+rtree_node_destroy (rtree, node->children[i]);
+
+  g_slice_free (struct rtree_node, node);
+}
+
+static struct rtree_node *
+rtree_node_insert (struct rtree *rtree, struct rtree_node **prev,
+  struct rtree_node *node, int w, int h)
+{
+  *prev = node->next;
+
+  if (((node->w - w) | (node->h - h)) > 1)
+{
+  int ww = node->w - w;
+  int hh = node->h - h;
+  int i = 0;
+
+  node->children[i] = rtree_node_create (rtree, pr

Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Victor Oliveira
yes,

export GEGL_ENABLE_OPENCL=yes

also, when you build GEGL, put the option --enable-config.
with that you can set:

export GEGL_DEBUG=opencl

so you can see if OpenCL is really being used or if there is some bug.

Victor

On Tue, Jan 29, 2013 at 11:31 AM, Paka  wrote:
> * Victor Oliveira  [01-29-13 07:39]:
>> You can use OpenCL in the CPU, just install the AMD OpenCL SDK. GEGL
>> looks for libOpenCL.so in /usr/lib.
>>
>> You should use GEGL_ENABLE_OPENCL=yes
>
> export as environment varible or ??
>
> tks,
> --
> (paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
> http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
> http://en.opensuse.org   openSUSE Community Member
> Registered Linux User #207535@ http://linuxcounter.net
> ___
> gimp-developer-list mailing list
> gimp-developer-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gimp-developer-list
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Paka
* Victor Oliveira  [01-29-13 12:34]:
> yes,
> 
> export GEGL_ENABLE_OPENCL=yes
> 
> also, when you build GEGL, put the option --enable-config.
> with that you can set:
> 
> export GEGL_DEBUG=opencl
> 
> so you can see if OpenCL is really being used or if there is some bug.

tks, I added to ~/.bashrc as I use pre-packaged rpm.
I cannot see that opencl is required or used by gimp, as
  rpm -q gimp --requires 
does not show opencl 


is there a test to show usage other than dis-abling, timing an action, and
enabling and timing same action?

tks,  
-- 
(paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
http://en.opensuse.org   openSUSE Community Member
Registered Linux User #207535@ http://linuxcounter.net
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Victor Oliveira
no, besides building gegl by yourself, no.
GIMP doesn't require OpenCL because the libOpenCL.so is loaded at
runtime (like, dlopen) in the case it is present at the machine.

Victor

On Tue, Jan 29, 2013 at 3:57 PM, Paka  wrote:
> * Victor Oliveira  [01-29-13 12:34]:
>> yes,
>>
>> export GEGL_ENABLE_OPENCL=yes
>>
>> also, when you build GEGL, put the option --enable-config.
>> with that you can set:
>>
>> export GEGL_DEBUG=opencl
>>
>> so you can see if OpenCL is really being used or if there is some bug.
>
> tks, I added to ~/.bashrc as I use pre-packaged rpm.
> I cannot see that opencl is required or used by gimp, as
>   rpm -q gimp --requires
> does not show opencl
>
>
> is there a test to show usage other than dis-abling, timing an action, and
> enabling and timing same action?
>
> tks,
> --
> (paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
> http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
> http://en.opensuse.org   openSUSE Community Member
> Registered Linux User #207535@ http://linuxcounter.net
> ___
> gimp-developer-list mailing list
> gimp-developer-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gimp-developer-list
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Paka
* Victor Oliveira  [01-29-13 14:35]:
> no, besides building gegl by yourself, no.
> GIMP doesn't require OpenCL because the libOpenCL.so is loaded at
> runtime (like, dlopen) in the case it is present at the machine.

Then I guess the gimp package on my system does not utilize opencl.  I
opened gimp and loaded an image, instructed gimp to use GEGL and performed
a GEGL operation on the photo.  psaux does not reveal any opencl process
or library being loaded.   

Or is my thinking flawed?

tks,
-- 
(paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
http://en.opensuse.org   openSUSE Community Member
Registered Linux User #207535@ http://linuxcounter.net
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Liam R E Quin
On Tue, 2013-01-29 at 17:10 -0500, Paka wrote:
> psaux does not reveal any opencl process
> or library being loaded.   

You'd more likely need to use strace to see if the library was opened; I
am not sure that anything would show up in ps in this case.

Liam


-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Paka
* Liam R E Quin  [01-29-13 18:12]:
> On Tue, 2013-01-29 at 17:10 -0500, Paka wrote:
> > psaux does not reveal any opencl process
> > or library being loaded.   
> 
> You'd more likely need to use strace to see if the library was opened; I
> am not sure that anything would show up in ps in this case.

tks, 

ran strace -o  gimp

opened image
enabled GEGL under video
enabled GEGL under colors
performed tools->gegl-operation->noise-reduction
closed image/gimp

did  grep -i opencl 
got no hits

so I do not have opencl compiled in gimp

I am using proprietary NVidia drivers, 310-19, and have support installed
for opencl and can confirm that darktable uses it.

Does this appear correct?
-- 
(paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
http://en.opensuse.org   openSUSE Community Member
Registered Linux User #207535@ http://linuxcounter.net
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list


Re: [Gimp-developer] multithreading and GEGL

2013-01-29 Thread Victor Oliveira
It should work on GIMP 2.8.2. Do you have libOpenCL.so?
Also, I'm not sure if it spawn a separated process.

If you continue to have problems, I suggest you to build GEGL.

Victor

On Tue, Jan 29, 2013 at 8:10 PM, Paka  wrote:
> * Victor Oliveira  [01-29-13 14:35]:
>> no, besides building gegl by yourself, no.
>> GIMP doesn't require OpenCL because the libOpenCL.so is loaded at
>> runtime (like, dlopen) in the case it is present at the machine.
>
> Then I guess the gimp package on my system does not utilize opencl.  I
> opened gimp and loaded an image, instructed gimp to use GEGL and performed
> a GEGL operation on the photo.  psaux does not reveal any opencl process
> or library being loaded.
>
> Or is my thinking flawed?
>
> tks,
> --
> (paka)Patrick Shanahan   Plainfield, Indiana, USA  HOG # US1244711
> http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
> http://en.opensuse.org   openSUSE Community Member
> Registered Linux User #207535@ http://linuxcounter.net
> ___
> gimp-developer-list mailing list
> gimp-developer-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gimp-developer-list
___
gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list