diff options
author | Kenneth Russel <kbrussel@alum.mit.edu> | 2006-03-23 17:48:28 +0000 |
---|---|---|
committer | Kenneth Russel <kbrussel@alum.mit.edu> | 2006-03-23 17:48:28 +0000 |
commit | 158ef34fb8c7c8d95dd92606d66b8a78f98a9f4f (patch) | |
tree | cbd59ff723d097f08bbbc226fbf3547d6690446b /src/classes/javax | |
parent | 6a5a2de148e829df94ae93bf28c1e76685581e50 (diff) |
Fixed extreme slowdown with Java2D/OpenGL pipeline and FBO case on ATI
hardware pointed out by Chris Campbell by unbinding the FBO from
Java2D's context before making it current in ours
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@677 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax')
-rw-r--r-- | src/classes/javax/media/opengl/GLJPanel.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java index 529b951a3..a6a8b608d 100644 --- a/src/classes/javax/media/opengl/GLJPanel.java +++ b/src/classes/javax/media/opengl/GLJPanel.java @@ -174,6 +174,18 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { private int[] frameBufferDepthBuffer; private int[] frameBufferTexture; private boolean createNewDepthBuffer; + // Current (as of this writing) ATI drivers have problems when the + // same FBO is bound in two different contexts. Here we check for + // this case and explicitly release the FBO from Java2D's context + // before switching to ours. Java2D will re-bind the FBO when it + // makes its context current the next time. Interestingly, if we run + // this code path on NVidia hardware, it breaks the rendering + // results -- no output is generated. This doesn't appear to be an + // interaction with the abovementioned NVidia-specific workarounds, + // as even if we disable that code the FBO is still reported as + // incomplete in our context. + private boolean checkedGLVendor; + private boolean vendorIsATI; // These are always set to (0, 0) except when the Java2D / OpenGL // pipeline is active @@ -273,6 +285,25 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { System.err.println("GLJPanel: FBO COLOR_ATTACHMENT0: " + frameBufferTexture[0]); } } + + if (!checkedGLVendor) { + checkedGLVendor = true; + String vendor = gl.glGetString(GL.GL_VENDOR); + + if ((vendor != null) && + vendor.startsWith("ATI")) { + vendorIsATI = true; + } + } + + if (vendorIsATI) { + // Unbind the FBO from Java2D's context as it appears that + // driver bugs on ATI's side are causing problems if the FBO is + // simultaneously bound to more than one context. Java2D will + // re-bind the FBO during the next validation of its context. + // Note: this breaks rendering at least on NVidia hardware + gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); + } } } |