WebKit Bugzilla
Attachment 360749 Details for
Bug 194068
: [WebGPU] WebGPUAdapterDescriptor -> GPURequestAdapterOptions and take powerPreference into account
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-194068-20190131115849.patch (text/plain), 28.96 KB, created by
Justin Fan
on 2019-01-31 11:58:50 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Justin Fan
Created:
2019-01-31 11:58:50 PST
Size:
28.96 KB
patch
obsolete
>Subversion Revision: 240795 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 083bb3d0dfd3a9789bef1bcf9610f617cc93787c..d277c456cee6c4802cb676d1ff02c08a4f4daa87 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,33 @@ >+2019-01-31 Justin Fan <justin_fan@apple.com> >+ >+ [WebGPU] WebGPUAdapterDescriptor -> GPURequestAdapterOptions and take powerPreference into account >+ https://bugs.webkit.org/show_bug.cgi?id=194068 >+ <rdar://problem/47680215> >+ >+ Reviewed by Dean Jackson. >+ >+ Per the Web GPU IDL, WebGPUAdapterDescriptor is now known as GPURequestAdapterOptions and is optional. >+ In addition, Web GPU now actually attempts to return an integrated GPU when a low-power adapter is requested. >+ >+ Test: adapter-options.html >+ >+ * Modules/webgpu/GPURequestAdapterOptions.idl: Renamed from Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.idl. >+ * Modules/webgpu/WebGPU.cpp: >+ (WebCore::WebGPU::requestAdapter const): >+ * Modules/webgpu/WebGPU.h: >+ * Modules/webgpu/WebGPU.idl: >+ * Modules/webgpu/WebGPUAdapter.cpp: >+ (WebCore::WebGPUAdapter::create): >+ (WebCore::WebGPUAdapter::WebGPUAdapter): >+ * Modules/webgpu/WebGPUAdapter.h: >+ (WebCore::WebGPUAdapter::options const): >+ * Modules/webgpu/WebGPUDevice.cpp: >+ (WebCore::WebGPUDevice::create): >+ * platform/graphics/gpu/GPUDevice.h: >+ * platform/graphics/gpu/GPURequestAdapterOptions.h: Renamed from Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.h. >+ * platform/graphics/gpu/cocoa/GPUDeviceMetal.mm: >+ (WebCore::GPUDevice::create): >+ > 2019-01-31 Darin Adler <darin@apple.com> > > Simplify and streamline code that creates an appropriate document based on MIME type >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index d355e7b2a0695c3175c3dad6e65526137ee2c11a..938fe9a5af1ab54ad0156994c33df45c57324566 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -464,9 +464,9 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/webgpu/DOMWindowWebGPU.idl > Modules/webgpu/GPUCompareFunction.idl > Modules/webgpu/GPUDepthStencilStateDescriptor.idl >+ Modules/webgpu/GPURequestAdapterOptions.idl > Modules/webgpu/WebGPU.idl > Modules/webgpu/WebGPUAdapter.idl >- Modules/webgpu/WebGPUAdapterDescriptor.idl > Modules/webgpu/WebGPUBindGroup.idl > Modules/webgpu/WebGPUBindGroupBinding.idl > Modules/webgpu/WebGPUBindGroupDescriptor.idl >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index 5e54b7cb4a8caf6d367ce0a97370f624b1c2e0f2..bc3009ef50c964b6e6784ce82c07649cf7945edd 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -374,9 +374,9 @@ JS_BINDING_IDLS = \ > $(WebCore)/Modules/webgpu/DOMWindowWebGPU.idl \ > $(WebCore)/Modules/webgpu/GPUCompareFunction.idl \ > $(WebCore)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl \ >+ $(WebCore)/Modules/webgpu/GPURequestAdapterOptions.idl \ > $(WebCore)/Modules/webgpu/WebGPU.idl \ > $(WebCore)/Modules/webgpu/WebGPUAdapter.idl \ >- $(WebCore)/Modules/webgpu/WebGPUAdapterDescriptor.idl \ > $(WebCore)/Modules/webgpu/WebGPUBindGroup.idl \ > $(WebCore)/Modules/webgpu/WebGPUBindGroupBinding.idl \ > $(WebCore)/Modules/webgpu/WebGPUBindGroupDescriptor.idl \ >diff --git a/Source/WebCore/Modules/webgpu/GPURequestAdapterOptions.idl b/Source/WebCore/Modules/webgpu/GPURequestAdapterOptions.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..cbc84f244051038b74a5acc5da4c342dc90cada5 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/GPURequestAdapterOptions.idl >@@ -0,0 +1,37 @@ >+/* >+ * Copyright (C) 2018 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. >+ */ >+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl >+ >+enum GPUPowerPreference { >+ "low-power", >+ "high-performance" >+}; >+ >+[ >+ Conditional=WEBGPU, >+ EnabledAtRuntime=WebGPU >+] dictionary GPURequestAdapterOptions { >+ GPUPowerPreference powerPreference; >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPU.cpp b/Source/WebCore/Modules/webgpu/WebGPU.cpp >index 0dc411ae303e4b086edbf9f868f85db4d1ac64ff..38f993c162713c09fb07fdb29909c3aa9a38c940 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPU.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPU.cpp >@@ -28,6 +28,7 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURequestAdapterOptions.h" > #include "JSWebGPUAdapter.h" > > namespace WebCore { >@@ -37,9 +38,9 @@ Ref<WebGPU> WebGPU::create() > return adoptRef(*new WebGPU); > } > >-void WebGPU::requestAdapter(const WebGPUAdapterDescriptor& descriptor, WebGPUAdapterPromise&& deferred) const >+void WebGPU::requestAdapter(Optional<GPURequestAdapterOptions>&& options, WebGPUAdapterPromise&& deferred) const > { >- auto adapter = WebGPUAdapter::create(descriptor); >+ auto adapter = WebGPUAdapter::create(WTFMove(options)); > deferred.resolve(adapter.get()); > } > >diff --git a/Source/WebCore/Modules/webgpu/WebGPU.h b/Source/WebCore/Modules/webgpu/WebGPU.h >index 0d510769028e136019a8c266bb0b7d6ca850b03c..27270378a9ddb25671696974ef20855806185e8f 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPU.h >+++ b/Source/WebCore/Modules/webgpu/WebGPU.h >@@ -28,12 +28,13 @@ > #if ENABLE(WEBGPU) > > #include "JSDOMPromiseDeferred.h" >+#include <wtf/Optional.h> > > namespace WebCore { > > class WebGPUAdapter; > >-struct WebGPUAdapterDescriptor; >+struct GPURequestAdapterOptions; > > class WebGPU : public RefCounted<WebGPU> { > public: >@@ -41,7 +42,7 @@ public: > > using WebGPUAdapterPromise = DOMPromiseDeferred<IDLInterface<WebGPUAdapter>>; > >- void requestAdapter(const WebGPUAdapterDescriptor&, WebGPUAdapterPromise&&) const; >+ void requestAdapter(Optional<GPURequestAdapterOptions>&&, WebGPUAdapterPromise&&) const; > > private: > WebGPU() = default; >diff --git a/Source/WebCore/Modules/webgpu/WebGPU.idl b/Source/WebCore/Modules/webgpu/WebGPU.idl >index c63de8ad53d16237989c54a515cb60e9977a6116..1cc9e4f9760fc99358de77d67016b39b0f3cebdc 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPU.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPU.idl >@@ -29,5 +29,5 @@ > EnabledAtRuntime=WebGPU, > ImplementationLacksVTable > ] interface WebGPU { >- Promise<WebGPUAdapter> requestAdapter(WebGPUAdapterDescriptor desc); >+ Promise<WebGPUAdapter> requestAdapter(optional GPURequestAdapterOptions options); > }; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp b/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp >index 77f9f491e4fc1619e00db926748eaababbd511ba..8bf6e9bb43f5201518161f574ee6ef115316e7a0 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp >@@ -29,21 +29,18 @@ > #if ENABLE(WEBGPU) > > #include "ScriptExecutionContext.h" >-#include "WebGPUAdapterDescriptor.h" > #include "WebGPUDevice.h" > > namespace WebCore { > >-Ref<WebGPUAdapter> WebGPUAdapter::create(const WebGPUAdapterDescriptor& descriptor) >+Ref<WebGPUAdapter> WebGPUAdapter::create(Optional<GPURequestAdapterOptions>&& options) > { >- // FIXME: Validation on descriptor. >- return adoptRef(*new WebGPUAdapter(descriptor)); >+ return adoptRef(*new WebGPUAdapter(WTFMove(options))); > } > >-WebGPUAdapter::WebGPUAdapter(const WebGPUAdapterDescriptor& descriptor) >- : m_descriptor(descriptor) >+WebGPUAdapter::WebGPUAdapter(Optional<GPURequestAdapterOptions>&& options) >+ : m_options(WTFMove(options)) > { >- UNUSED_PARAM(m_descriptor); > } > > RefPtr<WebGPUDevice> WebGPUAdapter::createDevice() >diff --git a/Source/WebCore/Modules/webgpu/WebGPUAdapter.h b/Source/WebCore/Modules/webgpu/WebGPUAdapter.h >index 8d04e54bf2a6408e9e88254c8204cec55c168084..bf7cc3ff828e16bc1714122f204a8a0ef44965e2 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUAdapter.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUAdapter.h >@@ -27,6 +27,8 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURequestAdapterOptions.h" >+#include <wtf/Optional.h> > #include <wtf/RefCounted.h> > #include <wtf/RefPtr.h> > >@@ -35,18 +37,18 @@ namespace WebCore { > class ScriptExecutionContext; > class WebGPUDevice; > >-struct WebGPUAdapterDescriptor; >- > class WebGPUAdapter : public RefCounted<WebGPUAdapter> { > public: >- static Ref<WebGPUAdapter> create(const WebGPUAdapterDescriptor&); >+ static Ref<WebGPUAdapter> create(Optional<GPURequestAdapterOptions>&&); > > RefPtr<WebGPUDevice> createDevice(); >+ >+ Optional<GPURequestAdapterOptions> options() const { return m_options; } > > private: >- WebGPUAdapter(const WebGPUAdapterDescriptor&); >+ explicit WebGPUAdapter(Optional<GPURequestAdapterOptions>&&); > >- const WebGPUAdapterDescriptor& m_descriptor; >+ Optional<GPURequestAdapterOptions> m_options; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.h >deleted file mode 100644 >index dee4d89a133956305ee38971a891da25e979cf0d..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.h >+++ /dev/null >@@ -1,44 +0,0 @@ >-/* >- * Copyright (C) 2018 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 >- >-#if ENABLE(WEBGPU) >- >-namespace WebCore { >- >-struct WebGPUAdapterDescriptor { >- enum class PowerPreference { >- Default, >- LowPower, >- HighPerformance >- }; >- >- PowerPreference powerPreference = PowerPreference::Default; >-}; >- >-} // namespace WebCore >- >-#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.idl >deleted file mode 100644 >index c294d7cb345eaa9653a437e1cc0915dae075ba74..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPUAdapterDescriptor.idl >+++ /dev/null >@@ -1,38 +0,0 @@ >-/* >- * Copyright (C) 2018 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. >- */ >-// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl >- >-enum WebGPUPowerPreference { >- "default", >- "low-power", >- "high-performance" >-}; >- >-[ >- Conditional=WEBGPU, >- EnabledAtRuntime=WebGPU >-] dictionary WebGPUAdapterDescriptor { >- WebGPUPowerPreference powerPreference = "default"; >-}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp b/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >index 0d98e13db3f78815a3d41f9427beee525fca3391..4dd0a9420dbb76d63332a1e8302d05046cd7ec12 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >@@ -58,7 +58,7 @@ namespace WebCore { > > RefPtr<WebGPUDevice> WebGPUDevice::create(Ref<WebGPUAdapter>&& adapter) > { >- if (auto device = GPUDevice::create()) // FIXME: Take adapter into account when creating m_device. >+ if (auto device = GPUDevice::create(adapter->options())) > return adoptRef(new WebGPUDevice(WTFMove(adapter), device.releaseNonNull())); > return nullptr; > } >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index c27d917330942bd808df22dd97662240c1ac5941..378c0653b8090cf01c3b0dadca3959130e7f8584 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -2770,6 +2770,7 @@ JSGeoposition.cpp > JSGlobalCrypto.cpp > JSGlobalEventHandlers.cpp > JSGlobalPerformance.cpp >+JSGPURequestAdapterOptions.cpp > JSHTMLAllCollection.cpp > JSHTMLAnchorElement.cpp > JSHTMLAppletElement.cpp >@@ -3294,7 +3295,6 @@ JSWaveShaperNode.cpp > JSWebAnimation.cpp > JSWebGPU.cpp > JSWebGPUAdapter.cpp >-JSWebGPUAdapterDescriptor.cpp > JSWebGPUBindGroup.cpp > JSWebGPUBindGroupBinding.cpp > JSWebGPUBindGroupDescriptor.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 6ead73c98949762e2254002883780adf4e7a6a9b..88cf902a69b039b06f04eb09634184474308b2d0 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13948,8 +13948,7 @@ > D0232B5821CB49B7009483B9 /* GPUBindGroupLayoutMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBindGroupLayoutMetal.mm; sourceTree = "<group>"; }; > D02454D021C4A41C00B73628 /* GPUBindGroupLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroupLayout.h; sourceTree = "<group>"; }; > D02B83ED21C8397A00F85473 /* WebGPUBindGroupLayoutDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroupLayoutDescriptor.idl; sourceTree = "<group>"; }; >- D02C26912181416D00D818E4 /* WebGPUAdapterDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUAdapterDescriptor.h; sourceTree = "<group>"; }; >- D02C26922181416D00D818E4 /* WebGPUAdapterDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUAdapterDescriptor.idl; sourceTree = "<group>"; }; >+ D02C26922181416D00D818E4 /* GPURequestAdapterOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPURequestAdapterOptions.idl; sourceTree = "<group>"; }; > D02F854E21682A4A0088EE74 /* WebMetalCommandQueue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebMetalCommandQueue.idl; sourceTree = "<group>"; }; > D02F855021682A560088EE74 /* WebMetalComputeCommandEncoder.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebMetalComputeCommandEncoder.idl; sourceTree = "<group>"; }; > D02F855121682A560088EE74 /* WebMetalComputePipelineState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebMetalComputePipelineState.h; sourceTree = "<group>"; }; >@@ -14043,6 +14042,7 @@ > D063AE4721C06626000E6A35 /* WebGPUInputStepMode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUInputStepMode.idl; sourceTree = "<group>"; }; > D063AE4821C066DB000E6A35 /* WebGPUIndexFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUIndexFormat.h; sourceTree = "<group>"; }; > D063AE4921C066DB000E6A35 /* WebGPUIndexFormat.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUIndexFormat.idl; sourceTree = "<group>"; }; >+ D06A9A2122026C7A0083C662 /* GPURequestAdapterOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPURequestAdapterOptions.h; sourceTree = "<group>"; }; > D06C0D8D0CFD11460065F43F /* RemoveFormatCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoveFormatCommand.h; sourceTree = "<group>"; }; > D06C0D8E0CFD11460065F43F /* RemoveFormatCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoveFormatCommand.cpp; sourceTree = "<group>"; }; > D07DEAB70A36554A00CA30F8 /* InsertListCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InsertListCommand.cpp; sourceTree = "<group>"; }; >@@ -18464,6 +18464,7 @@ > D03211CE21AC954E00763CF2 /* GPURenderPassEncoder.h */, > 312FF8B921A4C2EF00EB199D /* GPURenderPipeline.h */, > 312FF8BC21A4C2F000EB199D /* GPURenderPipelineDescriptor.h */, >+ D06A9A2122026C7A0083C662 /* GPURequestAdapterOptions.h */, > 312FF8BB21A4C2F000EB199D /* GPUShaderModule.h */, > 312FF8C021A4C2F200EB199D /* GPUShaderModuleDescriptor.h */, > 312FF8BA21A4C2EF00EB199D /* GPUSwapChain.h */, >@@ -26031,14 +26032,13 @@ > D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */, > D03C849E21FFCF000002227F /* GPUCompareFunction.idl */, > D03C84A221FFD7230002227F /* GPUDepthStencilStateDescriptor.idl */, >+ D02C26922181416D00D818E4 /* GPURequestAdapterOptions.idl */, > D00F5947216EFE54000D71DB /* WebGPU.cpp */, > D00F5946216EFE54000D71DB /* WebGPU.h */, > D00F5948216EFE54000D71DB /* WebGPU.idl */, > D00F5950216FFAC2000D71DB /* WebGPUAdapter.cpp */, > D00F594F216FFAC2000D71DB /* WebGPUAdapter.h */, > D00F5951216FFAC2000D71DB /* WebGPUAdapter.idl */, >- D02C26912181416D00D818E4 /* WebGPUAdapterDescriptor.h */, >- D02C26922181416D00D818E4 /* WebGPUAdapterDescriptor.idl */, > D0BE106121E6C0EB00E42A89 /* WebGPUBindGroup.cpp */, > D0BE106021E6C0EB00E42A89 /* WebGPUBindGroup.h */, > D0BE106221E6C0EB00E42A89 /* WebGPUBindGroup.idl */, >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDevice.h b/Source/WebCore/platform/graphics/gpu/GPUDevice.h >index 6e6d5153185b8baede4b349cb05a2317cba18a4a..9c9b5977a4a02b176191ae73dec5e1537d57510a 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDevice.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUDevice.h >@@ -28,6 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "GPUQueue.h" >+#include <wtf/Optional.h> > #include <wtf/RefCounted.h> > #include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >@@ -50,11 +51,12 @@ struct GPUBindGroupLayoutDescriptor; > struct GPUBufferDescriptor; > struct GPUPipelineLayoutDescriptor; > struct GPURenderPipelineDescriptor; >+struct GPURequestAdapterOptions; > struct GPUShaderModuleDescriptor; > > class GPUDevice : public RefCounted<GPUDevice> { > public: >- static RefPtr<GPUDevice> create(); >+ static RefPtr<GPUDevice> create(Optional<GPURequestAdapterOptions>&&); > > RefPtr<GPUBuffer> createBuffer(GPUBufferDescriptor&&) const; > >diff --git a/Source/WebCore/platform/graphics/gpu/GPURequestAdapterOptions.h b/Source/WebCore/platform/graphics/gpu/GPURequestAdapterOptions.h >new file mode 100644 >index 0000000000000000000000000000000000000000..421311653b9b8a54f3046a5ae49492cf1262b646 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPURequestAdapterOptions.h >@@ -0,0 +1,43 @@ >+/* >+ * 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. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+namespace WebCore { >+ >+struct GPURequestAdapterOptions { >+ enum class PowerPreference { >+ LowPower, >+ HighPerformance >+ }; >+ >+ PowerPreference powerPreference; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm >index e8387a7711b0200ed9192fa1420d3592f8e48189..ee9777efbda0547977a165ee64c8aa3231da165f 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm >@@ -28,6 +28,7 @@ > > #if ENABLE(WEBGPU) > >+#import "GPURequestAdapterOptions.h" > #import "Logging.h" > > #import <Metal/Metal.h> >@@ -35,23 +36,35 @@ > > namespace WebCore { > >-RefPtr<GPUDevice> GPUDevice::create() >+RefPtr<GPUDevice> GPUDevice::create(Optional<GPURequestAdapterOptions>&& options) > { >- PlatformDeviceSmartPtr device; >+ PlatformDeviceSmartPtr devicePtr; > > BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- device = adoptNS(MTLCreateSystemDefaultDevice()); // FIXME: Take WebGPUPowerPreference into account. >+ >+ if (options && options->powerPreference == GPURequestAdapterOptions::PowerPreference::LowPower) { >+ auto devices = adoptNS(MTLCopyAllDevices()); >+ >+ for (id <MTLDevice> device : devices.get()) { >+ if (device.lowPower) { >+ devicePtr = retainPtr(device); >+ break; >+ } >+ } >+ } >+ >+ if (!devicePtr) >+ devicePtr = adoptNS(MTLCreateSystemDefaultDevice()); > > END_BLOCK_OBJC_EXCEPTIONS; > >- if (!device) { >+ if (!devicePtr) { > LOG(WebGPU, "GPUDevice::GPUDevice(): Unable to create GPUDevice!"); > return nullptr; > } > >- LOG(WebGPU, "GPUDevice::GPUDevice(): MTLDevice is %p", device.get()); >- return adoptRef(new GPUDevice(WTFMove(device))); >+ LOG(WebGPU, "GPUDevice::GPUDevice(): MTLDevice is %p", devicePtr.get()); >+ return adoptRef(new GPUDevice(WTFMove(devicePtr))); > } > > GPUDevice::GPUDevice(PlatformDeviceSmartPtr&& device) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index b0be8865e22218951b2b718d8419c6b0e2351fb0..1174c1bc8462284c71ff9378d85e101843a78c69 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,21 @@ >+2019-01-31 Justin Fan <justin_fan@apple.com> >+ >+ [WebGPU] WebGPUAdapterDescriptor -> GPURequestAdapterOptions and take powerPreference into account >+ https://bugs.webkit.org/show_bug.cgi?id=194068 >+ <rdar://problem/47680215> >+ >+ Reviewed by Dean Jackson. >+ >+ Add simple test to create device with all options. Update helper functions for other Web GPU >+ tests to request different adapters. (No change in test behavior expected.) >+ >+ * webgpu/adapter-options-expected.txt: Added. >+ * webgpu/adapter-options.html: Added. >+ * webgpu/js/basic-webgpu-functions.js: >+ (async.setUpContexts): Update to use no adapter request argument at all. >+ * webgpu/js/webgpu-functions.js: >+ (async.getBasicDevice): Update to request the low-power adapter. >+ > 2019-01-31 Zalan Bujtas <zalan@apple.com> > > [LFC] Use the used margin values in outOfFlowReplacedHorizontalGeometry consistently >diff --git a/LayoutTests/webgpu/adapter-options-expected.txt b/LayoutTests/webgpu/adapter-options-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2df1a50fa0abf09cc8cec7ed4afb1cb15b0b2de9 >--- /dev/null >+++ b/LayoutTests/webgpu/adapter-options-expected.txt >@@ -0,0 +1,5 @@ >+ >+PASS Create the default device. >+PASS Create a device with a low-power option. >+PASS Create a device with a high-performance option. >+ >diff --git a/LayoutTests/webgpu/adapter-options.html b/LayoutTests/webgpu/adapter-options.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f042f28c85dd29e3df22f15e5d16ffef738d1eab >--- /dev/null >+++ b/LayoutTests/webgpu/adapter-options.html >@@ -0,0 +1,29 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] --> >+<meta charset=utf-8> >+<title>Create GPUDevices from various options.</title> >+<body> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<script> >+promise_test(async () => { >+ const defaultAdapter = await webgpu.requestAdapter(); >+ const device = defaultAdapter.createDevice(); >+ >+ assert_true(device instanceof WebGPUDevice, "Default device successfully created."); >+}, "Create the default device."); >+ >+promise_test(async () => { >+ const lowPowerAdapter = await webgpu.requestAdapter({ powerPreference: "low-power" }); >+ const device = lowPowerAdapter.createDevice(); >+ >+ assert_true(device instanceof WebGPUDevice, "Device successfully created using low-power option."); >+}, "Create a device with a low-power option."); >+ >+promise_test(async () => { >+ const highPerfAdapter = await webgpu.requestAdapter({ powerPreference: "high-performance" }); >+ const device = highPerfAdapter.createDevice(); >+ >+ assert_true(device instanceof WebGPUDevice, "Device successfully created using high-performance option."); >+}, "Create a device with a high-performance option."); >+</script> >+</body> >\ No newline at end of file >diff --git a/LayoutTests/webgpu/js/basic-webgpu-functions.js b/LayoutTests/webgpu/js/basic-webgpu-functions.js >index 0d0870262f7009e1a3d930eed4dae49e00099c6f..083732536309f9c3a36b61a5576338570d3fad81 100644 >--- a/LayoutTests/webgpu/js/basic-webgpu-functions.js >+++ b/LayoutTests/webgpu/js/basic-webgpu-functions.js >@@ -60,8 +60,7 @@ async function setUpContexts(canvas) { > > shouldBeDefined(window.webgpu); > >- // FIXME: requestAdapter should take a WebGPUAdapterDescriptor. >- adapter = await window.webgpu.requestAdapter({}); >+ adapter = await window.webgpu.requestAdapter(); > if (!adapter) { > testFailed("Could not create default WebGPUAdapter!") > return; >diff --git a/LayoutTests/webgpu/js/webgpu-functions.js b/LayoutTests/webgpu/js/webgpu-functions.js >index 767f946521a4ad22213f92f0d4fcb5720c826317..f3789c9f254b439044df7945f2f4c1e1e078af55 100644 >--- a/LayoutTests/webgpu/js/webgpu-functions.js >+++ b/LayoutTests/webgpu/js/webgpu-functions.js >@@ -1,6 +1,5 @@ > async function getBasicDevice() { >- // FIXME: requestAdapter should take a WebGPUAdapterDescriptor. >- const adapter = await window.webgpu.requestAdapter({}); >+ const adapter = await window.webgpu.requestAdapter({ powerPreference: "low-power" }); > const device = adapter.createDevice(); > return device; > }
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 194068
:
360659
|
360662
|
360744
| 360749