Package icyllis.arc3d.granite
Class UniformDataCache
java.lang.Object
icyllis.arc3d.granite.UniformDataCache
- All Implemented Interfaces:
AutoCloseable
Add a block of data to the cache and return a stable pointer to the contents (assuming that a
resettable gatherer had accumulated the input data pointer).
If an identical block of data is already in the cache, that existing pointer is returned, making pointer comparison suitable when comparing data blocks retrieved from the cache.
- See Also:
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
UniformDataCache
public UniformDataCache()
-
-
Method Details
-
insert
Find an existing data block with the contents of the given block. The given block is just a memory view, and it can be reused by changing itsBuffer.position()
andBuffer.limit()
. TheIntBuffer.hashCode()
andIntBuffer.equals(Object)
of the given block will be used. If absent, a copy of the given data will be made and its memory is managed by this object, return value is a stable pointer to that memory, you can simply check the reference equality via==
as it's deduplicated.- Parameters:
block
- an immutable view of uniform data- Returns:
- a stable pointer to existing or copied uniform data
-
size
public int size()The number of unique data blocks in the cache. -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-