[wire][server] Update the wire server to use C++ structs when possible. - Now that we have the dawn::wire::* C++ structs, the server can mostly be updated to use the new types, updating a lot of the signatures and removing a slew of no-longer necessary FromAPIs. - This change also adds AsAPIType helper in dawn_platform to expose a unified way to help templating code get the C API types from the C++ one. Bug: 526537254 Change-Id: I3bc1588b15c33cf54ea2a2768af9d8fd820f42f9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/335676 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/generator/templates/dawn/dawn_platform.h.tmpl b/generator/templates/dawn/dawn_platform.h.tmpl index b4600f5..42726e4 100644 --- a/generator/templates/dawn/dawn_platform.h.tmpl +++ b/generator/templates/dawn/dawn_platform.h.tmpl
@@ -292,3 +292,21 @@ // SAFETY: The returned Span has the same lifetime as the input Span. return DAWN_UNSAFE_BUFFERS(dawn::detail::SpanBase<ResultItem, Index, ResultItem*, Extent>(FromAPI(rhs.data()), rhs.size())); } + +namespace detail { +template <typename T> +struct AsAPITypeImpl { + using type = T; +}; +template <typename T> + requires requires { ToAPI(std::declval<T>()); } +struct AsAPITypeImpl<T> { + using type = decltype(ToAPI(std::declval<T>())); +}; +} // namespace detail + +// Helper useful in templating code, especially for MSVC where template deduction fails for some +// overloads sometimes. +template <typename T> +using AsAPIType = typename detail::AsAPITypeImpl<T>::type; +
diff --git a/src/dawn/wire/server/Server.cpp b/src/dawn/wire/server/Server.cpp index 9ba5e8d..2d2bd91 100644 --- a/src/dawn/wire/server/Server.cpp +++ b/src/dawn/wire/server/Server.cpp
@@ -185,7 +185,7 @@ device->handle, {nullptr, [](WGPULoggingType type, WGPUStringView message, void* userdata, void*) { DeviceInfo* info = static_cast<DeviceInfo*>(userdata); - info->server->OnLogging(info->self, type, message); + info->server->OnLogging(info->self, FromAPI(type), FromAPI(message)); info->server->Flush(); }, device->info.get(), nullptr});
diff --git a/src/dawn/wire/server/Server.h b/src/dawn/wire/server/Server.h index b0fb772..6894044 100644 --- a/src/dawn/wire/server/Server.h +++ b/src/dawn/wire/server/Server.h
@@ -36,10 +36,59 @@ #include "src/dawn/common/MutexProtected.h" #include "src/dawn/wire/ChunkedCommandSerializer.h" -namespace dawn::wire::server { - +namespace dawn::wire { +namespace server { class Server; class MemoryTransferService; +} // namespace server + +namespace detail { + +template <typename Target, typename Arg> +Target ConvertFromAPI(Arg&& arg) { + if constexpr (std::is_same_v<Target, std::decay_t<Arg>>) { + return std::forward<Arg>(arg); + } else { + return FromAPI(std::forward<Arg>(arg)); + } +} + +template <auto F, typename _ = decltype(F)> +struct ForwardToServerHelper; + +template <auto F, typename UserdataT, typename... Args> +struct ForwardToServerHelper<F, void (server::Server::*)(UserdataT*, Args...)> { + using Userdata = UserdataT; + + static void Callback(AsAPIType<Args>... args, void* userdata, void*) { + // Acquire the userdata, and cast it to UserdataT. + std::unique_ptr<Userdata> data(static_cast<Userdata*>(userdata)); + auto server = data->server.lock(); + if (!server) { + // If the server is destroyed, release any callback owned results and return. + ( + []<typename T>(const DawnProcTable& procs, T arg) { + if constexpr (server::WGPUTraits<T>::Release != nullptr) { + if (arg) { + (procs.*server::WGPUTraits<T>::Release)(arg); + } + } + }(*(data->procs), args), + ...); + return; + } + // Forward the arguments and the typed userdata to the Server:: member function. + { + auto serverGuard = server.get()->GetGuard(); + (server.get()->*F)(data.get(), ConvertFromAPI<Args>(args)...); + } + server.get()->Flush(); + } +}; + +} // namespace detail + +namespace server { // CallbackUserdata and its derived classes are intended to be created by // Server::MakeUserdata<T> and then passed as the userdata argument for Dawn @@ -49,9 +98,9 @@ // |serverIsAlive|. If the weak pointer has expired, it means the server has // been destroyed and the callback must not use the Server pointer. // To assist with checking |serverIsAlive| and lifetime management of the userdata, -// |ForwardToServer| (defined later in this file) can be used to acquire the userdata, -// return early if |serverIsAlive| has expired, and then forward the arguments -// to userdata->server->MyCallbackHandler. +// |ForwardToServerHelper| (defined earlier in this file) can be used to acquire the +// userdata, return early if |serverIsAlive| has expired, and then forward the arguments to +// userdata->server->MyCallbackHandler. // // Example Usage: // @@ -61,7 +110,7 @@ // userdata->foo = 2; // // callMyCallbackHandler( -// ForwardToServer<&Server::MyCallbackHandler>::Callback, +// ForwardToServerHelper<&Server::MyCallbackHandler>::Callback, // userdata.release()); // // void Server::MyCallbackHandler(MyUserdata* userdata, Other args) { } @@ -74,49 +123,15 @@ std::shared_ptr<const DawnProcTable>& procs); }; -template <auto F, typename _ = decltype(F)> -struct ForwardToServerHelper; - -template <auto F, typename UserdataT, typename... Args> -struct ForwardToServerHelper<F, void (Server::*)(UserdataT*, Args...)> { - using Userdata = UserdataT; - - static void Callback(Args... args, void* userdata, void*) { - // Acquire the userdata, and cast it to UserdataT. - std::unique_ptr<Userdata> data(static_cast<Userdata*>(userdata)); - auto server = data->server.lock(); - if (!server) { - // If the server is destroyed, release any callback owned results and return. - ( - []<typename T>(const DawnProcTable& procs, T arg) { - if constexpr (WGPUTraits<T>::Release != nullptr) { - if (arg) { - (procs.*WGPUTraits<T>::Release)(arg); - } - } - }(*(data->procs), std::forward<Args>(args)), - ...); - return; - } - // Forward the arguments and the typed userdata to the Server:: member function. - { - auto serverGuard = server.get()->GetGuard(); - (server.get()->*F)(data.get(), std::forward<Args>(args)...); - } - server.get()->Flush(); - } -}; - struct MapUserdata : CallbackUserdata { using CallbackUserdata::CallbackUserdata; ObjectHandle buffer; - WGPUBuffer bufferObj; ObjectId instanceId; - WGPUFuture future; + Future future; size_t offset; size_t size; - WGPUMapMode mode; + wgpu::MapMode mode; }; struct ErrorScopeUserdata : CallbackUserdata { @@ -124,14 +139,14 @@ ObjectHandle device; ObjectId instanceId; - WGPUFuture future; + Future future; }; struct ShaderModuleGetCompilationInfoUserdata : CallbackUserdata { using CallbackUserdata::CallbackUserdata; ObjectId instanceId; - WGPUFuture future; + Future future; }; struct QueueWorkDoneUserdata : CallbackUserdata { @@ -139,7 +154,7 @@ ObjectHandle queue; ObjectId instanceId; - WGPUFuture future; + Future future; }; struct CreatePipelineAsyncUserData : CallbackUserdata { @@ -147,7 +162,7 @@ ObjectHandle device; ObjectId instanceId; - WGPUFuture future; + Future future; ObjectHandle pipeline; }; @@ -155,7 +170,7 @@ using CallbackUserdata::CallbackUserdata; ObjectId instanceId; - WGPUFuture future; + Future future; ObjectHandle adapter; }; @@ -163,16 +178,15 @@ using CallbackUserdata::CallbackUserdata; ObjectId instanceId; - WGPUFuture future; + Future future; ObjectHandle device; - WGPUFuture deviceLostFuture; }; struct DeviceLostUserdata : CallbackUserdata { using CallbackUserdata::CallbackUserdata; ObjectId instanceId; - WGPUFuture future; + Future future; }; class Server : public ServerBase { @@ -207,10 +221,12 @@ template <typename CallbackInfo, auto F, - WGPUCallbackMode DefaultMode = WGPUCallbackMode_AllowProcessEvents> - CallbackInfo MakeCallbackInfo(ForwardToServerHelper<F>::Userdata* userdata) { - return {nullptr, mUseSpontaneousCallbacks ? WGPUCallbackMode_AllowSpontaneous : DefaultMode, - &ForwardToServerHelper<F>::Callback, userdata, nullptr}; + wgpu::CallbackMode DefaultMode = wgpu::CallbackMode::AllowProcessEvents> + CallbackInfo MakeCallbackInfo(typename detail::ForwardToServerHelper<F>::Userdata* userdata) { + return { + nullptr, + ToAPI(mUseSpontaneousCallbacks ? wgpu::CallbackMode::AllowSpontaneous : DefaultMode), + &detail::ForwardToServerHelper<F>::Callback, userdata, nullptr}; } private: @@ -257,45 +273,47 @@ // ForwardToServerHelper::Callback unless specified otherwise in the comments. void OnDeviceLost(DeviceLostUserdata* userdata, WGPUDevice const* device, - WGPUDeviceLostReason reason, - WGPUStringView message); + wgpu::DeviceLostReason reason, + StringView message); void OnDevicePopErrorScope(ErrorScopeUserdata* userdata, - WGPUPopErrorScopeStatus status, - WGPUErrorType type, - WGPUStringView message); + wgpu::PopErrorScopeStatus status, + wgpu::ErrorType type, + StringView message); void OnBufferMapAsyncCallback(MapUserdata* userdata, - WGPUMapAsyncStatus status, - WGPUStringView message); + wgpu::MapAsyncStatus status, + StringView message); void OnQueueWorkDone(QueueWorkDoneUserdata* userdata, - WGPUQueueWorkDoneStatus status, - WGPUStringView message); + wgpu::QueueWorkDoneStatus status, + StringView message); void OnCreateComputePipelineAsyncCallback(CreatePipelineAsyncUserData* userdata, - WGPUCreatePipelineAsyncStatus status, + wgpu::CreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, - WGPUStringView message); + StringView message); void OnCreateRenderPipelineAsyncCallback(CreatePipelineAsyncUserData* userdata, - WGPUCreatePipelineAsyncStatus status, + wgpu::CreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, - WGPUStringView message); + StringView message); void OnShaderModuleGetCompilationInfo(ShaderModuleGetCompilationInfoUserdata* userdata, - WGPUCompilationInfoRequestStatus status, - const WGPUCompilationInfo* info); + wgpu::CompilationInfoRequestStatus status, + const CompilationInfo* info); void OnRequestAdapterCallback(RequestAdapterUserdata* userdata, - WGPURequestAdapterStatus status, + wgpu::RequestAdapterStatus status, WGPUAdapter adapter, - WGPUStringView message); + StringView message); void OnRequestDeviceCallback(RequestDeviceUserdata* userdata, - WGPURequestDeviceStatus status, + wgpu::RequestDeviceStatus status, WGPUDevice device, - WGPUStringView message); + StringView message); // The |OnUncapturedError| callback is special in that: - // 1) It is a repeating callback, so it can't be used with ForwardToServerHelper::Callback. - void OnUncapturedError(ObjectHandle device, WGPUErrorType type, WGPUStringView message); + // 1) It is a repeating callback, so it can't be used with + // ForwardToServerHelper::Callback. + void OnUncapturedError(ObjectHandle device, wgpu::ErrorType type, StringView message); // The |OnLogging| callback is special in that: - // 1) It is a repeating callback, so it can't be used with ForwardToServerHelper::Callback. + // 1) It is a repeating callback, so it can't be used with + // ForwardToServerHelper::Callback. // 2) It does not require holding the server object storage lock, i.e. |GetGuard| before // being called because it never interacts with the object store. - void OnLogging(ObjectHandle device, WGPULoggingType type, WGPUStringView message); + void OnLogging(ObjectHandle device, wgpu::LoggingType type, StringView message); #include "dawn/wire/server/ServerPrototypes_autogen.inc" @@ -310,6 +328,7 @@ std::unique_ptr<MemoryTransferService> CreateInlineMemoryTransferService(); -} // namespace dawn::wire::server +} // namespace server +} // namespace dawn::wire #endif // SRC_DAWN_WIRE_SERVER_SERVER_H_
diff --git a/src/dawn/wire/server/ServerAdapter.cpp b/src/dawn/wire/server/ServerAdapter.cpp index de5120c..eacf074 100644 --- a/src/dawn/wire/server/ServerAdapter.cpp +++ b/src/dawn/wire/server/ServerAdapter.cpp
@@ -48,14 +48,13 @@ auto userdata = MakeUserdata<RequestDeviceUserdata>(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; userdata->device = device.AsHandle(); - userdata->deviceLostFuture = ToAPI(deviceLostFuture); // Update the descriptor with the device lost callback associated with this request. auto deviceLostUserdata = MakeUserdata<DeviceLostUserdata>(); deviceLostUserdata->instanceId = instance.id; - deviceLostUserdata->future = ToAPI(deviceLostFuture); + deviceLostUserdata->future = deviceLostFuture; WGPUDeviceDescriptor desc = *ToAPI(descriptor); desc.deviceLostCallbackInfo = @@ -67,7 +66,7 @@ DeviceInfo* info = static_cast<DeviceInfo*>(userdata); { auto serverGuard = info->server->GetGuard(); - info->server->OnUncapturedError(info->self, type, message); + info->server->OnUncapturedError(info->self, FromAPI(type), FromAPI(message)); } info->server->Flush(); }, @@ -76,21 +75,21 @@ mProcs->adapterRequestDevice( adapter->handle, &desc, MakeCallbackInfo<WGPURequestDeviceCallbackInfo, &Server::OnRequestDeviceCallback, - WGPUCallbackMode_AllowSpontaneous>(userdata.release())); + wgpu::CallbackMode::AllowSpontaneous>(userdata.release())); return WireResult::Success; } void Server::OnRequestDeviceCallback(RequestDeviceUserdata* data, - WGPURequestDeviceStatus status, + wgpu::RequestDeviceStatus status, WGPUDevice device, - WGPUStringView message) { + StringView message) { ReturnAdapterRequestDeviceCallbackCmd cmd = {}; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.message = FromAPI(message); + cmd.future = data->future; + cmd.status = status; + cmd.message = message; - if (status != WGPURequestDeviceStatus_Success) { + if (status != wgpu::RequestDeviceStatus::Success) { DAWN_ASSERT(device == nullptr); SerializeCommand(std::move(cmd)); return; @@ -109,7 +108,7 @@ device = nullptr; cmd.status = wgpu::RequestDeviceStatus::Error; - cmd.message = FromAPI(ToOutputStringView("Requested feature not supported.")); + cmd.message = "Requested feature not supported."; SerializeCommand(std::move(cmd)); return; } @@ -134,7 +133,7 @@ Known<WGPUDevice> reservation; if (FillReservation(data->device, device, &reservation) == WireResult::FatalError) { cmd.status = wgpu::RequestDeviceStatus::CallbackCancelled; - cmd.message = FromAPI(ToOutputStringView("Destroyed before request was fulfilled.")); + cmd.message = "Destroyed before request was fulfilled."; SerializeCommand(std::move(cmd)); return; }
diff --git a/src/dawn/wire/server/ServerBuffer.cpp b/src/dawn/wire/server/ServerBuffer.cpp index 18e01a1..451d09f 100644 --- a/src/dawn/wire/server/ServerBuffer.cpp +++ b/src/dawn/wire/server/ServerBuffer.cpp
@@ -88,9 +88,8 @@ std::unique_ptr<MapUserdata> userdata = MakeUserdata<MapUserdata>(); userdata->buffer = buffer.AsHandle(); userdata->instanceId = instance.id; - userdata->bufferObj = buffer->handle; - userdata->future = ToAPI(future); - userdata->mode = ToAPI(mode); + userdata->future = future; + userdata->mode = mode; // Make sure that the size is not WGPU_WHOLE_MAP_SIZE because we want the client to give us an // explicit size (so we don't have to handle the defaulting here). The client needs to track @@ -188,8 +187,8 @@ } void Server::OnBufferMapAsyncCallback(MapUserdata* data, - WGPUMapAsyncStatus status, - WGPUStringView message) { + wgpu::MapAsyncStatus status, + StringView message) { // Skip sending the callback if the buffer has already been destroyed. Known<WGPUBuffer> buffer; if (Get(data->buffer.id, &buffer) != WireResult::Success || @@ -197,13 +196,13 @@ return; } - bool isSuccess = status == WGPUMapAsyncStatus_Success; + bool isSuccess = status == wgpu::MapAsyncStatus::Success; ReturnBufferMapAsyncCallbackCmd cmd = {}; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.message = FromAPI(message); + cmd.future = data->future; + cmd.status = status; + cmd.message = message; if (!isSuccess) { SerializeCommand(std::move(cmd)); @@ -211,12 +210,12 @@ } switch (data->mode) { - case WGPUMapMode_Read: { + case wgpu::MapMode::Read: { DAWN_ASSERT(data->size != WGPU_WHOLE_MAP_SIZE); // Validated in DoBufferMapAsync. buffer->mapState.Use([&](auto mapState) { const std::byte* mappedData = static_cast<const std::byte*>( - mProcs->bufferGetConstMappedRange(data->bufferObj, data->offset, data->size)); + mProcs->bufferGetConstMappedRange(buffer->handle, data->offset, data->size)); // SAFETY: If GetConstMappedRange with size != WGPU_WHOLE_MAP_SIZE returns non-null, // it points to at least `size` valid bytes. @@ -237,7 +236,7 @@ }); break; } - case WGPUMapMode_Write: { + case wgpu::MapMode::Write: { SerializeCommand(std::move(cmd)); break; }
diff --git a/src/dawn/wire/server/ServerDevice.cpp b/src/dawn/wire/server/ServerDevice.cpp index 35b5af3..d156c16 100644 --- a/src/dawn/wire/server/ServerDevice.cpp +++ b/src/dawn/wire/server/ServerDevice.cpp
@@ -34,11 +34,11 @@ namespace dawn::wire::server { -void Server::OnUncapturedError(ObjectHandle device, WGPUErrorType type, WGPUStringView message) { +void Server::OnUncapturedError(ObjectHandle device, wgpu::ErrorType type, StringView message) { ReturnDeviceUncapturedErrorCallbackCmd cmd; cmd.device = device; - cmd.type = FromAPI(type); - cmd.message = FromAPI(message); + cmd.type = type; + cmd.message = message; SerializeCommand(std::move(cmd)); Flush(); @@ -46,22 +46,22 @@ void Server::OnDeviceLost(DeviceLostUserdata* userdata, WGPUDevice const* device, - WGPUDeviceLostReason reason, - WGPUStringView message) { + wgpu::DeviceLostReason reason, + StringView message) { ReturnDeviceLostCallbackCmd cmd; cmd.instanceId = userdata->instanceId; - cmd.future = FromAPI(userdata->future); - cmd.reason = FromAPI(reason); - cmd.message = FromAPI(message); + cmd.future = userdata->future; + cmd.reason = reason; + cmd.message = message; SerializeCommand(std::move(cmd)); } -void Server::OnLogging(ObjectHandle device, WGPULoggingType type, WGPUStringView message) { +void Server::OnLogging(ObjectHandle device, wgpu::LoggingType type, StringView message) { ReturnDeviceLoggingCallbackCmd cmd; cmd.device = device; - cmd.type = FromAPI(type); - cmd.message = FromAPI(message); + cmd.type = type; + cmd.message = message; SerializeCommand(std::move(cmd)); } @@ -72,7 +72,7 @@ auto userdata = MakeUserdata<ErrorScopeUserdata>(); userdata->device = device.AsHandle(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; mProcs->devicePopErrorScope( device->handle, @@ -82,15 +82,15 @@ } void Server::OnDevicePopErrorScope(ErrorScopeUserdata* userdata, - WGPUPopErrorScopeStatus status, - WGPUErrorType type, - WGPUStringView message) { + wgpu::PopErrorScopeStatus status, + wgpu::ErrorType type, + StringView message) { ReturnDevicePopErrorScopeCallbackCmd cmd; cmd.instanceId = userdata->instanceId; - cmd.future = FromAPI(userdata->future); - cmd.status = FromAPI(status); - cmd.type = FromAPI(type); - cmd.message = FromAPI(message); + cmd.future = userdata->future; + cmd.status = status; + cmd.type = type; + cmd.message = message; SerializeCommand(std::move(cmd)); } @@ -106,7 +106,7 @@ auto userdata = MakeUserdata<CreatePipelineAsyncUserData>(); userdata->device = device.AsHandle(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; userdata->pipeline = pipeline.AsHandle(); mProcs->deviceCreateComputePipelineAsync( @@ -117,19 +117,19 @@ } void Server::OnCreateComputePipelineAsyncCallback(CreatePipelineAsyncUserData* data, - WGPUCreatePipelineAsyncStatus status, + wgpu::CreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, - WGPUStringView message) { + StringView message) { ReturnDeviceCreateComputePipelineAsyncCallbackCmd cmd; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.message = FromAPI(message); + cmd.future = data->future; + cmd.status = status; + cmd.message = message; - if (status == WGPUCreatePipelineAsyncStatus_Success && + if (status == wgpu::CreatePipelineAsyncStatus::Success && FillReservation(data->pipeline, pipeline) == WireResult::FatalError) { cmd.status = wgpu::CreatePipelineAsyncStatus::CallbackCancelled; - cmd.message = FromAPI(ToOutputStringView("Destroyed before request was fulfilled.")); + cmd.message = "Destroyed before request was fulfilled."; } SerializeCommand(std::move(cmd)); } @@ -145,7 +145,7 @@ auto userdata = MakeUserdata<CreatePipelineAsyncUserData>(); userdata->device = device.AsHandle(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; userdata->pipeline = pipeline.AsHandle(); mProcs->deviceCreateRenderPipelineAsync( @@ -156,19 +156,19 @@ } void Server::OnCreateRenderPipelineAsyncCallback(CreatePipelineAsyncUserData* data, - WGPUCreatePipelineAsyncStatus status, + wgpu::CreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, - WGPUStringView message) { + StringView message) { ReturnDeviceCreateRenderPipelineAsyncCallbackCmd cmd; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.message = FromAPI(message); + cmd.future = data->future; + cmd.status = status; + cmd.message = message; - if (status == WGPUCreatePipelineAsyncStatus_Success && + if (status == wgpu::CreatePipelineAsyncStatus::Success && FillReservation(data->pipeline, pipeline) == WireResult::FatalError) { cmd.status = wgpu::CreatePipelineAsyncStatus::CallbackCancelled; - cmd.message = FromAPI(ToOutputStringView("Destroyed before request was fulfilled.")); + cmd.message = "Destroyed before request was fulfilled."; } SerializeCommand(std::move(cmd)); }
diff --git a/src/dawn/wire/server/ServerInstance.cpp b/src/dawn/wire/server/ServerInstance.cpp index 877afe9..2021704 100644 --- a/src/dawn/wire/server/ServerInstance.cpp +++ b/src/dawn/wire/server/ServerInstance.cpp
@@ -43,27 +43,27 @@ auto userdata = MakeUserdata<RequestAdapterUserdata>(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; userdata->adapter = adapter.AsHandle(); mProcs->instanceRequestAdapter( instance->handle, ToAPI(options), MakeCallbackInfo<WGPURequestAdapterCallbackInfo, &Server::OnRequestAdapterCallback, - WGPUCallbackMode_AllowSpontaneous>(userdata.release())); + wgpu::CallbackMode::AllowSpontaneous>(userdata.release())); return WireResult::Success; } void Server::OnRequestAdapterCallback(RequestAdapterUserdata* data, - WGPURequestAdapterStatus status, + wgpu::RequestAdapterStatus status, WGPUAdapter adapter, - WGPUStringView message) { + StringView message) { ReturnInstanceRequestAdapterCallbackCmd cmd = {}; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.message = FromAPI(message); + cmd.future = data->future; + cmd.status = status; + cmd.message = message; - if (status != WGPURequestAdapterStatus_Success) { + if (status != wgpu::RequestAdapterStatus::Success) { DAWN_ASSERT(adapter == nullptr); SerializeCommand(std::move(cmd)); return; @@ -72,7 +72,7 @@ // Assign the handle and allocated status if the adapter is created successfully. if (FillReservation(data->adapter, adapter) == WireResult::FatalError) { cmd.status = wgpu::RequestAdapterStatus::CallbackCancelled; - cmd.message = FromAPI(ToOutputStringView("Destroyed before request was fulfilled.")); + cmd.message = "Destroyed before request was fulfilled."; SerializeCommand(std::move(cmd)); return; }
diff --git a/src/dawn/wire/server/ServerQueue.cpp b/src/dawn/wire/server/ServerQueue.cpp index 572d580..dc68289 100644 --- a/src/dawn/wire/server/ServerQueue.cpp +++ b/src/dawn/wire/server/ServerQueue.cpp
@@ -36,13 +36,13 @@ namespace dawn::wire::server { void Server::OnQueueWorkDone(QueueWorkDoneUserdata* data, - WGPUQueueWorkDoneStatus status, - WGPUStringView message) { + wgpu::QueueWorkDoneStatus status, + StringView message) { ReturnQueueWorkDoneCallbackCmd cmd; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.message = FromAPI(message); + cmd.future = data->future; + cmd.status = status; + cmd.message = message; SerializeCommand(std::move(cmd)); } @@ -53,7 +53,7 @@ auto userdata = MakeUserdata<QueueWorkDoneUserdata>(); userdata->queue = queue.AsHandle(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; mProcs->queueOnSubmittedWorkDone( queue->handle, MakeCallbackInfo<WGPUQueueWorkDoneCallbackInfo, &Server::OnQueueWorkDone>(
diff --git a/src/dawn/wire/server/ServerShaderModule.cpp b/src/dawn/wire/server/ServerShaderModule.cpp index 6df9403..8ed8c51 100644 --- a/src/dawn/wire/server/ServerShaderModule.cpp +++ b/src/dawn/wire/server/ServerShaderModule.cpp
@@ -37,7 +37,7 @@ Future future) { auto userdata = MakeUserdata<ShaderModuleGetCompilationInfoUserdata>(); userdata->instanceId = instance.id; - userdata->future = ToAPI(future); + userdata->future = future; mProcs->shaderModuleGetCompilationInfo( shaderModule->handle, @@ -47,13 +47,13 @@ } void Server::OnShaderModuleGetCompilationInfo(ShaderModuleGetCompilationInfoUserdata* data, - WGPUCompilationInfoRequestStatus status, - const WGPUCompilationInfo* info) { + wgpu::CompilationInfoRequestStatus status, + const CompilationInfo* info) { ReturnShaderModuleGetCompilationInfoCallbackCmd cmd; cmd.instanceId = data->instanceId; - cmd.future = FromAPI(data->future); - cmd.status = FromAPI(status); - cmd.info = FromAPI(info); + cmd.future = data->future; + cmd.status = status; + cmd.info = info; SerializeCommand(std::move(cmd)); }