Skip to content

Commit

Permalink
Fix CAS toggle broken by retained render world (#16533)
Browse files Browse the repository at this point in the history
# Objective

Fixes #16531

I also added change detection when creating the pipeline, which
technically isn't needed but it felt weird leaving it as is.

## Solution

Remove the pipeline if CAS is disabled. The uniform was already being
removed, which caused flickering / weirdness.

## Testing

Tested the anti_alias example by toggling CAS a bunch on/off.
  • Loading branch information
kristoff3r authored Nov 27, 2024
1 parent af10aa3 commit 3d72e08
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,22 @@ fn prepare_cas_pipelines(
pipeline_cache: Res<PipelineCache>,
mut pipelines: ResMut<SpecializedRenderPipelines<CasPipeline>>,
sharpening_pipeline: Res<CasPipeline>,
views: Query<(Entity, &ExtractedView, &DenoiseCas), With<CasUniform>>,
views: Query<
(Entity, &ExtractedView, &DenoiseCas),
Or<(Added<CasUniform>, Changed<DenoiseCas>)>,
>,
mut removals: RemovedComponents<CasUniform>,
) {
for (entity, view, cas) in &views {
for entity in removals.read() {
commands.entity(entity).remove::<ViewCasPipeline>();
}

for (entity, view, denoise_cas) in &views {
let pipeline_id = pipelines.specialize(
&pipeline_cache,
&sharpening_pipeline,
CasPipelineKey {
denoise: cas.0,
denoise: denoise_cas.0,
texture_format: if view.hdr {
ViewTarget::TEXTURE_FORMAT_HDR
} else {
Expand Down

0 comments on commit 3d72e08

Please sign in to comment.