View | Details | Raw Unified | Return to bug 705
Collapse All | Expand All

(-)a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java (-2 / +31 lines)
Lines 81-92 public class GLRendererQuirks { Link Here
81
     */
81
     */
82
    public static final int GLFlushBeforeRelease = 7;
82
    public static final int GLFlushBeforeRelease = 7;
83
    
83
    
84
    // 
85
    // The JVM for the following system crashes on the second call to glXDestroyContext after
86
    // XCloseDisplay has been called once.
87
    //
88
    // The following will crash the system:
89
    //   XOpenDisplay(A), glXCreateNewContext(A), XOpenDisplay(B), glXCreateNewContext(B), 
90
    //   glXDestroyContext(A/B), XCloseDisplay(A/B), glXDestroyContext(B/A) (crash)
91
    //
92
    // Dell Latitude D520
93
    // Intel(R) Core(TM)2 CPU T7200
94
    // i810 Monitor driver
95
    // Platform       LINUX / Linux 2.6.18.8-0.3-default (os), i386 (arch), GENERIC_ABI, 2 cores
96
    // Platform       Java Version: 1.6.0_18, VM: Java HotSpot(TM) Server VM, Runtime: Java(TM) SE Runtime Environment
97
    // Platform       Java Vendor: Sun Microsystems Inc., http://java.sun.com/, JavaSE: true, Java6: true, AWT enabled: true
98
    // GL Profile     GLProfile[GL2/GL2.sw]
99
    // CTX VERSION    2.1 (Compatibility profile, FBO, software) - 2.1 Mesa 7.8.2
100
    // GL             jogamp.opengl.gl4.GL4bcImpl@472d48
101
    // GL_VENDOR      Brian Paul
102
    // GL_RENDERER    Mesa X11
103
    // GL_VERSION     2.1 Mesa 7.8.2
104
    //
105
    // The error can be reproduced using a C code, thus the error is indpendent of Java and JOGL.
106
    // The work around is to close all the X11 displays upon exit for a "Mesa X11" version < 8.
107
    // At this moment, it is unknown if the error exists in versions greater than 7.
108
    //
109
    // Martin C. Hegedus, March 30, 2013
110
    //
111
    public static final int DontCloseX11DisplayConnection = 8;
112
    
84
    /** Number of quirks known. */
113
    /** Number of quirks known. */
85
    public static final int COUNT = 8;
114
    public static final int COUNT = 9;
86
    
115
    
87
    private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
116
    private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
88
                                                          "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
117
                                                          "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
89
                                                          "GLNonCompliant", "GLFlushBeforeRelease"
118
                                                          "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11DisplayConnection"
90
                                                        };
119
                                                        };
91
120
92
    private final int _bitmask;
121
    private final int _bitmask;
(-)a/src/jogl/classes/javax/media/opengl/GLProfile.java (+25 lines)
Lines 64-69 import java.util.HashMap; Link Here
64
import java.util.Iterator;
64
import java.util.Iterator;
65
import java.util.List;
65
import java.util.List;
66
66
67
// Added to check if X11 Displays should be closed on exit
68
// Martin C. Hegedus, March 30, 2013
69
import com.jogamp.opengl.GLRendererQuirks;
70
import jogamp.nativewindow.x11.X11Util;
71
67
/**
72
/**
68
 * Specifies the the OpenGL profile.
73
 * Specifies the the OpenGL profile.
69
 * 
74
 * 
Lines 1524-1529 public class GLProfile { Link Here
1524
        final boolean addedEGLProfile     = null != defaultEGLDevice     ? initProfilesForDevice(defaultEGLDevice)     : false;
1529
        final boolean addedEGLProfile     = null != defaultEGLDevice     ? initProfilesForDevice(defaultEGLDevice)     : false;
1525
        final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false;        
1530
        final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false;        
1526
        final boolean addedAnyProfile     = addedEGLProfile || addedDesktopProfile ;
1531
        final boolean addedAnyProfile     = addedEGLProfile || addedDesktopProfile ;
1532
    
1533
	// Added to check if X11 Displays should be closed on exit
1534
	// NOTE:  This checks defaultEGLDevice and defaultDesktopDevice to determine if XCloseDisplay should be called on exit
1535
	// NOTE:  These checks must be done after initProfilesForDevice since GLContext must set up the renderer quirks.
1536
	// NOTE:  At this point the shared resource has already opened a display, created a new context, made it current, and
1537
	//        released it.  Let's cross our fingers that at this point in the code the context will not be destroyed and 
1538
	//        the display closed under any circumstances.
1539
	// NOTE:  The checks can be tricked if the default screen is using a driver other than X11 and later a X11 Display,
1540
	//        such as a remote display, is opened.  If this occurs then markAllDisplaysUnclosable will not have been
1541
	//        correctly set.  Something to deal with at a later date.
1542
	//
1543
	// Martin C. Hegedus, March 30, 2013
1544
	if (eglFactory != null && defaultEGLDevice != null &&
1545
	    eglFactory.hasRendererQuirk(defaultEGLDevice,GLRendererQuirks.DontCloseX11DisplayConnection) &&
1546
	    NativeWindowFactory.getNativeWindowType(true) == NativeWindowFactory.TYPE_X11)
1547
	    X11Util.markAllDisplaysUnclosable();
1548
	if (desktopFactory != null && defaultDesktopDevice != null &&
1549
	    desktopFactory.hasRendererQuirk(defaultDesktopDevice,GLRendererQuirks.DontCloseX11DisplayConnection) &&
1550
	    NativeWindowFactory.getNativeWindowType(true) == NativeWindowFactory.TYPE_X11)
1551
	    X11Util.markAllDisplaysUnclosable();
1527
            
1552
            
1528
        if(DEBUG) {
1553
        if(DEBUG) {
1529
            System.err.println("GLProfile.init addedAnyProfile       "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")");
1554
            System.err.println("GLProfile.init addedAnyProfile       "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")");
(-)a/src/jogl/classes/jogamp/opengl/GLContextImpl.java (+32 lines)
Lines 1551-1559 public abstract class GLContextImpl extends GLContext { Link Here
1551
            quirks[i++] = quirk;
1551
            quirks[i++] = quirk;
1552
        }
1552
        }
1553
    }
1553
    }
1554
    
1555
    //
1556
    // Mesa RENDERER related quirks
1557
    //
1558
    if( glRendererLowerCase.contains("mesa") ) {
1559
	// Added March 30, 2013
1560
	// Martin C. Hegedus
1561
	if ( glRendererLowerCase.contains("x11") && getMesaMajorVersion(glVersion) < 8.0 ) {
1562
            final int quirk = GLRendererQuirks.DontCloseX11DisplayConnection;
1563
            if(DEBUG) {
1564
                System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Mesa X11 < 8 : Renderer=" + glRenderer + ", Version=" +glVersion);
1565
            }
1566
            quirks[i++] = quirk;
1567
	}
1568
    }
1554
1569
1555
    glRendererQuirks = new GLRendererQuirks(quirks, 0, i);
1570
    glRendererQuirks = new GLRendererQuirks(quirks, 0, i);
1556
  }
1571
  }
1572
    
1573
    // Added by Martin C. Hegedus, March 30, 2013
1574
    private static final int getMesaMajorVersion(String version) {
1575
	if (version == null || version.length() <= 0) return -1;
1576
	String[] strings = version.trim().split("\\s+");
1577
	if (strings.length <= 0) return -1;
1578
	version = strings[strings.length-1];
1579
	int index = version.indexOf(".");
1580
	if (index ==  0) return -1;
1581
	if (index != -1) version = version.substring(0,index);
1582
	try {
1583
	    Integer iNumber = new Integer(version);
1584
	    return (iNumber == null) ? -1 : iNumber.intValue();
1585
	} catch (Throwable t) {
1586
	    return -1;
1587
	}
1588
    }
1557
  
1589
  
1558
  
1590
  
1559
  private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) {
1591
  private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) {
(-)a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java (-5 / +33 lines)
Lines 138-144 public class X11Util implements ToolkitProperties { Link Here
138
                        hasX11_EXTENSION_ATIFGLEXTENSION = false;
138
                        hasX11_EXTENSION_ATIFGLEXTENSION = false;
139
                    }
139
                    }
140
                    hasThreadingIssues = ATI_HAS_MULTITHREADING_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
140
                    hasThreadingIssues = ATI_HAS_MULTITHREADING_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
141
                    markAllDisplaysUnclosable = ATI_HAS_XCLOSEDISPLAY_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
141
		    // A check on nativewindow.debug.X11Util.HasX11CloseDisplayBug added March 30, 2013
142
		    // Martin C. Hegedus
143
		    if (!markAllDisplaysUnclosable) {
144
			markAllDisplaysUnclosable = ATI_HAS_XCLOSEDISPLAY_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
145
			if (Debug.isPropertyDefined("nativewindow.debug.X11Util.HasX11CloseDisplayBug", true))
146
			    markAllDisplaysUnclosable = true;
147
		    }
142
                    
148
                    
143
                    if(DEBUG) {
149
                    if(DEBUG) {
144
                        System.err.println("X11Util.initSingleton(): OK "+isInitOK+"]"+
150
                        System.err.println("X11Util.initSingleton(): OK "+isInitOK+"]"+
Lines 178-184 public class X11Util implements ToolkitProperties { Link Here
178
            synchronized(X11Util.class) {
184
            synchronized(X11Util.class) {
179
                if(isInit) {                    
185
                if(isInit) {                    
180
                    final boolean isJVMShuttingDown = NativeWindowFactory.isJVMShuttingDown() ;
186
                    final boolean isJVMShuttingDown = NativeWindowFactory.isJVMShuttingDown() ;
181
                    if(DEBUG || openDisplayMap.size() > 0 || reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0) {
187
		    // Modified March 30, 2013 so output is not created under "expected" circumstances
188
		    // Martin C. Hegedus
189
                    if(DEBUG || ((openDisplayMap.size() > 0 || reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0) &&
190
				 !(reusableDisplayList.size() == pendingDisplayList.size() && markAllDisplaysUnclosable))) {
182
                        System.err.println("X11Util.Display: Shutdown (JVM shutdown: "+isJVMShuttingDown+
191
                        System.err.println("X11Util.Display: Shutdown (JVM shutdown: "+isJVMShuttingDown+
183
                                           ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+
192
                                           ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+
184
                                           ", reusable (open, marked uncloseable): "+reusableDisplayList.size()+
193
                                           ", reusable (open, marked uncloseable): "+reusableDisplayList.size()+
Lines 242-247 public class X11Util implements ToolkitProperties { Link Here
242
        return nullDisplayName;
251
        return nullDisplayName;
243
    }
252
    }
244
    
253
    
254
    // Added March 30, 2013
255
    // Martin C. Hegedus
256
    public static void markAllDisplaysUnclosable() {
257
        synchronized(globalLock) {
258
	    markAllDisplaysUnclosable = true;
259
	    for(int i=0; i<openDisplayList.size(); i++)
260
		openDisplayList.get(i).setUncloseable(true);
261
	    for(int i=0; i<reusableDisplayList.size(); i++)
262
		reusableDisplayList.get(i).setUncloseable(true);
263
	    for(int i=0; i<pendingDisplayList.size(); i++)
264
		pendingDisplayList.get(i).setUncloseable(true);
265
	}
266
    }
267
    
245
    public static boolean getMarkAllDisplaysUnclosable() {
268
    public static boolean getMarkAllDisplaysUnclosable() {
246
        return markAllDisplaysUnclosable;
269
        return markAllDisplaysUnclosable;
247
    }
270
    }
Lines 326-332 public class X11Util implements ToolkitProperties { Link Here
326
                    XCloseDisplay(ndpy.getHandle());
349
                    XCloseDisplay(ndpy.getHandle());
327
                    num++;
350
                    num++;
328
                }
351
                }
329
                System.err.println("X11Util.closePendingDisplayConnections(): Closed "+num+" pending display connections");
352
		// Added DEBUG statement around print statement, March 30, 2013
353
		// Martin C. Hegedus
354
		if(DEBUG) {
355
		    System.err.println("X11Util.closePendingDisplayConnections(): Closed "+num+" pending display connections");
356
		}
330
            }
357
            }
331
        }
358
        }
332
        return num;
359
        return num;
Lines 462-468 public class X11Util implements ToolkitProperties { Link Here
462
            namedDpy.removeRef();
489
            namedDpy.removeRef();
463
            if(!openDisplayList.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); }
490
            if(!openDisplayList.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); }
464
            
491
            
465
            if(!namedDpy.isUncloseable()) {
492
	    // Modified March 30, 2013
493
	    // Martin C. Hegedus
494
            if(!(markAllDisplaysUnclosable || namedDpy.isUncloseable())) {
466
                XCloseDisplay(namedDpy.getHandle());
495
                XCloseDisplay(namedDpy.getHandle());
467
                pendingDisplayList.remove(namedDpy);
496
                pendingDisplayList.remove(namedDpy);
468
            } else {
497
            } else {
469
- 

Return to bug 705