diff options
author | Kenneth Russel <[email protected]> | 2004-06-19 01:58:40 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2004-06-19 01:58:40 +0000 |
commit | 8f1783018b2df30d1ba59866cfde9f884da5ad97 (patch) | |
tree | 30a815946edbf281d927a7b607bff18f9a6294f9 /src/net/java/games/jogl/impl/x11 | |
parent | 8fc1f6b579fa953abf7627df1198bf1677b9e54f (diff) |
This putback attempts to address the following issues:
Issue 59: GLContext Leak
Issue 67: Java/Jogl app hangs some systems, not others, during reshape.
Issue 69: Error on window resize
Issue 89: Losing Backbuffer when Resizing/Moving a window
The primary change is to support handing off of the display()
implementation to the AWT event queue thread via a new class called
SingleThreadedWorkaround in the impl package. This was done to cause
the AWT's reshape code to execute on the same thread as all other
OpenGL rendering without changing the threading model (e.g., Animator
and the ability to manually call display()) visible to the end user.
This set of changes appears to work around the problems seen on ATI
cards with random corruption when resizing animating windows due to
multithreading bugs in the drivers. More testing by a larger community
will confirm this fix. Currently the workaround is enabled by default
on ATI cards.
A secondary but related change is to properly destroy the OpenGL
context when a heavyweight component is removed from its container.
In order to implement the above workaround, it was necessary to
override addNotify and removeNotify to properly track whether
GLCanvases were realized; at that point it was a fairly small step to
properly delete and recreate OpenGL contexts. The previous heuristics
which attempted to determine when a heavyweight had been realized have
been removed. A new demo, TestContextDestruction, exercises the new
functionality. It does still appear to exhibit resource leaks,
however; removing and re-adding the GLCanvas from its parent multiple
times causes the system to eventually slow down significantly. More
work is needed in this area. However, the demo does now execute as
opposed to throwing an exception which was the previous behavior.
The current code has been tested on Windows on NVidia hardware with
all existing demos with the workaround both enabled and disabled, and
on ATI hardware with the existing compatible demos with the workaround
enabled. The new abstract method in GLContext, destroyImpl(), has been
implemented but not yet tested on X11 and Mac OS X.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@132 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/x11')
4 files changed, 20 insertions, 0 deletions
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java index e3bb4ce72..40e462fb3 100644 --- a/src/net/java/games/jogl/impl/x11/X11GLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11GLContext.java @@ -59,6 +59,11 @@ public abstract class X11GLContext extends GLContext { // OpenGL functions. private GLProcAddressTable glProcAddressTable; private static boolean haveResetGLXProcAddressTable; + // Cache the most recent value of the "display" variable (which we + // only guarantee to be valid in between makeCurrent / free pairs) + // so that we can implement displayImpl() (which must be done when + // the context is not current) + protected long mostRecentDisplay; static { functionNameMap = new HashMap(); @@ -167,6 +172,18 @@ public abstract class X11GLContext extends GLContext { } } + protected void destroyImpl() throws GLException { + if (context != 0) { + if (!GLX.glXDestroyContext(mostRecentDisplay, context)) { + throw new GLException("Unable to delete OpenGL context"); + } + if (DEBUG) { + System.err.println("!!! Destroyed OpenGL context " + context); + } + context = 0; + } + } + public abstract void swapBuffers() throws GLException; protected long dynamicLookupFunction(String glFuncName) { diff --git a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java index 8c88b0225..0290f8d44 100644 --- a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java @@ -129,6 +129,7 @@ public class X11OffscreenGLContext extends X11GLContext { pendingOffscreenResize = false; } } + mostRecentDisplay = display; return super.makeCurrent(initAction); } diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java index 911fc3740..1b5f54979 100644 --- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java @@ -189,6 +189,7 @@ public class X11OnscreenGLContext extends X11GLContext { visualID = 0; return false; } + mostRecentDisplay = display; return true; } diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java index ccbba8b92..5ab976870 100644 --- a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java @@ -217,6 +217,7 @@ public class X11PbufferGLContext extends X11GLContext { // Set up instance variables this.display = display; + mostRecentDisplay = display; this.parentContext = parentContext; buffer = tmpBuffer; this.fbConfig = fbConfig; |