WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-231012-20211019153101.patch (text/plain), 27.02 KB, created by
Kimmo Kinnunen
on 2021-10-19 05:31:03 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Kimmo Kinnunen
Created:
2021-10-19 05:31:03 PDT
Size:
27.02 KB
patch
obsolete
>Subversion Revision: 284237 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index cffc5130a6812a5471f4175ae4c5760f28c4f99f..d6cca3e54e941f9f7c03dd54134421918bbf5042 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2021-10-19 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ WebGL low-power and high-performance contexts should use different ANGLE Metal EGLDisplays >+ https://bugs.webkit.org/show_bug.cgi?id=231012 >+ <rdar://problem/83971417> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Use per-power preference EGLDisplay when creating Metal >+ contexts. >+ >+ Adds a new API test. >+ >+ * platform/RuntimeApplicationChecks.cpp: >+ (WebCore::setAuxiliaryProcessTypeForTesting): >+ * platform/RuntimeApplicationChecks.h: >+ Add a test function to reset the process type after test has set a specific type and then >+ run to completion. process for the duration of the test. The volatile context flag in >+ GraphicsContextGLOpenGL depends on condition isWebProcess || isGPUProcess. >+ * platform/graphics/angle/GraphicsContextGLANGLE.cpp: >+ (WebCore::GraphicsContextGLOpenGL::releaseThreadResources): >+ * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm: >+ (WebCore::initializeEGLDisplay): >+ (WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL): >+ (WebCore::GraphicsContextGLOpenGL::setContextVisibility): >+ (WebCore::GraphicsContextGLOpenGL::displayWasReconfigured): >+ * platform/graphics/opengl/GraphicsContextGLOpenGL.h: >+ > 2021-10-15 Kimmo Kinnunen <kkinnunen@apple.com> > > Cocoa GraphicsContextGLOpenGL should not use WebGLLayer >diff --git a/Source/WebCore/platform/RuntimeApplicationChecks.cpp b/Source/WebCore/platform/RuntimeApplicationChecks.cpp >index e045334ad16fc475bab0d626578ea2766ff5d1a0..4c2b53e8d38132b760eb0af780184af4521212e7 100644 >--- a/Source/WebCore/platform/RuntimeApplicationChecks.cpp >+++ b/Source/WebCore/platform/RuntimeApplicationChecks.cpp >@@ -75,6 +75,11 @@ void setAuxiliaryProcessType(AuxiliaryProcessType type) > auxiliaryProcessType() = type; > } > >+void setAuxiliaryProcessTypeForTesting(std::optional<AuxiliaryProcessType> type) >+{ >+ auxiliaryProcessType() = type; >+} >+ > bool checkAuxiliaryProcessType(AuxiliaryProcessType type) > { > auto currentType = auxiliaryProcessType(); >diff --git a/Source/WebCore/platform/RuntimeApplicationChecks.h b/Source/WebCore/platform/RuntimeApplicationChecks.h >index 06db78e8584239d4ceb03a198afc12d1a03164ec..2b968a73ce27e7b0160c262c4a2ff0278f8d9c33 100644 >--- a/Source/WebCore/platform/RuntimeApplicationChecks.h >+++ b/Source/WebCore/platform/RuntimeApplicationChecks.h >@@ -46,6 +46,7 @@ enum class AuxiliaryProcessType : uint8_t { > }; > > WEBCORE_EXPORT void setAuxiliaryProcessType(AuxiliaryProcessType); >+WEBCORE_EXPORT void setAuxiliaryProcessTypeForTesting(std::optional<AuxiliaryProcessType>); > WEBCORE_EXPORT bool checkAuxiliaryProcessType(AuxiliaryProcessType); > WEBCORE_EXPORT std::optional<AuxiliaryProcessType> processType(); > WEBCORE_EXPORT const char* processTypeDescription(std::optional<AuxiliaryProcessType>); >diff --git a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp b/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >index 574e1fa75ef912fe23c124fc3202f465dd259610..347b4c33b76cb3c9799a5960ac4617600a3f1d53 100644 >--- a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >+++ b/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >@@ -86,26 +86,31 @@ bool GraphicsContextGLOpenGL::releaseThreadResources(ReleaseThreadResourceBehavi > // Unset the EGL current context, since the next access might be from another thread, and the > // context cannot be current on multiple threads. > if (releaseBehavior == ReleaseThreadResourceBehavior::ReleaseCurrentContext) { >- if (EGL_GetCurrentContext() == EGL_NO_CONTEXT) >+ EGLDisplay display = EGL_GetCurrentDisplay(); >+ if (display == EGL_NO_DISPLAY) > return true; > // At the time of writing, ANGLE does not flush on MakeCurrent. Since we are > // potentially switching threads, we should flush. > // Note: Here we assume also that ANGLE has only one platform context -- otherwise > // we would need to flush each EGL context that has been used. > gl::Flush(); >- EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY); >- if (display == EGL_NO_DISPLAY) >- return true; > return EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); > } > if (releaseBehavior == ReleaseThreadResourceBehavior::TerminateAndReleaseThreadResources) { >- EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY); >- if (display != EGL_NO_DISPLAY) { >- if (EGL_GetCurrentContext() != EGL_NO_CONTEXT) { >- ASSERT_NOT_REACHED(); // All resources must have been destroyed. >- EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); >- } >- EGL_Terminate(display); >+ EGLDisplay currentDisplay = EGL_GetCurrentDisplay(); >+ if (currentDisplay != EGL_NO_DISPLAY) { >+ ASSERT_NOT_REACHED(); // All resources must have been destroyed. >+ EGL_MakeCurrent(currentDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); >+ } >+ constexpr EGLNativeDisplayType nativeDisplays[] = { >+ defaultDisplay, >+ lowPowerDisplay, >+ highPerformanceDisplay >+ }; >+ for (auto nativeDisplay : nativeDisplays) { >+ EGLDisplay display = EGL_GetDisplay(nativeDisplay); >+ if (display != EGL_NO_DISPLAY) >+ EGL_Terminate(display); > } > } > // Called when we do not know if we will ever see another call from this thread again. >diff --git a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm b/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm >index db0c9002ca90fd9599d04ea0376643237f3c3559..4e194bd4a22259f049e66309c44e98161e08b50e 100644 >--- a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm >+++ b/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm >@@ -146,24 +146,25 @@ static EGLDisplay initializeEGLDisplay(const GraphicsContextGLAttributes& attrs) > } > > LOG(WebGL, "Attempting to use ANGLE's %s backend.", attrs.useMetal ? "Metal" : "OpenGL"); >+ EGLNativeDisplayType nativeDisplay = GraphicsContextGLOpenGL::defaultDisplay; > if (attrs.useMetal) { > displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_ANGLE); > displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE); >- } >- >- if (attrs.powerPreference != GraphicsContextGLAttributes::PowerPreference::Default || attrs.forceRequestForHighPerformanceGPU) { >- displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE); >- if (attrs.powerPreference == GraphicsContextGLAttributes::PowerPreference::LowPower && !attrs.forceRequestForHighPerformanceGPU) { >- LOG(WebGL, "Requesting low power GPU."); >+ // These properties are defined for EGL_ANGLE_power_preference as EGLContext attributes, >+ // but Metal backend uses EGLDisplay attributes. >+ auto powerPreference = attrs.forceRequestForHighPerformanceGPU ? GraphicsContextGLAttributes::PowerPreference::HighPerformance : attrs.powerPreference; >+ if (powerPreference == GraphicsContextGLAttributes::PowerPreference::LowPower) { >+ displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE); > displayAttributes.append(EGL_LOW_POWER_ANGLE); >- } else { >- ASSERT(attrs.powerPreference == GraphicsContextGLAttributes::PowerPreference::HighPerformance || attrs.forceRequestForHighPerformanceGPU); >- LOG(WebGL, "Requesting high power GPU if available."); >+ nativeDisplay = GraphicsContextGLOpenGL::lowPowerDisplay; >+ } else if (powerPreference == GraphicsContextGLAttributes::PowerPreference::HighPerformance) { >+ displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE); > displayAttributes.append(EGL_HIGH_POWER_ANGLE); >+ nativeDisplay = GraphicsContextGLOpenGL::highPerformanceDisplay; > } > } > displayAttributes.append(EGL_NONE); >- display = EGL_GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY), displayAttributes.data()); >+ display = EGL_GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void*>(nativeDisplay), displayAttributes.data()); > > if (EGL_Initialize(display, &majorVersion, &minorVersion) == EGL_FALSE) { > LOG(WebGL, "EGLDisplay Initialization failed."); >@@ -172,7 +173,7 @@ static EGLDisplay initializeEGLDisplay(const GraphicsContextGLAttributes& attrs) > LOG(WebGL, "ANGLE initialised Major: %d Minor: %d", majorVersion, minorVersion); > if (shouldInitializeWithVolatileContextSupport) { > // After initialization, EGL_DEFAULT_DISPLAY will return the platform-customized display. >- ASSERT(display == EGL_GetDisplay(EGL_DEFAULT_DISPLAY)); >+ ASSERT(display == EGL_GetDisplay(nativeDisplay)); > ASSERT(checkVolatileContextSupportIfDeviceExists(display, "EGL_ANGLE_platform_device_context_volatile_eagl", "EGL_ANGLE_device_eagl", EGL_EAGL_CONTEXT_ANGLE)); > ASSERT(checkVolatileContextSupportIfDeviceExists(display, "EGL_ANGLE_platform_device_context_volatile_cgl", "EGL_ANGLE_device_cgl", EGL_CGL_CONTEXT_ANGLE)); > } >@@ -218,16 +219,25 @@ GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes att > if (!m_displayObj) > return; > >- bool supportsPowerPreference = false; > #if PLATFORM(MAC) >- const char *displayExtensions = EGL_QueryString(m_displayObj, EGL_EXTENSIONS); >- m_supportsPowerPreference = strstr(displayExtensions, "EGL_ANGLE_power_preference"); >- supportsPowerPreference = m_supportsPowerPreference; >-#endif >- if (!supportsPowerPreference && attrs.powerPreference == GraphicsContextGLPowerPreference::HighPerformance) { >- attrs.powerPreference = GraphicsContextGLPowerPreference::Default; >- setContextAttributes(attrs); >+ if (!attrs.useMetal) { >+ // For OpenGL, EGL_ANGLE_power_preference is used. The context is initialized with the >+ // default, low-power device. For high-performance contexts, we request the high-performance >+ // GPU in setContextVisibility. When the request is fullfilled by the system, we get the >+ // display reconfiguration callback. Upon this, we update the CGL contexts inside ANGLE. >+ const char *displayExtensions = EGL_QueryString(m_displayObj, EGL_EXTENSIONS); >+ bool supportsPowerPreference = strstr(displayExtensions, "EGL_ANGLE_power_preference"); >+ if (supportsPowerPreference) { >+ m_switchesGPUOnDisplayReconfiguration = attrs.powerPreference == GraphicsContextGLPowerPreference::HighPerformance >+ || attrs.forceRequestForHighPerformanceGPU; >+ } else { >+ if (attrs.powerPreference == GraphicsContextGLPowerPreference::HighPerformance) { >+ attrs.powerPreference = GraphicsContextGLPowerPreference::Default; >+ setContextAttributes(attrs); >+ } >+ } > } >+#endif > > EGLint configAttributes[] = { > EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, >@@ -509,7 +519,7 @@ void GraphicsContextGLOpenGL::checkGPUStatus() > void GraphicsContextGLOpenGL::setContextVisibility(bool isVisible) > { > #if PLATFORM(MAC) >- if (contextAttributes().powerPreference != GraphicsContextGLPowerPreference::HighPerformance) >+ if (!m_switchesGPUOnDisplayReconfiguration) > return; > if (isVisible) > m_highPerformanceGPURequest = ScopedHighPerformanceGPURequest::acquire(); >@@ -523,7 +533,7 @@ void GraphicsContextGLOpenGL::setContextVisibility(bool isVisible) > void GraphicsContextGLOpenGL::displayWasReconfigured() > { > #if PLATFORM(MAC) >- if (m_supportsPowerPreference) >+ if (m_switchesGPUOnDisplayReconfiguration) > EGL_HandleGPUSwitchANGLE(m_displayObj); > #endif > dispatchContextChangedNotification(); >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h >index 994ef15213055f097a08fc920be5e2f691307e57..291094cc2386aa0fa3b2ecf64fa6e818587bb984 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h >@@ -534,6 +534,9 @@ public: > #endif > #endif > >+ constexpr static EGLNativeDisplayType defaultDisplay = EGL_DEFAULT_DISPLAY; >+ constexpr static EGLNativeDisplayType lowPowerDisplay = EGL_CAST(EGLNativeDisplayType, -1); >+ constexpr static EGLNativeDisplayType highPerformanceDisplay = EGL_CAST(EGLNativeDisplayType, -2); > protected: > GraphicsContextGLOpenGL(GraphicsContextGLAttributes); > bool isValid() const; >@@ -785,7 +788,7 @@ private: > void* m_displayBufferPbuffer { nullptr }; > #endif > #if PLATFORM(MAC) >- bool m_supportsPowerPreference { false }; >+ bool m_switchesGPUOnDisplayReconfiguration { false }; > ScopedHighPerformanceGPURequest m_highPerformanceGPURequest; > #endif > #if ENABLE(VIDEO) && USE(AVFOUNDATION) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 81fa2315c27960efbbae2aada451fa43f70aaa89..8d4ccd644cb376cbb69b81da27493d76ae3ba5a6 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,29 @@ >+2021-10-19 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ WebGL low-power and high-performance contexts should use different ANGLE Metal EGLDisplays >+ https://bugs.webkit.org/show_bug.cgi?id=231012 >+ <rdar://problem/83971417> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a API test to test GraphicsContextGLOpenGL >+ Cocoa implementation regarding the bug where >+ the GraphicsContextGLOpenGL instances would use >+ the GPU that was selected by the first instance. >+ >+ * TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig: >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLOpenGLCocoa.mm: Added. >+ (TestWebKitAPI::WebCore::TestedGraphicsContextGLOpenGL::create): >+ (TestWebKitAPI::WebCore::TestedGraphicsContextGLOpenGL::TestedGraphicsContextGLOpenGL): >+ (TestWebKitAPI::hasMultipleGPUs): >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/WebCoreUtilities.h: Added. >+ (TestWebKitAPI::ScopedSetAuxiliaryProcessTypeForTesting::ScopedSetAuxiliaryProcessTypeForTesting): >+ (TestWebKitAPI::ScopedSetAuxiliaryProcessTypeForTesting::~ScopedSetAuxiliaryProcessTypeForTesting): >+ Add a utility state setter to set the process type for the >+ duration of a test. >+ > 2021-10-14 John Wilander <wilander@apple.com> > > TestWebKitAPI.PrivateClickMeasurement.FraudPrevention is a constant timeout >diff --git a/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig b/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig >index c062e6321fc253a6d6d5eb1e8f98c5fba02fdd34..5dfbfd3ef85b3166b14868df1261af8a40d93d74 100644 >--- a/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig >+++ b/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig >@@ -90,7 +90,7 @@ WK_UIKITMACHELPER_LDFLAGS_maccatalyst = -framework UIKitMacHelper; > > OTHER_CPLUSPLUSFLAGS = $(inherited) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders; > >-OTHER_LDFLAGS = $(inherited) -lgtest -force_load $(BUILT_PRODUCTS_DIR)/libTestWebKitAPI.a -framework JavaScriptCore -framework WebKit -lWebCoreTestSupport $(WK_APPSERVERSUPPORT_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) -framework Network $(WK_HID_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SYSTEM_LDFLAGS) $(WK_UIKITMACHELPER_LDFLAGS) $(WK_VISIONKITCORE_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH)); >+OTHER_LDFLAGS = $(inherited) -lgtest -force_load $(BUILT_PRODUCTS_DIR)/libTestWebKitAPI.a -framework JavaScriptCore -framework WebKit -lWebCoreTestSupport -framework Metal $(WK_APPSERVERSUPPORT_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) -framework Network $(WK_HID_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SYSTEM_LDFLAGS) $(WK_UIKITMACHELPER_LDFLAGS) $(WK_VISIONKITCORE_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH)); > OTHER_LDFLAGS_PLATFORM_ = -framework Cocoa -framework Carbon; > > // FIXME: This should not be built on iOS. Instead we should create and use a TestWebKitAPI application. >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 5e4132a19117d44d8696597ff20daa5c4c8b0027..4780a47d4657ccf75ea2d7a193311e8a1da58cbd 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -606,6 +606,7 @@ > 7B2739F32632AB640040F182 /* ThreadAssertionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B2739F22632AB640040F182 /* ThreadAssertionsTest.cpp */; }; > 7B774906267CCE72009873B4 /* TestRunnerTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B774904267CCE68009873B4 /* TestRunnerTests.cpp */; }; > 7B7D096A2519F8F90017A078 /* WebGLNoCrashOnOtherThreadAccess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7B7D09692519F8F90017A078 /* WebGLNoCrashOnOtherThreadAccess.mm */; }; >+ 7BA3936C271EDFCA0015911C /* TestGraphicsContextGLOpenGLCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7BA3936B271EDFCA0015911C /* TestGraphicsContextGLOpenGLCocoa.mm */; }; > 7C1AF7951E8DCBAB002645B9 /* PrepareForMoveToWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C1AF7931E8DCBAB002645B9 /* PrepareForMoveToWindow.mm */; }; > 7C3965061CDD74F90094DBB8 /* ColorTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* ColorTests.cpp */; }; > 7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */; }; >@@ -2510,6 +2511,8 @@ > 7B2739F22632AB640040F182 /* ThreadAssertionsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadAssertionsTest.cpp; sourceTree = "<group>"; }; > 7B774904267CCE68009873B4 /* TestRunnerTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestRunnerTests.cpp; sourceTree = "<group>"; }; > 7B7D09692519F8F90017A078 /* WebGLNoCrashOnOtherThreadAccess.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGLNoCrashOnOtherThreadAccess.mm; sourceTree = "<group>"; }; >+ 7BA3936B271EDFCA0015911C /* TestGraphicsContextGLOpenGLCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestGraphicsContextGLOpenGLCocoa.mm; sourceTree = "<group>"; }; >+ 7BA3936D271EEC530015911C /* WebCoreUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreUtilities.h; sourceTree = "<group>"; }; > 7C1AF7931E8DCBAB002645B9 /* PrepareForMoveToWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrepareForMoveToWindow.mm; sourceTree = "<group>"; }; > 7C3965051CDD74F90094DBB8 /* ColorTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorTests.cpp; sourceTree = "<group>"; }; > 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommandBackForward.mm; sourceTree = "<group>"; }; >@@ -3312,6 +3315,7 @@ > BC131AA8117131FC00B69727 /* TestsController.cpp */, > BCB9E7C711234E3A00A137E0 /* TestsController.h */, > 7C83E0361D0A5F7000FEBCF3 /* Utilities.h */, >+ 7BA3936D271EEC530015911C /* WebCoreUtilities.h */, > 7CBD5A2222DE42A6004A9E32 /* WTFStringUtilities.cpp */, > 44A622C114A0E2B60048515B /* WTFStringUtilities.h */, > ); >@@ -4975,6 +4979,7 @@ > 57F1C91025DDD51900E8F6EA /* PrivateClickMeasurementCocoa.mm */, > 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */, > A17991861E1C994E00A505ED /* SharedBuffer.mm */, >+ 7BA3936B271EDFCA0015911C /* TestGraphicsContextGLOpenGLCocoa.mm */, > CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */, > ); > path = cocoa; >@@ -5549,6 +5554,7 @@ > 7CCE7EEE1A411AE600447C4C /* DownloadDecideDestinationCrash.cpp in Sources */, > 637281A721AE1386009E0DE6 /* DownloadProgress.mm in Sources */, > 5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */, >+ 7BA3936C271EDFCA0015911C /* TestGraphicsContextGLOpenGLCocoa.mm in Sources */, > F4D4F3B61E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm in Sources */, > F46128B7211C8ED500D9FADB /* DragAndDropSimulatorMac.mm in Sources */, > F46128D7211E489C00D9FADB /* DragAndDropTests.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLOpenGLCocoa.mm b/Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLOpenGLCocoa.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..6199c953bf4ec214cda6546a40701e1178eb140b >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLOpenGLCocoa.mm >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "Test.h" >+ >+#if PLATFORM(COCOA) && ENABLE(WEBGL) >+#import "WebCoreUtilities.h" >+#import <Metal/Metal.h> >+#import <WebCore/GraphicsContextGLOpenGL.h> >+ >+namespace TestWebKitAPI { >+using namespace WebCore; >+ >+namespace { >+class TestedGraphicsContextGLOpenGL : public GraphicsContextGLOpenGL { >+public: >+ static RefPtr<TestedGraphicsContextGLOpenGL> create(GraphicsContextGLAttributes attributes) >+ { >+ auto context = adoptRef(*new TestedGraphicsContextGLOpenGL(WTFMove(attributes))); >+ return context; >+ } >+private: >+ TestedGraphicsContextGLOpenGL(GraphicsContextGLAttributes attributes) >+ : GraphicsContextGLOpenGL(WTFMove(attributes)) >+ { >+ } >+}; >+} >+ >+static bool hasMultipleGPUs() >+{ >+ auto devices = adoptNS(MTLCopyAllDevices()); >+ return [devices count] > 1; >+} >+ >+#if HAVE(WEBGL_COMPATIBLE_METAL) >+#define MAYBE_MultipleGPUsDifferentPowerPreferenceMetal MultipleGPUsDifferentPowerPreferenceMetal >+#else >+#define MAYBE_MultipleGPUsDifferentPowerPreferenceMetal DISABLED_MultipleGPUsDifferentPowerPreferenceMetal >+#endif >+// Tests for a bug where high-performance context would use low-power GPU if low-power or default >+// context was created first. Test is applicable only for Metal, since GPU selection for OpenGL is >+// very different. >+TEST(GraphicsContextGLOpenGLCocoaTest, MAYBE_MultipleGPUsDifferentPowerPreferenceMetal) >+{ >+ if (!hasMultipleGPUs()) >+ return; >+ ScopedSetAuxiliaryProcessTypeForTesting scopedProcessType { AuxiliaryProcessType::GPU }; >+ >+ GraphicsContextGLAttributes attributes; >+ attributes.useMetal = true; >+ EXPECT_EQ(attributes.powerPreference, GraphicsContextGLPowerPreference::Default); >+ auto defaultContext = TestedGraphicsContextGLOpenGL::create(attributes); >+ EXPECT_NE(defaultContext, nullptr); >+ >+ attributes.powerPreference = GraphicsContextGLPowerPreference::LowPower; >+ auto lowPowerContext = TestedGraphicsContextGLOpenGL::create(attributes); >+ EXPECT_NE(lowPowerContext, nullptr); >+ >+ attributes.powerPreference = GraphicsContextGLPowerPreference::HighPerformance; >+ auto highPerformanceContext = TestedGraphicsContextGLOpenGL::create(attributes); >+ EXPECT_NE(highPerformanceContext, nullptr); >+ >+ EXPECT_NE(lowPowerContext->getString(GraphicsContextGL::RENDERER), highPerformanceContext->getString(GraphicsContextGL::RENDERER)); >+ EXPECT_EQ(defaultContext->getString(GraphicsContextGL::RENDERER), lowPowerContext->getString(GraphicsContextGL::RENDERER)); >+} >+ >+} >+#endif >diff --git a/Tools/TestWebKitAPI/WebCoreUtilities.h b/Tools/TestWebKitAPI/WebCoreUtilities.h >new file mode 100644 >index 0000000000000000000000000000000000000000..42635d260caf2bc35a42a091f2ebb8793ac45f70 >--- /dev/null >+++ b/Tools/TestWebKitAPI/WebCoreUtilities.h >@@ -0,0 +1,47 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <WebCore/RuntimeApplicationChecks.h> >+ >+namespace TestWebKitAPI { >+ >+class ScopedSetAuxiliaryProcessTypeForTesting { >+public: >+ explicit ScopedSetAuxiliaryProcessTypeForTesting(WebCore::AuxiliaryProcessType type) >+ : m_oldType(WebCore::processType()) >+ { >+ setAuxiliaryProcessTypeForTesting(type); >+ } >+ ~ScopedSetAuxiliaryProcessTypeForTesting() >+ { >+ setAuxiliaryProcessTypeForTesting(m_oldType); >+ } >+private: >+ std::optional<WebCore::AuxiliaryProcessType> m_oldType; >+}; >+ >+} // namespace TestWebKitAPI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 231012
:
441712
|
441849
|
441873
|
441892
|
441998