From owner-svn-ports-head@freebsd.org Sat Dec 21 00:50:54 2019 Return-Path: Delivered-To: svn-ports-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8FF7C1E7ECB; Sat, 21 Dec 2019 00:50:54 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47fn9B3KFWz4cWy; Sat, 21 Dec 2019 00:50:54 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D4427500; Sat, 21 Dec 2019 00:50:54 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBL0osoO018507; Sat, 21 Dec 2019 00:50:54 GMT (envelope-from jbeich@FreeBSD.org) Received: (from jbeich@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBL0osia018506; Sat, 21 Dec 2019 00:50:54 GMT (envelope-from jbeich@FreeBSD.org) Message-Id: <201912210050.xBL0osia018506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jbeich set sender to jbeich@FreeBSD.org using -f From: Jan Beich Date: Sat, 21 Dec 2019 00:50:54 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r520537 - in head/www/firefox: . files X-SVN-Group: ports-head X-SVN-Commit-Author: jbeich X-SVN-Commit-Paths: in head/www/firefox: . files X-SVN-Commit-Revision: 520537 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2019 00:50:54 -0000 Author: jbeich Date: Sat Dec 21 00:50:53 2019 New Revision: 520537 URL: https://svnweb.freebsd.org/changeset/ports/520537 Log: www/firefox: drop dependency on Xwayland for WebGL check Submitted by: Greg V Added: head/www/firefox/files/patch-bug1556301 (contents, props changed) Modified: head/www/firefox/Makefile (contents, props changed) Modified: head/www/firefox/Makefile ============================================================================== --- head/www/firefox/Makefile Sat Dec 21 00:45:43 2019 (r520536) +++ head/www/firefox/Makefile Sat Dec 21 00:50:53 2019 (r520537) @@ -3,7 +3,7 @@ PORTNAME= firefox DISTVERSION= 71.0 -PORTREVISION= 3 +PORTREVISION= 4 PORTEPOCH= 1 CATEGORIES= www MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \ Added: head/www/firefox/files/patch-bug1556301 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/www/firefox/files/patch-bug1556301 Sat Dec 21 00:50:53 2019 (r520537) @@ -0,0 +1,232 @@ +commit 5f2329c58c1b +Author: myfreeweb +Date: Wed Dec 18 20:25:00 2019 +0000 + + Bug 1556301 - Wayland-EGL/GLES support in glxtest + + This allows GfxInfoX11 to get GLES3 and Mesa version from Wayland-EGL, which + allows automatic enablement of acceleration to work without Xwayland. + + This also fixes bug 1578598 - WebRender did not work correctly + without this GL version information. + + Differential Revision: https://phabricator.services.mozilla.com/D57474 +--- + toolkit/xre/glxtest.cpp | 132 +++++++++++++++++++++++++++++++++++-- + widget/gtk/mozwayland/mozwayland.h | 1 + + 2 files changed, 126 insertions(+), 7 deletions(-) + +diff --git toolkit/xre/glxtest.cpp toolkit/xre/glxtest.cpp +index 7b33a5c2b08f0..a1e6036cb6002 100644 +--- toolkit/xre/glxtest.cpp ++++ toolkit/xre/glxtest.cpp +@@ -35,6 +35,8 @@ + #include "X11/Xutil.h" + + #include "mozilla/Unused.h" ++#include "nsAppRunner.h" // for IsWaylandDisabled ++#include "mozilla/widget/mozwayland.h" + + // stuff from glx.h + typedef struct __GLXcontextRec* GLXContext; +@@ -74,6 +76,15 @@ typedef uint32_t GLenum; + #define GLX_RENDERER_ID_MESA 0x818E + // clang-format on + ++// stuff from egl.h ++#define EGL_BLUE_SIZE 0x3022 ++#define EGL_GREEN_SIZE 0x3023 ++#define EGL_RED_SIZE 0x3024 ++#define EGL_NONE 0x3038 ++#define EGL_VENDOR 0x3053 ++#define EGL_CONTEXT_CLIENT_VERSION 0x3098 ++#define EGL_NO_CONTEXT nullptr ++ + namespace mozilla { + namespace widget { + // the read end of the pipe, which will be used by GfxInfo +@@ -118,7 +129,10 @@ static int x_error_handler(Display*, XErrorEvent* ev) { + // care about leaking memory + extern "C" { + +-static int get_egl_status(char* buf, int bufsize) { ++typedef void* EGLNativeDisplayType; ++ ++static int get_egl_status(char* buf, int bufsize, ++ EGLNativeDisplayType native_dpy, bool gles_test) { + void* libegl = dlopen("libEGL.so.1", RTLD_LAZY); + if (!libegl) { + libegl = dlopen("libEGL.so", RTLD_LAZY); +@@ -164,7 +178,7 @@ static int get_egl_status(char* buf, int bufsize) { + return 0; + } + +- EGLDisplay dpy = eglGetDisplay(nullptr); ++ EGLDisplay dpy = eglGetDisplay(native_dpy); + if (!dpy) { + dlclose(libegl); + return 0; +@@ -177,9 +191,87 @@ static int get_egl_status(char* buf, int bufsize) { + } + + int length = 0; ++ ++ if (gles_test) { ++ typedef void* EGLConfig; ++ typedef void* EGLContext; ++ typedef void* EGLSurface; ++ ++ typedef EGLBoolean (*PFNEGLCHOOSECONFIGPROC)( ++ EGLDisplay dpy, EGLint const* attrib_list, EGLConfig* configs, ++ EGLint config_size, EGLint* num_config); ++ PFNEGLCHOOSECONFIGPROC eglChooseConfig = ++ cast(eglGetProcAddress("eglChooseConfig")); ++ ++ typedef EGLContext (*PFNEGLCREATECONTEXTPROC)( ++ EGLDisplay dpy, EGLConfig config, EGLContext share_context, ++ EGLint const* attrib_list); ++ PFNEGLCREATECONTEXTPROC eglCreateContext = ++ cast(eglGetProcAddress("eglCreateContext")); ++ ++ typedef EGLSurface (*PFNEGLCREATEPBUFFERSURFACEPROC)( ++ EGLDisplay dpy, EGLConfig config, EGLint const* attrib_list); ++ PFNEGLCREATEPBUFFERSURFACEPROC eglCreatePbufferSurface = ++ cast( ++ eglGetProcAddress("eglCreatePbufferSurface")); ++ ++ typedef EGLBoolean (*PFNEGLMAKECURRENTPROC)( ++ EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context); ++ PFNEGLMAKECURRENTPROC eglMakeCurrent = ++ cast(eglGetProcAddress("eglMakeCurrent")); ++ ++ void* libgles = dlopen("libGLESv2.so.2", RTLD_LAZY); ++ if (!libgles) { ++ libgles = dlopen("libGLESv2.so", RTLD_LAZY); ++ } ++ if (!libgles) { ++ fatal_error("Unable to load libGLESv2"); ++ } ++ ++ typedef GLubyte* (*PFNGLGETSTRING)(GLenum); ++ PFNGLGETSTRING glGetString = ++ cast(eglGetProcAddress("glGetString")); ++ ++ if (!glGetString) { ++ // Implementations disagree about whether eglGetProcAddress or dlsym ++ // should be used for getting functions from the actual API, see ++ // https://github.com/anholt/libepoxy/commit/14f24485e33816139398d1bd170d617703473738 ++ glGetString = cast(dlsym(libgles, "glGetString")); ++ } ++ ++ if (!glGetString) { ++ fatal_error("GLESv2 glGetString not found"); ++ } ++ ++ EGLint config_attrs[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, ++ EGL_BLUE_SIZE, 8, EGL_NONE}; ++ EGLConfig config; ++ EGLint num_config; ++ eglChooseConfig(dpy, config_attrs, &config, 1, &num_config); ++ EGLint ctx_attrs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; ++ EGLContext ectx = eglCreateContext(dpy, config, EGL_NO_CONTEXT, ctx_attrs); ++ EGLSurface pbuf = eglCreatePbufferSurface(dpy, config, nullptr); ++ eglMakeCurrent(dpy, pbuf, pbuf, ectx); ++ ++ const GLubyte* versionString = glGetString(GL_VERSION); ++ const GLubyte* vendorString = glGetString(GL_VENDOR); ++ const GLubyte* rendererString = glGetString(GL_RENDERER); ++ ++ if (!versionString || !vendorString || !rendererString) ++ fatal_error("glGetString returned null"); ++ ++ length = snprintf(buf, bufsize, ++ "VENDOR\n%s\nRENDERER\n%s\nVERSION\n%s\nTFP\nTRUE\n", ++ vendorString, rendererString, versionString); ++ if (length >= bufsize) { ++ fatal_error("GL strings length too large for buffer size"); ++ } ++ } ++ + const char* driDriver = eglGetDisplayDriverName(dpy); + if (driDriver) { +- length = snprintf(buf, bufsize, "DRI_DRIVER\n%s\n", driDriver); ++ length += ++ snprintf(buf + length, bufsize - length, "DRI_DRIVER\n%s\n", driDriver); + } + + eglTerminate(dpy); +@@ -187,7 +279,7 @@ static int get_egl_status(char* buf, int bufsize) { + return length; + } + +-void glxtest() { ++static void close_logging() { + // we want to redirect to /dev/null stdout, stderr, and while we're at it, + // any PR logging file descriptors. To that effect, we redirect all positive + // file descriptors up to what open() returns here. In particular, 1 is stdout +@@ -199,8 +291,30 @@ void glxtest() { + if (getenv("MOZ_AVOID_OPENGL_ALTOGETHER")) + fatal_error( + "The MOZ_AVOID_OPENGL_ALTOGETHER environment variable is defined"); ++} ++ ++bool wayland_egltest() { ++ // NOTE: returns false to fall back to X11 when the Wayland socket doesn't ++ // exist but fails with fatal_error if something actually went wrong ++ struct wl_display* dpy = wl_display_connect(nullptr); ++ if (!dpy) return false; ++ ++ enum { bufsize = 2048 }; ++ char buf[bufsize]; ++ ++ int length = get_egl_status(buf, bufsize, (EGLNativeDisplayType)dpy, true); ++ if (length >= bufsize) { ++ fatal_error("GL strings length too large for buffer size"); ++ } ++ ++ ///// Finally write data to the pipe ++ mozilla::Unused << write(write_end_of_the_pipe, buf, length); + +- ///// Open libGL and load needed symbols ///// ++ return true; ++} ++ ++void glxtest() { ++ ///// Open libGL and load needed symbols ///// + #if defined(__OpenBSD__) || defined(__NetBSD__) + # define LIBGL_FILENAME "libGL.so" + #else +@@ -401,7 +515,7 @@ void glxtest() { + // If we failed to get the driver name from X, try via EGL_MESA_query_driver. + // We are probably using Wayland. + if (!gotDriDriver) { +- length += get_egl_status(buf + length, bufsize - length); ++ length += get_egl_status(buf + length, bufsize - length, nullptr, false); + if (length >= bufsize) { + fatal_error("GL strings length too large for buffer size"); + } +@@ -431,7 +545,11 @@ bool fire_glxtest_process() { + if (pid == 0) { + close(pfd[0]); + write_end_of_the_pipe = pfd[1]; +- glxtest(); ++ close_logging(); ++ // TODO: --display command line argument is not properly handled ++ if (IsWaylandDisabled() || !wayland_egltest()) { ++ glxtest(); ++ } + close(pfd[1]); + _exit(0); + } +diff --git widget/gtk/mozwayland/mozwayland.h widget/gtk/mozwayland/mozwayland.h +index b31742fb2bc33..8aa0ce6f4665a 100644 +--- widget/gtk/mozwayland/mozwayland.h ++++ widget/gtk/mozwayland/mozwayland.h +@@ -20,6 +20,7 @@ + extern "C" { + #endif + ++MOZ_EXPORT struct wl_display* wl_display_connect(const char* name); + MOZ_EXPORT int wl_display_roundtrip_queue(struct wl_display* display, + struct wl_event_queue* queue); + MOZ_EXPORT uint32_t wl_proxy_get_version(struct wl_proxy* proxy);