aboutsummaryrefslogtreecommitdiffstats
path: root/make
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 /make
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 'make')
-rw-r--r--make/config/jogl/gl-common.cfg79
-rw-r--r--make/config/jogl/gl-gl4bc.cfg47
-rw-r--r--make/config/jogl/gl-if-CustomJavaCode-es3.java4
-rw-r--r--make/config/jogl/gl-if-gl2.cfg1
-rw-r--r--make/config/jogl/gl-impl-CustomCCode-gl4bc.c91
-rw-r--r--make/config/jogl/gl-impl-CustomCCode-gles1.c35
-rw-r--r--make/config/jogl/gl-impl-CustomCCode-gles3.c36
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-common.java165
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java238
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gles1.java59
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gles3.java67
-rw-r--r--make/scripts/tests.sh15
12 files changed, 640 insertions, 197 deletions
diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg
index e9996c64b..74ead0498 100644
--- a/make/config/jogl/gl-common.cfg
+++ b/make/config/jogl/gl-common.cfg
@@ -56,12 +56,66 @@ Ignore glDebugMessageCallbackARB
Ignore glDebugMessageCallbackKHR
Ignore glDebugMessageCallback
-# Manually implement glMapBuffer and glMapBufferRange as the size of the returned buffer
-# can only be computed by calling another routine
+#
+# Manually implement following GL functions to be redirected
+# to GLBufferObjectTracker.
+#
+ManuallyImplement glBufferData
+ForceProcAddressGen glBufferData
+MethodJavadoc glBufferData * <p>
+MethodJavadoc glBufferData * Throws a {@link GLException} if GL-function constraints are not met or the native GL-function fails.
+MethodJavadoc glBufferData * </p>
+MethodJavadoc glBufferData * <p>
+MethodJavadoc glBufferData * @throws GLException if buffer is not bound to target
+MethodJavadoc glBufferData * @throws GLException if size is less-than zero
+MethodJavadoc glBufferData * @throws GLException if a native GL-Error occurs
+MethodJavadoc glBufferData * </p>
+
+# FIXME: Add for OpenGL 4.4
+#Ignore glBufferStorage
+#ManuallyImplement glBufferStorage
+#ForceProcAddressGen glBufferStorage
+#MethodJavadoc glBufferStorage * <p>
+#MethodJavadoc glBufferStorage * Throws a {@link GLException} if GL-function constraints are not met or the native GL-function fails.
+#MethodJavadoc glBufferStorage * </p>
+#MethodJavadoc glBufferStorage * <p>
+#MethodJavadoc glBufferStorage * @throws GLException if buffer is not bound to target
+#MethodJavadoc glBufferStorage * @throws GLException if size is less-or-equal zero
+#MethodJavadoc glBufferStorage * @throws GLException if a native GL-Error occurs
+#MethodJavadoc glBufferStorage * </p>
+
ManuallyImplement glMapBuffer
ForceProcAddressGen glMapBuffer
+MethodJavadoc glMapBuffer * <p>
+MethodJavadoc glMapBuffer * Throws a {@link GLException} if GL-function constraints are not met.
+MethodJavadoc glMapBuffer * </p>
+MethodJavadoc glMapBuffer * <p>
+MethodJavadoc glMapBuffer * Returns {@link GL#mapBuffer(int, int)}'s {@link GLBufferStorage#getMappedBuffer()}.
+MethodJavadoc glMapBuffer * </p>
+MethodJavadoc glMapBuffer * @throws GLException if buffer is not bound to target
+MethodJavadoc glMapBuffer * @throws GLException if buffer is not tracked
+MethodJavadoc glMapBuffer * @throws GLException if buffer is already mapped
+MethodJavadoc glMapBuffer * @throws GLException if buffer has invalid store size, i.e. less-than zero
+MethodJavadoc glMapBuffer * </p>
+
ManuallyImplement glMapBufferRange
ForceProcAddressGen glMapBufferRange
+MethodJavadoc glMapBufferRange * <p>
+MethodJavadoc glMapBufferRange * Throws a {@link GLException} if GL-function constraints are not met.
+MethodJavadoc glMapBufferRange * </p>
+MethodJavadoc glMapBufferRange * <p>
+MethodJavadoc glMapBufferRange * Returns {@link GL#mapBufferRange(int, long, long, int)}'s {@link GLBufferStorage#getMappedBuffer()}.
+MethodJavadoc glMapBufferRange * </p>
+MethodJavadoc glMapBufferRange * <p>
+MethodJavadoc glMapBufferRange * @throws GLException if buffer is not bound to target
+MethodJavadoc glMapBufferRange * @throws GLException if buffer is not tracked
+MethodJavadoc glMapBufferRange * @throws GLException if buffer is already mapped
+MethodJavadoc glMapBufferRange * @throws GLException if buffer has invalid store size, i.e. less-than zero
+MethodJavadoc glMapBufferRange * @throws GLException if buffer mapping range does not fit, incl. offset
+MethodJavadoc glMapBufferRange * </p>
+
+ManuallyImplement glUnmapBuffer
+ForceProcAddressGen glUnmapBuffer
# Ignore the ATI_map_object_buffer extension for now unless someone
# claims they need it, as it will undoubtedly require a similar
@@ -550,15 +604,18 @@ JavaEpilogue glBindFramebuffer _context.setBoundFramebuffer(target, framebuffer
#
JavaPrologue glBegin inBeginEndPair = true;
JavaEpilogue glEnd inBeginEndPair = false;
-JavaEpilogue glBindBuffer bufferStateTracker.setBoundBufferObject({0}, {1});
-JavaEpilogue glBindBufferARB bufferStateTracker.setBoundBufferObject({0}, {1});
-JavaEpilogue glBindVertexArray bufferStateTracker.setBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, {0});
-JavaEpilogue glPushClientAttrib bufferStateTracker.clearBufferObjectState();
-JavaEpilogue glPushClientAttrib glStateTracker.pushAttrib(mask);
-JavaEpilogue glPopClientAttrib bufferStateTracker.clearBufferObjectState();
-JavaEpilogue glPopClientAttrib glStateTracker.popAttrib();
-JavaPrologue glBufferData synchronized(bufferSizeTracker) {
-JavaEpilogue glBufferData bufferSizeTracker.setBufferSize(bufferStateTracker, {0}, this, {1}); }
+
+JavaEpilogue glBindBuffer bufferStateTracker.setBoundBufferObject({0}, {1});
+JavaEpilogue glBindBufferARB bufferStateTracker.setBoundBufferObject({0}, {1});
+JavaEpilogue glBindBufferBase bufferStateTracker.setBoundBufferObject({0}, {2});
+JavaEpilogue glBindBufferRange bufferStateTracker.setBoundBufferObject({0}, {2});
+JavaEpilogue glBindVertexArray bufferStateTracker.setBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, {0});
+JavaEpilogue glPushClientAttrib bufferStateTracker.clear();
+JavaEpilogue glPushClientAttrib glStateTracker.pushAttrib(mask);
+JavaEpilogue glPopClientAttrib bufferStateTracker.clear();
+JavaEpilogue glPopClientAttrib glStateTracker.popAttrib();
+
+JavaPrologue glDeleteBuffers bufferObjectTracker.notifyBuffersDeleted({0}, {1});
BufferObjectKind Array glColorPointer
BufferObjectKind Array glEdgeFlagPointer
diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg
index 48ecb7378..6ccbace44 100644
--- a/make/config/jogl/gl-gl4bc.cfg
+++ b/make/config/jogl/gl-gl4bc.cfg
@@ -55,12 +55,51 @@ Include gl3-desktop.cfg
Include gl3-common.cfg
Include gl2_es2-CustomJavaCode.cfg
-# Manually implement glMapNamedBufferEXT as the size of the returned buffer
-# can only be computed by calling another routine
+#
+# Manually implement following GL functions to be redirected
+# to GLBufferObjectTracker.
+#
+ManuallyImplement glNamedBufferDataEXT
+ForceProcAddressGen glNamedBufferDataEXT
+MethodJavadoc glNamedBufferDataEXT * <p>
+MethodJavadoc glNamedBufferDataEXT * Throws a {@link GLException} if GL-function constraints are not met or the native GL-function fails.
+MethodJavadoc glNamedBufferDataEXT * </p>
+MethodJavadoc glNamedBufferDataEXT * <p>
+MethodJavadoc glNamedBufferDataEXT * @throws GLException if size is less-than zero
+MethodJavadoc glNamedBufferDataEXT * @throws GLException if a native GL-Error occurs
+MethodJavadoc glNamedBufferDataEXT * </p>
+
ManuallyImplement glMapNamedBufferEXT
ForceProcAddressGen glMapNamedBufferEXT
-JavaPrologue glNamedBufferDataEXT synchronized(bufferSizeTracker) {
-JavaEpilogue glNamedBufferDataEXT bufferSizeTracker.setDirectStateBufferSize({0}, this, {1}); }
+MethodJavadoc glMapNamedBufferEXT * <p>
+MethodJavadoc glMapNamedBufferEXT * Throws a {@link GLException} if GL-function constraints are not met.
+MethodJavadoc glMapNamedBufferEXT * </p>
+MethodJavadoc glMapNamedBufferEXT * <p>
+MethodJavadoc glMapNamedBufferEXT * Returns {@link GL2#mapNamedBuffer(int, int)}'s {@link GLBufferStorage#getMappedBuffer()}.
+MethodJavadoc glMapNamedBufferEXT * </p>
+MethodJavadoc glMapNamedBufferEXT * <p>
+MethodJavadoc glMapNamedBufferEXT * @throws GLException if buffer is not tracked
+MethodJavadoc glMapNamedBufferEXT * @throws GLException if buffer is already mapped
+MethodJavadoc glMapNamedBufferEXT * @throws GLException if buffer has invalid store size, i.e. less-than zero
+MethodJavadoc glMapNamedBufferEXT * </p>
+
+ManuallyImplement glMapNamedBufferRangeEXT
+ForceProcAddressGen glMapNamedBufferRangeEXT
+MethodJavadoc glMapNamedBufferRangeEXT * <p>
+MethodJavadoc glMapNamedBufferRangeEXT * Throws a {@link GLException} if GL-function constraints are not met.
+MethodJavadoc glMapNamedBufferRangeEXT * </p>
+MethodJavadoc glMapNamedBufferRangeEXT * <p>
+MethodJavadoc glMapNamedBufferRangeEXT * Returns {@link GL2#mapNamedBufferRange(int, long, long, int)}'s {@link GLBufferStorage#getMappedBuffer()}.
+MethodJavadoc glMapNamedBufferRangeEXT * </p>
+MethodJavadoc glMapNamedBufferRangeEXT * <p>
+MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer is not tracked
+MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer is already mapped
+MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer has invalid store size, i.e. less-than zero
+MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer mapping range does not fit, incl. offset
+MethodJavadoc glMapNamedBufferRangeEXT * </p>
+
+ManuallyImplement glUnmapNamedBufferEXT
+ForceProcAddressGen glUnmapNamedBufferEXT
# Manuall implement glDebugMessageCallback* using the proc address resolver
ForceProcAddressGen glDebugMessageCallback
diff --git a/make/config/jogl/gl-if-CustomJavaCode-es3.java b/make/config/jogl/gl-if-CustomJavaCode-es3.java
index b68b5123a..3f976d514 100644
--- a/make/config/jogl/gl-if-CustomJavaCode-es3.java
+++ b/make/config/jogl/gl-if-CustomJavaCode-es3.java
@@ -8,7 +8,11 @@ public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ;
/** Part of <code>GL_ARB_shader_image_load_store</code> */
public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ;
+/** @deprecated Avoid original GL API namespace conflict. Use {@link #isPBOPackBound()} */
public boolean glIsPBOPackBound();
+public boolean isPBOPackBound();
+/** @deprecated Avoid original GL API namespace conflict. Use {@link #isPBOUnpackBound()} */
public boolean glIsPBOUnpackBound();
+public boolean isPBOUnpackBound();
diff --git a/make/config/jogl/gl-if-gl2.cfg b/make/config/jogl/gl-if-gl2.cfg
index 37f7b6feb..0120bd674 100644
--- a/make/config/jogl/gl-if-gl2.cfg
+++ b/make/config/jogl/gl-if-gl2.cfg
@@ -26,6 +26,7 @@ Include gl-desktop.cfg
Include gl-if-gl3-ignores.cfg
Include gl-if-gl4-ignores.cfg
+IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl2.java
IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl_compat.java
IncludeAs CustomJavaCode GL2 gl2_es2-common-cpubufferJavaCode.java
IncludeAs CustomJavaCode GL2 gl2-common-cpubufferJavaCode.java
diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c
index 4ddc27bf2..42e5700ab 100644
--- a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c
+++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c
@@ -1,6 +1,77 @@
/* Java->C glue code:
* Java package: jogamp.opengl.gl4.GL4bcImpl
- * Java method: long dispatch_glMapBuffer(int target, int access)
+ * Java method: void dispatch_glBufferData(int target, long size, java.nio.Buffer data, int usage)
+ * C function: void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ */
+JNIEXPORT void JNICALL
+Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glBufferData(JNIEnv *env, jobject _unused, jint target, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) {
+ typedef void (APIENTRY*_local_PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ _local_PFNGLBUFFERDATAPROC ptr_glBufferData;
+ GLvoid * _data_ptr = NULL;
+ if ( NULL != data ) {
+ _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); }
+ ptr_glBufferData = (_local_PFNGLBUFFERDATAPROC) (intptr_t) procAddress;
+ assert(ptr_glBufferData != NULL);
+ (* ptr_glBufferData) ((GLenum) target, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage);
+ if ( JNI_FALSE == data_is_nio && NULL != data ) {
+ (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); }
+}
+
+/** FIXME Add for OpenGL 4.4: glBufferStorage */
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.gl4.GL4bcImpl
+ * Java method: void dispatch_glNamedBufferDataEXT(int buffer, long size, java.nio.Buffer data, int usage)
+ * C function: void glNamedBufferDataEXT(GLuint buffer, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ */
+JNIEXPORT void JNICALL
+Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glNamedBufferDataEXT(JNIEnv *env, jobject _unused, jint buffer, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) {
+ typedef void (APIENTRY*_local_PFNGLNAMEDBUFFERDATAEXTPROC)(GLuint buffer, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ _local_PFNGLNAMEDBUFFERDATAEXTPROC ptr_glNamedBufferDataEXT;
+ GLvoid * _data_ptr = NULL;
+ if ( NULL != data ) {
+ _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); }
+ ptr_glNamedBufferDataEXT = (_local_PFNGLNAMEDBUFFERDATAEXTPROC) (intptr_t) procAddress;
+ assert(ptr_glNamedBufferDataEXT != NULL);
+ (* ptr_glNamedBufferDataEXT) ((GLuint) buffer, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage);
+ if ( JNI_FALSE == data_is_nio && NULL != data ) {
+ (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); }
+}
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.gl4.GL4bcImpl
+ * Java method: boolean dispatch_glUnmapBuffer(int target)
+ * C function: GLboolean glUnmapBuffer(GLenum target);
+ */
+JNIEXPORT jboolean JNICALL
+Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glUnmapBuffer(JNIEnv *env, jobject _unused, jint target, jlong procAddress) {
+ typedef GLboolean (APIENTRY*_local_PFNGLUNMAPBUFFERPROC)(GLenum target);
+ _local_PFNGLUNMAPBUFFERPROC ptr_glUnmapBuffer;
+ GLboolean _res;
+ ptr_glUnmapBuffer = (_local_PFNGLUNMAPBUFFERPROC) (intptr_t) procAddress;
+ assert(ptr_glUnmapBuffer != NULL);
+ _res = (* ptr_glUnmapBuffer) ((GLenum) target);
+ return _res;
+}
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.gl4.GL4bcImpl
+ * Java method: boolean dispatch_glUnmapNamedBufferEXT(int buffer)
+ * C function: GLboolean glUnmapNamedBufferEXT(GLuint buffer);
+ */
+JNIEXPORT jboolean JNICALL
+Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glUnmapNamedBufferEXT(JNIEnv *env, jobject _unused, jint buffer, jlong procAddress) {
+ typedef GLboolean (APIENTRY*_local_PFNGLUNMAPNAMEDBUFFEREXTPROC)(GLuint buffer);
+ _local_PFNGLUNMAPNAMEDBUFFEREXTPROC ptr_glUnmapNamedBufferEXT;
+ GLboolean _res;
+ ptr_glUnmapNamedBufferEXT = (_local_PFNGLUNMAPNAMEDBUFFEREXTPROC) (intptr_t) procAddress;
+ assert(ptr_glUnmapNamedBufferEXT != NULL);
+ _res = (* ptr_glUnmapNamedBufferEXT) ((GLuint) buffer);
+ return _res;
+}
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.gl4.GL4bcImpl * Java method: long dispatch_glMapBuffer(int target, int access)
* C function: void * glMapBuffer(GLenum target, GLenum access);
*/
JNIEXPORT jlong JNICALL
@@ -40,10 +111,26 @@ Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapNamedBufferEXT(JNIEnv *env, jobj
void * _res;
ptr_glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC) (intptr_t) glProcAddress;
assert(ptr_glMapNamedBufferEXT != NULL);
- _res = (* ptr_glMapNamedBufferEXT) ((GLenum) target, (GLenum) access);
+ _res = (* ptr_glMapNamedBufferEXT) ((GLuint) target, (GLenum) access);
+ return (jlong) (intptr_t) _res;
+}
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.gl4.GL4bcImpl
+ * Java method: java.nio.ByteBuffer dispatch_glMapNamedBufferRangeEXT(int buffer, long offset, long length, int access)
+ * C function: void * glMapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
+ */
+JNIEXPORT jlong JNICALL
+Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapNamedBufferRangeEXT(JNIEnv *env, jobject _unused, jint buffer, jlong offset, jlong length, jint access, jlong procAddress) {
+ PFNGLMAPNAMEDBUFFERRANGEEXTPROC ptr_glMapNamedBufferRangeEXT;
+ void * _res;
+ ptr_glMapNamedBufferRangeEXT = (PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (intptr_t) procAddress;
+ assert(ptr_glMapNamedBufferRangeEXT != NULL);
+ _res = (* ptr_glMapNamedBufferRangeEXT) ((GLuint) buffer, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access);
return (jlong) (intptr_t) _res;
}
+
/* Java->C glue code:
* Java package: jogamp.opengl.gl4.GL4bcImpl
* Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity);
diff --git a/make/config/jogl/gl-impl-CustomCCode-gles1.c b/make/config/jogl/gl-impl-CustomCCode-gles1.c
index 88cfe4418..83b8c7586 100644
--- a/make/config/jogl/gl-impl-CustomCCode-gles1.c
+++ b/make/config/jogl/gl-impl-CustomCCode-gles1.c
@@ -1,3 +1,38 @@
+/* Java->C glue code:
+ * Java package: jogamp.opengl.es1.GLES1Impl
+ * Java method: void dispatch_glBufferData(int target, long size, java.nio.Buffer data, int usage)
+ * C function: void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ */
+JNIEXPORT void JNICALL
+Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glBufferData(JNIEnv *env, jobject _unused, jint target, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) {
+ typedef void (GL_APIENTRY*_local_PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ _local_PFNGLBUFFERDATAPROC ptr_glBufferData;
+ GLvoid * _data_ptr = NULL;
+ if ( NULL != data ) {
+ _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); }
+ ptr_glBufferData = (_local_PFNGLBUFFERDATAPROC) (intptr_t) procAddress;
+ assert(ptr_glBufferData != NULL);
+ (* ptr_glBufferData) ((GLenum) target, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage);
+ if ( JNI_FALSE == data_is_nio && NULL != data ) {
+ (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); }
+}
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.es1.GLES1Impl
+ * Java method: boolean dispatch_glUnmapBuffer(int target)
+ * C function: GLboolean glUnmapBufferOES(GLenum target);
+ */
+JNIEXPORT jboolean JNICALL
+Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glUnmapBuffer(JNIEnv *env, jobject _unused, jint target, jlong procAddress) {
+ typedef GLboolean (GL_APIENTRY*_local_PFNGLUNMAPBUFFEROESPROC)(GLenum target);
+ _local_PFNGLUNMAPBUFFEROESPROC ptr_glUnmapBufferOES;
+ GLboolean _res;
+ ptr_glUnmapBufferOES = (_local_PFNGLUNMAPBUFFEROESPROC) (intptr_t) procAddress;
+ assert(ptr_glUnmapBufferOES != NULL);
+ _res = (* ptr_glUnmapBufferOES) ((GLenum) target);
+ return _res;
+}
+
typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
/* Java->C glue code:
* Java package: jogamp.opengl.es1.GLES1Impl
diff --git a/make/config/jogl/gl-impl-CustomCCode-gles3.c b/make/config/jogl/gl-impl-CustomCCode-gles3.c
index 2f3329bfa..ff1d42e23 100644
--- a/make/config/jogl/gl-impl-CustomCCode-gles3.c
+++ b/make/config/jogl/gl-impl-CustomCCode-gles3.c
@@ -1,4 +1,40 @@
+/* Java->C glue code:
+ * Java package: jogamp.opengl.es3.GLES3Impl
+ * Java method: void dispatch_glBufferData(int target, long size, java.nio.Buffer data, int usage)
+ * C function: void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ */
+JNIEXPORT void JNICALL
+Java_jogamp_opengl_es3_GLES3Impl_dispatch_1glBufferData(JNIEnv *env, jobject _unused, jint target, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) {
+ typedef void (GL_APIENTRY*_local_PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ _local_PFNGLBUFFERDATAPROC ptr_glBufferData;
+ GLvoid * _data_ptr = NULL;
+ if ( NULL != data ) {
+ _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); }
+ ptr_glBufferData = (_local_PFNGLBUFFERDATAPROC) (intptr_t) procAddress;
+ assert(ptr_glBufferData != NULL);
+ (* ptr_glBufferData) ((GLenum) target, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage);
+ if ( JNI_FALSE == data_is_nio && NULL != data ) {
+ (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); }
+}
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.es3.GLES3Impl
+ * Java method: boolean dispatch_glUnmapBuffer(int target)
+ * C function: GLboolean glUnmapBuffer(GLenum target);
+ */
+JNIEXPORT jboolean JNICALL
+Java_jogamp_opengl_es3_GLES3Impl_dispatch_1glUnmapBuffer(JNIEnv *env, jobject _unused, jint target, jlong procAddress) {
+ typedef GLboolean (GL_APIENTRY*_local_PFNGLUNMAPBUFFERPROC)(GLenum target);
+ _local_PFNGLUNMAPBUFFERPROC ptr_glUnmapBuffer;
+ GLboolean _res;
+ ptr_glUnmapBuffer = (_local_PFNGLUNMAPBUFFERPROC) (intptr_t) procAddress;
+ assert(ptr_glUnmapBuffer != NULL);
+ _res = (* ptr_glUnmapBuffer) ((GLenum) target);
+ return _res;
+}
+
typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
+
/* Java->C glue code:
* Java package: jogamp.opengl.es3.GLES3Impl
* Java method: long dispatch_glMapBuffer(int target, int access)
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java
index 4b1fc0977..f0246355e 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-common.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java
@@ -6,23 +6,37 @@
@Override
public final int glGetBoundBuffer(int target) {
+ return getBoundBuffer(target);
+ }
+ @Override
+ public final int getBoundBuffer(int target) {
return bufferStateTracker.getBoundBufferObject(target, this);
}
@Override
- public final long glGetBufferSize(int buffer) {
- synchronized(bufferSizeTracker) {
- return bufferSizeTracker.getDirectStateBufferSize(buffer, this);
- }
+ public final long glGetBufferSize(int bufferName) {
+ return bufferObjectTracker.getBufferSize(bufferName);
+ }
+ @Override
+ public final GLBufferStorage getBufferStorage(int bufferName) {
+ return bufferObjectTracker.getBufferStorage(bufferName);
}
@Override
public final boolean glIsVBOArrayBound() {
+ return isVBOArrayBound();
+ }
+ @Override
+ public final boolean isVBOArrayBound() {
return checkArrayVBOBound(false);
}
@Override
public final boolean glIsVBOElementArrayBound() {
+ return isVBOElementArrayBound();
+ }
+ @Override
+ public final boolean isVBOElementArrayBound() {
return checkElementVBOBound(false);
}
@@ -130,101 +144,60 @@
return _context.getDefaultReadBuffer();
}
- private final HashMap<MemoryObject, MemoryObject> arbMemCache = new HashMap<MemoryObject, MemoryObject>();
-
- /** 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> */
- private final java.nio.ByteBuffer glMapBufferImpl(int target, boolean useRange, long offset, long length, int access, long glProcAddress) {
- if (glProcAddress == 0) {
- throw new GLException("Method \""+(useRange?"glMapBufferRange":"glMapBuffer")+"\" not available");
- }
- final long addr, sz;
- synchronized(bufferSizeTracker) {
- sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this);
- if (0 == sz) {
- return null;
- }
- if( !useRange ) {
- length = sz;
- offset = 0;
- } else {
- if( length + offset > sz ) {
- throw new GLException("Out of range: offset "+offset+" + length "+length+" > size "+sz);
- }
- if( 0 > length || 0 > offset ) {
- throw new GLException("Invalid values: offset "+offset+", length "+length);
+ private final GLStateTracker glStateTracker;
+
+ //
+ // GLBufferObjectTracker Redirects
+ //
+ private final GLBufferObjectTracker bufferObjectTracker;
+ private final GLBufferStateTracker bufferStateTracker;
+
+ private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch createBoundMutableStorageDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() {
+ public final void create(final int target, final long size, final Buffer data, final int mutableUsage, final long glProcAddress) {
+ final boolean data_is_direct = Buffers.isDirect(data);
+ dispatch_glBufferData(target, size,
+ data_is_direct ? data : Buffers.getArray(data),
+ data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data),
+ data_is_direct, mutableUsage, glProcAddress);
}
- if( 0 == length ) {
- return null;
+ };
+ private native void dispatch_glBufferData(int target, long size, Object data, int data_byte_offset, boolean data_is_direct, int usage, long procAddress);
+
+ private final jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch unmapBoundBufferDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch() {
+ public final boolean unmap(final int target, final long glProcAddress) {
+ return dispatch_glUnmapBuffer(target, glProcAddress);
}
- }
- addr = useRange ? dispatch_glMapBufferRange(target, offset, length, access, glProcAddress) :
- dispatch_glMapBuffer(target, access, glProcAddress);
- }
- if (0 == addr) {
- return null;
- }
- final ByteBuffer buffer;
- final MemoryObject memObj0 = new MemoryObject(addr, length); // object and key
- final MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0);
- if(memObj0 == memObj1) {
- // just added ..
- if(null != memObj0.getBuffer()) {
- throw new InternalError();
- }
- buffer = newDirectByteBuffer(addr, length);
- Buffers.nativeOrder(buffer);
- memObj0.setBuffer(buffer);
- } else {
- // already mapped
- buffer = memObj1.getBuffer();
- if(null == buffer) {
- throw new InternalError();
- }
- }
- buffer.position(0);
- return buffer;
+ };
+ private native boolean dispatch_glUnmapBuffer(int target, long procAddress);
+
+ @Override
+ public final java.nio.ByteBuffer glMapBuffer(int target, int access) {
+ return mapBuffer(target, access).getMappedBuffer();
+ }
+
+ @Override
+ public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) {
+ return mapBufferRange(target, offset, length, access).getMappedBuffer();
}
+
+ private final jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch mapBoundBufferAllDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch() {
+ public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); }
+ public final long mapBuffer(final int target, final int access, final long glProcAddress) {
+ return dispatch_glMapBuffer(target, access, glProcAddress);
+ }
+ };
private native long dispatch_glMapBuffer(int target, int access, long glProcAddress);
- private native long dispatch_glMapBufferRange(int target, long offset, long length, int access, long procAddress);
-
-
- /** Entry point to C language function: <code> GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access); </code> <br>Part of <code>GL_EXT_direct_state_access</code> */
- private final java.nio.ByteBuffer glMapNamedBufferImpl(int bufferName, int access, long glProcAddress) {
- if (glProcAddress == 0) {
- throw new GLException("Method \"glMapNamedBufferEXT\" not available");
- }
- final long addr, sz;
- synchronized(bufferSizeTracker) {
- sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this);
- if (0 == sz) {
- return null;
- }
- addr = dispatch_glMapNamedBufferEXT(bufferName, access, glProcAddress);
- }
- if (0 == addr) {
- return null;
- }
- final ByteBuffer buffer;
- final MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key
- final MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0);
- if(memObj0 == memObj1) {
- // just added ..
- if(null != memObj0.getBuffer()) {
- throw new InternalError();
- }
- buffer = newDirectByteBuffer(addr, sz);
- Buffers.nativeOrder(buffer);
- memObj0.setBuffer(buffer);
- } else {
- // already mapped
- buffer = memObj1.getBuffer();
- if(null == buffer) {
- throw new InternalError();
- }
- }
- buffer.position(0);
- return buffer;
- }
- private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress);
+
+ private final jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch mapBoundBufferRangeDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch() {
+ public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); }
+ public final long mapBuffer(final int target, final long offset, final long length, final int access, final long glProcAddress) {
+ return dispatch_glMapBufferRange(target, offset, length, access, glProcAddress);
+ }
+ };
+ private native long dispatch_glMapBufferRange(int target, long offset, long length, int access, long glProcAddress);
private native ByteBuffer newDirectByteBuffer(long addr, long capacity);
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
index e7389de10..f0adb5328 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
@@ -18,11 +18,11 @@ public void setObjectTracker(GLObjectTracker tracker) {
public GL4bcImpl(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;
}
@@ -280,10 +280,6 @@ public final void glFreeMemoryNV(java.nio.ByteBuffer pointer) {
// Helpers for ensuring the correct amount of texture data
//
-private final GLBufferSizeTracker bufferSizeTracker;
-private final GLBufferStateTracker bufferStateTracker;
-private final GLStateTracker glStateTracker;
-
private boolean haveARBPixelBufferObject;
private boolean haveEXTPixelBufferObject;
private boolean haveGL15;
@@ -431,67 +427,207 @@ 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 isPBOUnpackBound();
+}
+@Override
+public final boolean isPBOUnpackBound() {
return checkUnpackPBOBound(false);
}
-/** 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, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer);
+@Override
+public final void glVertexPointer(GLArrayData array) {
+ if(array.getComponentCount()==0) return;
+ if(array.isVBO()) {
+ glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset());
+ } else {
+ glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
}
+@Override
+public final void glColorPointer(GLArrayData array) {
+ if(array.getComponentCount()==0) return;
+ if(array.isVBO()) {
+ glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset());
+ } else {
+ glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
-/** 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, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange);
}
-
-/** Entry point to C language function: <code> GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access); </code> <br>Part of <code>GL_EXT_direct_state_access</code> */
-public final java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) {
- return glMapNamedBufferImpl(bufferName, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT);
+@Override
+public final void glNormalPointer(GLArrayData array) {
+ if(array.getComponentCount()==0) return;
+ if(array.getComponentCount()!=3) {
+ throw new GLException("Only 3 components per normal allowed");
+ }
+ if(array.isVBO()) {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getVBOOffset());
+ } else {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+}
+@Override
+public final void glTexCoordPointer(GLArrayData array) {
+ if(array.getComponentCount()==0) return;
+ if(array.isVBO()) {
+ glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset());
+ } else {
+ glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
}
- @Override
- public final void glVertexPointer(GLArrayData array) {
- if(array.getComponentCount()==0) return;
- if(array.isVBO()) {
- glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset());
- } else {
- glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
+//
+// GLBufferObjectTracker Redirects
+//
+
+@Override
+public final void glBufferData(int target, long size, Buffer data, int usage) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_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);
+}
+/** FIXME Add for OpenGL 4.4
+@Override
+public final void glBufferStorage(int target, long size, Buffer data, int flags) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glBufferStorage;
+ if ( 0 == glProcAddress ) {
+ throw new GLException(String.format("Method \"%s\" not available", "glBufferStorage"));
}
- @Override
- public final void glColorPointer(GLArrayData array) {
- if(array.getComponentCount()==0) return;
- if(array.isVBO()) {
- glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset());
- } else {
- glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
+ bufferObjectTracker.createBufferStorage(bufferStateTracker, this,
+ target, size, data, 0 * mutableUsage *, flags,
+ createBoundImmutableStorageDispatch, glProcAddress);
+}
+private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch createBoundImmutableStorageDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() {
+ public final void create(final int target, final long size, final Buffer data, final int immutableFlags, final long glProcAddress) {
+ final boolean data_is_direct = Buffers.isDirect(data);
+ dispatch_glBufferStorage(target, size,
+ data_is_direct ? data : Buffers.getArray(data),
+ data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data),
+ data_is_direct, immutableFlags, glProcAddress);
+ }
+ };
+private native void dispatch_glBufferStorage(int target, long size, Object data, int data_byte_offset, boolean data_is_direct, int flags, long procAddress);
+ */
+@Override
+public final void glNamedBufferDataEXT(int buffer, long size, Buffer data, int usage) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glNamedBufferDataEXT;
+ if ( 0 == glProcAddress ) {
+ throw new GLException(String.format("Method \"%s\" not available", "glNamedBufferDataEXT"));
}
- @Override
- public final void glNormalPointer(GLArrayData array) {
- if(array.getComponentCount()==0) return;
- if(array.getComponentCount()!=3) {
- throw new GLException("Only 3 components per normal allowed");
- }
- if(array.isVBO()) {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getVBOOffset());
- } else {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
- }
+ bufferObjectTracker.createBufferStorage(this,
+ buffer, size, data, usage, 0 /* immutableFlags */,
+ createNamedStorageDispatch, glProcAddress);
+}
+private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch createNamedStorageDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() {
+ public final void create(final int buffer, final long size, final Buffer data, final int mutableUsage, final long glProcAddress) {
+ final boolean data_is_direct = Buffers.isDirect(data);
+ dispatch_glNamedBufferDataEXT(buffer, size,
+ data_is_direct ? data : Buffers.getArray(data),
+ data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data),
+ data_is_direct, mutableUsage, glProcAddress);
+ }
+ };
+private native void dispatch_glNamedBufferDataEXT(int buffer, long size, Object data, int data_byte_offset, boolean data_is_direct, int usage, long procAddress);
+
+@Override
+public boolean glUnmapBuffer(int target) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapBuffer;
+ if ( 0 == glProcAddress ) {
+ throw new GLException(String.format("Method \"%s\" not available", "glUnmapBuffer"));
}
- @Override
- public final void glTexCoordPointer(GLArrayData array) {
- if(array.getComponentCount()==0) return;
- if(array.isVBO()) {
- glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset());
- } else {
- glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
+ return bufferObjectTracker.unmapBuffer(bufferStateTracker, this, target, unmapBoundBufferDispatch, glProcAddress);
+}
+
+@Override
+public boolean glUnmapNamedBufferEXT(int buffer) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapNamedBufferEXT;
+ if ( 0 == glProcAddress ) {
+ throw new GLException(String.format("Method \"%s\" not available", "glUnmapNamedBufferEXT"));
}
+ return bufferObjectTracker.unmapBuffer(buffer, unmapNamedBufferDispatch, glProcAddress);
+}
+private final jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch unmapNamedBufferDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch() {
+ public final boolean unmap(final int buffer, final long glProcAddress) {
+ return dispatch_glUnmapNamedBufferEXT(buffer, glProcAddress);
+ }
+ };
+private native boolean dispatch_glUnmapNamedBufferEXT(int buffer, long procAddress);
+
+@Override
+public final GLBufferStorage mapBuffer(final int target, final int access) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_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 = ((GL4bcProcAddressTable)_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);
+}
+
+@Override
+public final GLBufferStorage mapNamedBuffer(final int bufferName, final int access) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT;
+ if ( 0 == glProcAddress ) {
+ throw new GLException("Method \"glMapNamedBufferEXT\" not available");
+ }
+ return bufferObjectTracker.mapBuffer(bufferName, access, mapNamedBufferAllDispatch, glProcAddress);
+}
+private final jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch mapNamedBufferAllDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch() {
+ public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); }
+ public final long mapBuffer(final int bufferName, final int access, final long glProcAddress) {
+ return dispatch_glMapNamedBufferEXT(bufferName, access, glProcAddress);
+ }
+ };
+private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long glProcAddress);
+
+@Override
+public final GLBufferStorage mapNamedBufferRange(final int bufferName, final long offset, final long length, final int access) {
+ final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferRangeEXT;
+ if ( 0 == glProcAddress ) {
+ throw new GLException("Method \"glMapNamedBufferRangeEXT\" not available");
+ }
+ return bufferObjectTracker.mapBuffer(bufferName, offset, length, access, mapNamedBufferRangeDispatch, glProcAddress);
+}
+private final jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch mapNamedBufferRangeDispatch =
+ new jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch() {
+ public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); }
+ public final long mapBuffer(final int bufferName, final long offset, final long length, final int access, final long glProcAddress) {
+ return dispatch_glMapNamedBufferRangeEXT(bufferName, offset, length, access, glProcAddress);
+ }
+ };
+private native long dispatch_glMapNamedBufferRangeEXT(int buffer, long offset, long length, int access, long procAddress);
+
+@Override
+public final java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) {
+ return mapNamedBuffer(bufferName, access).getMappedBuffer();
+}
+
+@Override
+public final ByteBuffer glMapNamedBufferRangeEXT(int bufferName, long offset, long length, int access) {
+ return mapNamedBufferRange(bufferName, offset, length, access).getMappedBuffer();
+}
+
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
index 8d5dcc7a5..6a7e12ca1 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
@@ -1,11 +1,11 @@
public GLES1Impl(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;
}
@@ -199,10 +199,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
// Helpers for ensuring the correct amount of texture data
//
-private final GLBufferSizeTracker bufferSizeTracker;
-private final GLBufferStateTracker bufferStateTracker;
-private final GLStateTracker glStateTracker;
-
private final boolean checkBufferObject(boolean bound,
int state,
String kind, boolean throwException) {
@@ -269,16 +265,6 @@ private final boolean checkPackPBOBound(boolean throwException) {
return false;
}
-/** 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, ((GLES1ProcAddressTable)_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, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange);
-}
-
@Override
public final void glVertexPointer(GLArrayData array) {
if(array.getComponentCount()==0) return;
@@ -320,3 +306,44 @@ public final void glTexCoordPointer(GLArrayData array) {
}
}
+//
+// GLBufferObjectTracker Redirects
+//
+
+@Override
+public final void glBufferData(int target, long size, Buffer data, int usage) {
+ final long glProcAddress = ((GLES1ProcAddressTable)_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 = ((GLES1ProcAddressTable)_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 = ((GLES1ProcAddressTable)_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 = ((GLES1ProcAddressTable)_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);
+}
+
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);
+}
+
+
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 649256393..6bc1d4eb3 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -103,13 +103,17 @@ function jrun() {
#D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject"
#D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker"
#D_ARGS="-Djogl.debug.FBObject"
+ #D_ARGS="-Djogl.debug.GLBufferStateTracker -Djogl.debug.GLBufferObjectTracker -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000 -Dnewt.debug.EDT"
+ #D_ARGS="-Djogl.debug.GLBufferStateTracker -Djogl.debug.GLBufferObjectTracker"
+ #D_ARGS="-Djogl.debug.GLBufferObjectTracker"
+ #D_ARGS="-Djogl.debug.GLBufferObjectTracker -Djogl.debug.GLArrayData -Djogl.debug.TraceGL -Djogl.debug.DebugGL"
#D_ARGS="-Djogl.debug.GLSLCode"
#D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL"
#D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable"
#D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window"
#D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas"
#D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource"
- D_ARGS="-Dnativewindow.debug.JAWT"
+ #D_ARGS="-Dnativewindow.debug.JAWT"
#D_ARGS="-Djogl.debug.GLContext.TraceSwitch"
#D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch"
#D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode"
@@ -208,6 +212,7 @@ function jrun() {
#D_ARGS="-Xprof"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl"
+ #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl -Djogl.gljpanel.awtverticalflip"
#D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL"
#D_ARGS="-Djogl.gljpanel.noverticalflip"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator"
@@ -390,7 +395,13 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
+
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $*
+
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $*
@@ -536,7 +547,7 @@ function testawtswt() {
# OK (X11, OSX)
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $*
-testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $*