diff options
author | Sven Gothel <[email protected]> | 2010-04-13 21:24:44 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-13 21:24:44 +0200 |
commit | 2df3bea10859ee2f2c4b3622f3b610b17a5749d6 (patch) | |
tree | 9bb948241aef06fdaf1dd4d09f1b31989c76f858 /src/jogl/classes/com/jogamp/opengl/impl/windows | |
parent | 1c1053c6a8b669c067ae1316b9770871e213ea05 (diff) |
ATI (fglrx) PBuffer/X11Display bug workaround/cleanup
- See https://bugzilla.mozilla.org/show_bug.cgi?id=486277
- Description:
- To use PBuffer, a context must be current
- X11Display cannot be switched while using the PBuffer
[within one thread]. Hence we shall try harder to reuse
_the_ user configured X11Display - whenever possible.
This is actually a good thing, ie cleanup up our
code again.
- Changes to workaround/cleanup:
- GLDrawableFactory* methods 'canCreate*()'
are changed to 'canCreate*(AbstractGraphicsDevice)'
to allow pipelining the X11Display.
This reduces the overhead of using a local TLS X11Display.
- WindowsDummyWGLDrawable cstr gets the GLProfile as a parameter now,
this is done while adding X11DummyGLXDrawable - forseeing the
usecase to query available GLProfiles at startup.
- X11DummyGLXDrawable added, following the WindowsDummyWGLDrawable path
to have a dummy GLContext current to fix the ATI bug.
NativeWindow X11:
- Add XIOErrorHandler to identify the fatal failure
of closing a Display (-> ATI bug).
Build:
- Adding ant.jar and ant-junit.jar to the junit compile/run classpath
-
Misc:
- Fix: CreateDummyWindow(..) returns a HWND, not a HDC
- mapToRealGLFunctionName: Added mapping for X11/GLX.
- X11GLXGraphicsConfigurationFactory: Uncommented dead code 'createDefaultGraphicsConfigurationFBConfig'
Tests: Passed (Linux64bit: NVidia/ATI)
Todo: More tests on ATI, especially multithreading/X11Display usage.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/windows')
4 files changed, 24 insertions, 36 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index 49e646844..87a37da04 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -46,8 +46,8 @@ import com.jogamp.nativewindow.impl.NullWindow; public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { private long hwnd, hdc; - public WindowsDummyWGLDrawable(GLDrawableFactory factory) { - super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(null, true, true)), true); + public WindowsDummyWGLDrawable(GLDrawableFactory factory, GLProfile glp) { + super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(glp, null, true, true)), true); // All entries to CreateDummyWindow must synchronize on one object // to avoid accidentally registering the dummy window class twice synchronized (WindowsDummyWGLDrawable.class) { @@ -56,8 +56,9 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { hdc = WGL.GetDC(hwnd); NullWindow nw = (NullWindow) getNativeWindow(); nw.setSurfaceHandle(hdc); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration(); // Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context - GLCapabilities caps = new GLCapabilities(null); + GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities(); caps.setDepthBits(16); PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps); int pixelFormat = WGL.ChoosePixelFormat(hdc, pfd); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index 08c77539c..b3f4c498c 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -118,21 +118,9 @@ public class WindowsWGLContext extends GLContextImpl { return wglExtProcAddressTable; } - protected String mapToRealGLFunctionName(String glFunctionName) { - String lookup = (String) functionNameMap.get(glFunctionName); - if (lookup != null) { - return lookup; - } - return glFunctionName; - } + protected Map/*<String, String>*/ getFunctionNameMap() { return functionNameMap; } - protected String mapToRealGLExtensionName(String glExtensionName) { - String lookup = (String) extensionNameMap.get(glExtensionName); - if (lookup != null) { - return lookup; - } - return glExtensionName; - } + protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; } /** * Creates and initializes an appropriate OpenGL context. Should only be @@ -306,7 +294,7 @@ public class WindowsWGLContext extends GLContextImpl { if (WGL.wglGetCurrentContext() != hglrc) { if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) { - throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError())); + throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError()) + ", " + this); } else { if (DEBUG && VERBOSE) { System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 9e458c8d0..cb3ee19e0 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -85,12 +85,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements private boolean pbufferSupportInitialized = false; private boolean canCreateGLPbuffer = false; - public boolean canCreateGLPbuffer() { + public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { if (!pbufferSupportInitialized) { final GLDrawableFactory factory = this; Runnable r = new Runnable() { public void run() { - WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory); + WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory, null); GLContext dummyContext = dummyDrawable.createContext(null); if (dummyContext != null) { GLContext lastContext = GLContext.getCurrent(); @@ -123,7 +123,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements final GLDrawableFactory factory = this; Runnable r = new Runnable() { public void run() { - WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory); + WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory, null); WindowsWGLContext dummyContext = (WindowsWGLContext) dummyDrawable.createContext(null); GLContext lastContext = GLContext.getCurrent(); if (lastContext != null) { @@ -136,10 +136,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements dummyDrawable, dummyWGLExt); returnList.add(pbufferDrawable); - dummyContext.release(); - dummyContext.destroy(); - dummyDrawable.destroy(); } finally { + if(null!=dummyContext) { + dummyContext.release(); + dummyContext.destroy(); + } + if(null!=dummyDrawable) { + dummyDrawable.destroy(); + } if (lastContext != null) { lastContext.makeCurrent(); } @@ -162,7 +166,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements return WindowsExternalWGLContext.create(this, null); } - public boolean canCreateExternalGLDrawable() { + public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) { return true; } @@ -222,7 +226,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements return detail; } - public boolean canCreateContextOnJava2DSurface() { + public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) { return false; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 563173682..55b30ef3a 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -58,22 +58,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio return chooseGraphicsConfigurationStatic(caps, chooser, absScreen); } - protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) { - GLCapabilities caps = new GLCapabilities(null); + protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(GLProfile glp, AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) { + GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(onscreen); // FIXME DBLBUFOFFSCRN caps.setOnscreen (onscreen); caps.setPBuffer (usePBuffer); - GLCapabilities caps2 = (GLCapabilities) caps.clone(); - if(!caps2.isOnscreen()) { - // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN - caps2.setDoubleBuffered(false); - } - if(null==absScreen) { absScreen = DefaultGraphicsScreen.createScreenDevice(0); } - return new WindowsWGLGraphicsConfiguration(absScreen, caps2, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps2), -1, null); + return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps), -1, null); + } protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities caps, @@ -143,7 +138,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio GLContextImpl dummyContext = null; WGLExt dummyWGLExt = null; if (capabilities.getSampleBuffers()) { - dummyDrawable = new WindowsDummyWGLDrawable(factory); + dummyDrawable = new WindowsDummyWGLDrawable(factory, glProfile); dummyContext = (GLContextImpl) dummyDrawable.createContext(null); if (dummyContext != null) { dummyContext.makeCurrent(); |