diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index ff6327a8a0def..89a2d90c27c5f 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -110,7 +110,7 @@ void EntityPass::AddEntity(Entity entity) { } if (entity.GetBlendMode() > Entity::kLastPipelineBlendMode) { - advanced_blend_reads_from_pass_texture_ += 1; + advanced_blend_reads_from_pass_texture_ = true; } elements_.emplace_back(std::move(entity)); } @@ -277,10 +277,10 @@ EntityPass* EntityPass::AddSubpass(std::unique_ptr pass) { pass->superpass_ = this; if (pass->backdrop_filter_proc_) { - backdrop_filter_reads_from_pass_texture_ += 1; + backdrop_filter_reads_from_pass_texture_ = true; } if (pass->blend_mode_ > Entity::kLastPipelineBlendMode) { - advanced_blend_reads_from_pass_texture_ += 1; + advanced_blend_reads_from_pass_texture_ = true; } auto subpass_pointer = pass.get(); @@ -299,9 +299,11 @@ void EntityPass::AddSubpassInline(std::unique_ptr pass) { elements_.emplace_back(std::move(elements[i])); } - backdrop_filter_reads_from_pass_texture_ += + backdrop_filter_reads_from_pass_texture_ = + backdrop_filter_reads_from_pass_texture_ || pass->backdrop_filter_reads_from_pass_texture_; - advanced_blend_reads_from_pass_texture_ += + advanced_blend_reads_from_pass_texture_ = + advanced_blend_reads_from_pass_texture_ || pass->advanced_blend_reads_from_pass_texture_; } @@ -366,10 +368,10 @@ static EntityPassTarget CreateRenderTarget(ContentContext& renderer, renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA()); } -uint32_t EntityPass::GetTotalPassReads(ContentContext& renderer) const { +bool EntityPass::DoesBackdropGetRead(ContentContext& renderer) const { return renderer.GetDeviceCapabilities().SupportsFramebufferFetch() ? backdrop_filter_reads_from_pass_texture_ - : backdrop_filter_reads_from_pass_texture_ + + : backdrop_filter_reads_from_pass_texture_ || advanced_blend_reads_from_pass_texture_; } @@ -413,11 +415,10 @@ bool EntityPass::Render(ContentContext& renderer, EntityPassClipStack clip_stack = EntityPassClipStack( Rect::MakeSize(root_render_target.GetRenderTargetSize())); - bool reads_from_onscreen_backdrop = GetTotalPassReads(renderer) > 0; // In this branch path, we need to render everything to an offscreen texture // and then blit the results onto the onscreen texture. If using this branch, // there's no need to set up a stencil attachment on the root render target. - if (reads_from_onscreen_backdrop) { + if (DoesBackdropGetRead(renderer)) { EntityPassTarget offscreen_target = CreateRenderTarget( renderer, root_render_target.GetRenderTargetSize(), GetRequiredMipCount(), @@ -889,8 +890,7 @@ bool EntityPass::OnRender( pass_depth); } - InlinePassContext pass_context(renderer, pass_target, - GetTotalPassReads(renderer), GetElementCount(), + InlinePassContext pass_context(renderer, pass_target, GetElementCount(), collapsed_parent_pass); if (!pass_context.IsValid()) { VALIDATION_LOG << SPrintF("Pass context invalid (Depth=%d)", pass_depth); diff --git a/impeller/entity/entity_pass.h b/impeller/entity/entity_pass.h index 5fc017b873ee7..555921bdce104 100644 --- a/impeller/entity/entity_pass.h +++ b/impeller/entity/entity_pass.h @@ -346,18 +346,18 @@ class EntityPass { ContentBoundsPromise bounds_promise_ = ContentBoundsPromise::kUnknown; int32_t required_mip_count_ = 1; - /// These values are incremented whenever something is added to the pass that - /// requires reading from the backdrop texture. Currently, this can happen in - /// the following scenarios: + /// These values indicate whether something has been added to the EntityPass + /// that requires reading from the backdrop texture. Currently, this can + /// happen in the following scenarios: /// 1. An entity with an "advanced blend" is added to the pass. /// 2. A subpass with a backdrop filter is added to the pass. /// These are tracked as separate values because we may ignore - /// blend_reads_from_pass_texture_ if the device supports framebuffer based + /// `blend_reads_from_pass_texture_` if the device supports framebuffer based /// advanced blends. - uint32_t advanced_blend_reads_from_pass_texture_ = 0; - uint32_t backdrop_filter_reads_from_pass_texture_ = 0; + bool advanced_blend_reads_from_pass_texture_ = false; + bool backdrop_filter_reads_from_pass_texture_ = false; - uint32_t GetTotalPassReads(ContentContext& renderer) const; + bool DoesBackdropGetRead(ContentContext& renderer) const; BackdropFilterProc backdrop_filter_proc_ = nullptr; diff --git a/impeller/entity/inline_pass_context.cc b/impeller/entity/inline_pass_context.cc index 616d4f95437c0..1a1e2a92d88e5 100644 --- a/impeller/entity/inline_pass_context.cc +++ b/impeller/entity/inline_pass_context.cc @@ -20,7 +20,6 @@ namespace impeller { InlinePassContext::InlinePassContext( const ContentContext& renderer, EntityPassTarget& pass_target, - uint32_t pass_texture_reads, uint32_t entity_count, std::optional collapsed_parent_pass) : renderer_(renderer), diff --git a/impeller/entity/inline_pass_context.h b/impeller/entity/inline_pass_context.h index 93e69ff1737df..a1cc84645a558 100644 --- a/impeller/entity/inline_pass_context.h +++ b/impeller/entity/inline_pass_context.h @@ -25,7 +25,6 @@ class InlinePassContext { InlinePassContext( const ContentContext& renderer, EntityPassTarget& pass_target, - uint32_t pass_texture_reads, uint32_t entity_count, std::optional collapsed_parent_pass = std::nullopt);