Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c46bd77

Browse files
authored
[Impeller] Use booleans instead of counting backdrop reads. (#52181)
We don't need to track the actual number of reads anymore now that clips are replayed (since we no longer ever store the stencil or depth buffers). Also, we don't need to pass this into `InlinePassContext` anymore.
1 parent 6d752ad commit c46bd77

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

impeller/entity/entity_pass.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void EntityPass::AddEntity(Entity entity) {
110110
}
111111

112112
if (entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
113-
advanced_blend_reads_from_pass_texture_ += 1;
113+
advanced_blend_reads_from_pass_texture_ = true;
114114
}
115115
elements_.emplace_back(std::move(entity));
116116
}
@@ -277,10 +277,10 @@ EntityPass* EntityPass::AddSubpass(std::unique_ptr<EntityPass> pass) {
277277
pass->superpass_ = this;
278278

279279
if (pass->backdrop_filter_proc_) {
280-
backdrop_filter_reads_from_pass_texture_ += 1;
280+
backdrop_filter_reads_from_pass_texture_ = true;
281281
}
282282
if (pass->blend_mode_ > Entity::kLastPipelineBlendMode) {
283-
advanced_blend_reads_from_pass_texture_ += 1;
283+
advanced_blend_reads_from_pass_texture_ = true;
284284
}
285285

286286
auto subpass_pointer = pass.get();
@@ -299,9 +299,11 @@ void EntityPass::AddSubpassInline(std::unique_ptr<EntityPass> pass) {
299299
elements_.emplace_back(std::move(elements[i]));
300300
}
301301

302-
backdrop_filter_reads_from_pass_texture_ +=
302+
backdrop_filter_reads_from_pass_texture_ =
303+
backdrop_filter_reads_from_pass_texture_ ||
303304
pass->backdrop_filter_reads_from_pass_texture_;
304-
advanced_blend_reads_from_pass_texture_ +=
305+
advanced_blend_reads_from_pass_texture_ =
306+
advanced_blend_reads_from_pass_texture_ ||
305307
pass->advanced_blend_reads_from_pass_texture_;
306308
}
307309

@@ -366,10 +368,10 @@ static EntityPassTarget CreateRenderTarget(ContentContext& renderer,
366368
renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA());
367369
}
368370

369-
uint32_t EntityPass::GetTotalPassReads(ContentContext& renderer) const {
371+
bool EntityPass::DoesBackdropGetRead(ContentContext& renderer) const {
370372
return renderer.GetDeviceCapabilities().SupportsFramebufferFetch()
371373
? backdrop_filter_reads_from_pass_texture_
372-
: backdrop_filter_reads_from_pass_texture_ +
374+
: backdrop_filter_reads_from_pass_texture_ ||
373375
advanced_blend_reads_from_pass_texture_;
374376
}
375377

@@ -413,11 +415,10 @@ bool EntityPass::Render(ContentContext& renderer,
413415
EntityPassClipStack clip_stack = EntityPassClipStack(
414416
Rect::MakeSize(root_render_target.GetRenderTargetSize()));
415417

416-
bool reads_from_onscreen_backdrop = GetTotalPassReads(renderer) > 0;
417418
// In this branch path, we need to render everything to an offscreen texture
418419
// and then blit the results onto the onscreen texture. If using this branch,
419420
// there's no need to set up a stencil attachment on the root render target.
420-
if (reads_from_onscreen_backdrop) {
421+
if (DoesBackdropGetRead(renderer)) {
421422
EntityPassTarget offscreen_target = CreateRenderTarget(
422423
renderer, root_render_target.GetRenderTargetSize(),
423424
GetRequiredMipCount(),
@@ -889,8 +890,7 @@ bool EntityPass::OnRender(
889890
pass_depth);
890891
}
891892

892-
InlinePassContext pass_context(renderer, pass_target,
893-
GetTotalPassReads(renderer), GetElementCount(),
893+
InlinePassContext pass_context(renderer, pass_target, GetElementCount(),
894894
collapsed_parent_pass);
895895
if (!pass_context.IsValid()) {
896896
VALIDATION_LOG << SPrintF("Pass context invalid (Depth=%d)", pass_depth);

impeller/entity/entity_pass.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,18 +346,18 @@ class EntityPass {
346346
ContentBoundsPromise bounds_promise_ = ContentBoundsPromise::kUnknown;
347347
int32_t required_mip_count_ = 1;
348348

349-
/// These values are incremented whenever something is added to the pass that
350-
/// requires reading from the backdrop texture. Currently, this can happen in
351-
/// the following scenarios:
349+
/// These values indicate whether something has been added to the EntityPass
350+
/// that requires reading from the backdrop texture. Currently, this can
351+
/// happen in the following scenarios:
352352
/// 1. An entity with an "advanced blend" is added to the pass.
353353
/// 2. A subpass with a backdrop filter is added to the pass.
354354
/// These are tracked as separate values because we may ignore
355-
/// blend_reads_from_pass_texture_ if the device supports framebuffer based
355+
/// `blend_reads_from_pass_texture_` if the device supports framebuffer based
356356
/// advanced blends.
357-
uint32_t advanced_blend_reads_from_pass_texture_ = 0;
358-
uint32_t backdrop_filter_reads_from_pass_texture_ = 0;
357+
bool advanced_blend_reads_from_pass_texture_ = false;
358+
bool backdrop_filter_reads_from_pass_texture_ = false;
359359

360-
uint32_t GetTotalPassReads(ContentContext& renderer) const;
360+
bool DoesBackdropGetRead(ContentContext& renderer) const;
361361

362362
BackdropFilterProc backdrop_filter_proc_ = nullptr;
363363

impeller/entity/inline_pass_context.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace impeller {
2020
InlinePassContext::InlinePassContext(
2121
const ContentContext& renderer,
2222
EntityPassTarget& pass_target,
23-
uint32_t pass_texture_reads,
2423
uint32_t entity_count,
2524
std::optional<RenderPassResult> collapsed_parent_pass)
2625
: renderer_(renderer),

impeller/entity/inline_pass_context.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class InlinePassContext {
2525
InlinePassContext(
2626
const ContentContext& renderer,
2727
EntityPassTarget& pass_target,
28-
uint32_t pass_texture_reads,
2928
uint32_t entity_count,
3029
std::optional<RenderPassResult> collapsed_parent_pass = std::nullopt);
3130

0 commit comments

Comments
 (0)