← All reports

WebCore and WebKit move to the WebGPU C++ API

Component: WebGPU | 668135a

Source/WebCore/Modules/WebGPU/GPU.cpp

-GPU::GPU(Ref<WebGPU::GPU>&& backing)
+GPU::GPU(Ref<WebGPUIntegration>&& backing)
...
- m_backing->requestAdapter(convertToBacking(options), [promise = WTF::move(promise)](RefPtr<WebGPU::Adapter>&& adapter) mutable {
+ m_backing->requestAdapter(convertToBacking(options), [promise = WTF::move(promise), gpu = m_backing](RefPtr<WebGPU::Adapter>&& adapter) mutable {
...
- promise.resolve(GPUAdapter::create(adapter.releaseNonNull()).ptr());
+ promise.resolve(GPUAdapter::create(adapter.releaseNonNull(), WTF::move(gpu)).ptr());

WebGPU in WebKit is layered. The JS-facing GPU* classes in WebCore convert descriptors into backing types. In the GPU-process model those go through RemoteXProxy objects in the Web Process, are serialized over IPC, and are replayed by RemoteX objects in the GPU Process on top of the Metal implementation. The GPU Process is the privileged side. Its IPC converters, descriptor decoding and handle-to-object resolution keep a compromised Web Process from corrupting it.

This commit changes WebCore and WebKit to talk to WebGPU through the C++ API (WebGPU::X, from WebGPUCpp.h) instead of the C API, the InternalAPI abstract classes and the *Impl wrappers. WebCore::GPUX now holds Ref<WebGPU::X>, RemoteXProxy implements WebGPU::X, and RemoteX wraps WebGPU::Metal::X. InternalAPI/, WebGPUPtr.h, the ConvertToBackingContext helpers and the isRemoteXProxy()/isXImpl() checks are deleted.

The Web Process to GPU Process WebGPU boundary is rewritten, and unknown buffer-usage and color-write-mask bits now become Invalid and fail validation instead of being silently dropped.