Bug 1339256 - Only request robustness if requested on EGL - r=daoshengmu
MozReview-Commit-ID: GlMpalFwS2U
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -722,17 +722,18 @@ WebGLContext::CreateAndInitGL(bool force
reason.info.Append(reason.key);
out_failReasons->push_back(reason);
GenerateWarning("%s", reason.info.BeginReading());
return false;
}
}
const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this);
- gl::CreateContextFlags flags = gl::CreateContextFlags::NO_VALIDATION;
+ gl::CreateContextFlags flags = (gl::CreateContextFlags::NO_VALIDATION |
+ gl::CreateContextFlags::PREFER_ROBUSTNESS);
bool tryNativeGL = true;
bool tryANGLE = false;
if (forceEnabled) {
flags |= gl::CreateContextFlags::FORCE_ENABLE_HARDWARE;
}
if (IsWebGL2()) {
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -485,26 +485,28 @@ GLContextEGL::CreateGLContext(CreateCont
std::vector<EGLint> contextAttribs;
contextAttribs.push_back(LOCAL_EGL_CONTEXT_CLIENT_VERSION);
if (flags & CreateContextFlags::PREFER_ES3)
contextAttribs.push_back(3);
else
contextAttribs.push_back(2);
- if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_create_context)) {
- contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
- contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_KHR);
- contextAttribs.push_back(LOCAL_EGL_CONTEXT_FLAGS_KHR);
- contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR);
- } else if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::EXT_create_context_robustness)) {
- contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
- contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT);
- contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
- contextAttribs.push_back(LOCAL_EGL_TRUE);
+ if (flags & CreateContextFlags::PREFER_ROBUSTNESS) {
+ if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_create_context)) {
+ contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
+ contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_KHR);
+ contextAttribs.push_back(LOCAL_EGL_CONTEXT_FLAGS_KHR);
+ contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR);
+ } else if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::EXT_create_context_robustness)) {
+ contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
+ contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT);
+ contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
+ contextAttribs.push_back(LOCAL_EGL_TRUE);
+ }
}
for (const auto& cur : kTerminationAttribs) {
contextAttribs.push_back(cur);
}
EGLContext context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
config,
--- a/gfx/gl/GLContextTypes.h
+++ b/gfx/gl/GLContextTypes.h
@@ -51,15 +51,16 @@ enum class CreateContextFlags : int8_t {
// Force the use of hardware backed GL, don't allow software implementations.
FORCE_ENABLE_HARDWARE = 1 << 1,
/* Don't force discrete GPU to be used (if applicable) */
ALLOW_OFFLINE_RENDERER = 1 << 2,
// Ask for ES3 if possible
PREFER_ES3 = 1 << 3,
NO_VALIDATION = 1 << 4,
+ PREFER_ROBUSTNESS = 1 << 5,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
} /* namespace gl */
} /* namespace mozilla */
#endif /* GLCONTEXT_TYPES_H_ */