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

Commit bb2a216

Browse files
committed
[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 bb2a216

File tree

4 files changed

+14
-42
lines changed

4 files changed

+14
-42
lines changed

impeller/entity/entity_pass.cc

Lines changed: 7 additions & 26 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,34 +277,17 @@ 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();
287287
elements_.emplace_back(std::move(pass));
288288
return subpass_pointer;
289289
}
290290

291-
void EntityPass::AddSubpassInline(std::unique_ptr<EntityPass> pass) {
292-
if (!pass) {
293-
return;
294-
}
295-
FML_DCHECK(pass->superpass_ == nullptr);
296-
297-
std::vector<Element>& elements = pass->elements_;
298-
for (auto i = 0u; i < elements.size(); i++) {
299-
elements_.emplace_back(std::move(elements[i]));
300-
}
301-
302-
backdrop_filter_reads_from_pass_texture_ +=
303-
pass->backdrop_filter_reads_from_pass_texture_;
304-
advanced_blend_reads_from_pass_texture_ +=
305-
pass->advanced_blend_reads_from_pass_texture_;
306-
}
307-
308291
static const constexpr RenderTarget::AttachmentConfig kDefaultStencilConfig =
309292
RenderTarget::AttachmentConfig{
310293
.storage_mode = StorageMode::kDeviceTransient,
@@ -366,10 +349,10 @@ static EntityPassTarget CreateRenderTarget(ContentContext& renderer,
366349
renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA());
367350
}
368351

369-
uint32_t EntityPass::GetTotalPassReads(ContentContext& renderer) const {
352+
bool EntityPass::DoesBackdropGetRead(ContentContext& renderer) const {
370353
return renderer.GetDeviceCapabilities().SupportsFramebufferFetch()
371354
? backdrop_filter_reads_from_pass_texture_
372-
: backdrop_filter_reads_from_pass_texture_ +
355+
: backdrop_filter_reads_from_pass_texture_ ||
373356
advanced_blend_reads_from_pass_texture_;
374357
}
375358

@@ -413,11 +396,10 @@ bool EntityPass::Render(ContentContext& renderer,
413396
EntityPassClipStack clip_stack = EntityPassClipStack(
414397
Rect::MakeSize(root_render_target.GetRenderTargetSize()));
415398

416-
bool reads_from_onscreen_backdrop = GetTotalPassReads(renderer) > 0;
417399
// In this branch path, we need to render everything to an offscreen texture
418400
// and then blit the results onto the onscreen texture. If using this branch,
419401
// there's no need to set up a stencil attachment on the root render target.
420-
if (reads_from_onscreen_backdrop) {
402+
if (DoesBackdropGetRead(renderer)) {
421403
EntityPassTarget offscreen_target = CreateRenderTarget(
422404
renderer, root_render_target.GetRenderTargetSize(),
423405
GetRequiredMipCount(),
@@ -889,8 +871,7 @@ bool EntityPass::OnRender(
889871
pass_depth);
890872
}
891873

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

impeller/entity/entity_pass.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ class EntityPass {
111111
///
112112
EntityPass* AddSubpass(std::unique_ptr<EntityPass> pass);
113113

114-
//----------------------------------------------------------------------------
115-
/// @brief Merges a given pass into this pass. Useful for drawing
116-
/// pre-recorded pictures that don't require rendering into a separate
117-
/// subpass.
118-
///
119-
void AddSubpassInline(std::unique_ptr<EntityPass> pass);
120-
121114
EntityPass* GetSuperpass() const;
122115

123116
bool Render(ContentContext& renderer,
@@ -346,18 +339,18 @@ class EntityPass {
346339
ContentBoundsPromise bounds_promise_ = ContentBoundsPromise::kUnknown;
347340
int32_t required_mip_count_ = 1;
348341

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:
342+
/// These values indicate whether something has been added to the EntityPass
343+
/// that requires reading from the backdrop texture. Currently, this can
344+
/// happen in the following scenarios:
352345
/// 1. An entity with an "advanced blend" is added to the pass.
353346
/// 2. A subpass with a backdrop filter is added to the pass.
354347
/// These are tracked as separate values because we may ignore
355-
/// blend_reads_from_pass_texture_ if the device supports framebuffer based
348+
/// `blend_reads_from_pass_texture_` if the device supports framebuffer based
356349
/// advanced blends.
357-
uint32_t advanced_blend_reads_from_pass_texture_ = 0;
358-
uint32_t backdrop_filter_reads_from_pass_texture_ = 0;
350+
bool advanced_blend_reads_from_pass_texture_ = false;
351+
bool backdrop_filter_reads_from_pass_texture_ = false;
359352

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

362355
BackdropFilterProc backdrop_filter_proc_ = nullptr;
363356

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)