← All reports

WebGPU IPC texel-copy layout, adapter options and limits serialization (refactor)

Component: WebKit WebGPU IPC | cfba6db

Source/WebKit/Shared/WebGPU/WebGPURequestAdapterOptions.h

-struct RequestAdapterOptions {
- std::optional<::WebGPU::PowerPreference> powerPreference;
- bool forceFallbackAdapter { false };
- bool xrCompatible { false };
-};
+using RequestAdapterOptions = ::WebGPU::RequestAdapterOptions;

Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp

- auto convertedOptions = objectHeap->convertFromBacking(options);
- ASSERT(convertedOptions);
- if (!convertedOptions) {
- callback(std::nullopt);
- return;
- }
- backing->requestAdapter(*convertedOptions, ...
+ backing->requestAdapter(options, ...

WebGPU는 out-of-process로 동작합니다. WebContent 쪽 proxy가 IPC를 보내면 GPU process의 Remote* 객체가 이를 받는데, 이 객체들은 실제 Metal 기반 ::WebGPU:: API를 감싸고 있습니다. 이전에는 descriptor마다 대응되는 WebKit::WebGPU:: struct가 별도로 존재했고, convertFromBacking으로 필드를 하나씩 복사했습니다. 다만 이번에 다루는 타입들에서는 converter가 항상 성공했습니다. 이번 commit에서 ImageDataLayout, RequestAdapterOptions, SupportedLimits는 각각 ::WebGPU::TexelCopyBufferLayout, ::WebGPU::RequestAdapterOptions, ::WebGPU::Limits의 alias로 변경되었습니다. 결과적으로 IPC에서 직접 decode됩니다. converter 파일 세 개도 삭제되었습니다. 함께 RemoteGPU::requestAdapter의 사용되지 않던 실패 경로와 RemoteQueue::writeTexture의 layout 변환도 제거되었습니다.

중복된 IPC struct 세 개와 그 converter가 제거되면서, wire type이 C++ API를 자동으로 따라가게 되었고 validation은 여전히 generated decoder와 backend가 담당합니다. 기존 converter는 단순 복사만 수행했기 때문에 동작은 그대로 유지됩니다.

Narrow: 이 struct들은 이제 C++ API 타입 쪽에서 CustomHeader와 함께 선언됩니다. 또한 ImageCopyBuffer는 .serialization.in에서 ::WebGPU::TexelCopyBufferLayout을 상속합니다. 먼저 generated decoder가 powerPreference 같은 enum 필드를 여전히 검증하는지 확인할 필요가 있습니다. ::WebGPU::Limits의 필드 타입과 width가 기존 encoding과 일치하는지도 살펴봐야 합니다. 한편 offset + bytesPerRow * rows 범위는 converter에서도 검사된 적이 없습니다. 따라서 backing writeTexture에서 이 값이 data span과 대조되는지 확인해야 합니다. regression이 아니라 원래부터 존재하던 점검 대상입니다. Wider: backend가 decode 가능한 모든 requestAdapter option 조합을 처리하는지 확인이 필요합니다. 이때 release build에서 compile out되는 ASSERT에 의존하지 않는지가 핵심입니다. 또한 Limits에 추가되는 필드는 이제 자동으로 serialize되므로, requiredLimits가 device 생성 과정에서 어떻게 전달되는지 점검해야 합니다. 이번 commit에서는 DeviceDescriptor.cpp도 함께 수정되었습니다.