]> git.nega.tv - josh/narcissus/commitdiff
vulkan-sys: Add `VK_EXT_[swapchain,surface]_maintenance1`
authorJoshua Simmons <josh@nega.tv>
Fri, 5 Apr 2024 22:42:18 +0000 (00:42 +0200)
committerJoshua Simmons <josh@nega.tv>
Fri, 5 Apr 2024 22:42:18 +0000 (00:42 +0200)
external/vulkan-sys/src/enums.rs
external/vulkan-sys/src/flags.rs
external/vulkan-sys/src/functions.rs
external/vulkan-sys/src/lib.rs
external/vulkan-sys/src/structs.rs

index 4d8ce08f303e7f3d866b426a4d5a1578235d9a5b..9abeff3a86540ae10364f9042e10ef492bfe9332 100644 (file)
@@ -1366,6 +1366,15 @@ pub enum StructureType {
     PipelineRenderingCreateInfo = 1000044002,
     PhysicalDeviceDynamicRenderingFeatures = 1000044003,
     CommandBufferInheritanceRenderingInfo = 1000044004,
+    SurfacePresentModeExt = 1000274000,
+    SurfacePresentScalingCapabilitiesExt = 1000274001,
+    SurfacePresentModeCompatibilityExt = 1000274002,
+    PhysicalDeviceSwapchainMaintenance1FeaturesExt = 1000275000,
+    SwapchainPresentFenceInfoExt = 1000275001,
+    SwapchainPresentModesCreateInfoExt = 1000275002,
+    SwapchainPresentModeInfoExt = 1000275003,
+    SwapchainPresentScalingCreateInfoExt = 1000275004,
+    ReleaseSwapchainImagesInfoExt = 1000275005,
 }
 
 #[repr(i32)]
index 8db0c9824f02046d54d4b7f67cc85018b2ea491a..275b36d49168bbb52c5c93cbfb94149a6f694a16 100644 (file)
@@ -870,6 +870,24 @@ impl PipelineStageFlags2 {
     pub const INVOCATION_MASK_HUAWEI: Self = Self(0x10000000000);
 }
 
+#[repr(C)]
+pub struct PresentScalingFlagsEXT(u32);
+
+impl PresentScalingFlagsEXT {
+    pub const ONE_TO_ONE_EXT: Self = Self(0x00000001);
+    pub const ASPECT_RATIO_STRETCH_EXT: Self = Self(0x00000002);
+    pub const STRETCH_EXT: Self = Self(0x00000004);
+}
+
+#[repr(C)]
+pub struct PresentGravityFlagsEXT(u32);
+
+impl PresentGravityFlagsEXT {
+    pub const MIN_EXT: Self = Self(0x00000001);
+    pub const MAX_EXT: Self = Self(0x00000002);
+    pub const CENTERED_EXT: Self = Self(0x00000004);
+}
+
 macro_rules! impl_flags_u32 {
     ($($t:ty),+) => {
         $(
@@ -1123,7 +1141,9 @@ impl_flags_u32!(
     ResolveModeFlags,
     RenderingFlags,
     SubgroupFeatureFlags,
-    SubmitFlags
+    SubmitFlags,
+    PresentScalingFlagsEXT,
+    PresentGravityFlagsEXT
 );
 
 impl_flags_u64!(AccessFlags2, PipelineStageFlags2);
index e22a7115fa1663767e843e6b41062b168e11490d..9ddceb1938d3e8f19de901ef9763549d0cd9fcf6 100644 (file)
@@ -927,6 +927,9 @@ pub type FnAcquireNextImage2KHR = extern "system" fn(
     image_index: &mut u32,
 ) -> Result;
 
+pub type FnReleaseSwapchainImagesEXT =
+    extern "system" fn(device: Device, release_info: &ReleaseSwapchainImagesInfoEXT) -> Result;
+
 pub type FnGetPhysicalDeviceSurfaceCapabilities2KHR = extern "system" fn(
     physical_device: PhysicalDevice,
     surface_info: &PhysicalDeviceSurfaceInfo2KHR,
index c5221769b84b4fed62c2a96269071adb878ce748..a0f0c7816ed5b1910245b0d6cfdca559bf45f025 100644 (file)
@@ -2734,3 +2734,35 @@ impl SurfaceCapabilities2KhrFunctions {
         )
     }
 }
+
+pub struct SwapchainMaintenance1ExtFunctions {
+    release_swapchain_images_ext: FnReleaseSwapchainImagesEXT,
+}
+
+impl SwapchainMaintenance1ExtFunctions {
+    pub fn new(instance_functions: &InstanceFunctions, device: Device) -> Self {
+        unsafe {
+            let load = |name: &CStr| {
+                instance_functions
+                    .get_device_proc_addr(device, name)
+                    .unwrap_or_else(
+                        #[cold]
+                        || panic!("failed to load device function {}", name.to_string_lossy()),
+                    )
+            };
+            Self {
+                release_swapchain_images_ext: transmute::<_, _>(load(
+                    c"vkReleaseSwapchainImagesEXT",
+                )),
+            }
+        }
+    }
+
+    pub unsafe fn release_swapchain_images_ext(
+        &self,
+        device: Device,
+        release_info: &ReleaseSwapchainImagesInfoEXT,
+    ) -> Result {
+        (self.release_swapchain_images_ext)(device, release_info)
+    }
+}
index 2d46a600eac8807b40ae9a325a4c2fbf5a2b4a17..2fbb061aee1016ac4006723fed69282f712e9d4b 100644 (file)
@@ -543,6 +543,124 @@ impl Default for SurfaceFormatKHR {
     }
 }
 
+#[repr(C)]
+pub struct SurfacePresentModeEXT {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub present_mode: PresentModeKHR,
+}
+
+impl Default for SurfacePresentModeEXT {
+    fn default() -> Self {
+        Self {
+            _type: StructureType::SurfacePresentModeExt,
+            _next: core::ptr::null(),
+            present_mode: PresentModeKHR::Fifo,
+        }
+    }
+}
+
+#[repr(C)]
+pub struct SwapchainPresentModesCreateInfoEXT<'a> {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub present_modes: VulkanSlice1<'a, u32, PresentModeKHR, 4>,
+}
+
+impl<'a> Default for SwapchainPresentModesCreateInfoEXT<'a> {
+    fn default() -> Self {
+        Self {
+            _type: StructureType::SwapchainPresentModesCreateInfoExt,
+            _next: core::ptr::null(),
+            present_modes: Default::default(),
+        }
+    }
+}
+
+#[repr(C)]
+pub struct SurfacePresentModeCompatibilityEXT<'a> {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub present_modes: VulkanSlice1<'a, u32, PresentModeKHR, 4>,
+}
+
+impl<'a> Default for SurfacePresentModeCompatibilityEXT<'a> {
+    fn default() -> Self {
+        Self {
+            _type: StructureType::SurfacePresentModeCompatibilityExt,
+            _next: core::ptr::null(),
+            present_modes: Default::default(),
+        }
+    }
+}
+
+#[repr(C)]
+pub struct SurfacePresentScalingCapabilitiesEXT {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub supported_present_scaling: PresentScalingFlagsEXT,
+    pub supported_present_gravity_x: PresentGravityFlagsEXT,
+    pub supported_present_gravity_y: PresentGravityFlagsEXT,
+    pub min_scaled_image_extent: Extent2d,
+    pub max_scaled_image_extent: Extent2d,
+}
+
+impl Default for SurfacePresentScalingCapabilitiesEXT {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::SurfacePresentScalingCapabilitiesExt;
+        x
+    }
+}
+
+#[repr(C)]
+pub struct SwapchainPresentScalingCreateInfoEXT {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub scaling_behavior: PresentScalingFlagsEXT,
+    pub present_gravity_x: PresentGravityFlagsEXT,
+    pub present_gravity_y: PresentGravityFlagsEXT,
+}
+
+impl Default for SwapchainPresentScalingCreateInfoEXT {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::SwapchainPresentScalingCreateInfoExt;
+        x
+    }
+}
+
+#[repr(C)]
+pub struct SwapchainPresentFenceInfoEXT<'a> {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub fences: VulkanSlice1<'a, u32, Fence, 4>,
+}
+
+impl<'a> Default for SwapchainPresentFenceInfoEXT<'a> {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::SwapchainPresentFenceInfoExt;
+        x
+    }
+}
+
+#[repr(C)]
+pub struct ReleaseSwapchainImagesInfoEXT<'a> {
+    pub _type: StructureType,
+    pub _next: *const c_void,
+    pub swapchain: SwapchainKHR,
+    pub image_indices: VulkanSlice1<'a, u32, u32, 4>,
+}
+
+impl<'a> Default for ReleaseSwapchainImagesInfoEXT<'a> {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::ReleaseSwapchainImagesInfoExt;
+        x
+    }
+}
+
 #[repr(C)]
 pub struct SwapchainCreateInfoKHR<'a> {
     pub _type: StructureType,
@@ -2478,6 +2596,20 @@ impl Default for PhysicalDeviceVulkan13Features {
     }
 }
 
+pub struct PhysicalDeviceSwapchainMaintenance1FeaturesEXT {
+    pub _type: StructureType,
+    pub _next: *mut c_void,
+    pub swapchain_maintenance1: Bool32,
+}
+
+impl Default for PhysicalDeviceSwapchainMaintenance1FeaturesEXT {
+    fn default() -> Self {
+        let mut x = unsafe { MaybeUninit::<Self>::zeroed().assume_init() };
+        x._type = StructureType::PhysicalDeviceSwapchainMaintenance1FeaturesExt;
+        x
+    }
+}
+
 #[repr(C)]
 pub struct PhysicalDeviceProperties {
     pub api_version: u32,
@@ -2994,5 +3126,27 @@ mod test {
             assert!(is_aligned(addr_of!(semaphore_wait_info.semaphores.ptr0)));
             assert!(is_aligned(addr_of!(semaphore_wait_info.semaphores.ptr1)));
         }
+
+        {
+            let swapchain_present_modes_create_info = SwapchainPresentModesCreateInfoEXT::default();
+            assert!(is_aligned(addr_of!(
+                swapchain_present_modes_create_info.present_modes.ptr
+            )));
+
+            let surface_present_mode_capability = SurfacePresentModeCompatibilityEXT::default();
+            assert!(is_aligned(addr_of!(
+                surface_present_mode_capability.present_modes.ptr
+            )));
+
+            let swapchain_present_fence_info = SwapchainPresentFenceInfoEXT::default();
+            assert!(is_aligned(addr_of!(
+                swapchain_present_fence_info.fences.ptr
+            )));
+
+            let release_swapchain_images_info = ReleaseSwapchainImagesInfoEXT::default();
+            assert!(is_aligned(addr_of!(
+                release_swapchain_images_info.image_indices.ptr
+            )));
+        }
     }
 }