Class ResourceRegistry<R,N>
java.lang.Object
dev.engine.graphics.resource.ResourceRegistry<R,N>
- Type Parameters:
R- the phantom resource type (e.g., BufferResource)N- the native resource data (e.g., Integer for GL names, or a record for VK allocations)
Generic resource registry combining a HandlePool with native resource tracking.
Used by backends to manage GPU resources (buffers, textures, pipelines, etc.).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate()Allocates a handle without native data (for lazy init).voidclear()Clears all resources without cleanup.voiddestroyAll(Consumer<N> cleanup) Destroys all resources using the given cleanup function, then clears.voidforEach(BiConsumer<Integer, N> action) Iterates all live resources.get(int index) Gets the native resource by raw index.Gets the native resource for a handle.booleanChecks if a handle is valid (allocated and not released).voidAssociates native data with an existing handle.Allocates a handle and associates native resource data.Removes and returns the native resource, releases the handle.intReports leaked handles.intsize()Number of currently allocated handles.
-
Constructor Details
-
ResourceRegistry
-
-
Method Details
-
register
-
allocate
-
put
-
get
-
get
Gets the native resource by raw index. -
remove
-
isValid
-
size
public int size()Number of currently allocated handles. -
forEach
Iterates all live resources. -
destroyAll
-
reportLeaks
public int reportLeaks()Reports leaked handles. -
clear
public void clear()Clears all resources without cleanup.
-