Skip to content

Commit c20ce8d

Browse files
author
jonahwilliams
committed
++
1 parent 448d676 commit c20ce8d

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
215215
TextureGLES& color_gles = TextureGLES::Cast(*pass_data.color_attachment);
216216
const bool is_default_fbo = color_gles.IsWrapped();
217217

218+
std::optional<GLuint> fbo = 0;
218219
if (is_default_fbo) {
219220
if (color_gles.GetFBO().has_value()) {
220221
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
@@ -223,7 +224,7 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
223224
} else {
224225
// Create and bind an offscreen FBO.
225226
if (!color_gles.GetCachedFBO().IsDead()) {
226-
auto fbo = reactor.GetGLHandle(color_gles.GetCachedFBO());
227+
fbo = reactor.GetGLHandle(color_gles.GetCachedFBO());
227228
if (!fbo.has_value()) {
228229
return false;
229230
}
@@ -232,7 +233,7 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
232233
HandleGLES cached_fbo =
233234
reactor.CreateUntrackedHandle(HandleType::kFrameBuffer);
234235
color_gles.SetCachedFBO(cached_fbo);
235-
auto fbo = reactor.GetGLHandle(cached_fbo);
236+
fbo = reactor.GetGLHandle(cached_fbo);
236237
if (!fbo.has_value()) {
237238
return false;
238239
}
@@ -545,29 +546,28 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
545546
}
546547

547548
// Bind MSAA renderbuffer to read framebuffer.
548-
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
549+
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, fbo.value());
549550
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo);
550551

551552
RenderPassGLES::ResetGLState(gl);
552553
auto size = pass_data.color_attachment->GetSize();
553554

554-
gl.BlitFramebuffer(0, // srcX0
555-
0, // srcY0
556-
size.width, // srcX1
557-
size.height, // srcY1
558-
0, // dstX0
559-
0, // dstY0
560-
size.width, // dstX1
561-
size.height, // dstY1
562-
GL_COLOR_BUFFER_BIT, // mask
563-
GL_NEAREST // filter
564-
);
555+
gl.BlitFramebuffer(/*srcX0=*/0,
556+
/*srcY0=*/0,
557+
/*srcX1=*/size.width,
558+
/*srcY1=*/size.height,
559+
/*dstX0=*/0,
560+
/*dstY0=*/0,
561+
/*dstX1=*/size.width,
562+
/*dstY1=*/size.height,
563+
/*mask=*/GL_COLOR_BUFFER_BIT,
564+
/*filter=*/GL_NEAREST);
565565

566566
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, GL_NONE);
567567
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, GL_NONE);
568568
gl.DeleteFramebuffers(1u, &resolve_fbo);
569569
// Rebind the original FBO so that we can discard it below.
570-
gl.BindFramebuffer(GL_FRAMEBUFFER, fbo);
570+
gl.BindFramebuffer(GL_FRAMEBUFFER, fbo.value());
571571
}
572572

573573
if (gl.DiscardFramebufferEXT.IsAvailable()) {
@@ -638,7 +638,9 @@ bool RenderPassGLES::OnEncodeCommands(const Context& context) const {
638638

639639
// When we are using EXT_multisampled_render_to_texture, it is implicitly
640640
// resolved when we bind the texture to the framebuffer. We don't need to
641-
// discard the attachment when we are done.
641+
// discard the attachment when we are done. If not using
642+
// EXT_multisampled_render_to_texture but still using MSAA we discard the
643+
// attachment as normal.
642644
if (color0.resolve_texture) {
643645
pass_data->discard_color_attachment =
644646
pass_data->discard_color_attachment &&

engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ static bool IsDepthStencilFormat(PixelFormat format) {
4646

4747
static TextureGLES::Type GetTextureTypeFromDescriptor(
4848
const TextureDescriptor& desc,
49-
bool supports_implict_msaa) {
49+
const std::shared_ptr<const CapabilitiesGLES>& capabilities) {
5050
const auto usage = static_cast<TextureUsageMask>(desc.usage);
5151
const auto render_target = TextureUsage::kRenderTarget;
5252
const auto is_msaa = desc.sample_count == SampleCount::kCount4;
5353
if (usage == render_target && IsDepthStencilFormat(desc.format)) {
5454
return is_msaa ? TextureGLES::Type::kRenderBufferMultisampled
5555
: TextureGLES::Type::kRenderBuffer;
5656
}
57-
return is_msaa ? (supports_implict_msaa
57+
return is_msaa ? (capabilities->SupportsImplicitResolvingMSAA()
5858
? TextureGLES::Type::kTextureMultisampled
5959
: TextureGLES::Type::kRenderBufferMultisampled)
6060
: TextureGLES::Type::kTexture;
@@ -195,11 +195,9 @@ TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
195195
std::optional<HandleGLES> external_handle)
196196
: Texture(desc),
197197
reactor_(std::move(reactor)),
198-
type_(
199-
GetTextureTypeFromDescriptor(GetTextureDescriptor(),
200-
reactor_->GetProcTable()
201-
.GetCapabilities()
202-
->SupportsImplicitResolvingMSAA())),
198+
type_(GetTextureTypeFromDescriptor(
199+
GetTextureDescriptor(),
200+
reactor_->GetProcTable().GetCapabilities())),
203201
handle_(external_handle.has_value()
204202
? external_handle.value()
205203
: reactor_->CreateUntrackedHandle(ToHandleType(type_))),

0 commit comments

Comments
 (0)