ash/extensions/nv/
coverage_reduction_mode.rs

1use crate::prelude::*;
2use crate::vk;
3use crate::{Entry, Instance};
4use std::ffi::CStr;
5use std::mem;
6
7/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_NV_coverage_reduction_mode.html>
8#[derive(Clone)]
9pub struct CoverageReductionMode {
10    fp: vk::NvCoverageReductionModeFn,
11}
12
13impl CoverageReductionMode {
14    pub fn new(entry: &Entry, instance: &Instance) -> Self {
15        let fp = vk::NvCoverageReductionModeFn::load(|name| unsafe {
16            mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
17        });
18        Self { fp }
19    }
20
21    /// Retrieve the number of elements to pass to [`get_physical_device_supported_framebuffer_mixed_samples_combinations()`][Self::get_physical_device_supported_framebuffer_mixed_samples_combinations()]
22    #[inline]
23    pub unsafe fn get_physical_device_supported_framebuffer_mixed_samples_combinations_len(
24        &self,
25        physical_device: vk::PhysicalDevice,
26    ) -> VkResult<usize> {
27        let mut count = 0;
28        (self
29            .fp
30            .get_physical_device_supported_framebuffer_mixed_samples_combinations_nv)(
31            physical_device,
32            &mut count,
33            std::ptr::null_mut(),
34        )
35        .result_with_success(count as usize)
36    }
37
38    /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV.html>
39    ///
40    /// Call [`get_physical_device_supported_framebuffer_mixed_samples_combinations_len()`][Self::get_physical_device_supported_framebuffer_mixed_samples_combinations_len()] to query the number of elements to pass to `out`.
41    /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
42    #[inline]
43    pub unsafe fn get_physical_device_supported_framebuffer_mixed_samples_combinations(
44        &self,
45        physical_device: vk::PhysicalDevice,
46        out: &mut [vk::FramebufferMixedSamplesCombinationNV],
47    ) -> VkResult<()> {
48        let mut count = out.len() as u32;
49        (self
50            .fp
51            .get_physical_device_supported_framebuffer_mixed_samples_combinations_nv)(
52            physical_device,
53            &mut count,
54            out.as_mut_ptr(),
55        )
56        .result()?;
57        assert_eq!(count as usize, out.len());
58        Ok(())
59    }
60
61    #[inline]
62    pub const fn name() -> &'static CStr {
63        vk::NvCoverageReductionModeFn::name()
64    }
65
66    #[inline]
67    pub fn fp(&self) -> &vk::NvCoverageReductionModeFn {
68        &self.fp
69    }
70}