BruceSherwood/vpython-wx

Fix a problem with Intel graphics

Opened this issue · 9 comments

From Maciej Wochal, reported in VPython forum:
I think I have found the reason of rendering issues on Linux when using Intel card.
This project had a similar problem:
slic3r/Slic3r#2197
... which was solved by requesting a depth buffer:
slic3r/Slic3r@c1d2c4e?diff=split

In file create_display.py, after line 686, adding an attribList solved the problem for me. The same trick also works for version 6.05. I have two asus laptops with intel graphics cards and both are now working correctly, except that for the eeepc I had to go back to version 6.05 because 6.10 was too slow.
Here's the exact code I used (with 1 unchanged line before and after for providing context):
# For backward compatibility, maintain self._canvas as well as self.canvas
attribList = [_wx.glcanvas.WX_GL_DEPTH_SIZE, 16]
c = self.canvas = self._canvas = _wx.glcanvas.GLCanvas(parent, -1, pos=(x, y),
size=(w, h), attribList = attribList)
self._context = _wx.glcanvas.GLContext(c)

Thanks for the detailed information. It is very hard to understand how 6.10 could be slower than 6.05, as 6.10 represents a bunch of bug fixes, not a change in the architecture.

Maybe the bug fix caused something to function that the eeepc can't handle? They're both low end machines anyway. In case it's of use to someone I'll paste their specs below, the second one is the eeepc. I used this handy instruction site to get them:

http://xmodulo.com/how-to-check-graphics-card-on-linux.html

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Device 14c7
Flags: bus master, fast devsel, latency 0, IRQ 43
Memory at f7800000 (64-bit, non-prefetchable) [size=4M]
Memory at e0000000 (64-bit, prefetchable) [size=256M]
I/O ports at f000 [size=64]
Expansion ROM at [disabled]
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [a4] PCI Advanced Features
Kernel driver in use: i915

00:02.0 VGA compatible controller: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller (rev 02) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Device 83ac
Flags: bus master, fast devsel, latency 0, IRQ 44
Memory at f7e00000 (32-bit, non-prefetchable) [size=512K]
I/O ports at dc00 [size=8]
Memory at d0000000 (32-bit, prefetchable) [size=256M]
Memory at f7d00000 (32-bit, non-prefetchable) [size=1M]
Expansion ROM at [disabled]
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Kernel driver in use: i915
Kernel modules: i915

None of the bug fixes were "deep" ones and likely to cause a slowdown, nor are there any other reports of such a phenomenon. You might not be able to answer the question, but can you say anything about what specific aspects of 6.10 are slow?

The eeepc needs "enable_shaders = False" in vis/site_settings.py or it will use 100% cpu time of the processor it is running on. My 6.05 installation already had that configured, and after doing the same for 6.10 it only uses 40% cpu time and becomes much more responsive.

...not sure how to atach a real patch. I sent it to the mailing list. The patch below has two things. First is a patch to setup.py that makes it compile properly with Ubuntu 14.04. The second fixes this visual issue. The key is not only to add an explicit WX_GL_DEPTH_SIZE in the attribute list, but also an explicit WX_GL_DOUBLEBUFFER.

diff --git a/setup.py b/setup.py
index abfb2d0..9631cf0 100644
--- a/setup.py
+++ b/setup.py
@@ -80,7 +80,8 @@ elif os_host in ('linux'):
     LINK_FLAGS="-Wl,--export-dynamic"

     GTK_VIS_LIBS = get_libs()
-    GTK_VIS_LIBS.append('boost_python-mt-py' + versionString)
+    # GTK_VIS_LIBS.append('boost_python-mt-py' + versionString)
+    GTK_VIS_LIBS.append('boost_python-py' + versionString)
     GTK_VIS_LIBS.append('boost_signals')

     GTK_INCDIRS = get_includes()
diff --git a/site-packages/visual_common/create_display.py b/site-packages/visual_common/create_display.py
index f89a8f0..eb6c01f 100755
--- a/site-packages/visual_common/create_display.py
+++ b/site-packages/visual_common/create_display.py
@@ -684,7 +684,19 @@ class display(cvisual.display_kernel):
             w = self._width
             h = self._height
         # For backward compatibility, maintain self._canvas as well as self.canvas
-        c = self.canvas = self._canvas = _wx.glcanvas.GLCanvas(parent, -1, pos=(x, y), size=(w, h))
+        attribList = [_wx.glcanvas.WX_GL_DEPTH_SIZE, 24, 
+                      _wx.glcanvas.WX_GL_DOUBLEBUFFER, 1,
+                    0]
+        if _wx.glcanvas.GLCanvas_IsDisplaySupported(attribList):
+            c = self.canvas = self._canvas = _wx.glcanvas.GLCanvas(parent, -1, pos=(x, y), size=(w, h), attribList = attribList)
+        else:
+            attribList = [_wx.glcanvas.WX_GL_DEPTH_SIZE, 16, 
+                          _wx.glcanvas.WX_GL_DOUBLEBUFFER, 1,
+                          0]
+            if _wx.glcanvas.GLCanvas_IsDisplaySupported(attribList):
+                c = self.canvas = self._canvas = _wx.glcanvas.GLCanvas(parent, -1, pos=(x, y), size=(w, h), attribList = attribList)
+            else:
+                c = self.canvas = self._canvas = _wx.glcanvas.GLCanvas(parent, -1, pos=(x, y), size=(w, h))
         self._context = _wx.glcanvas.GLContext(c)

         if self.fillswindow: c.SetFocus()

I was having the same z-index/rendering order issues as in slic3r/Slic3r#2197. Modifying file create_display.py as in @rknop's patch fixed it for me.

Hardware information:

# lshw -c video
  *-display               
       description: VGA compatible controller
       product: RV710/M92 [Mobility Radeon HD 4530/4570/545v]
       vendor: Advanced Micro Devices, Inc. [AMD/ATI]
       physical id: 0
       bus info: pci@0000:01:00.0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: pm pciexpress msi vga_controller bus_master cap_list rom
       configuration: driver=radeon latency=0
       resources: irq:29 memory:d0000000-dfffffff ioport:2000(size=256) memory:cfef0000-cfefffff memory:cfe00000-cfe1ffff

The patch works for me as well. When I get a chance I'll check it in to git.

thanks!
-steve

On Dec 14, 2014, at 9:32 AM, Leandro Lovisolo notifications@github.com wrote:

I was having the same z-index/rendering order issues as in slic3r/Slic3r#2197. Modifying file create_display.py as in @rknop's patch fixed it for me.

Hardware information:

lshw -c video

*-display
description: VGA compatible controller
product: RV710/M92 [Mobility Radeon HD 4530/4570/545v]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:01:00.0
version: 00
width: 32 bits
clock: 33MHz
capabilities: pm pciexpress msi vga_controller bus_master cap_list rom
configuration: driver=radeon latency=0
resources: irq:29 memory:d0000000-dfffffff ioport:2000(size=256) memory:cfef0000-cfefffff memory:cfe00000-cfe1ffff

Reply to this email directly or view it on GitHub.

Oh, I also need to test it on Mac OS and Windows.

thanks,
-steve

On Dec 15, 2014, at 9:33 AM, Steve Spicklemire steve@spvi.com wrote:

The patch works for me as well. When I get a chance I'll check it in to git.

thanks!
-steve

On Dec 14, 2014, at 9:32 AM, Leandro Lovisolo notifications@github.com wrote:

I was having the same z-index/rendering order issues as in slic3r/Slic3r#2197. Modifying file create_display.py as in @rknop's patch fixed it for me.

Hardware information:

lshw -c video

*-display
description: VGA compatible controller
product: RV710/M92 [Mobility Radeon HD 4530/4570/545v]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:01:00.0
version: 00
width: 32 bits
clock: 33MHz
capabilities: pm pciexpress msi vga_controller bus_master cap_list rom
configuration: driver=radeon latency=0
resources: irq:29 memory:d0000000-dfffffff ioport:2000(size=256) memory:cfef0000-cfefffff memory:cfe00000-cfe1ffff

Reply to this email directly or view it on GitHub.