Check cached buffer results in OpenGL functions for matching capacity

This commit is contained in:
Elias Naur 2006-12-20 17:55:10 +00:00
parent 69e52d3361
commit 17d7df3f19
4 changed files with 7 additions and 7 deletions

View File

@ -89,7 +89,8 @@ static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) {
static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) { static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) {
if (old_buffer != NULL) { if (old_buffer != NULL) {
void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer); void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer);
if (old_buffer_address == p) jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer);
if (old_buffer_address == p && capacity == size)
return old_buffer; return old_buffer;
} }
return safeNewBuffer(env, p, size); return safeNewBuffer(env, p, size);

View File

@ -110,7 +110,7 @@ public interface ARB_buffer_object {
* ByteBuffer mapped_buffer; mapped_buffer = glMapBufferARB(..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferARB(..., ..., ..., mapped_buffer); * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferARB(..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferARB(..., ..., ..., mapped_buffer);
* *
* @param result_size The size of the buffer area. * @param result_size The size of the buffer area.
* @param old_buffer A ByteBuffer. If this argument points to the same address as the new mapping, it will be returned and no new buffer will be created. In that case, size is ignored. * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
* *
* @return A ByteBuffer representing the mapped buffer memory. * @return A ByteBuffer representing the mapped buffer memory.
*/ */

View File

@ -44,9 +44,8 @@ public interface ATI_map_object_buffer {
* new ByteBuffer is created. * new ByteBuffer is created.
* *
* @param result_size The size of the buffer area. * @param result_size The size of the buffer area.
* @param old_buffer A ByteBuffer. If this argument points to the same address as the new mapping, * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping,
* it will be returned and no new buffer will be created. In that case, size is * it will be returned and no new buffer will be created.
* ignored.
* *
* @return A ByteBuffer representing the mapped object buffer memory. * @return A ByteBuffer representing the mapped object buffer memory.
*/ */

View File

@ -116,8 +116,8 @@ public interface GL15 {
* mapped_buffer = glMapBuffer(..., ..., ..., mapped_buffer); * mapped_buffer = glMapBuffer(..., ..., ..., mapped_buffer);
* *
* @param result_size The size of the buffer area. * @param result_size The size of the buffer area.
* @param old_buffer A ByteBuffer. If this argument points to the same address as the new mapping, it will be returned and no * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no
* new buffer will be created. In that case, size is ignored. * new buffer will be created.
* *
* @return A ByteBuffer representing the mapped buffer memory. * @return A ByteBuffer representing the mapped buffer memory.
*/ */