Path: blob/main/release-content/migration-guides/composable_specialization.md
6592 views
---
---
The existing pipeline specialization APIs (SpecializedRenderPipeline
etc.) have been replaced with a single Specializer
trait and Variants
collection:
For more info on specialization, see the docs for bevy_render::render_resources::Specializer
Mutation and Base Descriptors
The main difference between the old and new trait is that instead of producing a pipeline descriptor, Specializer
s mutate existing descriptors based on a key. As such, Variants::new
takes in a "base descriptor" to act as the template from which the specializer creates pipeline variants.
When migrating, the "static" parts of the pipeline (that don't depend on the key) should become part of the base descriptor, while the specializer itself should only change the parts demanded by the key. In the full example below, instead of creating the entire pipeline descriptor the specializer only changes the msaa sample count and the bind group layout.
Composing Specializers
Specializer
s can also be composed with the included derive macro to combine their effects! This is a great way to encapsulate and reuse specialization logic, though the rest of this guide will focus on migrating "standalone" specializers.
Misc Changes
The analogue of SpecializedRenderPipelines
, Variants
, is no longer a Bevy Resource
. Instead, the cache should be stored in a user-created Resource
(shown below) or even in a Component
depending on the use case.
Full Migration Example
Before:
After: