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

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

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions impeller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions impeller/renderer/backend/gles/proc_table_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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* {
Expand Down
20 changes: 15 additions & 5 deletions impeller/renderer/backend/gles/proc_table_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace impeller {

const char* GLErrorToString(GLenum value);
bool GLErrorIsFatal(GLenum value);

struct AutoErrorCheck {
const PFNGLGETERRORPROC error_fn;
Expand All @@ -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;
}
}
}
};
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions impeller/tools/impeller.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down