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

Commit a0906bd

Browse files
authored
[Impeller] Load instead of restore drawing for non-MSAA passes (#41676)
This is essentially a revert of #41060 with better comments.
1 parent 1057b40 commit a0906bd

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

impeller/entity/inline_pass_context.cc

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,38 @@ InlinePassContext::RenderPassResult InlinePassContext::GetRenderPass(
103103
" Count=" + std::to_string(pass_count_));
104104

105105
RenderPassResult result;
106-
107-
if (pass_count_ > 0) {
108-
result.backdrop_texture =
109-
pass_target_.Flip(*context_->GetResourceAllocator());
110-
if (!result.backdrop_texture) {
111-
VALIDATION_LOG << "Could not flip the EntityPass render target.";
106+
{
107+
// If the pass target has a resolve texture, then we're using MSAA.
108+
bool is_msaa = pass_target_.GetRenderTarget()
109+
.GetColorAttachments()
110+
.find(0)
111+
->second.resolve_texture != nullptr;
112+
if (pass_count_ > 0 && is_msaa) {
113+
result.backdrop_texture =
114+
pass_target_.Flip(*context_->GetResourceAllocator());
115+
if (!result.backdrop_texture) {
116+
VALIDATION_LOG << "Could not flip the EntityPass render target.";
117+
}
112118
}
113119
}
114120

121+
// Find the color attachment a second time, since the target may have just
122+
// flipped.
115123
auto color0 =
116124
pass_target_.GetRenderTarget().GetColorAttachments().find(0)->second;
125+
bool is_msaa = color0.resolve_texture != nullptr;
117126

118-
color0.load_action =
119-
pass_count_ > 0 ? LoadAction::kDontCare : LoadAction::kClear;
127+
if (pass_count_ > 0) {
128+
// When MSAA is being used, we end up overriding the entire backdrop by
129+
// drawing the previous pass texture, and so we don't have to clear it and
130+
// can use kDontCare.
131+
color0.load_action = is_msaa ? LoadAction::kDontCare : LoadAction::kLoad;
132+
} else {
133+
color0.load_action = LoadAction::kClear;
134+
}
120135

121-
color0.store_action = color0.resolve_texture
122-
? StoreAction::kMultisampleResolve
123-
: StoreAction::kStore;
136+
color0.store_action =
137+
is_msaa ? StoreAction::kMultisampleResolve : StoreAction::kStore;
124138

125139
auto stencil = pass_target_.GetRenderTarget().GetStencilAttachment();
126140
if (!stencil.has_value()) {

0 commit comments

Comments
 (0)