#![allow(unused_imports)]
use crate::{vk::Result as VkResult, vk::*, *};
use core::ffi::{CStr, c_char, c_int, c_void};
use core::mem::transmute;
use core::ptr;
pub const EXTENSION_NAME: &CStr = c"VK_NV_coverage_reduction_mode";
pub(super) mod defs {
#![allow(non_camel_case_types, unused_imports)]
use crate::{vk::*, *};
use core::ffi::{CStr, c_char, c_int, c_void};
use core::fmt;
use core::marker::PhantomData;
use core::ptr;
#[repr(C)]
#[derive(Copy, Clone)]
#[must_use]
pub struct PhysicalDeviceCoverageReductionModeFeaturesNV<'a> {
pub s_type: StructureType,
pub p_next: *mut c_void,
pub coverage_reduction_mode: Bool32,
pub _marker: PhantomData<&'a ()>,
}
#[cfg(feature = "debug")]
impl fmt::Debug for PhysicalDeviceCoverageReductionModeFeaturesNV<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PhysicalDeviceCoverageReductionModeFeaturesNV")
.field("s_type", &self.s_type)
.field("p_next", &self.p_next)
.field("coverage_reduction_mode", &self.coverage_reduction_mode)
.finish()
}
}
unsafe impl<'a> TaggedStructure<'a> for PhysicalDeviceCoverageReductionModeFeaturesNV<'a> {
const STRUCTURE_TYPE: StructureType =
StructureType::PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV;
}
unsafe impl Extends<PhysicalDeviceFeatures2<'_>>
for PhysicalDeviceCoverageReductionModeFeaturesNV<'_>
{
}
unsafe impl Extends<DeviceCreateInfo<'_>> for PhysicalDeviceCoverageReductionModeFeaturesNV<'_> {}
impl Default for PhysicalDeviceCoverageReductionModeFeaturesNV<'_> {
fn default() -> Self {
Self {
s_type: Self::STRUCTURE_TYPE,
p_next: ptr::null_mut(),
coverage_reduction_mode: Default::default(),
_marker: PhantomData,
}
}
}
impl<'a> PhysicalDeviceCoverageReductionModeFeaturesNV<'a> {
#[inline]
pub fn coverage_reduction_mode(mut self, coverage_reduction_mode: bool) -> Self {
self.coverage_reduction_mode = coverage_reduction_mode.into();
self
}
}
#[repr(C)]
#[derive(Copy, Clone)]
#[must_use]
pub struct PipelineCoverageReductionStateCreateInfoNV<'a> {
pub s_type: StructureType,
pub p_next: *const c_void,
pub flags: PipelineCoverageReductionStateCreateFlagsNV,
pub coverage_reduction_mode: CoverageReductionModeNV,
pub _marker: PhantomData<&'a ()>,
}
#[cfg(feature = "debug")]
impl fmt::Debug for PipelineCoverageReductionStateCreateInfoNV<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PipelineCoverageReductionStateCreateInfoNV")
.field("s_type", &self.s_type)
.field("p_next", &self.p_next)
.field("flags", &self.flags)
.field("coverage_reduction_mode", &self.coverage_reduction_mode)
.finish()
}
}
unsafe impl<'a> TaggedStructure<'a> for PipelineCoverageReductionStateCreateInfoNV<'a> {
const STRUCTURE_TYPE: StructureType =
StructureType::PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV;
}
unsafe impl Extends<PipelineMultisampleStateCreateInfo<'_>>
for PipelineCoverageReductionStateCreateInfoNV<'_>
{
}
impl Default for PipelineCoverageReductionStateCreateInfoNV<'_> {
fn default() -> Self {
Self {
s_type: Self::STRUCTURE_TYPE,
p_next: ptr::null(),
flags: Default::default(),
coverage_reduction_mode: Default::default(),
_marker: PhantomData,
}
}
}
impl<'a> PipelineCoverageReductionStateCreateInfoNV<'a> {
#[inline]
pub fn flags(mut self, flags: PipelineCoverageReductionStateCreateFlagsNV) -> Self {
self.flags = flags;
self
}
#[inline]
pub fn coverage_reduction_mode(
mut self,
coverage_reduction_mode: CoverageReductionModeNV,
) -> Self {
self.coverage_reduction_mode = coverage_reduction_mode;
self
}
}
#[repr(C)]
#[derive(Copy, Clone)]
#[must_use]
pub struct FramebufferMixedSamplesCombinationNV<'a> {
pub s_type: StructureType,
pub p_next: *mut c_void,
pub coverage_reduction_mode: CoverageReductionModeNV,
pub rasterization_samples: SampleCountFlagBits,
pub depth_stencil_samples: SampleCountFlags,
pub color_samples: SampleCountFlags,
pub _marker: PhantomData<&'a ()>,
}
#[cfg(feature = "debug")]
impl fmt::Debug for FramebufferMixedSamplesCombinationNV<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FramebufferMixedSamplesCombinationNV")
.field("s_type", &self.s_type)
.field("p_next", &self.p_next)
.field("coverage_reduction_mode", &self.coverage_reduction_mode)
.field("rasterization_samples", &self.rasterization_samples)
.field("depth_stencil_samples", &self.depth_stencil_samples)
.field("color_samples", &self.color_samples)
.finish()
}
}
unsafe impl<'a> TaggedStructure<'a> for FramebufferMixedSamplesCombinationNV<'a> {
const STRUCTURE_TYPE: StructureType =
StructureType::FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV;
}
impl Default for FramebufferMixedSamplesCombinationNV<'_> {
fn default() -> Self {
Self {
s_type: Self::STRUCTURE_TYPE,
p_next: ptr::null_mut(),
coverage_reduction_mode: Default::default(),
rasterization_samples: Default::default(),
depth_stencil_samples: Default::default(),
color_samples: Default::default(),
_marker: PhantomData,
}
}
}
impl<'a> FramebufferMixedSamplesCombinationNV<'a> {
#[inline]
pub fn coverage_reduction_mode(
mut self,
coverage_reduction_mode: CoverageReductionModeNV,
) -> Self {
self.coverage_reduction_mode = coverage_reduction_mode;
self
}
#[inline]
pub fn rasterization_samples(mut self, rasterization_samples: SampleCountFlagBits) -> Self {
self.rasterization_samples = rasterization_samples;
self
}
#[inline]
pub fn depth_stencil_samples(mut self, depth_stencil_samples: SampleCountFlags) -> Self {
self.depth_stencil_samples = depth_stencil_samples;
self
}
#[inline]
pub fn color_samples(mut self, color_samples: SampleCountFlags) -> Self {
self.color_samples = color_samples;
self
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CoverageReductionModeNV(i32);
impl CoverageReductionModeNV {
#[inline]
pub const fn from_raw(x: i32) -> Self {
Self(x)
}
#[inline]
pub const fn as_raw(self) -> i32 {
self.0
}
pub const MERGE_NV: Self = Self(0);
pub const TRUNCATE_NV: Self = Self(1);
}
impl fmt::Debug for CoverageReductionModeNV {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = match *self {
Self::MERGE_NV => Some("MERGE_NV"),
Self::TRUNCATE_NV => Some("TRUNCATE_NV"),
_ => None,
};
if let Some(name) = name {
f.write_str(name)
} else {
self.0.fmt(f)
}
}
}
#[repr(transparent)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct PipelineCoverageReductionStateCreateFlagsNV(Flags);
vk_bitflags_wrapped!(PipelineCoverageReductionStateCreateFlagsNV, Flags);
impl fmt::Debug for PipelineCoverageReductionStateCreateFlagsNV {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
debug_flags(f, &[], self.0)
}
}
pub type PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV =
unsafe extern "system" fn(
physical_device: PhysicalDevice,
p_combination_count: *mut u32,
p_combinations: *mut FramebufferMixedSamplesCombinationNV<'_>,
) -> vk::Result;
}
#[cfg(feature = "ffi")]
pub(super) mod ffi {
#![allow(non_camel_case_types)]
use super::defs::*;
pub type VkPhysicalDeviceCoverageReductionModeFeaturesNV =
PhysicalDeviceCoverageReductionModeFeaturesNV<'static>;
pub type VkPipelineCoverageReductionStateCreateInfoNV =
PipelineCoverageReductionStateCreateInfoNV<'static>;
pub type VkFramebufferMixedSamplesCombinationNV = FramebufferMixedSamplesCombinationNV<'static>;
pub type VkCoverageReductionModeNV = CoverageReductionModeNV;
pub type VkPipelineCoverageReductionStateCreateFlagsNV =
PipelineCoverageReductionStateCreateFlagsNV;
impl PhysicalDeviceCoverageReductionModeFeaturesNV<'_> {
#[inline]
pub unsafe fn drop_lifetime_for_ffi(
&self,
) -> &VkPhysicalDeviceCoverageReductionModeFeaturesNV {
unsafe { core::mem::transmute(self) }
}
}
impl PipelineCoverageReductionStateCreateInfoNV<'_> {
#[inline]
pub unsafe fn drop_lifetime_for_ffi(
&self,
) -> &VkPipelineCoverageReductionStateCreateInfoNV {
unsafe { core::mem::transmute(self) }
}
}
impl FramebufferMixedSamplesCombinationNV<'_> {
#[inline]
pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkFramebufferMixedSamplesCombinationNV {
unsafe { core::mem::transmute(self) }
}
}
}
pub struct InstanceFn {
get_physical_device_supported_framebuffer_mixed_samples_combinations:
PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV,
}
impl LoadInstanceFn for InstanceFn {
unsafe fn load_with(
load: impl Fn(&CStr) -> Option<PFN_vkVoidFunction>,
) -> core::result::Result<Self, MissingEntryPointError> {
unsafe {
Ok(Self {
get_physical_device_supported_framebuffer_mixed_samples_combinations: transmute(
load(c"vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV")
.ok_or(MissingEntryPointError)?,
),
})
}
}
}
impl InstanceFn {
#[inline]
pub unsafe fn get_physical_device_supported_framebuffer_mixed_samples_combinations<'a>(
&self,
physical_device: PhysicalDevice,
mut combinations: impl EnumerateInto<FramebufferMixedSamplesCombinationNV<'a>>,
) -> crate::Result<()> {
unsafe {
let call = |combination_count, combinations| {
let result = (self
.get_physical_device_supported_framebuffer_mixed_samples_combinations)(
physical_device,
combination_count,
combinations as _,
);
match result {
VkResult::SUCCESS => Ok(()),
VkResult::INCOMPLETE => Ok(()),
err => Err(err),
}
};
let mut len = 0;
call(&mut len, std::ptr::null_mut())?;
let capacity = len.try_into().expect("failed to convert `N` to usize");
let combinations_buf = combinations.reserve(capacity);
len = combinations_buf.len().try_into().unwrap();
let result = call(&mut len, combinations_buf.as_mut_ptr() as *mut _)?;
combinations.set_len(len.try_into().unwrap());
Ok(result)
}
}
}