From acd204e85e56ed2409df296aa18a594f43bb3533 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 23 Nov 2023 14:05:37 +0100 Subject: [PATCH] [WebGL] Turn on more validation/error checking in webgl (when not on Win) --- dom/canvas/WebGLContext.cpp | 11 ++++++++--- dom/canvas/WebGLTextureUpload.cpp | 1 + modules/libpref/init/all.js | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 51442cba4b..2e7ddb42e0 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -676,9 +676,11 @@ WebGLContext::CreateAndInitGL(bool forceEnabled, std::vector* const out_failReasons) { const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this); - gl::CreateContextFlags flags = gl::CreateContextFlags::NO_VALIDATION; - bool tryNativeGL = true; - bool tryANGLE = false; + gl::CreateContextFlags flags = gl::CreateContextFlags::NONE; + + if (Preferences::GetBool("webgl.gl_khr_no_validation", false)) { + flags |= gl::CreateContextFlags::NO_VALIDATION; + } if (forceEnabled) { flags |= gl::CreateContextFlags::FORCE_ENABLE_HARDWARE; @@ -694,6 +696,9 @@ WebGLContext::CreateAndInitGL(bool forceEnabled, const bool useEGL = PR_GetEnv("MOZ_WEBGL_FORCE_EGL"); + bool tryNativeGL = true; + bool tryANGLE = false; + #ifdef XP_WIN tryNativeGL = false; tryANGLE = true; diff --git a/dom/canvas/WebGLTextureUpload.cpp b/dom/canvas/WebGLTextureUpload.cpp index 661fb91ce2..6b864f2ff5 100644 --- a/dom/canvas/WebGLTextureUpload.cpp +++ b/dom/canvas/WebGLTextureUpload.cpp @@ -2188,6 +2188,7 @@ WebGLTexture::CopyTexImage2D(TexImageTarget target, GLint level, GLenum internal srcTotalWidth, srcTotalHeight, srcUsage, 0, 0, 0, width, height, dstUsage)) { + Truncate(); return; } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 1dc38291cf..bfaa856536 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4338,6 +4338,13 @@ pref("webgl.dxgl.enabled", true); pref("webgl.dxgl.needs-finish", false); #endif +// Disable ANGLE's validation layer? +#ifdef XP_WIN +pref("webgl.gl_khr_no_validation", true); +#else +pref("webgl.gl_khr_no_validation", false); +#endif + pref("gfx.offscreencanvas.enabled", false); // Stagefright prefs