[WebGPU] Use of WebGPU should not force discrete GPU
authorjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 02:34:25 +0000 (02:34 +0000)
committerjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 02:34:25 +0000 (02:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200740

Reviewed by Myles C. Maxfield.

Request a low-power device from Metal by default.

No change in testable behavior.

* platform/graphics/gpu/GPURequestAdapterOptions.h:
* platform/graphics/gpu/cocoa/GPUDeviceMetal.mm:
(WebCore::GPUDevice::tryCreate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248704 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gpu/GPURequestAdapterOptions.h
Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm

index a3fb68b..055eb3a 100644 (file)
@@ -1,3 +1,18 @@
+2019-08-14  Justin Fan  <justin_fan@apple.com>
+
+        [WebGPU] Use of WebGPU should not force discrete GPU
+        https://bugs.webkit.org/show_bug.cgi?id=200740
+
+        Reviewed by Myles C. Maxfield.
+
+        Request a low-power device from Metal by default.
+
+        No change in testable behavior.
+
+        * platform/graphics/gpu/GPURequestAdapterOptions.h:
+        * platform/graphics/gpu/cocoa/GPUDeviceMetal.mm:
+        (WebCore::GPUDevice::tryCreate):
+
 2019-08-14  Chris Dumez  <cdumez@apple.com>
 
         Potentially non thread-safe usage of WebCore::MediaSample
index 1f5e88d..4e46310 100644 (file)
@@ -37,7 +37,7 @@ enum class GPUPowerPreference {
 };
 
 struct GPURequestAdapterOptions {
-    Optional<GPUPowerPreference> powerPreference;
+    Optional<GPUPowerPreference> powerPreference { GPUPowerPreference::LowPower };
 };
     
 } // namespace WebCore
index 97bc7bf..4d0ca65 100644 (file)
@@ -49,7 +49,7 @@ RefPtr<GPUDevice> GPUDevice::tryCreate(const Optional<GPURequestAdapterOptions>&
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
 #if PLATFORM(MAC)
-    if (options && options->powerPreference == GPUPowerPreference::LowPower) {
+    if (!options || !options->powerPreference || options->powerPreference == GPUPowerPreference::LowPower) {
         auto devices = adoptNS(MTLCopyAllDevices());
         
         for (id <MTLDevice> device : devices.get()) {