Diff
Modified: trunk/LayoutTests/ChangeLog (243089 => 243090)
--- trunk/LayoutTests/ChangeLog 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/LayoutTests/ChangeLog 2019-03-18 19:18:50 UTC (rev 243090)
@@ -1,5 +1,20 @@
2019-03-18 Justin Fan <justin_...@apple.com>
+ [Web GPU] GPUAdapter.createDevice -> GPUAdapter.requestDevice
+ https://bugs.webkit.org/show_bug.cgi?id=195781
+
+ Reviewed by Myles C. Maxfield.
+
+ Update affected Web GPU tests.
+
+ * webgpu/adapter-options.html:
+ * webgpu/js/webgpu-functions.js:
+ (async.getBasicDevice):
+ * webgpu/queue-creation.html:
+ * webgpu/webgpu-enabled.html:
+
+2019-03-18 Justin Fan <justin_...@apple.com>
+
[Web GPU] API updates: GPUTexture.createDefaultView and type-safe GPURenderPassEncoder.setPipeline
https://bugs.webkit.org/show_bug.cgi?id=195896
Modified: trunk/LayoutTests/webgpu/adapter-options.html (243089 => 243090)
--- trunk/LayoutTests/webgpu/adapter-options.html 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/LayoutTests/webgpu/adapter-options.html 2019-03-18 19:18:50 UTC (rev 243090)
@@ -7,7 +7,7 @@
<script>
promise_test(async () => {
const defaultAdapter = await gpu.requestAdapter();
- const device = defaultAdapter.createDevice();
+ const device = await defaultAdapter.requestDevice();
assert_true(device instanceof WebGPUDevice, "Default device successfully created.");
}, "Create the default device.");
@@ -14,7 +14,7 @@
promise_test(async () => {
const lowPowerAdapter = await gpu.requestAdapter({ powerPreference: "low-power" });
- const device = lowPowerAdapter.createDevice();
+ const device = await lowPowerAdapter.requestDevice();
assert_true(device instanceof WebGPUDevice, "Device successfully created using low-power option.");
}, "Create a device with a low-power option.");
@@ -21,7 +21,7 @@
promise_test(async () => {
const highPerfAdapter = await gpu.requestAdapter({ powerPreference: "high-performance" });
- const device = highPerfAdapter.createDevice();
+ const device = await highPerfAdapter.requestDevice();
assert_true(device instanceof WebGPUDevice, "Device successfully created using high-performance option.");
}, "Create a device with a high-performance option.");
Modified: trunk/LayoutTests/webgpu/js/webgpu-functions.js (243089 => 243090)
--- trunk/LayoutTests/webgpu/js/webgpu-functions.js 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/LayoutTests/webgpu/js/webgpu-functions.js 2019-03-18 19:18:50 UTC (rev 243090)
@@ -1,6 +1,6 @@
async function getBasicDevice() {
const adapter = await gpu.requestAdapter({ powerPreference: "low-power" });
- const device = adapter.createDevice();
+ const device = await adapter.requestDevice();
return device;
}
Modified: trunk/LayoutTests/webgpu/queue-creation.html (243089 => 243090)
--- trunk/LayoutTests/webgpu/queue-creation.html 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/LayoutTests/webgpu/queue-creation.html 2019-03-18 19:18:50 UTC (rev 243090)
@@ -17,8 +17,8 @@
const adapter = await window.gpu.requestAdapter({});
assert_true(adapter instanceof WebGPUAdapter, "requestAdapter returned a WebGPUAdapter.");
- const device = adapter.createDevice();
- assert_true(device instanceof WebGPUDevice, "createDevice returned a WebGPUDevice.");
+ const device = await adapter.requestDevice();
+ assert_true(device instanceof WebGPUDevice, "requestDevice returned a WebGPUDevice.");
const queue = device.getQueue();
assert_true(queue instanceof WebGPUQueue, "getQueue returned a WebGPUQueue.");
Modified: trunk/LayoutTests/webgpu/webgpu-enabled.html (243089 => 243090)
--- trunk/LayoutTests/webgpu/webgpu-enabled.html 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/LayoutTests/webgpu/webgpu-enabled.html 2019-03-18 19:18:50 UTC (rev 243090)
@@ -15,7 +15,7 @@
const adapter = await window.gpu.requestAdapter();
assert_true(adapter instanceof WebGPUAdapter, "Created default GPUAdapter.");
- const device = adapter.createDevice();
+ const device = await adapter.requestDevice();
assert_true(device instanceof WebGPUDevice, "Created GPUDevice.");
}, "Web GPU is enabled.");
</script>
Modified: trunk/Source/WebCore/ChangeLog (243089 => 243090)
--- trunk/Source/WebCore/ChangeLog 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/ChangeLog 2019-03-18 19:18:50 UTC (rev 243090)
@@ -1,5 +1,31 @@
2019-03-18 Justin Fan <justin_...@apple.com>
+ [Web GPU] GPUAdapter.createDevice -> GPUAdapter.requestDevice
+ https://bugs.webkit.org/show_bug.cgi?id=195781
+
+ Reviewed by Myles C. Maxfield.
+
+ A Web GPU device is now acquired via a promise returned from GPUAdapter.requestDevice().
+
+ Existing tests updated for new behavior.
+
+ * Modules/webgpu/WebGPUAdapter.cpp:
+ (WebCore::WebGPUAdapter::requestDevice const):
+ (WebCore::WebGPUAdapter::createDevice): Deleted.
+ * Modules/webgpu/WebGPUAdapter.h:
+ * Modules/webgpu/WebGPUAdapter.idl:
+ * Modules/webgpu/WebGPUDevice.cpp:
+ (WebCore::WebGPUDevice::tryCreate):
+ (WebCore::WebGPUDevice::WebGPUDevice):
+ (WebCore::WebGPUDevice::create): Deleted.
+ * Modules/webgpu/WebGPUDevice.h:
+ * platform/graphics/gpu/GPUDevice.h:
+ * platform/graphics/gpu/cocoa/GPUDeviceMetal.mm:
+ (WebCore::GPUDevice::tryCreate):
+ (WebCore::GPUDevice::create): Deleted.
+
+2019-03-18 Justin Fan <justin_...@apple.com>
+
[Web GPU] API updates: GPUTexture.createDefaultView and type-safe GPURenderPassEncoder.setPipeline
https://bugs.webkit.org/show_bug.cgi?id=195896
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp (243089 => 243090)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp 2019-03-18 19:18:50 UTC (rev 243090)
@@ -28,8 +28,8 @@
#if ENABLE(WEBGPU)
+#include "JSWebGPUDevice.h"
#include "ScriptExecutionContext.h"
-#include "WebGPUDevice.h"
namespace WebCore {
@@ -43,9 +43,12 @@
{
}
-RefPtr<WebGPUDevice> WebGPUAdapter::createDevice()
+void WebGPUAdapter::requestDevice(DeviceRequestPromise&& promise) const
{
- return WebGPUDevice::create(*this);
+ if (auto device = WebGPUDevice::tryCreate(*this))
+ promise.resolve(device.releaseNonNull());
+ else
+ promise.reject();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.h (243089 => 243090)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.h 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.h 2019-03-18 19:18:50 UTC (rev 243090)
@@ -28,9 +28,10 @@
#if ENABLE(WEBGPU)
#include "GPURequestAdapterOptions.h"
+#include "JSDOMPromiseDeferred.h"
#include <wtf/Optional.h>
+#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
namespace WebCore {
@@ -41,7 +42,8 @@
public:
static Ref<WebGPUAdapter> create(Optional<GPURequestAdapterOptions>&&);
- RefPtr<WebGPUDevice> createDevice();
+ using DeviceRequestPromise = DOMPromiseDeferred<IDLInterface<WebGPUDevice>>;
+ void requestDevice(DeviceRequestPromise&&) const;
Optional<GPURequestAdapterOptions> options() const { return m_options; }
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.idl (243089 => 243090)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.idl 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.idl 2019-03-18 19:18:50 UTC (rev 243090)
@@ -33,5 +33,6 @@
// readonly attribute WebGPUExtensions extensions;
// readonly attribute WebGPULimits limits; Don't expose higher limits for now.
- WebGPUDevice createDevice(/*WebGPUDeviceDescriptor descriptor*/);
+ // May reject with DOMException // TODO: DOMException("OperationError")?
+ Promise<WebGPUDevice> requestDevice(/*GPUDeviceDescriptor descriptor*/);
};
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (243089 => 243090)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp 2019-03-18 19:18:50 UTC (rev 243090)
@@ -63,18 +63,17 @@
namespace WebCore {
-RefPtr<WebGPUDevice> WebGPUDevice::create(Ref<WebGPUAdapter>&& adapter)
+RefPtr<WebGPUDevice> WebGPUDevice::tryCreate(Ref<const WebGPUAdapter>&& adapter)
{
- if (auto device = GPUDevice::create(adapter->options()))
+ if (auto device = GPUDevice::tryCreate(adapter->options()))
return adoptRef(new WebGPUDevice(WTFMove(adapter), device.releaseNonNull()));
return nullptr;
}
-WebGPUDevice::WebGPUDevice(Ref<WebGPUAdapter>&& adapter, Ref<GPUDevice>&& device)
+WebGPUDevice::WebGPUDevice(Ref<const WebGPUAdapter>&& adapter, Ref<GPUDevice>&& device)
: m_adapter(WTFMove(adapter))
, m_device(WTFMove(device))
{
- UNUSED_PARAM(m_adapter);
}
Ref<WebGPUBuffer> WebGPUDevice::createBuffer(GPUBufferDescriptor&& descriptor) const
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h (243089 => 243090)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h 2019-03-18 19:18:50 UTC (rev 243090)
@@ -60,7 +60,7 @@
class WebGPUDevice : public RefCounted<WebGPUDevice> {
public:
- static RefPtr<WebGPUDevice> create(Ref<WebGPUAdapter>&&);
+ static RefPtr<WebGPUDevice> tryCreate(Ref<const WebGPUAdapter>&&);
const WebGPUAdapter& adapter() const { return m_adapter.get(); }
const GPUDevice& device() const { return m_device.get(); }
@@ -83,9 +83,9 @@
RefPtr<WebGPUQueue> getQueue() const;
private:
- WebGPUDevice(Ref<WebGPUAdapter>&&, Ref<GPUDevice>&&);
+ WebGPUDevice(Ref<const WebGPUAdapter>&&, Ref<GPUDevice>&&);
- Ref<WebGPUAdapter> m_adapter;
+ Ref<const WebGPUAdapter> m_adapter;
Ref<GPUDevice> m_device;
mutable RefPtr<WebGPUQueue> m_queue;
};
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h (243089 => 243090)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h 2019-03-18 19:18:50 UTC (rev 243090)
@@ -61,7 +61,7 @@
class GPUDevice : public RefCounted<GPUDevice>, public CanMakeWeakPtr<GPUDevice> {
public:
- static RefPtr<GPUDevice> create(Optional<GPURequestAdapterOptions>&&);
+ static RefPtr<GPUDevice> tryCreate(Optional<GPURequestAdapterOptions>&&);
RefPtr<GPUBuffer> tryCreateBuffer(GPUBufferDescriptor&&);
RefPtr<GPUTexture> tryCreateTexture(GPUTextureDescriptor&&) const;
Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm (243089 => 243090)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm 2019-03-18 19:07:56 UTC (rev 243089)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm 2019-03-18 19:18:50 UTC (rev 243090)
@@ -36,7 +36,7 @@
namespace WebCore {
-RefPtr<GPUDevice> GPUDevice::create(Optional<GPURequestAdapterOptions>&& options)
+RefPtr<GPUDevice> GPUDevice::tryCreate(Optional<GPURequestAdapterOptions>&& options)
{
RetainPtr<MTLDevice> devicePtr;