Class GpuResourceManager
java.lang.Object
dev.engine.graphics.common.GpuResourceManager
Unified GPU resource lifecycle layer.
All GPU resource creation and destruction goes through this manager. Provides:
- Unified tracking of all live resources
- Deferred destruction — resources queued mid-frame are destroyed at frame end
- Cleaner-based safety net — unreachable handles are automatically cleaned by GC
- Leak detection on shutdown
- Resource statistics
Domain managers (MeshManager, TextureManager, etc.)
use this instead of RenderDevice directly.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGpuResourceManager(RenderDevice device) GpuResourceManager(RenderDevice device, ResourceStats resourceStats) -
Method Summary
Modifier and TypeMethodDescriptionbufferSubType(Handle<BufferResource> buffer) Returns the resource stats sub-type key for a buffer handle, orBUFFERif unknown.createBuffer(long size, BufferUsage usage, AccessPattern access) createBuffer(BufferDescriptor descriptor) createPipeline(PipelineDescriptor descriptor) createRenderTarget(RenderTargetDescriptor descriptor) createSampler(SamplerDescriptor descriptor) createTexture(TextureDescriptor descriptor) createVertexInput(VertexFormat format) voiddestroyBuffer(Handle<BufferResource> buffer) voiddestroyPipeline(Handle<PipelineResource> pipeline) voidvoiddestroySampler(Handle<SamplerResource> sampler) voiddestroyTexture(Handle<TextureResource> texture) voiddestroyVertexInput(Handle<VertexInputResource> vertexInput) device()Direct device access — escape hatch for operations not covered by this manager.getRenderTargetColorTexture(Handle<RenderTargetResource> rt, int index) intintintintintintvoidProcesses the deferred deletion queue.Returns the ResourceStats instance tracking all resource lifecycle operations.voidshutdown()Reports any leaked resources and destroys everything immediately.intvoiduploadTexture(Handle<TextureResource> texture, ByteBuffer pixels) writeBuffer(Handle<BufferResource> buffer) writeBuffer(Handle<BufferResource> buffer, long offset, long length)
-
Field Details
-
BUFFER
-
BUFFER_VERTEX
- See Also:
-
BUFFER_INDEX
- See Also:
-
BUFFER_UNIFORM
- See Also:
-
BUFFER_STORAGE
- See Also:
-
TEXTURE
- See Also:
-
RENDER_TARGET
- See Also:
-
PIPELINE
- See Also:
-
SAMPLER
- See Also:
-
VERTEX_INPUT
- See Also:
-
-
Constructor Details
-
GpuResourceManager
-
GpuResourceManager
-
-
Method Details
-
createBuffer
-
createBuffer
-
writeBuffer
-
writeBuffer
-
destroyBuffer
-
createTexture
-
uploadTexture
-
destroyTexture
-
createRenderTarget
-
getRenderTargetColorTexture
public Handle<TextureResource> getRenderTargetColorTexture(Handle<RenderTargetResource> rt, int index) -
destroyRenderTarget
-
createPipeline
-
destroyPipeline
-
createSampler
-
destroySampler
-
createVertexInput
-
destroyVertexInput
-
processDeferred
public void processDeferred()Processes the deferred deletion queue. Call once per frame after GPU submission is complete (after endFrame).Resources are deferred through a ring of queues sized to match the device's frames-in-flight count. A resource queued in frame N is deleted after
framesInFlight + 1calls to processDeferred(), ensuring all in-flight GPU frames have finished using it. -
resourceStats
Returns the ResourceStats instance tracking all resource lifecycle operations. -
liveBufferCount
public int liveBufferCount() -
liveTextureCount
public int liveTextureCount() -
liveRenderTargetCount
public int liveRenderTargetCount() -
livePipelineCount
public int livePipelineCount() -
liveSamplerCount
public int liveSamplerCount() -
liveVertexInputCount
public int liveVertexInputCount() -
totalLiveResources
public int totalLiveResources() -
shutdown
public void shutdown()Reports any leaked resources and destroys everything immediately. Call during engine shutdown. -
bufferSubType
Returns the resource stats sub-type key for a buffer handle, orBUFFERif unknown. -
device
Direct device access — escape hatch for operations not covered by this manager.
-