From 9370eb7d21a479cfba8e9e58c78bbc1e1dfdbdad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Tue, 21 May 2024 10:30:11 +0200 Subject: [PATCH] Update dawn + reuse format + print message --- .gitmodules | 2 +- dawn | 2 +- main.cpp | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 2aec77e..52f7b37 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "dawn"] path = dawn url = https://dawn.googlesource.com/dawn - branch = chromium/6167 # Chrome 121 + branch = chromium/6478 # Chrome 126 shallow = true diff --git a/dawn b/dawn index 12b2251..fda42b9 160000 --- a/dawn +++ b/dawn @@ -1 +1 @@ -Subproject commit 12b2251aaf0a2ee9cb02df8f9b156bd1f025cfe5 +Subproject commit fda42b9b030a9da4a3f3b3dc994bdba9eeb36b38 diff --git a/main.cpp b/main.cpp index 3dc87a2..0857694 100644 --- a/main.cpp +++ b/main.cpp @@ -13,19 +13,21 @@ wgpu::Device device; wgpu::RenderPipeline pipeline; wgpu::Surface surface; +wgpu::TextureFormat format; const uint32_t kWidth = 512; const uint32_t kHeight = 512; void ConfigureSurface() { wgpu::SurfaceCapabilities capabilities; surface.GetCapabilities(adapter, &capabilities); + format = capabilities.formats[0]; wgpu::SurfaceConfiguration config{ .device = device, + .format = format, + .alphaMode = capabilities.alphaModes[0], .width = kWidth, .height = kHeight, - .format = capabilities.formats[0], - .alphaMode = capabilities.alphaModes[0], .presentMode = capabilities.presentModes[0]}; surface.Configure(&config); } @@ -37,6 +39,9 @@ void GetAdapter(void (*callback)(wgpu::Adapter)) { // wgpu::RequestAdapterStatus and wgpu::Adapter. [](WGPURequestAdapterStatus status, WGPUAdapter cAdapter, const char* message, void* userdata) { + if (message) { + printf("RequestAdapter: %s\n", message); + } if (status != WGPURequestAdapterStatus_Success) { exit(0); } @@ -52,6 +57,9 @@ void GetDevice(void (*callback)(wgpu::Device)) { // wgpu::RequestDeviceStatus and wgpu::Device. [](WGPURequestDeviceStatus status, WGPUDevice cDevice, const char* message, void* userdata) { + if (message) { + printf("RequestDevice: %s\n", message); + } wgpu::Device device = wgpu::Device::Acquire(cDevice); device.SetUncapturedErrorCallback( [](WGPUErrorType type, const char* message, void* userdata) { @@ -82,8 +90,7 @@ void CreateRenderPipeline() { wgpu::ShaderModule shaderModule = device.CreateShaderModule(&shaderModuleDescriptor); - wgpu::ColorTargetState colorTargetState{ - .format = wgpu::TextureFormat::BGRA8Unorm}; + wgpu::ColorTargetState colorTargetState{.format = format}; wgpu::FragmentState fragmentState{.module = shaderModule, .targetCount = 1,