Skip to content

Commit

Permalink
check vulkan api version and extension
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 committed Nov 14, 2023
1 parent df05c13 commit 643a50e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
13 changes: 2 additions & 11 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 3 additions & 8 deletions wgpu-hal/src/vulkan/conv.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -410,9 +405,9 @@ pub fn map_vertex_format(vertex_format: wgt::VertexFormat) -> vk::Format {
pub fn map_aspects(aspects: crate::FormatAspects, plane: Option<u32>) -> 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;
}
Expand Down

0 comments on commit 643a50e

Please sign in to comment.