Expand description
RAII ownership of Godot RenderingDevice RIDs (CEL-91).
Owned<K> is the one handle type and carries the only Drop impl for GPU
resources in this crate; RidSink is the only place a free_rid call may live.
K is a phantom marker (Buffer, Texture, Shader, Pipeline,
UniformSet) — Godot frees every kind through the same free_rid, so the marker
carries no behaviour, only compile-time separation.
§DROP-ORDER CONTRACT (read this before adding fields to a GPU-resource struct)
RenderingDevice frees dependents together with their parent: freeing a shader or a
buffer also invalidates the uniform sets and pipelines derived from it. Therefore
uniform sets and pipelines must be freed BEFORE the shaders / buffers / textures they
derive from, or the later free_rid hits an already-dead RID.
Nothing in this code enforces that. It falls out of struct field declaration
order, because Rust drops fields top-to-bottom. Consumers (e.g. ChunkGpuResources)
must declare, in this order:
struct ChunkGpuResources {
// 1. uniform sets
set: RdUniformSet,
// 2. pipelines
pipeline: RdPipeline,
// 3. shaders / buffers / textures (the parents)
shader: RdShader,
buffer: RdBuffer,
}MainDeviceSink’s drain is FIFO, so the enqueue order produced by that field
order is exactly the order the RIDs are handed to free_rid.
Structs§
- Buffer
- Storage-buffer marker.
- Indirect
Multi Mesh - A
MultiMeshallocated withuse_indirect, plus the cleanup Godot forgets. - Local
Device Sink - Sink for a local
RenderingDevice(the GPU parity tests ingpu/chunk_gpu_test.rs). - Main
Device Sink - Sink for the main
RenderingDevice. - Owned
- The one RAII handle for a
RenderingDeviceRID. - Pipeline
- Compute-pipeline marker.
- Shader
- Compute-shader marker.
- Texture
- Texture marker.
- Uniform
Set - Uniform-set marker.
Traits§
Type Aliases§
- RdBuffer
- Owned storage buffer.
- RdPipeline
- Owned compute pipeline.
- RdShader
- Owned compute shader.
- RdTexture
- Owned texture.
- RdUniform
Set - Owned uniform set.