From 0b3fc055d3df8a2eb4a17cce2efda19f82316314 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 12 Apr 2023 13:19:35 +0000 Subject: [PATCH] Update samples to process events. This CL updates the `dawn/sample` programs to call the `dawn::native::InstanceProcessEvents` which allows things like shader validation errors to be emitted. Without this change the errors are never displayed. Change-Id: I054bb4f7177c5d0c110e97409852143b2bef1e02 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126760 Reviewed-by: Corentin Wallez Kokoro: Kokoro Commit-Queue: Dan Sinclair --- src/dawn/samples/Animometer.cpp | 1 + src/dawn/samples/CHelloTriangle.cpp | 1 + src/dawn/samples/ComputeBoids.cpp | 1 + src/dawn/samples/CppHelloTriangle.cpp | 1 + src/dawn/samples/ManualSwapChainTest.cpp | 1 + src/dawn/samples/SampleUtils.cpp | 4 ++++ src/dawn/samples/SampleUtils.h | 1 + 7 files changed, 10 insertions(+) diff --git a/src/dawn/samples/Animometer.cpp b/src/dawn/samples/Animometer.cpp index 810abf74e5..9d870c9ed7 100644 --- a/src/dawn/samples/Animometer.cpp +++ b/src/dawn/samples/Animometer.cpp @@ -186,6 +186,7 @@ int main(int argc, const char* argv[]) { timer->Start(); while (!ShouldQuit()) { utils::ScopedAutoreleasePool pool; + ProcessEvents(); frameCount++; frame(); if (frameCount % 60 == 0) { diff --git a/src/dawn/samples/CHelloTriangle.cpp b/src/dawn/samples/CHelloTriangle.cpp index 68ec723d84..c3b6ab367c 100644 --- a/src/dawn/samples/CHelloTriangle.cpp +++ b/src/dawn/samples/CHelloTriangle.cpp @@ -143,6 +143,7 @@ int main(int argc, const char* argv[]) { while (!ShouldQuit()) { utils::ScopedAutoreleasePool pool; + ProcessEvents(); frame(); utils::USleep(16000); } diff --git a/src/dawn/samples/ComputeBoids.cpp b/src/dawn/samples/ComputeBoids.cpp index 86158e9dbb..4cab8ab50e 100644 --- a/src/dawn/samples/ComputeBoids.cpp +++ b/src/dawn/samples/ComputeBoids.cpp @@ -323,6 +323,7 @@ int main(int argc, const char* argv[]) { while (!ShouldQuit()) { utils::ScopedAutoreleasePool pool; + ProcessEvents(); frame(); utils::USleep(16000); } diff --git a/src/dawn/samples/CppHelloTriangle.cpp b/src/dawn/samples/CppHelloTriangle.cpp index 48e52c7282..8f7299f087 100644 --- a/src/dawn/samples/CppHelloTriangle.cpp +++ b/src/dawn/samples/CppHelloTriangle.cpp @@ -176,6 +176,7 @@ int main(int argc, const char* argv[]) { while (!ShouldQuit()) { utils::ScopedAutoreleasePool pool; + ProcessEvents(); frame(); utils::USleep(16000); } diff --git a/src/dawn/samples/ManualSwapChainTest.cpp b/src/dawn/samples/ManualSwapChainTest.cpp index 4d82e325fd..01c0c9fb0d 100644 --- a/src/dawn/samples/ManualSwapChainTest.cpp +++ b/src/dawn/samples/ManualSwapChainTest.cpp @@ -339,6 +339,7 @@ int main(int argc, const char* argv[]) { while (windows.size() != 0) { utils::ScopedAutoreleasePool pool; glfwPollEvents(); + wgpuInstanceProcessEvents(instance->Get()); for (auto it = windows.begin(); it != windows.end();) { GLFWwindow* window = it->first; diff --git a/src/dawn/samples/SampleUtils.cpp b/src/dawn/samples/SampleUtils.cpp index f6358139f0..0dc2eee658 100644 --- a/src/dawn/samples/SampleUtils.cpp +++ b/src/dawn/samples/SampleUtils.cpp @@ -391,3 +391,7 @@ bool ShouldQuit() { GLFWwindow* GetGLFWWindow() { return window; } + +void ProcessEvents() { + dawn::native::InstanceProcessEvents(instance->Get()); +} diff --git a/src/dawn/samples/SampleUtils.h b/src/dawn/samples/SampleUtils.h index 2ff351c927..47761750c2 100644 --- a/src/dawn/samples/SampleUtils.h +++ b/src/dawn/samples/SampleUtils.h @@ -28,5 +28,6 @@ wgpu::Device CreateCppDawnDevice(); wgpu::TextureFormat GetPreferredSwapChainTextureFormat(); wgpu::SwapChain GetSwapChain(); wgpu::TextureView CreateDefaultDepthStencilView(const wgpu::Device& device); +void ProcessEvents(); #endif // SRC_DAWN_SAMPLES_SAMPLEUTILS_H_