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

Closes https://github.com/flutter/flutter/issues/135767.
diff --git a/impeller/BUILD.gn b/impeller/BUILD.gn
index 4e9707f..c89a89f 100644
--- a/impeller/BUILD.gn
+++ b/impeller/BUILD.gn
@@ -38,10 +38,6 @@
     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
diff --git a/impeller/renderer/backend/gles/proc_table_gles.cc b/impeller/renderer/backend/gles/proc_table_gles.cc
index b3c8a8f..5a5212a 100644
--- a/impeller/renderer/backend/gles/proc_table_gles.cc
+++ b/impeller/renderer/backend/gles/proc_table_gles.cc
@@ -32,6 +32,20 @@
   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* {
diff --git a/impeller/renderer/backend/gles/proc_table_gles.h b/impeller/renderer/backend/gles/proc_table_gles.h
index eac2b77..b9b22d3 100644
--- a/impeller/renderer/backend/gles/proc_table_gles.h
+++ b/impeller/renderer/backend/gles/proc_table_gles.h
@@ -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 @@
   ~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 @@
   ///
   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
diff --git a/impeller/tools/impeller.gni b/impeller/tools/impeller.gni
index 65b1f56..4ec7119 100644
--- a/impeller/tools/impeller.gni
+++ b/impeller/tools/impeller.gni
@@ -39,9 +39,6 @@
   # 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