diff options
25 files changed, 256 insertions, 29 deletions
diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index aa7f26ad6..6f9733c5f 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1222,6 +1222,11 @@ DOMInterfaces = { 'headerFile': 'WebGLExtensions.h' }, +'MOZ_debug_get': { + 'nativeType': 'mozilla::WebGLExtensionDebugGet', + 'headerFile': 'WebGLExtensions.h' +}, + 'WebGLFramebuffer': { 'nativeType': 'mozilla::WebGLFramebuffer', 'headerFile': 'WebGLFramebuffer.h' diff --git a/dom/canvas/WebGLContextExtensions.cpp b/dom/canvas/WebGLContextExtensions.cpp index 4a5a23274..7f338b4e9 100644 --- a/dom/canvas/WebGLContextExtensions.cpp +++ b/dom/canvas/WebGLContextExtensions.cpp @@ -40,6 +40,7 @@ WebGLContext::GetExtensionString(WebGLExtensionID ext) WEBGL_EXTENSION_IDENTIFIER(EXT_sRGB) WEBGL_EXTENSION_IDENTIFIER(EXT_texture_filter_anisotropic) WEBGL_EXTENSION_IDENTIFIER(EXT_disjoint_timer_query) + WEBGL_EXTENSION_IDENTIFIER(MOZ_debug_get) WEBGL_EXTENSION_IDENTIFIER(OES_element_index_uint) WEBGL_EXTENSION_IDENTIFIER(OES_standard_derivatives) WEBGL_EXTENSION_IDENTIFIER(OES_texture_float) @@ -91,6 +92,8 @@ bool WebGLContext::IsExtensionSupported(dom::CallerType callerType, switch (ext) { case WebGLExtensionID::EXT_disjoint_timer_query: return WebGLExtensionDisjointTimerQuery::IsSupported(this); + case WebGLExtensionID::MOZ_debug_get: + return true; case WebGLExtensionID::WEBGL_debug_renderer_info: return true; case WebGLExtensionID::WEBGL_debug_shaders: @@ -372,6 +375,11 @@ WebGLContext::EnableExtension(WebGLExtensionID ext) obj = new WebGLExtensionTextureFilterAnisotropic(this); break; + // MOZ_ + case WebGLExtensionID::MOZ_debug_get: + obj = new WebGLExtensionDebugGet(this); + break; + // OES_ case WebGLExtensionID::OES_element_index_uint: obj = new WebGLExtensionElementIndexUint(this); diff --git a/dom/canvas/WebGLContextState.cpp b/dom/canvas/WebGLContextState.cpp index e0234f5c6..c2f4c1a75 100644 --- a/dom/canvas/WebGLContextState.cpp +++ b/dom/canvas/WebGLContextState.cpp @@ -61,18 +61,6 @@ WebGLContext::Enable(GLenum cap) gl->fEnable(cap); } -static JS::Value -StringValue(JSContext* cx, const nsAString& str, ErrorResult& rv) -{ - JSString* jsStr = JS_NewUCStringCopyN(cx, str.BeginReading(), str.Length()); - if (!jsStr) { - rv.Throw(NS_ERROR_OUT_OF_MEMORY); - return JS::NullValue(); - } - - return JS::StringValue(jsStr); -} - bool WebGLContext::GetStencilBits(GLint* const out_stencilBits) { diff --git a/dom/canvas/WebGLContextUtils.cpp b/dom/canvas/WebGLContextUtils.cpp index 9c0d34939..3fd32eb30 100644 --- a/dom/canvas/WebGLContextUtils.cpp +++ b/dom/canvas/WebGLContextUtils.cpp @@ -874,4 +874,16 @@ InfoFrom(WebGLTexImageFunc func, WebGLTexDimensions dims) } } +JS::Value +StringValue(JSContext* cx, const nsAString& str, ErrorResult& er) +{ + JSString* jsStr = JS_NewUCStringCopyN(cx, str.BeginReading(), str.Length()); + if (!jsStr) { + er.Throw(NS_ERROR_OUT_OF_MEMORY); + return JS::NullValue(); + } + + return JS::StringValue(jsStr); +} + } // namespace mozilla diff --git a/dom/canvas/WebGLContextUtils.h b/dom/canvas/WebGLContextUtils.h index 5401fc878..1d06659b1 100644 --- a/dom/canvas/WebGLContextUtils.h +++ b/dom/canvas/WebGLContextUtils.h @@ -94,6 +94,8 @@ WebGLContext::WebGLObjectAsJSObject(JSContext* cx, */ const char* InfoFrom(WebGLTexImageFunc func, WebGLTexDimensions dims); +JS::Value StringValue(JSContext* cx, const nsAString& str, ErrorResult& er); + } // namespace mozilla #endif // WEBGL_CONTEXT_UTILS_H_ diff --git a/dom/canvas/WebGLExtensionDebugGet.cpp b/dom/canvas/WebGLExtensionDebugGet.cpp new file mode 100644 index 000000000..39bb3c57a --- /dev/null +++ b/dom/canvas/WebGLExtensionDebugGet.cpp @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "WebGLExtensions.h" + +#include "mozilla/dom/WebGLRenderingContextBinding.h" +#include "WebGLContext.h" +#include "WebGLContextUtils.h" + +namespace mozilla { + +WebGLExtensionDebugGet::WebGLExtensionDebugGet(WebGLContext* webgl) + : WebGLExtensionBase(webgl) +{ +} + +WebGLExtensionDebugGet::~WebGLExtensionDebugGet() +{ +} + +void +WebGLExtensionDebugGet::GetParameter(JSContext* cx, GLenum pname, + JS::MutableHandle<JS::Value> retval, + ErrorResult& er) const +{ + const auto& gl = mContext->gl; + gl->MakeCurrent(); + + switch (pname) { + case LOCAL_GL_EXTENSIONS: + { + nsString ret; + if (!gl->IsCoreProfile()) { + const auto rawExts = (const char*)gl->fGetString(LOCAL_GL_EXTENSIONS); + ret = NS_ConvertUTF8toUTF16(rawExts); + } else { + const auto& numExts = gl->GetIntAs<GLuint>(LOCAL_GL_NUM_EXTENSIONS); + for (GLuint i = 0; i < numExts; i++) { + const auto rawExt = (const char*)gl->fGetStringi(LOCAL_GL_EXTENSIONS, + i); + if (i > 0) { + ret.AppendLiteral(" "); + } + ret.Append(NS_ConvertUTF8toUTF16(rawExt)); + } + } + retval.set(StringValue(cx, ret, er)); + return; + } + + case LOCAL_GL_RENDERER: + case LOCAL_GL_VENDOR: + case LOCAL_GL_VERSION: + { + const auto raw = (const char*)gl->fGetString(pname); + retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(raw), er)); + return; + } + + case 0x10000: // "WSI_INFO" + { + nsCString info; + gl->GetWSIInfo(&info); + retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(info), er)); + return; + } + + default: + mContext->ErrorInvalidEnumArg("MOZ_debug_get.getParameter", "pname", pname); + retval.set(JS::NullValue()); + return; + } +} + +IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDebugGet, MOZ_debug_get) + +} // namespace mozilla diff --git a/dom/canvas/WebGLExtensions.h b/dom/canvas/WebGLExtensions.h index 741f6997f..7b6b6b54b 100644 --- a/dom/canvas/WebGLExtensions.h +++ b/dom/canvas/WebGLExtensions.h @@ -12,6 +12,7 @@ #include "WebGLTypes.h" namespace mozilla { +class ErrorResult; namespace dom { template<typename T> @@ -385,6 +386,19 @@ public: DECL_WEBGL_EXTENSION_GOOP }; +class WebGLExtensionDebugGet final + : public WebGLExtensionBase +{ +public: + explicit WebGLExtensionDebugGet(WebGLContext* webgl); + virtual ~WebGLExtensionDebugGet(); + + void GetParameter(JSContext* cx, GLenum pname, + JS::MutableHandle<JS::Value> retval, ErrorResult& er) const; + + DECL_WEBGL_EXTENSION_GOOP +}; + } // namespace mozilla #endif // WEBGL_EXTENSIONS_H_ diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h index 42b8701f3..2f4a4368a 100644 --- a/dom/canvas/WebGLTypes.h +++ b/dom/canvas/WebGLTypes.h @@ -149,6 +149,7 @@ enum class WebGLExtensionID : uint8_t { EXT_shader_texture_lod, EXT_texture_filter_anisotropic, EXT_disjoint_timer_query, + MOZ_debug_get, OES_element_index_uint, OES_standard_derivatives, OES_texture_float, diff --git a/dom/canvas/moz.build b/dom/canvas/moz.build index f7555b33d..6d5e2756f 100644 --- a/dom/canvas/moz.build +++ b/dom/canvas/moz.build @@ -105,6 +105,7 @@ UNIFIED_SOURCES += [ 'WebGLExtensionCompressedTextureETC1.cpp', 'WebGLExtensionCompressedTexturePVRTC.cpp', 'WebGLExtensionCompressedTextureS3TC.cpp', + 'WebGLExtensionDebugGet.cpp', 'WebGLExtensionDebugRendererInfo.cpp', 'WebGLExtensionDebugShaders.cpp', 'WebGLExtensionDepthTexture.cpp', diff --git a/dom/webidl/WebGLRenderingContext.webidl b/dom/webidl/WebGLRenderingContext.webidl index dd0e6ff69..323d23421 100644 --- a/dom/webidl/WebGLRenderingContext.webidl +++ b/dom/webidl/WebGLRenderingContext.webidl @@ -1046,3 +1046,12 @@ interface EXT_disjoint_timer_query { any getQueryEXT(GLenum target, GLenum pname); any getQueryObjectEXT(WebGLQuery query, GLenum pname); }; + +[NoInterfaceObject] +interface MOZ_debug_get { + const GLenum EXTENSIONS = 0x1F03; + const GLenum WSI_INFO = 0x10000; + + [Throws] + any getParameter(GLenum pname); +}; diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index f20563070..c82efceda 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -221,6 +221,8 @@ public: return false; } + virtual void GetWSIInfo(nsCString* const out) const = 0; + /** * Return true if we are running on a OpenGL core profile context */ diff --git a/gfx/gl/GLContextCGL.h b/gfx/gl/GLContextCGL.h index 12da90aee..1a29f3d15 100644 --- a/gfx/gl/GLContextCGL.h +++ b/gfx/gl/GLContextCGL.h @@ -58,6 +58,8 @@ public: virtual bool SupportsRobustness() const override { return false; } virtual bool SwapBuffers() override; + + virtual void GetWSIInfo(nsCString* const out) const override; }; } // namespace gl diff --git a/gfx/gl/GLContextEAGL.h b/gfx/gl/GLContextEAGL.h index 86e9a5b98..df25d0f1e 100644 --- a/gfx/gl/GLContextEAGL.h +++ b/gfx/gl/GLContextEAGL.h @@ -55,6 +55,8 @@ public: virtual bool SwapBuffers() override; + virtual void GetWSIInfo(nsCString* const out) const override; + virtual GLuint GetDefaultFramebuffer() override { return mBackbufferFB; } diff --git a/gfx/gl/GLContextEGL.h b/gfx/gl/GLContextEGL.h index 9755ecfe7..64b9b13fb 100644 --- a/gfx/gl/GLContextEGL.h +++ b/gfx/gl/GLContextEGL.h @@ -89,6 +89,8 @@ public: virtual bool SwapBuffers() override; + virtual void GetWSIInfo(nsCString* const out) const override; + // hold a reference to the given surface // for the lifetime of this context. void HoldSurface(gfxASurface* aSurf); diff --git a/gfx/gl/GLContextGLX.h b/gfx/gl/GLContextGLX.h index ca476baec..1f2cee08d 100644 --- a/gfx/gl/GLContextGLX.h +++ b/gfx/gl/GLContextGLX.h @@ -59,6 +59,8 @@ public: virtual bool SwapBuffers() override; + virtual void GetWSIInfo(nsCString* const out) const override; + // Overrides the current GLXDrawable backing the context and makes the // context current. bool OverrideDrawable(GLXDrawable drawable); diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index 0b8add435..ceab3046c 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -166,6 +166,11 @@ GLContextCGL::SwapBuffers() return true; } +void +GLContextCGL::GetWSIInfo(nsCString* const out) const +{ + out->AppendLiteral("CGL"); +} already_AddRefed<GLContext> GLContextProviderCGL::CreateWrappingExisting(void*, void*) diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm index 784a3e29e..507616e2f 100644 --- a/gfx/gl/GLContextProviderEAGL.mm +++ b/gfx/gl/GLContextProviderEAGL.mm @@ -155,6 +155,11 @@ GLContextEAGL::SwapBuffers() return true; } +void +GLContextEAGL::GetWSIInfo(nsCString* const out) const +{ + out->AppendLiteral("EAGL"); +} already_AddRefed<GLContext> GLContextProviderEAGL::CreateWrappingExisting(void*, void*) diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 098662200..7979f3bf0 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -418,6 +418,24 @@ GLContextEGL::SwapBuffers() } } +void +GLContextEGL::GetWSIInfo(nsCString* const out) const +{ + out->AppendLiteral("EGL_VENDOR: "); + out->Append((const char*)sEGLLibrary.fQueryString(EGL_DISPLAY(), LOCAL_EGL_VENDOR)); + + out->AppendLiteral("\nEGL_VERSION: "); + out->Append((const char*)sEGLLibrary.fQueryString(EGL_DISPLAY(), LOCAL_EGL_VERSION)); + + out->AppendLiteral("\nEGL_EXTENSIONS: "); + out->Append((const char*)sEGLLibrary.fQueryString(EGL_DISPLAY(), LOCAL_EGL_EXTENSIONS)); + +#ifndef ANDROID // This query will crash some old android. + out->AppendLiteral("\nEGL_EXTENSIONS(nullptr): "); + out->Append((const char*)sEGLLibrary.fQueryString(nullptr, LOCAL_EGL_EXTENSIONS)); +#endif +} + // hold a reference to the given surface // for the lifetime of this context. void diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index d804f95af..5560357e1 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -994,6 +994,27 @@ GLContextGLX::SwapBuffers() return true; } +void +GLContextGLX::GetWSIInfo(nsCString* const out) const +{ + Display* display = DefaultXDisplay(); + int screen = DefaultScreen(display); + + int majorVersion, minorVersion; + sGLXLibrary.xQueryVersion(display, &majorVersion, &minorVersion); + + out->Append(nsPrintfCString("GLX %u.%u", majorVersion, minorVersion)); + + out->AppendLiteral("\nGLX_VENDOR(client): "); + out->Append(sGLXLibrary.xGetClientString(display, LOCAL_GLX_VENDOR)); + + out->AppendLiteral("\nGLX_VENDOR(server): "); + out->Append(sGLXLibrary.xQueryServerString(display, screen, LOCAL_GLX_VENDOR)); + + out->AppendLiteral("\nExtensions: "); + out->Append(sGLXLibrary.xQueryExtensionsString(display, screen)); +} + bool GLContextGLX::OverrideDrawable(GLXDrawable drawable) { diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index c9c3f0a54..35957259d 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -373,6 +373,13 @@ GLContextWGL::SwapBuffers() { return ::SwapBuffers(mDC); } +void +GLContextWGL::GetWSIInfo(nsCString* const out) const +{ + out->AppendLiteral("wglGetExtensionsString: "); + out->Append(sWGLLib.fGetExtensionsString(mDC)); +} + bool GLContextWGL::SetupLookupFunction() { diff --git a/gfx/gl/GLContextWGL.h b/gfx/gl/GLContextWGL.h index 9d270bf52..839b10aa7 100644 --- a/gfx/gl/GLContextWGL.h +++ b/gfx/gl/GLContextWGL.h @@ -57,6 +57,8 @@ public: virtual bool SwapBuffers() override; + virtual void GetWSIInfo(nsCString* const out) const override; + virtual bool SetupLookupFunction() override; HGLRC Context() { return mContext; } diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 4e42a5687..1d17be391 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -180,9 +180,12 @@ var snapshotFormatters = { title = key; } } + let td = $.new("td", value); + td.style["white-space"] = "pre-wrap"; + return $.new("tr", [ $.new("th", title, "column"), - $.new("td", value), + td, ]); } @@ -306,8 +309,14 @@ var snapshotFormatters = { apzInfo.length ? apzInfo.join("; ") : localizedMsg(["apzNone"])); - addRowFromKey("features", "webglRenderer"); + addRowFromKey("features", "webgl1Renderer"); + addRowFromKey("features", "webgl1Version"); + addRowFromKey("features", "webgl1Extensions"); + addRowFromKey("features", "webgl1WSIInfo"); addRowFromKey("features", "webgl2Renderer"); + addRowFromKey("features", "webgl2Version"); + addRowFromKey("features", "webgl2Extensions"); + addRowFromKey("features", "webgl2WSIInfo"); addRowFromKey("features", "supportsHardwareH264", "hardwareH264"); addRowFromKey("features", "currentAudioBackend", "audioBackend"); addRowFromKey("features", "direct2DEnabled", "#Direct2D"); diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.properties b/toolkit/locales/en-US/chrome/global/aboutSupport.properties index 0bc612b79..115d91ca1 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties @@ -71,8 +71,14 @@ gpuRAM = RAM gpuDriverVersion = Driver Version gpuDriverDate = Driver Date gpuActive = Active -webglRenderer = WebGL Renderer -webgl2Renderer = WebGL2 Renderer +webgl1Renderer = WebGL 1 Renderer +webgl1Version = WebGL 1 GL Version +webgl1Extensions = WebGL 1 GL Extensions +webgl1WSIInfo = WebGL 1 WSI Info +webgl2Renderer = WebGL 2 Renderer +webgl2Version = WebGL 2 GL Version +webgl2Extensions = WebGL 2 GL Extensions +webgl2WSIInfo = WebGL 2 WSI Info GPU1 = GPU #1 GPU2 = GPU #2 blocklistedBug = Blocklisted due to known issues diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index cea7c8f29..65342b623 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -419,7 +419,12 @@ var dataProviders = { .createInstance(Ci.nsIDOMParser) .parseFromString("<html/>", "text/html"); - function GetWebGLInfo(contextType) { + function GetWebGLInfo(data, keyPrefix, contextType) { + data[keyPrefix + "Renderer"] = "-"; + data[keyPrefix + "Version"] = "-"; + data[keyPrefix + "Extensions"] = "-"; + data[keyPrefix + "WSIInfo"] = "-"; + let canvas = doc.createElement("canvas"); canvas.width = 1; canvas.height = 1; @@ -446,16 +451,21 @@ var dataProviders = { creationError = e.toString(); } } - if (!gl) - return creationError || "(no info)"; + if (!gl) { + data[keyPrefix + "Renderer"] = creationError || "(no creation error info)"; + return; + } - let infoExt = gl.getExtension("WEBGL_debug_renderer_info"); + let ext = gl.getExtension("MOZ_debug_get"); // This extension is unconditionally available to chrome. No need to check. - let vendor = gl.getParameter(infoExt.UNMASKED_VENDOR_WEBGL); - let renderer = gl.getParameter(infoExt.UNMASKED_RENDERER_WEBGL); + let vendor = ext.getParameter(gl.VENDOR); + let renderer = ext.getParameter(gl.RENDERER); - let contextInfo = vendor + " -- " + renderer; + data[keyPrefix + "Renderer"] = vendor + " -- " + renderer; + data[keyPrefix + "Version"] = ext.getParameter(gl.VERSION); + data[keyPrefix + "Extensions"] = ext.getParameter(ext.EXTENSIONS); + data[keyPrefix + "WSIInfo"] = ext.getParameter(ext.WSI_INFO); // Eagerly free resources. @@ -463,14 +473,11 @@ var dataProviders = { if (loseExt) { loseExt.loseContext(); } - - - return contextInfo; } - data.webglRenderer = GetWebGLInfo("webgl"); - data.webgl2Renderer = GetWebGLInfo("webgl2"); + GetWebGLInfo(data, "webgl1", "webgl"); + GetWebGLInfo(data, "webgl2", "webgl2"); let infoInfo = gfxInfo.getInfo(); diff --git a/toolkit/modules/tests/browser/browser_Troubleshoot.js b/toolkit/modules/tests/browser/browser_Troubleshoot.js index 7f0069dc9..e449e99a3 100644 --- a/toolkit/modules/tests/browser/browser_Troubleshoot.js +++ b/toolkit/modules/tests/browser/browser_Troubleshoot.js @@ -298,12 +298,30 @@ const SNAPSHOT_SCHEMA = { clearTypeParameters: { type: "string", }, - webglRenderer: { + webgl1Renderer: { + type: "string", + }, + webgl1Version: { + type: "string", + }, + webgl1Extensions: { + type: "string", + }, + webgl1WSIInfo: { type: "string", }, webgl2Renderer: { type: "string", }, + webgl2Version: { + type: "string", + }, + webgl2Extensions: { + type: "string", + }, + webgl2WSIInfo: { + type: "string", + }, info: { type: "object", }, |