[Impeller] Make some Open GL errors non-fatal, check in debug mode (not unopt). (flutter/engine#46434)

Closes https://github.com/flutter/flutter/issues/135767.
This commit is contained in:
Matan Lurey
2023-09-30 09:43:58 -07:00
committed by GitHub
parent 1457312aa0
commit aa8dd4faa7
4 changed files with 29 additions and 12 deletions

View File

@@ -38,10 +38,6 @@ config("impeller_public_config") {
defines += [ "IMPELLER_TRACE_ALL_GL_CALLS" ]
}
if (impeller_error_check_all_gl_calls) {
defines += [ "IMPELLER_ERROR_CHECK_ALL_GL_CALLS" ]
}
if (is_win) {
defines += [
# TODO(dnfield): https://github.com/flutter/flutter/issues/50053

View File

@@ -32,6 +32,20 @@ const char* GLErrorToString(GLenum value) {
return "Unknown.";
}
bool GLErrorIsFatal(GLenum value) {
switch (value) {
case GL_NO_ERROR:
return false;
case GL_INVALID_ENUM:
case GL_INVALID_VALUE:
case GL_INVALID_OPERATION:
case GL_INVALID_FRAMEBUFFER_OPERATION:
case GL_OUT_OF_MEMORY:
return true;
}
return false;
}
ProcTableGLES::Resolver WrappedResolver(
const ProcTableGLES::Resolver& resolver) {
return [resolver](const char* function_name) -> void* {

View File

@@ -17,6 +17,7 @@
namespace impeller {
const char* GLErrorToString(GLenum value);
bool GLErrorIsFatal(GLenum value);
struct AutoErrorCheck {
const PFNGLGETERRORPROC error_fn;
@@ -28,9 +29,18 @@ struct AutoErrorCheck {
~AutoErrorCheck() {
if (error_fn) {
auto error = error_fn();
FML_CHECK(error == GL_NO_ERROR)
<< "GL Error " << GLErrorToString(error) << "(" << error << ")"
<< " encountered on call to " << name;
if (error == GL_NO_ERROR) {
return;
}
if (GLErrorIsFatal(error)) {
FML_LOG(FATAL) << "Fatal GL Error " << GLErrorToString(error) << "("
<< error << ")"
<< " encountered on call to " << name;
} else {
FML_LOG(ERROR) << "GL Error " << GLErrorToString(error) << "(" << error
<< ")"
<< " encountered on call to " << name;
}
}
}
};
@@ -63,9 +73,9 @@ struct GLProc {
///
template <class... Args>
auto operator()(Args&&... args) const {
#ifdef IMPELLER_ERROR_CHECK_ALL_GL_CALLS
#ifdef IMPELLER_DEBUG
AutoErrorCheck error(error_fn, name);
#endif // IMPELLER_ERROR_CHECK_ALL_GL_CALLS
#endif // IMPELLER_DEBUG
#ifdef IMPELLER_TRACE_ALL_GL_CALLS
TRACE_EVENT0("impeller", name);
#endif // IMPELLER_TRACE_ALL_GL_CALLS

View File

@@ -39,9 +39,6 @@ declare_args() {
# overhead may be substantial, this is not enabled by default.
impeller_trace_all_gl_calls = false
# Call glGetError after each OpenGL call and log failures.
impeller_error_check_all_gl_calls = is_debug
# Enable experimental 3D scene rendering.
impeller_enable_3d = false