Skip to main content

Module owned

Module owned 

Source
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.
IndirectMultiMesh
A MultiMesh allocated with use_indirect, plus the cleanup Godot forgets.
LocalDeviceSink
Sink for a local RenderingDevice (the GPU parity tests in gpu/chunk_gpu_test.rs).
MainDeviceSink
Sink for the main RenderingDevice.
Owned
The one RAII handle for a RenderingDevice RID.
Pipeline
Compute-pipeline marker.
Shader
Compute-shader marker.
Texture
Texture marker.
UniformSet
Uniform-set marker.

Traits§

RdKind
WHAT kind of RID — a compile-time marker only.
RidSink
WHO deallocates a RID.

Type Aliases§

RdBuffer
Owned storage buffer.
RdPipeline
Owned compute pipeline.
RdShader
Owned compute shader.
RdTexture
Owned texture.
RdUniformSet
Owned uniform set.