From 3d72e08f3234421ab8f6fb3087ab20fc90c48eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20S=C3=B8holm?= Date: Thu, 28 Nov 2024 00:38:09 +0100 Subject: [PATCH] Fix CAS toggle broken by retained render world (#16533) # 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. --- .../src/contrast_adaptive_sharpening/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index e76be196d59f8..fbc3ecfec3f75 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -243,14 +243,22 @@ fn prepare_cas_pipelines( pipeline_cache: Res, mut pipelines: ResMut>, sharpening_pipeline: Res, - views: Query<(Entity, &ExtractedView, &DenoiseCas), With>, + views: Query< + (Entity, &ExtractedView, &DenoiseCas), + Or<(Added, Changed)>, + >, + mut removals: RemovedComponents, ) { - for (entity, view, cas) in &views { + for entity in removals.read() { + commands.entity(entity).remove::(); + } + + 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 {