From 5cb08416a6ed44814065771f469a94f79c49ab3f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Oct 2013 00:58:58 +0100 Subject: Bug 776 GLContext Sharing: GLSharedContextSetter API Doc: No 'Driver stability constraints' ; Fixing Test cases: Enable all, GearsObject*: Check VBO - GLSharedContextSetter API Doc: No 'Driver stability constraints' - No driver issues .. - Use 'Lifecycle Considerations' to describe usage issues .. - Fixing Test cases: Enable all, GearsObject*: Check VBO - GearsObject* needs to check whether VBO is 'still alive' if sharing is enabled. - Enable all unit tests. --- .../javax/media/opengl/GLSharedContextSetter.java | 46 +++++++++++++++------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'src/jogl/classes/javax/media') diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index 8c2311329..fd48d12bf 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -36,24 +36,40 @@ package javax.media.opengl; *

*

* A master {@link GLContext} is the {@link GLContext} which is created first, - * shared {@link GLContext} w/ this master are referred as slave {@link GLContext}. + * shared {@link GLContext} w/ this master are referred as slave {@link GLContext} + * and controls the shared object's lifecycle, i.e. their construction and destruction. *

- *
Driver stability constraints
+ *
Lifecycle Considerations
*

- * Be aware that the master {@link GLContext} and related resources, i.e. the {@link GLAutoDrawable}, - * shall not be destroyed before it's slave {@link GLContext} instances.
- * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV if shared resources are still used!
- * Note that this is not specified within OpenGL and should work, however, some drivers - * do not seem to handle this situation well, i.e. they do not postpone resource destruction - * until the last reference is removed.
- * Since pending destruction of {@link GLContext} and it's {@link GLDrawable} is complex and nearly impossible - * for us at the top level, considering the different windowing systems and {@link GLAutoDrawable} types, - * the user shall take care of proper destruction order. + * Be aware that the master {@link GLContext} and related resources + * shall not be destroyed before it's slave {@link GLContext} instances while they are using them.
+ * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV, since using already destroyed resources, + * e.g. OpenGL buffer objects, may not be validated by the driver!
*

*

- * Users may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} + * Either proper lifecycle synchronization is implemented, e.g. by notifying the slaves about the loss of the shared resources, + * or the slaves validate whether the resources are still valid. + *

+ *

+ * To simplify above lifecycle issues, one may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} * {@link GLDrawable} and it's {@link GLContext} as the master of all shared slave {@link GLContext}. - * Same constraints as above apply, i.e. it shall be destroyed after all shared slaves. + * Since this dummy instance does not depend on any native windowing system, it can be controlled easily w/o being in sight.
+ * Below code creates a {@link GLAutoDrawable} based on a dummy GLDrawable: + *

+        // GLProfile and GLCapabilities should be equal across all shared GL drawable/context.
+        final GLCapabilitiesImmutable caps = ... ;
+        final GLProfile glp = caps.getGLProfile();
+        ..
+        final boolean createNewDevice = true; // use 'own' display device!
+        final GLAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, createNewDevice, glp);
+        sharedDrawable.display(); // triggers GLContext object creation and native realization.
+        ...
+        // Later a shared 'slave' can be created e.g.:
+        GLWindow glad = GLWindow.create(caps); // or any other GLAutoDrawable supporting GLSharedContextSetter
+        glad.setSharedAutoDrawable(sharedDrawable);
+        glad.addGLEventListener(..);
+        glad.setVisible(true); // GLWindow creation ..
+ * 
*

*/ public interface GLSharedContextSetter extends GLAutoDrawable { @@ -69,7 +85,7 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * as long it is not {@link GLContext#isCreated() created natively}. *

*

- * See driver stability constraints. + * See Lifecycle Considerations. *

* * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. @@ -93,7 +109,7 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * or has not been {@link GLContext#isCreated() created natively}. *

*

- * See driver stability constraints. + * See Lifecycle Considerations. *

* * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. -- cgit v1.2.3