Reverts "[Impeller] support GLES 3.0 MSAA without extension. (#56705)" (flutter/engine#56741)

Reverts: flutter/engine#56705
Initiated by: jonahwilliams
Reason for reverting: goldens occassionally fail to render anything.
Original PR Author: jonahwilliams

Reviewed By: {gaaclarke}

This change reverts the following previous change:
Adds multisampling support for GLES devices without GL_EXT_multisampled_render_to_texture provided they are at least GLES 3.0 to support mutlisampled render buffers.

Fixes https://github.com/flutter/flutter/issues/158360
Fixes https://github.com/flutter/flutter/issues/157951

TBD: should we prefer renderbuffer 3.0 approach over multisample_render_to_texture?
This commit is contained in:
auto-submit[bot] 2024-11-21 23:18:48 +00:00 committed by GitHub
parent 0e426efd96
commit 8958ff46da
5 changed files with 23 additions and 102 deletions

View File

@ -1667,15 +1667,10 @@ bool Canvas::BlitToOnscreen() {
auto offscreen_target = render_passes_.back()
.inline_pass_context->GetPassTarget()
.GetRenderTarget();
// Unlike other backends the blit to restore the onscreen fails for GLES
// if the src is a multisample framebuffer, even if we specifically target
// the non-multisampled resolve of the dst.
bool is_gles_and_must_skip_blit = renderer_.GetContext()->GetBackendType() ==
Context::BackendType::kOpenGLES;
if (renderer_.GetContext()
->GetCapabilities()
->SupportsTextureToTextureBlits() &&
!is_gles_and_must_skip_blit) {
->SupportsTextureToTextureBlits()) {
auto blit_pass = command_buffer->CreateBlitPass();
blit_pass->AddCopy(offscreen_target.GetRenderTargetTexture(),
render_target_.GetRenderTargetTexture());

View File

@ -125,11 +125,7 @@ CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
// We hard-code 4x MSAA, so let's make sure it's supported.
GLint value = 0;
gl.GetIntegerv(GL_MAX_SAMPLES, &value);
supports_offscreen_msaa_ = value >= 4;
} else if (desc->GetGlVersion().major_version >= 3 && desc->IsES()) {
GLint value = 0;
gl.GetIntegerv(GL_MAX_SAMPLES, &value);
gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
supports_offscreen_msaa_ = value >= 4;
}
is_es_ = desc->IsES();

View File

@ -242,7 +242,6 @@ void(glDepthRange)(GLdouble n, GLdouble f);
PROC(FenceSync); \
PROC(DeleteSync); \
PROC(WaitSync); \
PROC(RenderbufferStorageMultisample) \
PROC(BlitFramebuffer);
#define FOR_EACH_IMPELLER_EXT_PROC(PROC) \

View File

@ -7,6 +7,7 @@
#include <cstdint>
#include "GLES3/gl3.h"
#include "flutter/fml/trace_event.h"
#include "fml/closure.h"
#include "fml/logging.h"
#include "impeller/base/validation.h"
@ -126,7 +127,6 @@ struct RenderPassData {
Scalar clear_depth = 1.0;
std::shared_ptr<Texture> color_attachment;
std::shared_ptr<Texture> resolve_attachment;
std::shared_ptr<Texture> depth_attachment;
std::shared_ptr<Texture> stencil_attachment;
@ -191,6 +191,8 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
const ReactorGLES& reactor,
const std::vector<Command>& commands,
const std::shared_ptr<GPUTracerGLES>& tracer) {
TRACE_EVENT0("impeller", "RenderPassGLES::EncodeCommandsInReactor");
const auto& gl = reactor.GetProcTable();
#ifdef IMPELLER_DEBUG
tracer->MarkFrameStart(gl);
@ -488,55 +490,6 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
}
}
if (pass_data.resolve_attachment &&
!gl.GetCapabilities()->SupportsImplicitResolvingMSAA() &&
!is_default_fbo) {
FML_DCHECK(pass_data.resolve_attachment != pass_data.color_attachment);
// Perform multisample resolve via blit.
// Create and bind a resolve FBO.
GLuint resolve_fbo;
gl.GenFramebuffers(1u, &resolve_fbo);
gl.BindFramebuffer(GL_FRAMEBUFFER, resolve_fbo);
if (!TextureGLES::Cast(*pass_data.resolve_attachment)
.SetAsFramebufferAttachment(
GL_FRAMEBUFFER, TextureGLES::AttachmentType::kColor0)) {
return false;
}
auto status = gl.CheckFramebufferStatus(GL_FRAMEBUFFER);
if (gl.CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
VALIDATION_LOG << "Could not create a complete frambuffer: "
<< DebugToFramebufferError(status);
return false;
}
// Bind MSAA renderbuffer to read framebuffer.
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo);
RenderPassGLES::ResetGLState(gl);
auto size = pass_data.color_attachment->GetSize();
gl.BlitFramebuffer(0, // srcX0
0, // srcY0
size.width, // srcX1
size.height, // srcY1
0, // dstX0
0, // dstY0
size.width, // dstX1
size.height, // dstY1
GL_COLOR_BUFFER_BIT, // mask
GL_NEAREST // filter
);
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, GL_NONE);
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, GL_NONE);
gl.DeleteFramebuffers(1u, &resolve_fbo);
// Rebind the original FBO so that we can discard it below.
gl.BindFramebuffer(GL_FRAMEBUFFER, fbo);
}
if (gl.DiscardFramebufferEXT.IsAvailable()) {
std::vector<GLenum> attachments;
@ -594,7 +547,6 @@ bool RenderPassGLES::OnEncodeCommands(const Context& context) const {
/// Setup color data.
///
pass_data->color_attachment = color0.texture;
pass_data->resolve_attachment = color0.resolve_texture;
pass_data->clear_color = color0.clear_color;
pass_data->clear_color_attachment = CanClearAttachment(color0.load_action);
pass_data->discard_color_attachment =
@ -604,9 +556,8 @@ bool RenderPassGLES::OnEncodeCommands(const Context& context) const {
// resolved when we bind the texture to the framebuffer. We don't need to
// discard the attachment when we are done.
if (color0.resolve_texture) {
pass_data->discard_color_attachment =
pass_data->discard_color_attachment &&
!context.GetCapabilities()->SupportsImplicitResolvingMSAA();
FML_DCHECK(context.GetCapabilities()->SupportsImplicitResolvingMSAA());
pass_data->discard_color_attachment = false;
}
//----------------------------------------------------------------------------

View File

@ -45,8 +45,7 @@ static bool IsDepthStencilFormat(PixelFormat format) {
}
static TextureGLES::Type GetTextureTypeFromDescriptor(
const TextureDescriptor& desc,
bool supports_implict_msaa) {
const TextureDescriptor& desc) {
const auto usage = static_cast<TextureUsageMask>(desc.usage);
const auto render_target = TextureUsage::kRenderTarget;
const auto is_msaa = desc.sample_count == SampleCount::kCount4;
@ -54,9 +53,7 @@ static TextureGLES::Type GetTextureTypeFromDescriptor(
return is_msaa ? TextureGLES::Type::kRenderBufferMultisampled
: TextureGLES::Type::kRenderBuffer;
}
return is_msaa ? (supports_implict_msaa
? TextureGLES::Type::kTextureMultisampled
: TextureGLES::Type::kRenderBufferMultisampled)
return is_msaa ? TextureGLES::Type::kTextureMultisampled
: TextureGLES::Type::kTexture;
}
@ -193,11 +190,7 @@ TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
std::optional<HandleGLES> external_handle)
: Texture(desc),
reactor_(std::move(reactor)),
type_(
GetTextureTypeFromDescriptor(GetTextureDescriptor(),
reactor_->GetProcTable()
.GetCapabilities()
->SupportsImplicitResolvingMSAA())),
type_(GetTextureTypeFromDescriptor(GetTextureDescriptor())),
handle_(external_handle.has_value()
? external_handle.value()
: reactor_->CreateHandle(ToHandleType(type_))),
@ -369,7 +362,7 @@ static std::optional<GLenum> ToRenderBufferFormat(PixelFormat format) {
switch (format) {
case PixelFormat::kB8G8R8A8UNormInt:
case PixelFormat::kR8G8B8A8UNormInt:
return GL_RGBA8;
return GL_RGBA4;
case PixelFormat::kR32G32B32A32Float:
return GL_RGBA32F;
case PixelFormat::kR16G16B16A16Float:
@ -452,32 +445,19 @@ void TextureGLES::InitializeContentsIfNecessary() const {
{
TRACE_EVENT0("impeller", "RenderBufferStorageInitialization");
if (type_ == Type::kRenderBufferMultisampled) {
// BEWARE: these functions are not at all equivalent! the extensions
// are from EXT_multisampled_render_to_texture and cannot be used
// with regular GLES 3.0 multisampled renderbuffers/textures.
if (gl.GetCapabilities()->SupportsImplicitResolvingMSAA()) {
gl.RenderbufferStorageMultisampleEXT(
/*target=*/GL_RENDERBUFFER, //
/*samples=*/4, //
/*internal_format=*/render_buffer_format.value(), //
/*width=*/size.width, //
/*height=*/size.height //
);
} else {
gl.RenderbufferStorageMultisample(
/*target=*/GL_RENDERBUFFER, //
/*samples=*/4, //
/*internal_format=*/render_buffer_format.value(), //
/*width=*/size.width, //
/*height=*/size.height //
);
}
gl.RenderbufferStorageMultisampleEXT(
GL_RENDERBUFFER, // target
4, // samples
render_buffer_format.value(), // internal format
size.width, // width
size.height // height
);
} else {
gl.RenderbufferStorage(
/*target=*/GL_RENDERBUFFER, //
/*internal_format=*/render_buffer_format.value(), //
/*width=*/size.width, //
/*height=*/size.height //
GL_RENDERBUFFER, // target
render_buffer_format.value(), // internal format
size.width, // width
size.height // height
);
}
}