diff options
Diffstat (limited to 'make')
-rw-r--r-- | make/config/jogl/gl-impl-CustomCCode-gl4bc.c | 6 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomCCode-gles1.c | 6 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomCCode-gles2.c | 6 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 92 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 63 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-gles2.java | 63 |
6 files changed, 101 insertions, 135 deletions
diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c index 0bd8b68da..778559eba 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c +++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c @@ -30,10 +30,10 @@ Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_dispatch_1glMapNamedBufferEXT(JNIEnv * /* Java->C glue code: * Java package: com.jogamp.opengl.impl.gl4.GL4bcImpl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); + * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); */ JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { +Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong capacity) { return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); } diff --git a/make/config/jogl/gl-impl-CustomCCode-gles1.c b/make/config/jogl/gl-impl-CustomCCode-gles1.c index a71ca4aae..422935ba7 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gles1.c +++ b/make/config/jogl/gl-impl-CustomCCode-gles1.c @@ -16,10 +16,10 @@ Java_com_jogamp_opengl_impl_es1_GLES1Impl_dispatch_1glMapBuffer(JNIEnv *env, job /* Java->C glue code: * Java package: com.jogamp.opengl.impl.es1.GLES1Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); + * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); */ JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_es1_GLES1Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { +Java_com_jogamp_opengl_impl_es1_GLES1Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong capacity) { return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); } diff --git a/make/config/jogl/gl-impl-CustomCCode-gles2.c b/make/config/jogl/gl-impl-CustomCCode-gles2.c index f99822d65..86fc47b4b 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gles2.c +++ b/make/config/jogl/gl-impl-CustomCCode-gles2.c @@ -16,10 +16,10 @@ Java_com_jogamp_opengl_impl_es2_GLES2Impl_dispatch_1glMapBuffer(JNIEnv *env, job /* Java->C glue code: * Java package: com.jogamp.opengl.impl.es2.GLES2Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); + * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); */ JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_es2_GLES2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { +Java_com_jogamp_opengl_impl_es2_GLES2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong capacity) { return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index ff177ec94..6776feeb7 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -274,32 +274,7 @@ public boolean glIsPBOUnpackEnabled() { return checkUnpackPBOEnabled(false); } -// Attempt to return the same ByteBuffer object from glMapBuffer if -// the vertex buffer object's base address and size haven't changed -private static class ARBVBOKey { - private long addr; - private int capacity; - - ARBVBOKey(long addr, int capacity) { - this.addr = addr; - this.capacity = capacity; - } - - public int hashCode() { - return (int) addr; - } - - public boolean equals(Object o) { - if ((o == null) || (!(o instanceof ARBVBOKey))) { - return false; - } - - ARBVBOKey other = (ARBVBOKey) o; - return ((addr == other.addr) && (capacity == other.capacity)); - } -} - -private Map/*<ARBVBOKey, ByteBuffer>*/ arbVBOCache = new HashMap(); +private HashMap/*<MemoryObject>*/ arbMemCache = new HashMap(); /** Entry point to C language function: <br> <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ public java.nio.ByteBuffer glMapBuffer(int target, int access) { @@ -307,53 +282,78 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { if (__addr_ == 0) { throw new GLException("Method \"glMapBuffer\" not available"); } - int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); if (0 == sz) { return null; } - long addr; - addr = dispatch_glMapBuffer(target, access, __addr_); + final long addr = dispatch_glMapBuffer(target, access, __addr_); if (0 == addr) { return null; } - ARBVBOKey key = new ARBVBOKey(addr, sz); - ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key); - if (_res == null) { - _res = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(_res); - arbVBOCache.put(key, _res); + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key + 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(); + } } - _res.position(0); - return _res; + buffer.position(0); + return buffer; } /** Encapsulates function pointer for OpenGL function <br>: <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); /** 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 java.nio.ByteBuffer glMapNamedBufferEXT(int buffer, int access) { +public java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) { final long __addr_ = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT; if (__addr_ == 0) { throw new GLException("Method \"glMapNamedBufferEXT\" not available"); } - int sz = bufferSizeTracker.getDirectStateBufferSize(buffer, this); + final long sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this); if (0 == sz) { return null; } - long addr; - addr = dispatch_glMapNamedBufferEXT(buffer, access, __addr_); + final long addr = dispatch_glMapNamedBufferEXT(bufferName, access, __addr_); if (0 == addr) { return null; } - ByteBuffer _res = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(_res); - _res.position(0); - return _res; + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key + 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); -native private ByteBuffer newDirectByteBuffer(long addr, int capacity); +native private ByteBuffer newDirectByteBuffer(long addr, long capacity); public void glVertexPointer(GLArrayData array) { if(array.getComponentNumber()==0) return; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index d29fe1645..faff8b89f 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -249,32 +249,7 @@ private boolean checkPackPBOEnabled(boolean throwException) { return false; } -// Attempt to return the same ByteBuffer object from glMapBufferARB if -// the vertex buffer object's base address and size haven't changed -private static class ARBVBOKey { - private long addr; - private int capacity; - - ARBVBOKey(long addr, int capacity) { - this.addr = addr; - this.capacity = capacity; - } - - public int hashCode() { - return (int) addr; - } - - public boolean equals(Object o) { - if ((o == null) || (!(o instanceof ARBVBOKey))) { - return false; - } - - ARBVBOKey other = (ARBVBOKey) o; - return ((addr == other.addr) && (capacity == other.capacity)); - } -} - -private Map/*<ARBVBOKey, ByteBuffer>*/ arbVBOCache = new HashMap(); +private HashMap/*<MemoryObject>*/ arbMemCache = new HashMap(); /** Entry point to C language function: <br> <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ public java.nio.ByteBuffer glMapBuffer(int target, int access) { @@ -282,32 +257,40 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { if (__addr_ == 0) { throw new GLException("Method \"glMapBuffer\" not available"); } - int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, - target, - this); + final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); if (0 == sz) { return null; } - long addr; - addr = dispatch_glMapBuffer(target, access, __addr_); + final long addr = dispatch_glMapBuffer(target, access, __addr_); if (0 == addr) { return null; } - ARBVBOKey key = new ARBVBOKey(addr, sz); - java.nio.ByteBuffer _res = (java.nio.ByteBuffer) arbVBOCache.get(key); - if (_res == null) { - _res = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(_res); - arbVBOCache.put(key, _res); + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key + 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(); + } } - _res.position(0); - return _res; + buffer.position(0); + return buffer; } /** Encapsulates function pointer for OpenGL function <br>: <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); -native private ByteBuffer newDirectByteBuffer(long addr, int capacity); +native private ByteBuffer newDirectByteBuffer(long addr, long capacity); public void glVertexPointer(GLArrayData array) { if(array.getComponentNumber()==0) return; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java index e65c491a2..e096d2185 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java @@ -259,32 +259,7 @@ private boolean checkPackPBOEnabled(boolean throwException) { return false; } -// Attempt to return the same ByteBuffer object from glMapBufferARB if -// the vertex buffer object's base address and size haven't changed -private static class ARBVBOKey { - private long addr; - private int capacity; - - ARBVBOKey(long addr, int capacity) { - this.addr = addr; - this.capacity = capacity; - } - - public int hashCode() { - return (int) addr; - } - - public boolean equals(Object o) { - if ((o == null) || (!(o instanceof ARBVBOKey))) { - return false; - } - - ARBVBOKey other = (ARBVBOKey) o; - return ((addr == other.addr) && (capacity == other.capacity)); - } -} - -private Map/*<ARBVBOKey, ByteBuffer>*/ arbVBOCache = new HashMap(); +private HashMap/*<MemoryObject>*/ arbMemCache = new HashMap(); /** Entry point to C language function: <br> <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ public java.nio.ByteBuffer glMapBuffer(int target, int access) { @@ -292,32 +267,40 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { if (__addr_ == 0) { throw new GLException("Method \"glMapBuffer\" not available"); } - int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, - target, - this); + final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); if (0 == sz) { return null; } - long addr; - addr = dispatch_glMapBuffer(target, access, __addr_); + final long addr = dispatch_glMapBuffer(target, access, __addr_); if (0 == addr) { return null; } - ARBVBOKey key = new ARBVBOKey(addr, sz); - java.nio.ByteBuffer _res = (java.nio.ByteBuffer) arbVBOCache.get(key); - if (_res == null) { - _res = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(_res); - arbVBOCache.put(key, _res); + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key + 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(); + } } - _res.position(0); - return _res; + buffer.position(0); + return buffer; } /** Encapsulates function pointer for OpenGL function <br>: <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); -native private ByteBuffer newDirectByteBuffer(long addr, int capacity); +native private ByteBuffer newDirectByteBuffer(long addr, long capacity); public void glClearDepth(double depth) { glClearDepthf((float)depth); |