aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-25 06:08:01 +0200
committerSven Gothel <[email protected]>2013-04-25 06:08:01 +0200
commit75b3d37a3b15c071b49609921244bcb62d329fa9 (patch)
treea3a539aedb2401a53628886cbb7edefb53a3242e /src
parente2323aea92dc8d47f583002921287a06230b2d93 (diff)
Fix Bug 706 and Bug 520: Certain ATI GPU/driver require a current context when calling wglCreateContextAttribsARB (Windows)
See discussion at https://jogamp.org/bugzilla/show_bug.cgi?id=520 https://jogamp.org/bugzilla/show_bug.cgi?id=706
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java25
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java51
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java14
-rw-r--r--src/nativewindow/native/win32/DeviceDriverQuery.txt41
4 files changed, 100 insertions, 31 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index 77d06f548..92b12a7ff 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -218,7 +218,6 @@ public class WindowsWGLContext extends GLContextImpl {
};
if ( major > 3 || major == 3 && minor >= 2 ) {
- // FIXME: Verify with a None drawable binding (default framebuffer)
attribs[idx_profile+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB;
if( ctBwdCompat ) {
attribs[idx_profile+1] = WGLExt.WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
@@ -269,11 +268,12 @@ public class WindowsWGLContext extends GLContextImpl {
*/
@Override
protected boolean createImpl(GLContextImpl shareWith) {
- AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
- AbstractGraphicsDevice device = config.getScreen().getDevice();
- WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
- WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device);
- GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities();
+ final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
+ final AbstractGraphicsDevice device = config.getScreen().getDevice();
+ final WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
+ final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device);
+ final WindowsWGLContext sharedContext = (WindowsWGLContext) ( null != sharedResource ? sharedResource.getContext() : null );
+ final GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities();
isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable
@@ -296,7 +296,18 @@ public class WindowsWGLContext extends GLContextImpl {
// utilize the shared context's GLXExt in case it was using the ARB method and it already exists ; exclude BITMAP
if( null != sharedContext && sharedContext.isCreatedWithARBMethod() && !glCaps.isBitmap() ) {
- contextHandle = createContextARB(share, true);
+ if ( sharedResource.needsCurrenContext4ARBCreateContextAttribs() ) {
+ if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) {
+ throw new GLException("Could not make Shared Context current: "+sharedContext);
+ }
+ contextHandle = createContextARB(share, true);
+ sharedContext.release();
+ if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError());
+ }
+ } else {
+ contextHandle = createContextARB(share, true);
+ }
createContextARBTried = true;
if ( DEBUG && 0 != contextHandle ) {
System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share);
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index e9742c4fe..483e31611 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -208,18 +208,19 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
static final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0);
static class SharedResource implements SharedResourceRunner.Resource {
+ private final boolean hasARBPixelFormat;
+ private final boolean hasARBMultisample;
+ private final boolean hasARBPBuffer;
+ private final boolean hasARBReadDrawable;
+ private final String vendor;
+ private final boolean isVendorATI;
+ private final boolean isVendorNVIDIA;
+ private final boolean needsCurrenContext4ARBPFDQueries;
+ private final boolean needsCurrenContext4ARBCreateContextAttribs;
private WindowsGraphicsDevice device;
private AbstractGraphicsScreen screen;
private GLDrawableImpl drawable;
private GLContextImpl context;
- private boolean hasARBPixelFormat;
- private boolean hasARBMultisample;
- private boolean hasARBPBuffer;
- private boolean hasARBReadDrawable;
- private String vendor;
- private boolean isVendorATI;
- private boolean isVendorNVIDIA;
- private boolean needsCurrenContext4ARBPFDQueries;
SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, GLDrawableImpl draw, GLContextImpl ctx,
boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable, String glVendor) {
@@ -235,20 +236,26 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
if(null != vendor) {
isVendorNVIDIA = vendor.startsWith("NVIDIA") ;
isVendorATI = vendor.startsWith("ATI") ;
+ } else {
+ isVendorNVIDIA = false;
+ isVendorATI = false;
}
- if ( isVendorATI() ) {
+ if ( isVendorATI ) {
+ needsCurrenContext4ARBCreateContextAttribs = true;
final VersionNumber winVersion = Platform.getOSVersionNumber();
final boolean isWinXPOrLess = winVersion.compareTo(winXPVersionNumber) <= 0;
- if(DEBUG) {
- System.err.println("needsCurrenContext4ARBPFDQueries: "+winVersion+" <= "+winXPVersionNumber+" = "+isWinXPOrLess+" - "+Platform.getOSVersion());
- }
needsCurrenContext4ARBPFDQueries = isWinXPOrLess;
- } else {
- if(DEBUG) {
- System.err.println("needsCurrenContext4ARBPFDQueries: false");
+ if(DEBUG) {
+ System.err.println("ATI && isWinXPOrLess = "+winVersion+" <= "+winXPVersionNumber+" = "+isWinXPOrLess+" - "+Platform.getOSVersion());
}
+ } else {
needsCurrenContext4ARBPFDQueries = false;
+ needsCurrenContext4ARBCreateContextAttribs = false;
+ }
+ if(DEBUG) {
+ System.err.println("needsCurrenContext4ARBCreateContextAttribs: "+needsCurrenContext4ARBCreateContextAttribs);
+ System.err.println("needsCurrenContext4ARBPFDQueries: "+needsCurrenContext4ARBPFDQueries);
}
}
@@ -273,12 +280,22 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
/**
* Solves bug #480
*
- * TODO: Validate if bug is actually relates to the 'old' ATI Windows driver for old GPU's like X300 etc
- * and unrelated to the actual Windows version !
+ * TODO: Validate if bug actually relates to the 'old' ATI Windows driver for old GPU's like X300 etc
+ * and not to the Windows version !
*
* @return true if GL_VENDOR is ATI _and_ platform is Windows version XP or less!
*/
final boolean needsCurrentContext4ARBPFDQueries() { return needsCurrenContext4ARBPFDQueries; }
+
+ /**
+ * Solves bug #706 and bug #520
+ *
+ * TODO: Validate if quirk can be reduced to a certain range of GPUs and/or driver versions,
+ * where we would also need a method to query the latter (-> jogl/src/nativewindow/native/win32/DeviceDriverQuery.txt).
+ *
+ * @return true if GL_VENDOR is ATI
+ */
+ final boolean needsCurrenContext4ARBCreateContextAttribs() { return needsCurrenContext4ARBCreateContextAttribs; }
}
class SharedResourceImplementation implements SharedResourceRunner.Implementation {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 19005e48c..0d89468a9 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -157,17 +157,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
private HashMap<String /* connection */, SharedResourceRunner.Resource> sharedMap;
static class SharedResource implements SharedResourceRunner.Resource {
+ private final String glXServerVendorName;
+ private final boolean isGLXServerVendorATI;
+ private final boolean isGLXServerVendorNVIDIA;
+ private final VersionNumber glXServerVersion;
+ private final boolean glXServerVersionOneOneCapable;
+ private final boolean glXServerVersionOneThreeCapable;
+ private final boolean glXMultisampleAvailable;
X11GraphicsDevice device;
X11GraphicsScreen screen;
GLDrawableImpl drawable;
GLContextImpl context;
- String glXServerVendorName;
- boolean isGLXServerVendorATI;
- boolean isGLXServerVendorNVIDIA;
- VersionNumber glXServerVersion;
- boolean glXServerVersionOneOneCapable;
- boolean glXServerVersionOneThreeCapable;
- boolean glXMultisampleAvailable;
SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn,
GLDrawableImpl draw, GLContextImpl ctx,
diff --git a/src/nativewindow/native/win32/DeviceDriverQuery.txt b/src/nativewindow/native/win32/DeviceDriverQuery.txt
new file mode 100644
index 000000000..7401ed83b
--- /dev/null
+++ b/src/nativewindow/native/win32/DeviceDriverQuery.txt
@@ -0,0 +1,41 @@
+
+ // INCOMPLETE !
+ //
+ // See Bug 706 and Bug 520
+ // https://jogamp.org/bugzilla/show_bug.cgi?id=520
+ // https://jogamp.org/bugzilla/show_bug.cgi?id=706
+ //
+ // Device Driver SDK
+ // http://msdn.microsoft.com/en-us/library/ff553567.aspx#ddk_setupdi_device_information_functions_dg
+ {
+ /**
+ System-Defined Device Setup Classes Available to Vendors (GUID)
+
+ Display Adapters
+ Class = Display
+ ClassGuid = {4d36e968-e325-11ce-bfc1-08002be10318}
+ This class includes video adapters. Drivers for this class include display drivers and video miniport drivers.
+
+ /opt-windows/mingw/include/devguid.h GUID_DEVCLASS_DISPLAY
+ GUID_DEVCLASS_DISPLAY
+ HDEVINFO SetupDiGetClassDevs(
+ _In_opt_ const GUID *ClassGuid,
+ _In_opt_ PCTSTR Enumerator,
+ _In_opt_ HWND hwndParent,
+ _In_ DWORD Flags
+ );
+
+ */
+ const GUID devClassDisplay = GUID_DEVCLASS_DISPLAY;
+ // http://msdn.microsoft.com/en-us/library/ff551069.aspx
+ HDEVINFO DeviceInfoSet = SetupDiGetClassDevs(&GUID_DEVCLASS_DISPLAY, NULL /* bus */, NULL /* windows */, DIGCF_PRESENT | DIGCF_PROFILE /* flags */);
+ DWORD MemberIndex = 0;
+ SP_DEVINFO_DATA DeviceInfoData;
+ DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+ while( TRUE == SetupDiEnumDeviceInfo(DeviceInfoSet, MemberIndex, &DeviceInfoData) ) {
+ SetupDiGetSelectedDevice();
+ MemberIndex++;
+ }
+ SetupDiDestroyDeviceInfoList(hDevInfo);
+ }
+