Skip to content

Commit

Permalink
vk: eliminate duplicate values in SurfaceCapabilities's formats fie…
Browse files Browse the repository at this point in the history
…ld (#3227)
  • Loading branch information
jinleili authored Nov 26, 2022
1 parent 82e9dcf commit d7fe7ef
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions wgpu-hal/src/vulkan/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,22 @@ pub fn map_vk_surface_formats(sf: vk::SurfaceFormatKHR) -> Option<wgt::TextureFo
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,
Some(match sf.color_space {
vk::ColorSpaceKHR::SRGB_NONLINEAR => 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,
_ => return None,
},
vk::ColorSpaceKHR::EXTENDED_SRGB_LINEAR_EXT => match sf.format {
F::R16G16B16A16_SFLOAT => Tf::Rgba16Float,
F::R16G16B16A16_SNORM => Tf::Rgba16Snorm,
F::R16G16B16A16_UNORM => Tf::Rgba16Unorm,
F::A2B10G10R10_UNORM_PACK32 => Tf::Rgb10a2Unorm,
_ => return None,
},
_ => return None,
})
}
Expand Down

0 comments on commit d7fe7ef

Please sign in to comment.