pub struct PipelineCache { /* private fields */ }
Expand description

Cache for render and compute pipelines.

The cache stores existing render and compute pipelines allocated on the GPU, as well as pending creation. Pipelines inserted into the cache are identified by a unique ID, which can be used to retrieve the actual GPU object once it’s ready. The creation of the GPU pipeline object is deferred to the RenderStage::Render stage, just before the render graph starts being processed, as this requires access to the GPU.

Note that the cache do not perform automatic deduplication of identical pipelines. It is up to the user not to insert the same pipeline twice to avoid wasting GPU resources.

Implementations

Create a new pipeline cache associated with the given render device.

Get the state of a cached render pipeline.

See PipelineCache::queue_render_pipeline().

Get the state of a cached compute pipeline.

See PipelineCache::queue_compute_pipeline().

Get the render pipeline descriptor a cached render pipeline was inserted from.

See PipelineCache::queue_render_pipeline().

Get the compute pipeline descriptor a cached render pipeline was inserted from.

See PipelineCache::queue_compute_pipeline().

Try to retrieve a render pipeline GPU object from a cached ID.

Returns

This method returns a successfully created render pipeline if any, or None if the pipeline was not created yet or if there was an error during creation. You can check the actual creation state with PipelineCache::get_render_pipeline_state().

Try to retrieve a compute pipeline GPU object from a cached ID.

Returns

This method returns a successfully created compute pipeline if any, or None if the pipeline was not created yet or if there was an error during creation. You can check the actual creation state with PipelineCache::get_compute_pipeline_state().

Insert a render pipeline into the cache, and queue its creation.

The pipeline is always inserted and queued for creation. There is no attempt to deduplicate it with an already cached pipeline.

Returns

This method returns the unique render shader ID of the cached pipeline, which can be used to query the caching state with get_render_pipeline_state() and to retrieve the created GPU pipeline once it’s ready with get_render_pipeline().

Insert a compute pipeline into the cache, and queue its creation.

The pipeline is always inserted and queued for creation. There is no attempt to deduplicate it with an already cached pipeline.

Returns

This method returns the unique compute shader ID of the cached pipeline, which can be used to query the caching state with get_compute_pipeline_state() and to retrieve the created GPU pipeline once it’s ready with get_compute_pipeline().

Process the pipeline queue and create all pending pipelines if possible.

This is generally called automatically during the RenderStage::Render stage, but can be called manually to force creation at a different time.

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more