mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Use booleans instead of counting backdrop reads. (flutter/engine#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.
This commit is contained in:
parent
5c2ff391b5
commit
df1248e088
@ -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<EntityPass> 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<EntityPass> 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);
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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<RenderPassResult> collapsed_parent_pass)
|
||||
: renderer_(renderer),
|
||||
|
||||
@ -25,7 +25,6 @@ class InlinePassContext {
|
||||
InlinePassContext(
|
||||
const ContentContext& renderer,
|
||||
EntityPassTarget& pass_target,
|
||||
uint32_t pass_texture_reads,
|
||||
uint32_t entity_count,
|
||||
std::optional<RenderPassResult> collapsed_parent_pass = std::nullopt);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user