WebGPUSerialize.h (2494B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef WEBGPU_SERIALIZE_H_ 7 #define WEBGPU_SERIALIZE_H_ 8 9 #include "WebGPUTypes.h" 10 #include "ipc/EnumSerializer.h" 11 #include "ipc/IPCMessageUtils.h" 12 #include "mozilla/dom/BindingIPCUtils.h" 13 #include "mozilla/dom/WebGPUBinding.h" 14 #include "mozilla/webgpu/ffi/wgpu.h" 15 16 namespace IPC { 17 18 #define DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, guard) \ 19 template <> \ 20 struct ParamTraits<something> \ 21 : public ContiguousEnumSerializer<something, something(0), guard> {} 22 23 #define DEFINE_IPC_SERIALIZER_DOM_ENUM(something) \ 24 template <> \ 25 struct ParamTraits<something> \ 26 : public mozilla::dom::WebIDLEnumSerializer<something> {} 27 #define DEFINE_IPC_SERIALIZER_FFI_ENUM(something) \ 28 DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something##_Sentinel) 29 30 // - 31 32 DEFINE_IPC_SERIALIZER_DOM_ENUM(mozilla::dom::GPUErrorFilter); 33 DEFINE_IPC_SERIALIZER_DOM_ENUM(mozilla::dom::GPUPowerPreference); 34 35 DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUHostMap); 36 37 DEFINE_IPC_SERIALIZER_WITHOUT_FIELDS(mozilla::dom::GPUCommandBufferDescriptor); 38 39 DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::GPURequestAdapterOptions, 40 mPowerPreference, mForceFallbackAdapter); 41 42 DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::GPUBufferDescriptor, mSize, 43 mUsage, mMappedAtCreation); 44 45 DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::PopErrorScopeResult, 46 resultType, message); 47 48 DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::WebGPUCompilationMessage, 49 message, lineNum, linePos, offset, length); 50 51 #undef DEFINE_IPC_SERIALIZER_FFI_ENUM 52 #undef DEFINE_IPC_SERIALIZER_DOM_ENUM 53 #undef DEFINE_IPC_SERIALIZER_ENUM_GUARD 54 55 // - 56 57 template <> 58 struct ParamTraits<mozilla::webgpu::PopErrorScopeResultType> 59 : public ContiguousEnumSerializerInclusive< 60 mozilla::webgpu::PopErrorScopeResultType, 61 mozilla::webgpu::PopErrorScopeResultType{0}, 62 mozilla::webgpu::PopErrorScopeResultType::_LAST> {}; 63 64 } // namespace IPC 65 66 #endif // WEBGPU_SERIALIZE_H_