Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e21fe67639f696ba546c4ed59a041c1163ce9a54
https://github.com/WebKit/WebKit/commit/e21fe67639f696ba546c4ed59a041c1163ce9a54
Author: Kimmo Kinnunen <[email protected]>
Date: 2026-09-28 (Mon, 28 Sep 2026)
Changed paths:
M Source/WebGPU/CMakeLists.txt
M Source/WebGPU/WebGPU.xcodeproj/project.pbxproj
M Source/WebGPU/WebGPU/APIConversions.h
M Source/WebGPU/WebGPU/Adapter.h
M Source/WebGPU/WebGPU/Adapter.mm
M Source/WebGPU/WebGPU/BindGroup.h
M Source/WebGPU/WebGPU/BindGroup.mm
M Source/WebGPU/WebGPU/BindGroupLayout.h
M Source/WebGPU/WebGPU/BindGroupLayout.mm
M Source/WebGPU/WebGPU/BindableResource.h
M Source/WebGPU/WebGPU/Buffer.h
M Source/WebGPU/WebGPU/Buffer.mm
M Source/WebGPU/WebGPU/Buffer.swift
M Source/WebGPU/WebGPU/CMakeLists.txt
M Source/WebGPU/WebGPU/CommandBuffer.h
M Source/WebGPU/WebGPU/CommandBuffer.mm
M Source/WebGPU/WebGPU/CommandEncoder.h
M Source/WebGPU/WebGPU/CommandEncoder.mm
M Source/WebGPU/WebGPU/CommandEncoder.swift
M Source/WebGPU/WebGPU/CommandsMixin.h
M Source/WebGPU/WebGPU/CommandsMixin.mm
M Source/WebGPU/WebGPU/ComputePassEncoder.h
M Source/WebGPU/WebGPU/ComputePassEncoder.mm
M Source/WebGPU/WebGPU/ComputePipeline.h
M Source/WebGPU/WebGPU/ComputePipeline.mm
M Source/WebGPU/WebGPU/CxxBridging.h
M Source/WebGPU/WebGPU/Device.h
M Source/WebGPU/WebGPU/Device.mm
M Source/WebGPU/WebGPU/ExternalTexture.h
M Source/WebGPU/WebGPU/ExternalTexture.mm
M Source/WebGPU/WebGPU/HardwareCapabilities.h
M Source/WebGPU/WebGPU/HardwareCapabilities.mm
M Source/WebGPU/WebGPU/Instance.h
M Source/WebGPU/WebGPU/Instance.mm
M Source/WebGPU/WebGPU/Internal/module.modulemap
M Source/WebGPU/WebGPU/IsValidToUseWith.h
M Source/WebGPU/WebGPU/Pipeline.h
M Source/WebGPU/WebGPU/Pipeline.mm
M Source/WebGPU/WebGPU/PipelineLayout.h
M Source/WebGPU/WebGPU/PipelineLayout.mm
M Source/WebGPU/WebGPU/PresentationContext.h
M Source/WebGPU/WebGPU/PresentationContext.mm
M Source/WebGPU/WebGPU/PresentationContextIOSurface.h
M Source/WebGPU/WebGPU/PresentationContextIOSurface.mm
M Source/WebGPU/WebGPU/QuerySet.h
M Source/WebGPU/WebGPU/QuerySet.mm
M Source/WebGPU/WebGPU/Queue.h
M Source/WebGPU/WebGPU/Queue.mm
M Source/WebGPU/WebGPU/Queue.swift
M Source/WebGPU/WebGPU/RenderBundle.h
M Source/WebGPU/WebGPU/RenderBundle.mm
M Source/WebGPU/WebGPU/RenderBundleEncoder.h
M Source/WebGPU/WebGPU/RenderBundleEncoder.mm
M Source/WebGPU/WebGPU/RenderPassEncoder.h
M Source/WebGPU/WebGPU/RenderPassEncoder.mm
M Source/WebGPU/WebGPU/RenderPipeline.h
M Source/WebGPU/WebGPU/RenderPipeline.mm
M Source/WebGPU/WebGPU/Sampler.h
M Source/WebGPU/WebGPU/Sampler.mm
M Source/WebGPU/WebGPU/ShaderModule.h
M Source/WebGPU/WebGPU/ShaderModule.mm
M Source/WebGPU/WebGPU/ShaderStage.h
M Source/WebGPU/WebGPU/Sources.txt
M Source/WebGPU/WebGPU/Texture.h
M Source/WebGPU/WebGPU/Texture.mm
M Source/WebGPU/WebGPU/TextureOrTextureView.h
M Source/WebGPU/WebGPU/TextureView.h
M Source/WebGPU/WebGPU/TextureView.mm
A Source/WebGPU/WebGPU/WebGPUCppBridge.h
A Source/WebGPU/WebGPU/WebGPUCppBridge.mm
A Source/WebGPU/WebGPU/WebGPUCppConversions.h
M Source/WebGPU/WebGPU/WorkAround173516139.h
M Source/WebGPU/WebGPU/XRBinding.h
M Source/WebGPU/WebGPU/XRBinding.mm
M Source/WebGPU/WebGPU/XRProjectionLayer.h
M Source/WebGPU/WebGPU/XRProjectionLayer.mm
M Source/WebGPU/WebGPU/XRSubImage.h
M Source/WebGPU/WebGPU/XRSubImage.mm
M Source/WebGPU/WebGPU/XRView.h
M Source/WebGPU/WebGPU/XRView.mm
A Source/WebGPU/WebGPUCpp.h
Log Message:
-----------
WebGPU: Add WebGPU C++ API skeleton and move implementation to WebGPU::Metal
https://bugs.webkit.org/show_bug.cgi?id=325288
rdar://188399751
Reviewed by Mike Wyrzykowski.
This is the foundation step of making the WebGPU C++ (WebGPUCpp.h) API
the interface between WebCore / WebKit and the WebGPU implementations,
instead of the WGPU C API. There is no behaviour change.
The WebGPUCpp.h API will serve two purposes:
1. Let the WebCore call into WebGPU.framework to invoke the real
implementation, directly with C++ without conversions to unsafe
C API.
2. Let the WebKit IPC implementation reuse the API definition instead
of rewriting it.
This commit adds the C++ API, moves existing implementation to Metal
subnamespace and changes the implementation to use
the API base classes. 1. and 2. are done in future commits.
Move the implementation in Source/WebGPU/WebGPU from namespace ::WebGPU
to namespace ::WebGPU::Metal, so that namespace ::WebGPU is free for the
C++ API. This is mechanical, including the Swift sources (WebGPU.X ->
WebGPU.Metal.X). The functions of the generated WebGPUSwift-Generated.h
stay in namespace WebGPU, and the C++ callers in WebGPU::Metal find them
by unqualified lookup. The SpanUInt8 / SpanConstUInt8 typedefs of
CxxBridgingPublic.h stay in namespace ::WebGPU, too. The WGPU*Impl
structs, the C API and namespace WGSL are unchanged.
Add the C++ API header Source/WebGPU/WebGPUCpp.h, <WebGPU/WebGPUCpp.h>.
It sits outside the Metal-only Source/WebGPU/WebGPU directory. On Cocoa,
it is a private header of WebGPU.framework (CMake and Xcode) and is in
the WebGPU_Private module through the PrivateHeaders umbrella. On other
ports that enable WebGPU, Source/WebGPU/CMakeLists.txt copies it into
the WebGPU private headers directory. It includes only WTF headers, no
Objective-C or Metal. Its content is inside #ifdef __cplusplus, like
CxxBridgingPublic.h, because the WebGPU_Private module includes every
private header. It has:
- all 37 enums of WebCore/Modules/WebGPU/InternalAPI, with the same
enumerators and values, so that WebCore can alias them later without
changing IPC. The flag enums (BufferUsage, ColorWrite, MapMode,
ShaderStage, TextureUsage) are used as OptionSet; ColorWrite has no
combined All value.
- the value types WebGPU::Extent3D, WebGPU::Origin3D, WebGPU::Color and
WebGPU::Limits. Limits is the struct replacing the stored WGPULimits
above, moved from HardwareCapabilities.h.
- abstract base classes for the 27 object types: Adapter, BindGroup,
BindGroupLayout, Buffer, CommandBuffer, CommandEncoder,
ComputePassEncoder, ComputePipeline, Device, ExternalTexture,
Instance, PipelineLayout, PresentationContext, QuerySet, Queue,
RenderBundle, RenderBundleEncoder, RenderPassEncoder, RenderPipeline,
Sampler, ShaderModule, Texture, TextureView, XRBinding,
XRProjectionLayer, XRSubImage and XRView. Each derives from
ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr, has a virtual
destructor, setLabel(String&&) and isValid(), and is a
SWIFT_SHARED_REFERENCE with global refWebGPUX() / derefWebGPUX()
functions, so that Swift can use Ref<WebGPU::X>.
The WebGPU::Metal classes derive from the C++ API base classes,
for example class WebGPU::Metal::Buffer final : public WebGPU::Buffer,
public WGPUBufferImpl, ... They drop their own RefCounted,
RefCountedAndCanMakeWeakPtr, ThreadSafeRefCounted or
ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr base. The ones that were
single threaded (all except Buffer, CommandBuffer, Device, Instance and
Queue) now have atomic reference counts, and the WeakPtrs to them became
ThreadSafeWeakPtrs: BindGroupLayout::m_autogeneratedPipelineLayout,
Texture::m_textureViews, RenderBundleEncoder::m_renderPassEncoder,
RenderBundleICBWithResources.pipeline and a local in
Buffer::indirectBufferInvalidated(). PresentationContextIOSurface holds
a RefPtr instead of a WeakPtr to the texture it reads back. The existing
setLabel() and isValid() members override the API ones; Adapter,
ExternalTexture, Instance and PresentationContext get an empty
setLabel(). PresentationContext stays non-final, because
PresentationContextIOSurface derives from it. The Metal classes keep
their SWIFT_SHARED_REFERENCE annotations. Because the annotation of the
API base is inherited, every WebGPU::Metal class is now a Swift foreign
reference type, and Swift needs the definitions of the ones it reaches
through forward declarations, so CommandEncoder.swift imports their
WebGPU_Internal submodules.
Add WebGPUCppConversions.h with the conversions between the WGPU enums
and flags and the C++ API ones: constexpr switch functions
fromAPI(WGPUx) -> std::optional<WebGPU::X> and toAPI(WebGPU::X) ->
WGPUx, and xFromAPI(WGPUFlags) / toAPI(OptionSet<WebGPU::X>) for flags.
fromAPI() returns std::nullopt for values without an equivalent, such as
the _Undefined values and unknown bits. There are no callers yet; P2
uses them in the wgpu* entry points.
Add the temporary transition bridge <WebGPU/WebGPUCppBridge.h>: exported
WebGPU::X& WebGPU::fromAPI(WGPUx) and WGPUx WebGPU::toAPI(WebGPU::X&),
one static cast each, for WebCore to exchange objects between converted
and unconverted code while it moves to the C++ API. There are no callers
yet.
* Source/WebGPU/CMakeLists.txt:
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
* Source/WebGPU/WebGPU/APIConversions.h:
* Source/WebGPU/WebGPU/Adapter.h:
* Source/WebGPU/WebGPU/Adapter.mm:
* Source/WebGPU/WebGPU/BindGroup.h:
* Source/WebGPU/WebGPU/BindGroup.mm:
* Source/WebGPU/WebGPU/BindGroupLayout.h:
* Source/WebGPU/WebGPU/BindGroupLayout.mm:
* Source/WebGPU/WebGPU/BindableResource.h:
* Source/WebGPU/WebGPU/Buffer.h:
* Source/WebGPU/WebGPU/Buffer.mm:
* Source/WebGPU/WebGPU/Buffer.swift:
* Source/WebGPU/WebGPU/CMakeLists.txt:
* Source/WebGPU/WebGPU/CommandBuffer.h:
* Source/WebGPU/WebGPU/CommandBuffer.mm:
* Source/WebGPU/WebGPU/CommandEncoder.h:
* Source/WebGPU/WebGPU/CommandEncoder.mm:
* Source/WebGPU/WebGPU/CommandEncoder.swift:
* Source/WebGPU/WebGPU/CommandsMixin.h:
* Source/WebGPU/WebGPU/CommandsMixin.mm:
* Source/WebGPU/WebGPU/ComputePassEncoder.h:
* Source/WebGPU/WebGPU/ComputePassEncoder.mm:
* Source/WebGPU/WebGPU/ComputePipeline.h:
* Source/WebGPU/WebGPU/ComputePipeline.mm:
* Source/WebGPU/WebGPU/CxxBridging.h:
* Source/WebGPU/WebGPU/Device.h:
* Source/WebGPU/WebGPU/Device.mm:
* Source/WebGPU/WebGPU/ExternalTexture.h:
* Source/WebGPU/WebGPU/ExternalTexture.mm:
* Source/WebGPU/WebGPU/HardwareCapabilities.h:
* Source/WebGPU/WebGPU/HardwareCapabilities.mm:
* Source/WebGPU/WebGPU/Instance.h:
* Source/WebGPU/WebGPU/Instance.mm:
* Source/WebGPU/WebGPU/Internal/module.modulemap:
* Source/WebGPU/WebGPU/IsValidToUseWith.h:
* Source/WebGPU/WebGPU/Pipeline.h:
* Source/WebGPU/WebGPU/Pipeline.mm:
* Source/WebGPU/WebGPU/PipelineLayout.h:
* Source/WebGPU/WebGPU/PipelineLayout.mm:
* Source/WebGPU/WebGPU/PresentationContext.h:
* Source/WebGPU/WebGPU/PresentationContext.mm:
* Source/WebGPU/WebGPU/PresentationContextIOSurface.h:
* Source/WebGPU/WebGPU/PresentationContextIOSurface.mm:
* Source/WebGPU/WebGPU/QuerySet.h:
* Source/WebGPU/WebGPU/QuerySet.mm:
* Source/WebGPU/WebGPU/Queue.h:
* Source/WebGPU/WebGPU/Queue.mm:
* Source/WebGPU/WebGPU/Queue.swift:
* Source/WebGPU/WebGPU/RenderBundle.h:
* Source/WebGPU/WebGPU/RenderBundle.mm:
* Source/WebGPU/WebGPU/RenderBundleEncoder.h:
* Source/WebGPU/WebGPU/RenderBundleEncoder.mm:
* Source/WebGPU/WebGPU/RenderPassEncoder.h:
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
* Source/WebGPU/WebGPU/RenderPipeline.h:
* Source/WebGPU/WebGPU/RenderPipeline.mm:
* Source/WebGPU/WebGPU/Sampler.h:
* Source/WebGPU/WebGPU/Sampler.mm:
* Source/WebGPU/WebGPU/ShaderModule.h:
* Source/WebGPU/WebGPU/ShaderModule.mm:
* Source/WebGPU/WebGPU/ShaderStage.h:
* Source/WebGPU/WebGPU/Sources.txt:
* Source/WebGPU/WebGPU/Texture.h:
* Source/WebGPU/WebGPU/Texture.mm:
* Source/WebGPU/WebGPU/TextureOrTextureView.h:
* Source/WebGPU/WebGPU/TextureView.h:
* Source/WebGPU/WebGPU/TextureView.mm:
* Source/WebGPU/WebGPU/WebGPUCppBridge.h: Added.
* Source/WebGPU/WebGPU/WebGPUCppBridge.mm: Added.
* Source/WebGPU/WebGPU/WebGPUCppConversions.h: Added.
* Source/WebGPU/WebGPU/XRBinding.h:
* Source/WebGPU/WebGPU/XRBinding.mm:
* Source/WebGPU/WebGPU/XRProjectionLayer.h:
* Source/WebGPU/WebGPU/XRProjectionLayer.mm:
* Source/WebGPU/WebGPU/XRSubImage.h:
* Source/WebGPU/WebGPU/XRSubImage.mm:
* Source/WebGPU/WebGPU/XRView.h:
* Source/WebGPU/WebGPU/XRView.mm:
* Source/WebGPU/WebGPUCpp.h: Added.
Canonical link: https://commits.webkit.org/322061@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications