From 643a50e88c79ff054a2cb61788016c6ce45e3f5f Mon Sep 17 00:00:00 2001 From: xiaopengli89 Date: Mon, 13 Nov 2023 14:32:04 +0800 Subject: [PATCH] check vulkan api version and extension --- wgpu-hal/src/vulkan/adapter.rs | 13 ++----------- wgpu-hal/src/vulkan/conv.rs | 11 +++-------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index d742c1d11f0..a9881ef7f35 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -530,19 +530,10 @@ impl PhysicalDeviceFeatures { supports_bgra8unorm_storage(instance, phd, caps.device_api_version), ); - // https://github.com/KhronosGroup/MoltenVK/issues/440 - #[cfg(not(any(target_os = "macos", target_os = "ios")))] features.set( F::TEXTURE_FORMAT_NV12, - supports_format( - instance, - phd, - vk::Format::G8_B8R8_2PLANE_420_UNORM, - vk::ImageTiling::OPTIMAL, - vk::FormatFeatureFlags::SAMPLED_IMAGE - | vk::FormatFeatureFlags::TRANSFER_SRC - | vk::FormatFeatureFlags::TRANSFER_DST, - ), + caps.device_api_version >= vk::API_VERSION_1_1 + || caps.supports_extension(vk::KhrSamplerYcbcrConversionFn::name()), ); (features, dl_flags) diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index aa309a2f699..49d3308a5dc 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -1,10 +1,5 @@ use ash::vk; -// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkImageAspectFlagBits.html -const VK_IMAGE_ASPECT_PLANE_0_BIT: vk::Flags = 0x00000010; -const VK_IMAGE_ASPECT_PLANE_1_BIT: vk::Flags = 0x00000020; -const VK_IMAGE_ASPECT_PLANE_2_BIT: vk::Flags = 0x00000040; - impl super::PrivateCapabilities { pub fn map_texture_format(&self, format: wgt::TextureFormat) -> vk::Format { use ash::vk::Format as F; @@ -410,9 +405,9 @@ pub fn map_vertex_format(vertex_format: wgt::VertexFormat) -> vk::Format { pub fn map_aspects(aspects: crate::FormatAspects, plane: Option) -> vk::ImageAspectFlags { let mut flags = vk::ImageAspectFlags::empty(); match plane { - Some(0) => flags |= vk::ImageAspectFlags::from_raw(VK_IMAGE_ASPECT_PLANE_0_BIT), - Some(1) => flags |= vk::ImageAspectFlags::from_raw(VK_IMAGE_ASPECT_PLANE_1_BIT), - Some(2) => flags |= vk::ImageAspectFlags::from_raw(VK_IMAGE_ASPECT_PLANE_2_BIT), + Some(0) => flags |= vk::ImageAspectFlags::PLANE_0, + Some(1) => flags |= vk::ImageAspectFlags::PLANE_1, + Some(2) => flags |= vk::ImageAspectFlags::PLANE_2, _ if aspects.contains(crate::FormatAspects::COLOR) => { flags |= vk::ImageAspectFlags::COLOR; }