From 947a7deb99687a270f12540c41ec9ade9489b57b Mon Sep 17 00:00:00 2001 From: Le Hoang Quyen Date: Wed, 29 Mar 2023 07:06:18 +0000 Subject: [PATCH] DawnNative: Add dawn::native::InstanceProcessEvents() Make this a standalone function instead of a dawn::native::Instance's member method. Some code base don't use dawn::native::Instance but instead use wgpu::Instance. And InstanceProcessEvents() function actually returns a bool unlike wgpu::Instance::ProcessEvents() which returns void. Bug: dawn:752 Change-Id: Ia354a4ed5b5568ee23bcc70935c104059a9f6fc8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125660 Reviewed-by: Austin Eng Kokoro: Kokoro Commit-Queue: Quyen Le --- include/dawn/native/DawnNative.h | 4 ++-- src/dawn/fuzzers/DawnWireServerFuzzer.cpp | 2 +- src/dawn/native/DawnNative.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h index cf074cc10a..06e3f1182e 100644 --- a/include/dawn/native/DawnNative.h +++ b/include/dawn/native/DawnNative.h @@ -187,8 +187,6 @@ class DAWN_NATIVE_EXPORT Instance { uint64_t GetDeviceCountForTesting() const; - bool ProcessEvents(); - // Returns the underlying WGPUInstance object. WGPUInstance Get() const; @@ -225,6 +223,8 @@ DAWN_NATIVE_EXPORT std::vector GetProcMapNamesForTesting(); DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device); +DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance); + // ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp DAWN_NATIVE_EXPORT void EnableErrorInjector(); DAWN_NATIVE_EXPORT void DisableErrorInjector(); diff --git a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp index 2f85f17e2e..3bf3762106 100644 --- a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp @@ -136,7 +136,7 @@ int DawnWireServerFuzzer::Run(const uint8_t* data, // Flush remaining callbacks to avoid memory leaks. // TODO(crbug.com/dawn/1712): DeviceNull's APITick() will always return true so cannot // do a polling loop here. - sInstance->ProcessEvents(); + dawn::native::InstanceProcessEvents(sInstance->Get()); // Note: Deleting the server will release all created objects. // Deleted devices will wait for idle on destruction. diff --git a/src/dawn/native/DawnNative.cpp b/src/dawn/native/DawnNative.cpp index 3e6ca7285a..21d8f41748 100644 --- a/src/dawn/native/DawnNative.cpp +++ b/src/dawn/native/DawnNative.cpp @@ -251,10 +251,6 @@ uint64_t Instance::GetDeviceCountForTesting() const { return mImpl->GetDeviceCountForTesting(); } -bool Instance::ProcessEvents() { - return mImpl->APIProcessEvents(); -} - WGPUInstance Instance::Get() const { return ToAPI(mImpl); } @@ -298,6 +294,10 @@ DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device) { return FromAPI(device)->APITick(); } +DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance) { + return FromAPI(instance)->APIProcessEvents(); +} + // ExternalImageDescriptor ExternalImageDescriptor::ExternalImageDescriptor(ExternalImageType type) : mType(type) {}