diff options
author | Sven Gothel <[email protected]> | 2014-01-21 18:16:22 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-21 18:16:22 +0100 |
commit | 09fc7aa5539731bb0fba835caee61f6eb837ecff (patch) | |
tree | 12798cf9a888d24b10e3aee8f677755a84f06a17 /make/config/jogl/gl-impl-CustomJavaCode-gles3.java | |
parent | 19c91de9f02fc713fce09277ea243d966cbc9ac8 (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 'make/config/jogl/gl-impl-CustomJavaCode-gles3.java')
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 67 |
1 files changed, 52 insertions, 15 deletions
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index d5ad16873..a5c0d1998 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -2,11 +2,11 @@ public GLES3Impl(GLProfile glp, GLContextImpl context) { this._context = context; if(null != context) { - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferObjectTracker = context.getBufferObjectTracker(); this.bufferStateTracker = context.getBufferStateTracker(); this.glStateTracker = context.getGLStateTracker(); } else { - this.bufferSizeTracker = null; + this.bufferObjectTracker = null; this.bufferStateTracker = null; this.glStateTracker = null; } @@ -211,9 +211,6 @@ public final GL2GL3 getGL2GL3() throws GLException { // private final boolean _isES3; -private final GLBufferSizeTracker bufferSizeTracker; -private final GLBufferStateTracker bufferStateTracker; -private final GLStateTracker glStateTracker; private final boolean checkBufferObject(boolean extensionAvail, boolean allowVAO, @@ -333,22 +330,20 @@ private final boolean checkPackPBOBound(boolean throwException) { @Override public final boolean glIsPBOPackBound() { + return isPBOPackBound(); +} +@Override +public final boolean isPBOPackBound() { return checkPackPBOBound(false); } @Override public final boolean glIsPBOUnpackBound() { - return checkUnpackPBOBound(false); + return isPBOUnpackBound(); } - -/** Entry point to C language function: <code> void * {@native glMapBuffer}(GLenum target, GLenum access); </code> <br>Part of <code>GL_VERSION_1_5</code>; <code>GL_OES_mapbuffer</code> */ -public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - return glMapBufferImpl(target, false, 0, 0, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); -} - -/** Entry point to C language function: <code> void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); </code> <br>Part of <code>GL_ES_VERSION_3_0</code>, <code>GL_VERSION_3_0</code>; <code>GL_EXT_map_buffer_range</code> */ -public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { - return glMapBufferImpl(target, true, offset, length, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +@Override +public final boolean isPBOUnpackBound() { + return checkUnpackPBOBound(false); } @Override @@ -361,3 +356,45 @@ public final void glDepthRange(double zNear, double zFar) { glDepthRangef((float)zNear, (float)zFar); } +// +// GLBufferObjectTracker Redirects +// + +@Override +public final void glBufferData(int target, long size, Buffer data, int usage) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glBufferData; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glBufferData")); + } + bufferObjectTracker.createBufferStorage(bufferStateTracker, this, + target, size, data, usage, 0 /* immutableFlags */, + createBoundMutableStorageDispatch, glProcAddress); +} + +@Override +public boolean glUnmapBuffer(int target) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glUnmapBuffer")); + } + return bufferObjectTracker.unmapBuffer(bufferStateTracker, this, target, unmapBoundBufferDispatch, glProcAddress); +} + +@Override +public final GLBufferStorage mapBuffer(final int target, final int access) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBuffer\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, access, mapBoundBufferAllDispatch, glProcAddress); +} +@Override +public final GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBufferRange\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, offset, length, access, mapBoundBufferRangeDispatch, glProcAddress); +} + + |