From 3b9574890575612bbafd272213f7fb191cbb939a Mon Sep 17 00:00:00 2001 From: Sandor Molnar Date: Tue, 28 Nov 2023 02:31:02 +0200 Subject: [PATCH] Backed out changeset c1e95a42b8d7 (bug 1843782) for causing gv-junit-fis failures. CLOSED TREE --- gfx/config/gfxVars.h | 3 +- gfx/gl/GLContextProviderEGL.cpp | 96 +++++++++++++++++------------------------ gfx/gl/GLLibraryEGL.cpp | 56 ++++++++++-------------- gfx/thebes/gfxPlatform.cpp | 2 - gfx/thebes/gfxPlatformGtk.cpp | 11 ++--- widget/GfxInfoBase.cpp | 3 -- widget/gtk/GfxInfo.cpp | 7 --- widget/nsIGfxInfo.idl | 4 +- 8 files changed, 67 insertions(+), 115 deletions(-) diff --git a/gfx/config/gfxVars.h b/gfx/config/gfxVars.h index d520ec771674..808dd838da94 100644 --- a/gfx/config/gfxVars.h +++ b/gfx/config/gfxVars.h @@ -98,8 +98,7 @@ class gfxVarReceiver; _(AllowBackdropFilter, bool, true) \ _(WebglOopAsyncPresentForceSync, bool, true) \ _(UseAcceleratedCanvas2D, bool, false) \ - _(AllowSoftwareWebRenderOGL, bool, false) \ - _(WebglUseHardware, bool, true) + _(AllowSoftwareWebRenderOGL, bool, false) /* Add new entries above this line. */ diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 45da0e40cb69..8a544c2e6227 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -1129,70 +1129,54 @@ RefPtr GLContextEGL::CreateWithoutSurface( const std::shared_ptr egl, const GLContextCreateDesc& desc, nsACString* const out_failureId) { const auto WithUseGles = [&](const bool useGles) -> RefPtr { - if (egl->IsExtensionSupported(EGLExtension::KHR_no_config_context) && - egl->IsExtensionSupported(EGLExtension::KHR_surfaceless_context)) { - // These extensions have been supported by mesa and nvidia drivers - // since 2014 or earlier, this is the preferred code path - auto fullDesc = GLContextDesc{desc}; - fullDesc.isOffscreen = true; - RefPtr gl = GLContextEGL::CreateGLContext( - egl, fullDesc, EGL_NO_CONFIG, EGL_NO_SURFACE, useGles, EGL_NO_CONFIG, - out_failureId); - if (!gl) { - NS_WARNING("Failed to create GLContext without surface"); - return nullptr; - } - return gl; - } else { - const EGLConfig surfaceConfig = ChooseConfig(*egl, desc, useGles); - if (surfaceConfig == EGL_NO_CONFIG) { - *out_failureId = "FEATURE_FAILURE_EGL_NO_CONFIG"_ns; - NS_WARNING("Failed to find a compatible config."); - return nullptr; - } + const EGLConfig surfaceConfig = ChooseConfig(*egl, desc, useGles); + if (surfaceConfig == EGL_NO_CONFIG) { + *out_failureId = "FEATURE_FAILURE_EGL_NO_CONFIG"_ns; + NS_WARNING("Failed to find a compatible config."); + return nullptr; + } - if (GLContext::ShouldSpew()) { - egl->DumpEGLConfig(surfaceConfig); - } - const EGLConfig contextConfig = - egl->IsExtensionSupported(EGLExtension::KHR_no_config_context) - ? nullptr - : surfaceConfig; + if (GLContext::ShouldSpew()) { + egl->DumpEGLConfig(surfaceConfig); + } + const EGLConfig contextConfig = + egl->IsExtensionSupported(EGLExtension::KHR_no_config_context) + ? nullptr + : surfaceConfig; - auto dummySize = mozilla::gfx::IntSize{16, 16}; - EGLSurface surface = nullptr; + auto dummySize = mozilla::gfx::IntSize{16, 16}; + EGLSurface surface = nullptr; #ifdef MOZ_WAYLAND - if (GdkIsWaylandDisplay()) { - surface = GLContextEGL::CreateWaylandOffscreenSurface( - *egl, surfaceConfig, dummySize); - } else + if (GdkIsWaylandDisplay()) { + surface = GLContextEGL::CreateWaylandOffscreenSurface(*egl, surfaceConfig, + dummySize); + } else #endif - { - surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo( - *egl, surfaceConfig, LOCAL_EGL_NONE, dummySize); - } - if (!surface) { - *out_failureId = "FEATURE_FAILURE_EGL_POT"_ns; - NS_WARNING("Failed to create PBuffer for context!"); - return nullptr; - } + { + surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo( + *egl, surfaceConfig, LOCAL_EGL_NONE, dummySize); + } + if (!surface) { + *out_failureId = "FEATURE_FAILURE_EGL_POT"_ns; + NS_WARNING("Failed to create PBuffer for context!"); + return nullptr; + } - auto fullDesc = GLContextDesc{desc}; - fullDesc.isOffscreen = true; - RefPtr gl = - GLContextEGL::CreateGLContext(egl, fullDesc, surfaceConfig, surface, - useGles, contextConfig, out_failureId); - if (!gl) { - NS_WARNING("Failed to create GLContext from PBuffer"); - egl->fDestroySurface(surface); + auto fullDesc = GLContextDesc{desc}; + fullDesc.isOffscreen = true; + RefPtr gl = + GLContextEGL::CreateGLContext(egl, fullDesc, surfaceConfig, surface, + useGles, contextConfig, out_failureId); + if (!gl) { + NS_WARNING("Failed to create GLContext from PBuffer"); + egl->fDestroySurface(surface); #if defined(MOZ_WAYLAND) - DeleteWaylandOffscreenGLSurface(surface); + DeleteWaylandOffscreenGLSurface(surface); #endif - return nullptr; - } - - return gl; + return nullptr; } + + return gl; }; bool preferGles; diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 9f6d9db65172..a90d73d2a270 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -171,13 +171,10 @@ static std::shared_ptr GetAndInitDisplay( #ifdef MOZ_WIDGET_GTK static std::shared_ptr GetAndInitDeviceDisplay( - GLLibraryEGL& egl, const StaticMutexAutoLock& aProofOfLock, - bool useDrmRenderDevice) { + GLLibraryEGL& egl, const StaticMutexAutoLock& aProofOfLock) { nsAutoCString drmRenderDevice(gfx::gfxVars::DrmRenderDevice()); - if (!useDrmRenderDevice) { - drmRenderDevice = ""; - } - if (!egl.IsExtensionSupported(EGLLibExtension::EXT_platform_device) || + if (drmRenderDevice.IsEmpty() || + !egl.IsExtensionSupported(EGLLibExtension::EXT_platform_device) || !egl.IsExtensionSupported(EGLLibExtension::EXT_device_enumeration)) { return nullptr; } @@ -198,9 +195,8 @@ static std::shared_ptr GetAndInitDeviceDisplay( for (const auto& device : devices) { const char* renderNodeString = egl.fQueryDeviceStringEXT(device, LOCAL_EGL_DRM_RENDER_NODE_FILE_EXT); - // We are looking for a specific device, skip others - if (strcmp(renderNodeString ? renderNodeString : "", - drmRenderDevice.get()) == 0) { + if (renderNodeString && + strcmp(renderNodeString, drmRenderDevice.get()) == 0) { const EGLAttrib attrib_list[] = {LOCAL_EGL_NONE}; display = egl.fGetPlatformDisplay(LOCAL_EGL_PLATFORM_DEVICE_EXT, device, attrib_list); @@ -896,36 +892,28 @@ std::shared_ptr GLLibraryEGL::CreateDisplayLocked( } } } else { + void* nativeDisplay = EGL_DEFAULT_DISPLAY; #ifdef MOZ_WIDGET_GTK - // Check if we allow hardware rendering for WebGL - if (gfx::gfxVars::WebglUseHardware()) { - // Initialize the display the normal way - if (gdk_display_get_default()) { - void* nativeDisplay = EGL_DEFAULT_DISPLAY; + if (!gdk_display_get_default()) { + ret = GetAndInitDeviceDisplay(*this, aProofOfLock); + if (!ret) { + ret = GetAndInitSurfacelessDisplay(*this, aProofOfLock); + } + } # ifdef MOZ_WAYLAND - if (widget::GdkIsWaylandDisplay()) { - // Wayland does not support EGL_DEFAULT_DISPLAY - nativeDisplay = widget::WaylandDisplayGetWLDisplay(); - if (!nativeDisplay) { - NS_WARNING("Failed to get wl_display."); - return nullptr; - } - } -# endif - ret = GetAndInitDisplay(*this, nativeDisplay, aProofOfLock); - } else { - // Enumerate EGL devices to find the chosen drm render device - ret = GetAndInitDeviceDisplay(*this, aProofOfLock, true); - // Try a mesa surfaceless display - if (!ret) { - ret = GetAndInitSurfacelessDisplay(*this, aProofOfLock); - } + else if (widget::GdkIsWaylandDisplay()) { + // Wayland does not support EGL_DEFAULT_DISPLAY + nativeDisplay = widget::WaylandDisplayGetWLDisplay(); + if (!nativeDisplay) { + NS_WARNING("Failed to get wl_display."); + return nullptr; } - } else { - // Initialize a swrast egl device such as llvmpipe - ret = GetAndInitDeviceDisplay(*this, aProofOfLock, false); } +# endif #endif + if (!ret) { + ret = GetAndInitDisplay(*this, nativeDisplay, aProofOfLock); + } } if (!ret) { diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 3e476f784135..d7ef77d854d9 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -2995,8 +2995,6 @@ void gfxPlatform::InitWebGLConfig() { IsFeatureOk(nsIGfxInfo::FEATURE_WEBGL_OPENGL)); gfxVars::SetAllowWebglAccelAngle( IsFeatureOk(nsIGfxInfo::FEATURE_WEBGL_ANGLE)); - gfxVars::SetWebglUseHardware( - IsFeatureOk(nsIGfxInfo::FEATURE_WEBGL_USE_HARDWARE)); if (kIsMacOS) { // Avoid crash for Intel HD Graphics 3000 on OSX. (Bug 1413269) diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 3d33cb4407e6..7d541d4a372b 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -225,16 +225,11 @@ void gfxPlatformGtk::InitDmabufConfig() { "FEATURE_FAILURE_REQUIRES_EGL"_ns); } - if (!gfxVars::WebglUseHardware()) { - feature.Disable(FeatureStatus::Blocklisted, - "Blocklisted with forced software rendering", failureId); - } + nsAutoCString drmRenderDevice; + gfxInfo->GetDrmRenderDevice(drmRenderDevice); + gfxVars::SetDrmRenderDevice(drmRenderDevice); if (feature.IsEnabled()) { - nsAutoCString drmRenderDevice; - gfxInfo->GetDrmRenderDevice(drmRenderDevice); - gfxVars::SetDrmRenderDevice(drmRenderDevice); - if (!GetDMABufDevice()->IsEnabled(failureId)) { feature.ForceDisable(FeatureStatus::Failed, "Failed to configure", failureId); diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index be5f2d056d89..9b53589cf566 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -269,9 +269,6 @@ static const char* GetPrefNameForFeature(int32_t aFeature) { case nsIGfxInfo::FEATURE_VIDEO_SOFTWARE_OVERLAY: name = BLOCKLIST_PREF_BRANCH "video-software-overlay"; break; - case nsIGfxInfo::FEATURE_WEBGL_USE_HARDWARE: - name = BLOCKLIST_PREF_BRANCH "webgl-use-hardware"; - break; default: MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!"); break; diff --git a/widget/gtk/GfxInfo.cpp b/widget/gtk/GfxInfo.cpp index b34e85baa28e..978166cbb3fb 100644 --- a/widget/gtk/GfxInfo.cpp +++ b/widget/gtk/GfxInfo.cpp @@ -973,13 +973,6 @@ const nsTArray& GfxInfo::GetGfxDriverInfo() { nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0), "FEATURE_FAILURE_WEBRENDER_MESA_VM", ""); - // Disable hardware mesa drivers in virtual machines due to instability. - APPEND_TO_DRIVER_BLOCKLIST_EXT( - OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All, - WindowProtocol::All, DriverVendor::MesaVM, DeviceFamily::All, - nsIGfxInfo::FEATURE_WEBGL_USE_HARDWARE, - nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED, - V(0, 0, 0, 0), "FEATURE_FAILURE_WEBGL_MESA_VM", ""); //////////////////////////////////// // FEATURE_WEBRENDER_COMPOSITOR diff --git a/widget/nsIGfxInfo.idl b/widget/nsIGfxInfo.idl index 2bf6351611c2..3e7386a3ccc0 100644 --- a/widget/nsIGfxInfo.idl +++ b/widget/nsIGfxInfo.idl @@ -187,10 +187,8 @@ interface nsIGfxInfo : nsISupports const long FEATURE_AV1_HW_DECODE = 45; /* Whether video overlay of software decoded video is supported, starting in 116. */ const long FEATURE_VIDEO_SOFTWARE_OVERLAY = 46; - /* Whether WebGL is allowed to use hardware rendering, otherwise software fallbacks. */ - const long FEATURE_WEBGL_USE_HARDWARE = 47; /* the maximum feature value. */ - const long FEATURE_MAX_VALUE = FEATURE_WEBGL_USE_HARDWARE; + const long FEATURE_MAX_VALUE = FEATURE_VIDEO_SOFTWARE_OVERLAY; /* * A set of return values from GetFeatureStatus -- 2.11.4.GIT