aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLContextImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-21 18:16:22 +0100
committerSven Gothel <[email protected]>2014-01-21 18:16:22 +0100
commit09fc7aa5539731bb0fba835caee61f6eb837ecff (patch)
tree12798cf9a888d24b10e3aee8f677755a84f06a17 /src/jogl/classes/jogamp/opengl/GLContextImpl.java
parent19c91de9f02fc713fce09277ea243d966cbc9ac8 (diff)
Bug 942: GLBufferObjectTracker: Tracking GLBufferStorage accurately, synchronized and secure [1/2]
GLBufferSizeTracker becomes GLBufferObjectTracker and tracks the buffer's data store, GLBufferStorage, accurately, synchronized and secure. Synchronization is required, since the GLBufferStorage can be shared across many GLContext on multiple threads. This requires all GLBufferStorage lifecycle affecting GL functions to utilize synchronized GLBufferObjectTracker methods while passing a native GL-func callback. These GL functions are: - glBufferData, glBufferStorage (GL 4.4), glNamedBufferDataEXT Creating the GLBufferStorage object - glMapBuffer, glMapBufferRange, and their *Named*EXT variants - glUnmapBuffer, glUnmapNamedBufferEXT 'glDeleteBuffers' can simply notify the GLBufferObjectTracker No more HashMap is required to associate the mapped buffer address to the mapped ByteBuffer. GLBufferObjectTracker simply utilizes a buffer-name (int) -> GLBufferStorage map. +++ The security aspect shall be implemented by validating all arguments whether they match the required GL constraints, as well as validating tracked states like 'size'. The following functions will throw an GLException accordingly: - glBufferData, glNamedBufferDataEXT * @throws GLException if size is less-than zero * @throws GLException if a native GL-Error occurs - glBufferStorage (GL 4.4) * @throws GLException if size is less-or-eqaul zero * @throws GLException if a native GL-Error occurs - glMapBuffer, and it's *Named*EXT variant * @throws GLException if buffer is not bound to target * @throws GLException if buffer is not tracked * @throws GLException if buffer is already mapped * @throws GLException if buffer has invalid store size, i.e. less-than zero - glMapBufferRange, and it's *Named*EXT variant * @throws GLException if buffer is not bound to target * @throws GLException if buffer is not tracked * @throws GLException if buffer is already mapped * @throws GLException if buffer has invalid store size, i.e. less-than zero * @throws GLException if buffer mapping range does not fit, incl. offset - glMapBufferRange, and it's *Named*EXT variant Only clear mapped buffer reference of GLBufferStorage if native unmap was successful. Further more special error handling shall be applied to: - glMapBuffer, and it's *Named*EXT variant, glMapBuffer, and it's *Named*EXT variant - A zero GLBufferStorage size will avoid a native call and returns null - A null native mapping result indicating an error will not cause a GLException but returns null This allows the user to handle this case.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 66eed9d96..ee9f315c8 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -100,9 +100,9 @@ public abstract class GLContextImpl extends GLContext {
private String glRendererLowerCase;
private String glVersion;
- // Tracks creation and initialization of buffer objects to avoid
+ // Tracks lifecycle of buffer objects to avoid
// repeated glGet calls upon glMapBuffer operations
- private final GLBufferSizeTracker bufferSizeTracker;
+ private final GLBufferObjectTracker bufferObjectTracker;
private final GLBufferStateTracker bufferStateTracker;
private final GLStateTracker glStateTracker = new GLStateTracker();
private GLDebugMessageHandler glDebugHandler = null;
@@ -141,10 +141,10 @@ public abstract class GLContextImpl extends GLContext {
bufferStateTracker = new GLBufferStateTracker();
if ( null != shareWith ) {
GLContextShareSet.registerSharing(this, shareWith);
- bufferSizeTracker = ((GLContextImpl)shareWith).getBufferSizeTracker();
- assert (bufferSizeTracker != null) : "shared context hash null bufferSizeTracker: "+shareWith;
+ bufferObjectTracker = ((GLContextImpl)shareWith).getBufferObjectTracker();
+ assert (bufferObjectTracker != null) : "shared context hash null GLBufferObjectTracker: "+shareWith;
} else {
- bufferSizeTracker = new GLBufferSizeTracker();
+ bufferObjectTracker = new GLBufferObjectTracker();
}
this.drawable = drawable;
@@ -155,9 +155,9 @@ public abstract class GLContextImpl extends GLContext {
private final void clearStates() {
if( !GLContextShareSet.hasCreatedSharedLeft(this) ) {
- bufferSizeTracker.clearCachedBufferSizes();
+ bufferObjectTracker.clear();
}
- bufferStateTracker.clearBufferObjectState();
+ bufferStateTracker.clear();
glStateTracker.setEnabled(false);
glStateTracker.clearStates();
}
@@ -2122,8 +2122,8 @@ public abstract class GLContextImpl extends GLContext {
//----------------------------------------------------------------------
// Helpers for buffer object optimizations
- public final GLBufferSizeTracker getBufferSizeTracker() {
- return bufferSizeTracker;
+ public final GLBufferObjectTracker getBufferObjectTracker() {
+ return bufferObjectTracker;
}
public final GLBufferStateTracker getBufferStateTracker() {