From f49e4e339b00c056d469d79a0d13539a7f95a3d4 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Thu, 23 Jun 2022 10:38:23 -0400 Subject: [PATCH] Fix windows build errors --- wgpu-hal/src/dx12/mod.rs | 1 + wgpu-hal/src/vulkan/adapter.rs | 2 +- wgpu-hal/src/vulkan/conv.rs | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 9d89cf6836..44062ee0c7 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -772,6 +772,7 @@ impl crate::Queue for Queue { wgt::PresentMode::Immediate => (0, dxgi::DXGI_PRESENT_ALLOW_TEARING), wgt::PresentMode::Mailbox => (0, 0), wgt::PresentMode::Fifo => (1, 0), + m => unreachable!("Cannot make surface with present mode {m:?}"), }; profiling::scope!("IDXGISwapchain3::Present"); diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index fd971db835..0fd31196f6 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1618,7 +1618,7 @@ impl crate::Adapter for super::Adapter { let formats = raw_surface_formats .into_iter() - .map(|sf| self.private_caps.map_texture_format(sf.format)) + .filter_map(conv::map_vk_surface_formats) .collect(); Some(crate::SurfaceCapabilities { formats, diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index d9b74168a5..dc5b915970 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -144,6 +144,24 @@ impl super::PrivateCapabilities { } } +pub fn map_vk_surface_formats(sf: vk::SurfaceFormatKHR) -> Option { + use ash::vk::Format as F; + use wgt::TextureFormat as Tf; + // List we care about pulled from https://vulkan.gpuinfo.org/listsurfaceformats.php + Some(match sf.format { + F::B8G8R8A8_UNORM => Tf::Bgra8Unorm, + F::B8G8R8A8_SRGB => Tf::Bgra8UnormSrgb, + F::R8G8B8A8_SNORM => Tf::Rgba8Snorm, + F::R8G8B8A8_UNORM => Tf::Rgba8Unorm, + F::R8G8B8A8_SRGB => Tf::Rgba8UnormSrgb, + F::R16G16B16A16_SFLOAT => Tf::Rgba16Float, + F::R16G16B16A16_SNORM => Tf::Rgba16Snorm, + F::R16G16B16A16_UNORM => Tf::Rgba16Unorm, + F::A2B10G10R10_UNORM_PACK32 => Tf::Rgb10a2Unorm, + _ => return None, + }) +} + impl crate::Attachment<'_, super::Api> { pub(super) fn make_attachment_key( &self,