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

Commit 620431d

Browse files
authored
[Impeller] Simplify subpass branches; remove unused effect_matrix param (#40292)
1 parent d1934a9 commit 620431d

File tree

4 files changed

+26
-35
lines changed

4 files changed

+26
-35
lines changed

impeller/aiks/paint.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ std::shared_ptr<Contents> Paint::CreateContentsForGeometry(
5757

5858
std::shared_ptr<Contents> Paint::WithFilters(
5959
std::shared_ptr<Contents> input,
60-
std::optional<bool> is_solid_color,
61-
const Matrix& effect_transform) const {
60+
std::optional<bool> is_solid_color) const {
6261
bool is_solid_color_val = is_solid_color.value_or(!color_source);
6362
input = WithColorFilter(input);
6463
input = WithInvertFilter(input);
65-
input = WithMaskBlur(input, is_solid_color_val, effect_transform);
66-
input = WithImageFilter(input, effect_transform, /*is_subpass=*/false);
64+
input = WithMaskBlur(input, is_solid_color_val, Matrix());
65+
input = WithImageFilter(input, Matrix(), /*is_subpass=*/false);
6766
return input;
6867
}
6968

impeller/aiks/paint.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ struct Paint {
8787
/// original contents is returned.
8888
std::shared_ptr<Contents> WithFilters(
8989
std::shared_ptr<Contents> input,
90-
std::optional<bool> is_solid_color = std::nullopt,
91-
const Matrix& effect_transform = Matrix()) const;
90+
std::optional<bool> is_solid_color = std::nullopt) const;
9291

9392
/// @brief Wrap this paint's configured filters to the given contents of
9493
/// subpass target.

impeller/entity/entity_pass.cc

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void EntityPass::SetDelegate(std::unique_ptr<EntityPassDelegate> delegate) {
4343

4444
void EntityPass::AddEntity(Entity entity) {
4545
if (entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
46-
blend_reads_from_pass_texture_ += 1;
46+
advanced_blend_reads_from_pass_texture_ += 1;
4747
}
4848
elements_.emplace_back(std::move(entity));
4949
}
@@ -131,10 +131,10 @@ EntityPass* EntityPass::AddSubpass(std::unique_ptr<EntityPass> pass) {
131131
pass->superpass_ = this;
132132

133133
if (pass->backdrop_filter_proc_.has_value()) {
134-
filter_reads_from_pass_texture_ += 1;
134+
backdrop_filter_reads_from_pass_texture_ += 1;
135135
}
136136
if (pass->blend_mode_ > Entity::kLastPipelineBlendMode) {
137-
blend_reads_from_pass_texture_ += 1;
137+
advanced_blend_reads_from_pass_texture_ += 1;
138138
}
139139

140140
auto subpass_pointer = pass.get();
@@ -190,15 +190,16 @@ static RenderTarget CreateRenderTarget(ContentContext& renderer,
190190
);
191191
}
192192

193-
uint32_t EntityPass::ComputeTotalReads(ContentContext& renderer) const {
193+
uint32_t EntityPass::GetTotalPassReads(ContentContext& renderer) const {
194194
return renderer.GetDeviceCapabilities().SupportsFramebufferFetch()
195-
? filter_reads_from_pass_texture_
196-
: filter_reads_from_pass_texture_ + blend_reads_from_pass_texture_;
195+
? backdrop_filter_reads_from_pass_texture_
196+
: backdrop_filter_reads_from_pass_texture_ +
197+
advanced_blend_reads_from_pass_texture_;
197198
}
198199

199200
bool EntityPass::Render(ContentContext& renderer,
200201
const RenderTarget& render_target) const {
201-
if (ComputeTotalReads(renderer) > 0) {
202+
if (GetTotalPassReads(renderer) > 0) {
202203
auto offscreen_target =
203204
CreateRenderTarget(renderer, render_target.GetRenderTargetSize(), true);
204205
if (!OnRender(renderer, offscreen_target.GetRenderTargetSize(),
@@ -329,33 +330,25 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
329330
if (backdrop_coverage.has_value()) {
330331
backdrop_coverage->origin += position;
331332

332-
if (subpass_coverage.has_value()) {
333-
subpass_coverage = subpass_coverage->Union(backdrop_coverage.value());
334-
} else {
335-
subpass_coverage = backdrop_coverage;
336-
}
333+
subpass_coverage =
334+
subpass_coverage.has_value()
335+
? subpass_coverage->Union(backdrop_coverage.value())
336+
: backdrop_coverage;
337337
}
338338
}
339339

340-
if (subpass_coverage.has_value()) {
341-
subpass_coverage =
342-
subpass_coverage->Intersection(Rect::MakeSize(root_pass_size));
343-
}
344-
345-
if (!subpass_coverage.has_value()) {
340+
if (!subpass_coverage.has_value() || subpass_coverage->size.IsEmpty()) {
341+
// The subpass doesn't contain anything visible, so skip it.
346342
return EntityPass::EntityResult::Skip();
347343
}
348344

349-
if (subpass_coverage->size.IsEmpty()) {
350-
// It is not an error to have an empty subpass. But subpasses that can't
351-
// create their intermediates must trip errors.
352-
return EntityPass::EntityResult::Skip();
353-
}
345+
subpass_coverage =
346+
subpass_coverage->Intersection(Rect::MakeSize(root_pass_size));
354347

355348
auto subpass_target =
356349
CreateRenderTarget(renderer, //
357350
ISize(subpass_coverage->size), //
358-
subpass->ComputeTotalReads(renderer) > 0);
351+
subpass->GetTotalPassReads(renderer) > 0);
359352

360353
auto subpass_texture = subpass_target.GetRenderTargetTexture();
361354

@@ -418,7 +411,7 @@ bool EntityPass::OnRender(ContentContext& renderer,
418411

419412
auto context = renderer.GetContext();
420413
InlinePassContext pass_context(context, render_target,
421-
ComputeTotalReads(renderer),
414+
GetTotalPassReads(renderer),
422415
std::move(collapsed_parent_pass));
423416
if (!pass_context.IsValid()) {
424417
return false;

impeller/entity/entity_pass.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ class EntityPass {
119119
BlendMode blend_mode_ = BlendMode::kSourceOver;
120120
bool cover_whole_screen_ = false;
121121

122-
/// These value are incremented whenever something is added to the pass that
122+
/// These values are incremented whenever something is added to the pass that
123123
/// requires reading from the backdrop texture. Currently, this can happen in
124124
/// the following scenarios:
125125
/// 1. An entity with an "advanced blend" is added to the pass.
126126
/// 2. A subpass with a backdrop filter is added to the pass.
127127
/// These are tracked as separate values because we may ignore
128128
/// blend_reads_from_pass_texture_ if the device supports framebuffer based
129129
/// advanced blends.
130-
uint32_t filter_reads_from_pass_texture_ = 0;
131-
uint32_t blend_reads_from_pass_texture_ = 0;
130+
uint32_t advanced_blend_reads_from_pass_texture_ = 0;
131+
uint32_t backdrop_filter_reads_from_pass_texture_ = 0;
132132

133-
uint32_t ComputeTotalReads(ContentContext& renderer) const;
133+
uint32_t GetTotalPassReads(ContentContext& renderer) const;
134134

135135
std::optional<BackdropFilterProc> backdrop_filter_proc_ = std::nullopt;
136136

0 commit comments

Comments
 (0)