lava 0.4.9

Rust wrapper to manipulate Vulkan more conveniently than with bindings.
Documentation
// Generated by `scripts/generate.js`

use utils::vk_traits::*;

/// Wrapper for [VkSamplerCreateFlags](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSamplerCreateFlags.html).
///
/// Use the macro `VkSamplerCreateFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
/// ```
/// VkSamplerCreateFlags!(subsampled_ext, subsampled_coarse_reconstruction_ext)
/// ```
/// ```
/// VkSamplerCreateFlags {
///     subsampled_ext: true,
///     subsampled_coarse_reconstruction_ext: true,
/// }
/// ```
#[derive(Debug, Clone)]
pub struct VkSamplerCreateFlags {
    pub subsampled_ext: bool,
    pub subsampled_coarse_reconstruction_ext: bool,
}

#[doc(hidden)]
pub type RawVkSamplerCreateFlags = u32;

impl VkWrappedType<RawVkSamplerCreateFlags> for VkSamplerCreateFlags {
    fn vk_to_raw(src: &VkSamplerCreateFlags, dst: &mut RawVkSamplerCreateFlags) {
        *dst = 0;
        if src.subsampled_ext { *dst |= 0x00000001; }
        if src.subsampled_coarse_reconstruction_ext { *dst |= 0x00000002; }
    }
}

impl VkRawType<VkSamplerCreateFlags> for RawVkSamplerCreateFlags {
    fn vk_to_wrapped(src: &RawVkSamplerCreateFlags) -> VkSamplerCreateFlags {
        VkSamplerCreateFlags {
            subsampled_ext: (src & 0x00000001) != 0,
            subsampled_coarse_reconstruction_ext: (src & 0x00000002) != 0,
        }
    }
}

impl Default for VkSamplerCreateFlags {
    fn default() -> VkSamplerCreateFlags {
        VkSamplerCreateFlags {
            subsampled_ext: false,
            subsampled_coarse_reconstruction_ext: false,
        }
    }
}

impl VkSamplerCreateFlags {
    
    /// Return a structure with all flags to `false`.
    pub fn none() -> Self {
        VkSamplerCreateFlags {
            subsampled_ext: false,
            subsampled_coarse_reconstruction_ext: false,
        }
    }
    
    /// Return a structure with all flags to `true`.
    pub fn all() -> Self {
        VkSamplerCreateFlags {
            subsampled_ext: true,
            subsampled_coarse_reconstruction_ext: true,
        }
    }
    
    /// Return the numerical bit flags corresponding to the structure (as described in the Vulkan specs).
    pub fn to_u32(&self) -> u32 {
        0
        + if self.subsampled_ext { 0x00000001 } else { 0 }
        + if self.subsampled_coarse_reconstruction_ext { 0x00000002 } else { 0 }
    }
    
    /// Create a structure corresponding to the specified numerical bit flags.
    pub fn from_u32(value: u32) -> Self {
        VkSamplerCreateFlags {
            subsampled_ext: value & 0x00000001 > 0,
            subsampled_coarse_reconstruction_ext: value & 0x00000002 > 0,
        }
    }
}

#[doc(hidden)]
#[macro_export]
macro_rules! VkSamplerCreateFlags {
    ( $( $x:ident ),* ) => {
        VkSamplerCreateFlags {
            $($x: true,)*
            ..VkSamplerCreateFlags::none()
        }
    }
}