@@ -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 &&
0 commit comments