← 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());

WebKit의 WebGPU는 여러 계층으로 나뉘어 있습니다. 먼저 WebCore에서 JS에 노출되는 GPU* 클래스가 descriptor를 backing type으로 변환합니다. GPU process 모델에서는 이 값이 Web Process의 RemoteXProxy 객체를 거쳐 IPC로 직렬화됩니다. 이후 GPU Process의 RemoteX 객체가 Metal 구현 위에서 이를 다시 실행합니다. 이때 권한이 높은 쪽은 GPU Process입니다. 그래서 IPC converter, descriptor decoding, handle을 객체로 변환하는 과정이 장악된 Web Process로부터 GPU Process를 보호하는 방어선 역할을 합니다.

이 commit에서는 WebCore와 WebKit이 WebGPU와 통신하는 방식이 변경되었습니다. 기존에는 C API, InternalAPI 추상 클래스, *Impl wrapper를 거쳤습니다. 이제는 WebGPUCpp.h에 정의된 C++ API(WebGPU::X)를 직접 사용합니다. 그 결과 WebCore::GPUX는 Ref<WebGPU::X>를 보유하고, RemoteXProxy는 WebGPU::X를 구현하며, RemoteX는 WebGPU::Metal::X를 감싸도록 바뀌었습니다. 한편 InternalAPI/, WebGPUPtr.h, ConvertToBackingContext helper, 그리고 isRemoteXProxy()/isXImpl() 검사는 모두 삭제되었습니다.

Web Process와 GPU Process 사이의 WebGPU 경계가 새로 작성되었습니다. 또한 알 수 없는 buffer-usage 및 color-write-mask bit는 더 이상 조용히 버려지지 않고, Invalid로 처리되어 validation 단계에서 실패합니다.