Skip to content

Commit

Permalink
[WebGPU] GPUQueueDescriptor.idl is missing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=272554
<radar://126298421>

Reviewed by Tadeu Zagallo.

Add GPUQueueDescriptor which simply sets the label on the GPUQueue.

* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Modules/WebGPU/GPUDeviceDescriptor.h:
* Source/WebCore/Modules/WebGPU/GPUDeviceDescriptor.idl:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:

* Source/WebCore/Modules/WebGPU/GPUQueueDescriptor.h: Added.
* Source/WebCore/Modules/WebGPU/GPUQueueDescriptor.idl: Added.

Canonical link: https://commits.webkit.org/278365@main
  • Loading branch information
mwyrzykowski committed May 4, 2024
1 parent dc88c33 commit d729147
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 5 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,7 @@ list(APPEND WebCore_NON_SVG_IDL_FILES
Modules/WebGPU/GPUQuerySetDescriptor.idl
Modules/WebGPU/GPUQueryType.idl
Modules/WebGPU/GPUQueue.idl
Modules/WebGPU/GPUQueueDescriptor.idl
Modules/WebGPU/GPURenderBundle.idl
Modules/WebGPU/GPURenderBundleDescriptor.idl
Modules/WebGPU/GPURenderBundleEncoder.idl
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/DerivedSources-input.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ $(PROJECT_DIR)/Modules/WebGPU/GPUQuerySet.idl
$(PROJECT_DIR)/Modules/WebGPU/GPUQuerySetDescriptor.idl
$(PROJECT_DIR)/Modules/WebGPU/GPUQueryType.idl
$(PROJECT_DIR)/Modules/WebGPU/GPUQueue.idl
$(PROJECT_DIR)/Modules/WebGPU/GPUQueueDescriptor.idl
$(PROJECT_DIR)/Modules/WebGPU/GPURenderBundle.idl
$(PROJECT_DIR)/Modules/WebGPU/GPURenderBundleDescriptor.idl
$(PROJECT_DIR)/Modules/WebGPU/GPURenderBundleEncoder.idl
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/DerivedSources-output.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUQueryType.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUQueryType.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUQueue.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUQueue.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUQueueDescriptor.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUQueueDescriptor.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURenderBundle.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURenderBundle.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURenderBundleDescriptor.cpp
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ JS_BINDING_IDLS := \
$(WebCore)/Modules/WebGPU/GPUQuerySetDescriptor.idl \
$(WebCore)/Modules/WebGPU/GPUQueryType.idl \
$(WebCore)/Modules/WebGPU/GPUQueue.idl \
$(WebCore)/Modules/WebGPU/GPUQueueDescriptor.idl \
$(WebCore)/Modules/WebGPU/GPURenderBundle.idl \
$(WebCore)/Modules/WebGPU/GPURenderBundleDescriptor.idl \
$(WebCore)/Modules/WebGPU/GPURenderBundleEncoder.idl \
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/Modules/WebGPU/GPUAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void GPUAdapter::requestDevice(ScriptExecutionContext& scriptExecutionContext, c
if (!device.get())
promise.reject(Exception(ExceptionCode::OperationError));
else {
Ref<GPUDevice> gpuDevice = GPUDevice::create(scriptExecutionContextRef.ptr(), device.releaseNonNull());
auto queueLabel = deviceDescriptor->defaultQueue.label;
Ref<GPUDevice> gpuDevice = GPUDevice::create(scriptExecutionContextRef.ptr(), device.releaseNonNull(), deviceDescriptor ? WTFMove(queueLabel) : ""_s);
gpuDevice->suspendIfNeeded();
promise.resolve(WTFMove(gpuDevice));
}
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/Modules/WebGPU/GPUDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ namespace WebCore {

WTF_MAKE_ISO_ALLOCATED_IMPL(GPUDevice);

GPUDevice::GPUDevice(ScriptExecutionContext* scriptExecutionContext, Ref<WebGPU::Device>&& backing)
GPUDevice::GPUDevice(ScriptExecutionContext* scriptExecutionContext, Ref<WebGPU::Device>&& backing, String&& queueLabel)
: ActiveDOMObject { scriptExecutionContext }
, m_lostPromise(makeUniqueRef<LostPromise>())
, m_backing(WTFMove(backing))
, m_queue(GPUQueue::create(Ref { m_backing->queue() }))
, m_autoPipelineLayout(createAutoPipelineLayout())
{
m_queue->setLabel(WTFMove(queueLabel));
}

GPUDevice::~GPUDevice() = default;
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/Modules/WebGPU/GPUDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ struct GPUTextureDescriptor;
class GPUDevice : public RefCounted<GPUDevice>, public ActiveDOMObject, public EventTarget {
WTF_MAKE_ISO_ALLOCATED(GPUDevice);
public:
static Ref<GPUDevice> create(ScriptExecutionContext* scriptExecutionContext, Ref<WebGPU::Device>&& backing)
static Ref<GPUDevice> create(ScriptExecutionContext* scriptExecutionContext, Ref<WebGPU::Device>&& backing, String&& queueLabel)
{
return adoptRef(*new GPUDevice(scriptExecutionContext, WTFMove(backing)));
return adoptRef(*new GPUDevice(scriptExecutionContext, WTFMove(backing), WTFMove(queueLabel)));
}

virtual ~GPUDevice();
Expand Down Expand Up @@ -143,7 +143,7 @@ class GPUDevice : public RefCounted<GPUDevice>, public ActiveDOMObject, public E
WeakPtr<GPUExternalTexture> takeExternalTextureForVideoElement(const HTMLVideoElement&);

private:
GPUDevice(ScriptExecutionContext*, Ref<WebGPU::Device>&&);
GPUDevice(ScriptExecutionContext*, Ref<WebGPU::Device>&&, String&& queueLabel);

// FIXME: We probably need to override more methods to make this work properly.
RefPtr<GPUPipelineLayout> createAutoPipelineLayout();
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/Modules/WebGPU/GPUDeviceDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "GPUFeatureName.h"
#include "GPUObjectDescriptorBase.h"
#include "GPUQueueDescriptor.h"
#include "WebGPUDeviceDescriptor.h"
#include <cstdint>
#include <wtf/HashMap.h>
Expand All @@ -50,6 +51,7 @@ struct GPUDeviceDescriptor : public GPUObjectDescriptorBase {

Vector<GPUFeatureName> requiredFeatures;
Vector<KeyValuePair<String, uint64_t>> requiredLimits;
GPUQueueDescriptor defaultQueue;
};

}
1 change: 1 addition & 0 deletions Source/WebCore/Modules/WebGPU/GPUDeviceDescriptor.idl
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ typedef [EnforceRange] unsigned long long GPUSize64;
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
sequence<GPUFeatureName> requiredFeatures = [];
record<DOMString, GPUSize64> requiredLimits;
GPUQueueDescriptor defaultQueue = {};
};
35 changes: 35 additions & 0 deletions Source/WebCore/Modules/WebGPU/GPUQueueDescriptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2021-2023 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 "GPUObjectDescriptorBase.h"

namespace WebCore {

struct GPUQueueDescriptor : public GPUObjectDescriptorBase {
};

}
32 changes: 32 additions & 0 deletions Source/WebCore/Modules/WebGPU/GPUQueueDescriptor.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2021-2023 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://gpuweb.github.io/gpuweb/#dictdef-gpuqueuedescriptor

[
EnabledBySetting=WebGPUEnabled
]
dictionary GPUQueueDescriptor : GPUObjectDescriptorBase {
};
1 change: 1 addition & 0 deletions Source/WebCore/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3688,6 +3688,7 @@ JSGPUQuerySet.cpp
JSGPUQuerySetDescriptor.cpp
JSGPUQueryType.cpp
JSGPUQueue.cpp
JSGPUQueueDescriptor.cpp
JSGPURenderBundle.cpp
JSGPURenderBundleDescriptor.cpp
JSGPURenderBundleEncoder.cpp
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7108,6 +7108,8 @@
0C3F1F5910C8871200D72CE1 /* WebGLUniformLocation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLUniformLocation.idl; sourceTree = "<group>"; };
0C45342510CDBBFA00869157 /* JSWebGLUniformLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLUniformLocation.cpp; sourceTree = "<group>"; };
0C45342610CDBBFA00869157 /* JSWebGLUniformLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLUniformLocation.h; sourceTree = "<group>"; };
0D2F291B2BC84EA100872B23 /* GPUQueueDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUQueueDescriptor.h; sourceTree = "<group>"; };
0D2F291C2BC84EA100872B23 /* GPUQueueDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUQueueDescriptor.idl; sourceTree = "<group>"; };
0D431A7C2B5A397C00864655 /* DigitalCredential.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DigitalCredential.h; sourceTree = "<group>"; };
0D431A7E2B5A3A9700864655 /* DigitalCredential.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DigitalCredential.idl; sourceTree = "<group>"; };
0D431A7F2B5A3A9700864655 /* IdentityRequestProvider.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IdentityRequestProvider.idl; sourceTree = "<group>"; };
Expand Down Expand Up @@ -22776,6 +22778,8 @@
1C66A6EC2A4F78120086DB6F /* GPUQueue.cpp */,
1C66A7E32A4F78610086DB6F /* GPUQueue.h */,
1C66A7342A4F78270086DB6F /* GPUQueue.idl */,
0D2F291B2BC84EA100872B23 /* GPUQueueDescriptor.h */,
0D2F291C2BC84EA100872B23 /* GPUQueueDescriptor.idl */,
1C66A6FE2A4F78170086DB6F /* GPURenderBundle.cpp */,
1C66A7682A4F783C0086DB6F /* GPURenderBundle.h */,
1C66A8002A4F78690086DB6F /* GPURenderBundle.idl */,
Expand Down

0 comments on commit d729147

Please sign in to comment.