[vk] require VK_KHR_maintenance1 (in preparation for creating 2D texture views from slices of 3D textures)

This commit is contained in:
teoxoy 2025-04-23 14:41:53 +02:00 committed by Teodor Tanasoaia
parent d714e3d95a
commit 2bb8325f85
3 changed files with 7 additions and 27 deletions

View File

@ -1,7 +1,7 @@
use alloc::{borrow::ToOwned as _, collections::BTreeMap, sync::Arc, vec::Vec}; use alloc::{borrow::ToOwned as _, collections::BTreeMap, sync::Arc, vec::Vec};
use core::ffi::CStr; use core::ffi::CStr;
use ash::{amd, ext, google, khr, vk}; use ash::{ext, google, khr, vk};
use parking_lot::Mutex; use parking_lot::Mutex;
use super::conv; use super::conv;
@ -943,13 +943,8 @@ impl PhysicalDeviceProperties {
extensions.push(khr::swapchain::NAME); extensions.push(khr::swapchain::NAME);
if self.device_api_version < vk::API_VERSION_1_1 { if self.device_api_version < vk::API_VERSION_1_1 {
// Require either `VK_KHR_maintenance1` or `VK_AMD_negative_viewport_height` // Require `VK_KHR_maintenance1`
if self.supports_extension(khr::maintenance1::NAME) { extensions.push(khr::maintenance1::NAME);
extensions.push(khr::maintenance1::NAME);
} else {
// `VK_AMD_negative_viewport_height` is obsoleted by `VK_KHR_maintenance1` and must not be enabled alongside it
extensions.push(amd::negative_viewport_height::NAME);
}
// Optional `VK_KHR_maintenance2` // Optional `VK_KHR_maintenance2`
if self.supports_extension(khr::maintenance2::NAME) { if self.supports_extension(khr::maintenance2::NAME) {
@ -1638,12 +1633,11 @@ impl super::Instance {
); );
return None; return None;
} }
if !phd_capabilities.supports_extension(amd::negative_viewport_height::NAME) if !phd_capabilities.supports_extension(khr::maintenance1::NAME)
&& !phd_capabilities.supports_extension(khr::maintenance1::NAME)
&& phd_capabilities.device_api_version < vk::API_VERSION_1_1 && phd_capabilities.device_api_version < vk::API_VERSION_1_1
{ {
log::warn!( log::warn!(
"viewport Y-flip is not supported, hiding adapter: {}", "VK_KHR_maintenance1 is not supported, hiding adapter: {}",
info.name info.name
); );
return None; return None;
@ -1661,8 +1655,6 @@ impl super::Instance {
} }
let private_caps = super::PrivateCapabilities { let private_caps = super::PrivateCapabilities {
flip_y_requires_shift: phd_capabilities.device_api_version >= vk::API_VERSION_1_1
|| phd_capabilities.supports_extension(khr::maintenance1::NAME),
imageless_framebuffers: match phd_features.imageless_framebuffer { imageless_framebuffers: match phd_features.imageless_framebuffer {
Some(features) => features.imageless_framebuffer == vk::TRUE, Some(features) => features.imageless_framebuffer == vk::TRUE,
None => phd_features None => phd_features

View File

@ -788,11 +788,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
}; };
let vk_viewports = [vk::Viewport { let vk_viewports = [vk::Viewport {
x: 0.0, x: 0.0,
y: if self.device.private_caps.flip_y_requires_shift { y: desc.extent.height as f32,
desc.extent.height as f32
} else {
0.0
},
width: desc.extent.width as f32, width: desc.extent.width as f32,
height: -(desc.extent.height as f32), height: -(desc.extent.height as f32),
min_depth: 0.0, min_depth: 0.0,
@ -967,11 +963,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: Range<f32>) { unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: Range<f32>) {
let vk_viewports = [vk::Viewport { let vk_viewports = [vk::Viewport {
x: rect.x, x: rect.x,
y: if self.device.private_caps.flip_y_requires_shift { y: rect.y + rect.h,
rect.y + rect.h
} else {
rect.y
},
width: rect.w, width: rect.w,
height: -rect.h, // flip Y height: -rect.h, // flip Y
min_depth: depth_range.start, min_depth: depth_range.start,

View File

@ -488,10 +488,6 @@ struct RayTracingDeviceExtensionFunctions {
/// device geometry, but affect the code paths taken internally. /// device geometry, but affect the code paths taken internally.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct PrivateCapabilities { struct PrivateCapabilities {
/// Y-flipping is implemented with either `VK_AMD_negative_viewport_height` or `VK_KHR_maintenance1`/1.1+. The AMD extension for negative viewport height does not require a Y shift.
///
/// This flag is `true` if the device has `VK_KHR_maintenance1`/1.1+ and `false` otherwise (i.e. in the case of `VK_AMD_negative_viewport_height`).
flip_y_requires_shift: bool,
imageless_framebuffers: bool, imageless_framebuffers: bool,
image_view_usage: bool, image_view_usage: bool,
timeline_semaphores: bool, timeline_semaphores: bool,