Top Description Inners Fields Constructors Methods
jogamp.opengl

public Class GLBufferObjectTracker

extends Object
Class Inheritance
Imports
java.nio.Buffer, .ByteBuffer, .IntBuffer, com.jogamp.opengl.*, com.jogamp.common.ExceptionUtils, com.jogamp.common.nio.Buffers, com.jogamp.common.util.IntObjectHashMap, .PropertyAccess

Tracking of GLBufferStorage instances via GL API callbacks.

See GLBufferStorage for generic details.

Buffer storage is created via

Note that storage recreation as mentioned above also invalidate a previous storage instance, i.e. disposed the buffer's current storage if exist and attaches a new storage instance.

Buffers storage is disposed via

Implementation throws a GLException in all construction methods as listed below, if GL-function constraints are not met. createBufferStorage also throws an exception if the native GL-function fails.

In destruction and informal methods, i.e. all others, implementation only issues a WARNING debug message, if enabled.

Buffer mapping methods like GL#mapBuffer(int, int) ..., require knowledge of the buffer's storage size as determined via it's creation with GL#glBufferData(int, long, java.nio.Buffer, int) ....

Hence we track the OpenGL buffer's GLBufferStorage to be able to access the buffer's storage size. The tracked GLBufferStorage instances also allow users to conveniently access details of their created and maybe mapped buffer storage.

The GLBufferObjectTracker and it's tracked GLBufferStorage instances maybe shared across multiple OpenGL context, hence this class is thread safe and employs synchronization.

Implementation requires and utilizes a local GLBufferStateTracker to resolve the actual buffer-name bound to the given target.

Note

This tracker requires to be notified about all OpenGL buffer storage operations, as well as the local GLBufferStateTracker to be notified about all OpenGL buffer binding operations. Hence buffer storage cannot be accessed properly if managed via native code.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
pack-priv static class
public static interface
public static interface
public static interface
public static interface

Field Summary

Modifier and TypeField and Description
private final IntObjectHashMap
bufferName2StorageMap

Map from buffer names to GLBufferObject.

protected static final boolean
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final synchronized void
clear()

Clear all tracked buffer object knowledge.

public final synchronized void
createBufferStorage(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final long size, final Buffer data, final int
glBufferData, glNamedBufferData usage
mutableUsage
,
final int
glBufferStorage flags
immutableFlags
,
final GLBufferObjectTracker.CreateStorageDispatch dispatch)

Must be called when [re]creating the GL buffer object via GL#glBufferData(int, long, java.nio.Buffer, int) and GL4#glBufferStorage(int, long, Buffer, int), i.e. implies destruction of the buffer.

public final synchronized void
createBufferStorage(final GL caller, final int bufferName, final long size, final Buffer data, final int mutableUsage, final int immutableFlags, final GLBufferObjectTracker.CreateStorageDispatch dispatch)

Must be called when [re]creating the GL buffer object via glNamedBufferDataEXT, glNamedBufferData, and GL4#glNamedBufferStorage(int, long, Buffer, int), i.e. implies destruction of the buffer.

public final synchronized GLBufferStorage
getBufferStorage(final int bufferName)

public final synchronized GLBufferStorage
mapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final int access, final GLBufferObjectTracker.MapBufferAllDispatch dispatch)

Must be called when mapping GL buffer objects via GL#mapBuffer(int, int).

public final synchronized GLBufferStorage
mapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final long offset, final long length, final int access, final GLBufferObjectTracker.MapBufferRangeDispatch dispatch)

Must be called when mapping GL buffer objects via GL#mapBufferRange(int, long, long, int).

public final synchronized GLBufferStorage
mapBuffer(final int bufferName, final int access, final GLBufferObjectTracker.MapBufferAllDispatch dispatch)

Must be called when mapping GL buffer objects via GL2#mapNamedBufferEXT(int, int).

public final synchronized GLBufferStorage
mapBuffer(final int bufferName, final long offset, final long length, final int access, final GLBufferObjectTracker.MapBufferRangeDispatch dispatch)

Must be called when mapping GL buffer objects via GL2#mapNamedBufferRangeEXT(int, long, long, int).

private final synchronized GLBufferStorage
mapBufferImpl(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final boolean useRange, final long offset, final long length, final int access, final GLBufferObjectTracker.MapBufferDispatch dispatch)

private final synchronized GLBufferStorage
mapBufferImpl(final int target, final int bufferName, final boolean isNamedBuffer, final boolean useRange, long offset, long length, final int access, final GLBufferObjectTracker.MapBufferDispatch dispatch)

A zero store size will avoid a native call and returns the unmapped GLBufferStorage.

private final synchronized void
notifyBufferDeleted(final int bufferName, final int i, final int count)

Must be called when deleting GL buffer objects vis GL#glDeleteBuffers(int, IntBuffer).

public final synchronized void
notifyBuffersDeleted(final int count, final int[] bufferNames, final int offset)

Must be called when deleting GL buffer objects vis glDeleteBuffers.

public final synchronized void
notifyBuffersDeleted(final int n, final IntBuffer bufferNames)

Must be called when deleting GL buffer objects vis glDeleteBuffers.

public final synchronized boolean
unmapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final GLBufferObjectTracker.UnmapBufferDispatch dispatch)

Must be called when unmapping GL buffer objects via GL#glUnmapBuffer(int).

public final synchronized boolean
unmapBuffer(final int bufferName, final GLBufferObjectTracker.UnmapBufferDispatch dispatch)

Must be called when unmapping GL buffer objects via GL2#glUnmapNamedBuffer(int).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferName2StorageMapback to summary
private final IntObjectHashMap bufferName2StorageMap

Map from buffer names to GLBufferObject.

DEBUGback to summary
protected static final boolean DEBUG
GL_INVALID_OPERATIONback to summary
private static final String GL_INVALID_OPERATION
GL_INVALID_VALUEback to summary
private static final String GL_INVALID_VALUE
msgClazzNameback to summary
private static final String msgClazzName
msgCreateBoundback to summary
private static final String msgCreateBound
msgCreateNamedback to summary
private static final String msgCreateNamed
msgMapBufferback to summary
private static final String msgMapBuffer
msgUnmappedback to summary
private static final String msgUnmapped
warningback to summary
private static final String warning

Constructor Detail

GLBufferObjectTrackerback to summary
public GLBufferObjectTracker()

Method Detail

clearback to summary
public final synchronized void clear()

Clear all tracked buffer object knowledge.

Shall only be called at GLContext destruction iff there are no other shared GLContext instances left.

createBufferStorageback to summary
public final synchronized void createBufferStorage(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final long size, final Buffer data, final int mutableUsage, final int immutableFlags, final GLBufferObjectTracker.CreateStorageDispatch dispatch) throws GLException

Must be called when [re]creating the GL buffer object via GL#glBufferData(int, long, java.nio.Buffer, int) and GL4#glBufferStorage(int, long, Buffer, int), i.e. implies destruction of the buffer.

Parameters
mutableUsage:int

glBufferData, glNamedBufferData usage

immutableFlags:int

glBufferStorage flags

Exceptions
GLException:
  • if buffer is not bound to target
  • if size is less-or-eqaul zero for glBufferStorage, or size is less-than zero otherwise
  • if a native GL-Error occurs
createBufferStorageback to summary
public final synchronized void createBufferStorage(final GL caller, final int bufferName, final long size, final Buffer data, final int mutableUsage, final int immutableFlags, final GLBufferObjectTracker.CreateStorageDispatch dispatch) throws GLException

Must be called when [re]creating the GL buffer object via glNamedBufferDataEXT, glNamedBufferData, and GL4#glNamedBufferStorage(int, long, Buffer, int), i.e. implies destruction of the buffer.

Exceptions
GLException:
  • if size is less-than zero
  • if a native GL-Error occurs
getBufferStorageback to summary
public final synchronized GLBufferStorage getBufferStorage(final int bufferName)
mapBufferback to summary
public final synchronized GLBufferStorage mapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final int access, final GLBufferObjectTracker.MapBufferAllDispatch dispatch) throws GLException

Must be called when mapping GL buffer objects via GL#mapBuffer(int, int).

Exceptions
GLException:
  • if buffer is not bound to target
  • if buffer is not tracked
  • if buffer is already mapped
  • if buffer has invalid store size, i.e. less-than zero
mapBufferback to summary
public final synchronized GLBufferStorage mapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final long offset, final long length, final int access, final GLBufferObjectTracker.MapBufferRangeDispatch dispatch) throws GLException

Must be called when mapping GL buffer objects via GL#mapBufferRange(int, long, long, int).

Exceptions
GLException:
  • if buffer is not bound to target
  • if buffer is not tracked
  • if buffer is already mapped
  • if buffer has invalid store size, i.e. less-than zero
  • if buffer mapping range does not fit, incl. offset
mapBufferback to summary
public final synchronized GLBufferStorage mapBuffer(final int bufferName, final int access, final GLBufferObjectTracker.MapBufferAllDispatch dispatch) throws GLException

Must be called when mapping GL buffer objects via GL2#mapNamedBufferEXT(int, int).

Exceptions
GLException:
  • if buffer is not tracked
  • if buffer is already mapped
  • if buffer has invalid store size, i.e. less-than zero
mapBufferback to summary
public final synchronized GLBufferStorage mapBuffer(final int bufferName, final long offset, final long length, final int access, final GLBufferObjectTracker.MapBufferRangeDispatch dispatch) throws GLException

Must be called when mapping GL buffer objects via GL2#mapNamedBufferRangeEXT(int, long, long, int).

Exceptions
GLException:
  • if buffer is not tracked
  • if buffer is already mapped
  • if buffer has invalid store size, i.e. less-than zero
  • if buffer mapping range does not fit, incl. offset
mapBufferImplback to summary
private final synchronized GLBufferStorage mapBufferImpl(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final boolean useRange, final long offset, final long length, final int access, final GLBufferObjectTracker.MapBufferDispatch dispatch) throws GLException
Exceptions
GLException:
  • if buffer is not bound to target
  • if buffer is not tracked
  • if buffer is already mapped
  • if buffer has invalid store size, i.e. less-than zero
  • if buffer mapping range does not fit, incl. optional offset
mapBufferImplback to summary
private final synchronized GLBufferStorage mapBufferImpl(final int target, final int bufferName, final boolean isNamedBuffer, final boolean useRange, long offset, long length, final int access, final GLBufferObjectTracker.MapBufferDispatch dispatch) throws GLException

A zero store size will avoid a native call and returns the unmapped GLBufferStorage.

A null native mapping result indicating an error will not cause a GLException but returns the unmapped GLBufferStorage. This allows the user to handle this case.

Exceptions
GLException:
  • if buffer is not tracked
  • if buffer is already mapped
  • if buffer has invalid store size, i.e. less-than zero
  • if buffer mapping range does not fit, incl. optional offset
notifyBufferDeletedback to summary
private final synchronized void notifyBufferDeleted(final int bufferName, final int i, final int count)

Must be called when deleting GL buffer objects vis GL#glDeleteBuffers(int, IntBuffer).

notifyBuffersDeletedback to summary
public final synchronized void notifyBuffersDeleted(final int count, final int[] bufferNames, final int offset)

Must be called when deleting GL buffer objects vis glDeleteBuffers.

notifyBuffersDeletedback to summary
public final synchronized void notifyBuffersDeleted(final int n, final IntBuffer bufferNames)

Must be called when deleting GL buffer objects vis glDeleteBuffers.

unmapBufferback to summary
public final synchronized boolean unmapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, final int target, final GLBufferObjectTracker.UnmapBufferDispatch dispatch)

Must be called when unmapping GL buffer objects via GL#glUnmapBuffer(int).

Only clear mapped buffer reference of GLBufferStorage if native unmapping was successful.

unmapBufferback to summary
public final synchronized boolean unmapBuffer(final int bufferName, final GLBufferObjectTracker.UnmapBufferDispatch dispatch)

Must be called when unmapping GL buffer objects via GL2#glUnmapNamedBuffer(int).

Only clear mapped buffer reference of GLBufferStorage if native unmapping was successful.

jogamp.opengl back to summary

public Interface GLBufferObjectTracker.CreateStorageDispatch


Method Summary

Modifier and TypeMethod and Description
public void
create(final int targetOrBufferName, final long size, final Buffer data, final int mutableUsageOrImmutableFlags)

Method Detail

createback to summary
public void create(final int targetOrBufferName, final long size, final Buffer data, final int mutableUsageOrImmutableFlags)
jogamp.opengl back to summary

pack-priv final Class GLBufferObjectTracker.GLBufferStorageImpl

extends GLBufferStorage
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
GLBufferStorageImpl(final int name, final long size, final int mutableUsage, final int immutableFlags)

Method Summary

Modifier and TypeMethod and Description
protected final void
reset(final long size, final int mutableUsage, final int immutableFlags)

Overrides com.jogamp.opengl.GLBufferStorage.reset.

protected final void
Inherited from com.jogamp.opengl.GLBufferStorage:
getImmutableFlagsgetMappedBuffergetMutableUsagegetNamegetSizeisMutableStoragetoStringtoString

Constructor Detail

GLBufferStorageImplback to summary
pack-priv GLBufferStorageImpl(final int name, final long size, final int mutableUsage, final int immutableFlags)

Method Detail

resetback to summary
protected final void reset(final long size, final int mutableUsage, final int immutableFlags)

Overrides com.jogamp.opengl.GLBufferStorage.reset.

setMappedBufferback to summary
protected final void setMappedBuffer(final ByteBuffer buffer)

Overrides com.jogamp.opengl.GLBufferStorage.setMappedBuffer.

jogamp.opengl back to summary

public Interface GLBufferObjectTracker.MapBufferAllDispatch

extends MapBufferDispatch

Method Summary

Modifier and TypeMethod and Description
public long
mapBuffer(final int targetOrBufferName, final int access)

Inherited from jogamp.opengl.GLBufferObjectTracker.MapBufferDispatch:
allocNioByteBuffer

Method Detail

mapBufferback to summary
public long mapBuffer(final int targetOrBufferName, final int access)
jogamp.opengl back to summary

public Interface GLBufferObjectTracker.MapBufferDispatch

Known Direct Subinterfaces
jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch, jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
allocNioByteBuffer(final long addr, final long length)

Method Detail

allocNioByteBufferback to summary
public ByteBuffer allocNioByteBuffer(final long addr, final long length)
jogamp.opengl back to summary

public Interface GLBufferObjectTracker.MapBufferRangeDispatch

extends MapBufferDispatch

Method Summary

Modifier and TypeMethod and Description
public long
mapBuffer(final int targetOrBufferName, final long offset, final long length, final int access)

Inherited from jogamp.opengl.GLBufferObjectTracker.MapBufferDispatch:
allocNioByteBuffer

Method Detail

mapBufferback to summary
public long mapBuffer(final int targetOrBufferName, final long offset, final long length, final int access)
jogamp.opengl back to summary

public Interface GLBufferObjectTracker.UnmapBufferDispatch


Method Summary

Modifier and TypeMethod and Description
public boolean
unmap(final int targetOrBufferName)

Method Detail

unmapback to summary
public boolean unmap(final int targetOrBufferName)