pub fn unnormalized(device: Arc<Device>, filter: Filter,
                        address_u: UnnormalizedSamplerAddressMode,
                        address_v: UnnormalizedSamplerAddressMode)
                        -> Result<Arc<Sampler>, SamplerCreationError> {
        let vk = device.pointers();

        let border_color = address_u.border_color();
        let border_color = match (border_color, address_v.border_color()) {
            (Some(b1), Some(b2)) => {
                assert_eq!(b1, b2);
                Some(b1)
            },
            (None, b) => b,
            (b, None) => b,
        };

        let sampler = unsafe {
            let infos = vk::SamplerCreateInfo {
                sType: vk::STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
                pNext: ptr::null(),
                flags: 0, // reserved
                magFilter: filter as u32,
                minFilter: filter as u32,
                mipmapMode: vk::SAMPLER_MIPMAP_MODE_NEAREST,
                addressModeU: address_u.to_vk(),
                addressModeV: address_v.to_vk(),
                addressModeW: vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // unused by the impl
                mipLodBias: 0.0,
                anisotropyEnable: vk::FALSE,
                maxAnisotropy: 1.0,
                compareEnable: vk::FALSE,
                compareOp: vk::COMPARE_OP_NEVER,
                minLod: 0.0,
                maxLod: 0.0,
                borderColor: border_color.map(|b| b as u32).unwrap_or(0),
                unnormalizedCoordinates: vk::TRUE,
            };

            let mut output = mem::uninitialized();
            check_errors(vk.CreateSampler(device.internal_object(),
                                          &infos,
                                          ptr::null(),
                                          &mut output))?;
            output
        };

        Ok(Arc::new(Sampler {
                        sampler: sampler,
                        device: device.clone(),
                        compare_mode: false,
                        unnormalized: true,
                        usable_with_float_formats: match border_color {
                            Some(BorderColor::FloatTransparentBlack) => true,
                            Some(BorderColor::FloatOpaqueBlack) => true,
                            Some(BorderColor::FloatOpaqueWhite) => true,
                            Some(_) => false,
                            None => true,
                        },
                        usable_with_int_formats: match border_color {
                            Some(BorderColor::IntTransparentBlack) => true,
                            Some(BorderColor::IntOpaqueBlack) => true,
                            Some(BorderColor::IntOpaqueWhite) => true,
                            Some(_) => false,
                            None => true,
                        },
                        usable_with_swizzling: match border_color {
                            Some(BorderColor::FloatOpaqueBlack) => false,
                            Some(BorderColor::IntOpaqueBlack) => false,
                            _ => true,
                        },
                    }))
    }
/// Creates a sampler with unnormalized coordinates. This means that texture coordinates won't
/// range between `0.0` and `1.0` but use plain pixel offsets.
///
/// Using an unnormalized sampler adds a few restrictions:
///
/// - It can only be used with non-array 1D or 2D images.
/// - It can only be used with images with a single mipmap.
/// - Projection and offsets can't be used by shaders. Only the first mipmap can be accessed.
///
/// # Panic
///
/// - Panics if multiple `ClampToBorder` values are passed and the border color is different.
///
Creates a sampler with unnormalized coordinates. This means that texture coordinates won't
range between `0.0` and `1.0` but use plain pixel offsets.

Using an unnormalized sampler adds a few restrictions.

It can only be used with non-array 1D or 2D images.
It can only be used with images with a single mipmap.
Projection and offsets can't be used by shaders. Only the first mipmap can be accessed.
Creates a sampler with unnormalized coordinates . This means that texture coordinates won ' t range between ` 0 . 0 ` and ` 1 . 0 ` but use plain pixel offsets . Using an unnormalized sampler adds a few restrictions . It can only be used with non - array 1D or 2D images . It can only be used with images with a single mipmap . Projection and offsets can ' t be used by shaders . Only the first mipmap can be accessed .
pub fn unnormalized(device: Arc<Device>, filter: Filter,
                        address_u: UnnormalizedSamplerAddressMode,
                        address_v: UnnormalizedSamplerAddressMode)
                        -> Result<Arc<Sampler>, SamplerCreationError> {
        let vk = device.pointers();
        let border_color = address_u.border_color();
        let border_color = match (border_color, address_v.border_color()) {
            (Some(b1), Some(b2)) => {
                assert_eq!(b1, b2);
                Some(b1)
            },
            (None, b) => b,
            (b, None) => b,
        };
        let sampler = unsafe {
            let infos = vk::SamplerCreateInfo {
                sType: vk::STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
                pNext: ptr::null(),
                flags: 0, // reserved
                magFilter: filter as u32,
                minFilter: filter as u32,
                mipmapMode: vk::SAMPLER_MIPMAP_MODE_NEAREST,
                addressModeU: address_u.to_vk(),
                addressModeV: address_v.to_vk(),
                addressModeW: vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // unused by the impl
                mipLodBias: 0.0,
                anisotropyEnable: vk::FALSE,
                maxAnisotropy: 1.0,
                compareEnable: vk::FALSE,
                compareOp: vk::COMPARE_OP_NEVER,
                minLod: 0.0,
                maxLod: 0.0,
                borderColor: border_color.map(|b| b as u32).unwrap_or(0),
                unnormalizedCoordinates: vk::TRUE,
            };
            let mut output = mem::uninitialized();
            check_errors(vk.CreateSampler(device.internal_object(),
                                          &infos,
                                          ptr::null(),
                                          &mut output))?;
            output
        };
        Ok(Arc::new(Sampler {
                        sampler: sampler,
                        device: device.clone(),
                        compare_mode: false,
                        unnormalized: true,
                        usable_with_float_formats: match border_color {
                            Some(BorderColor::FloatTransparentBlack) => true,
                            Some(BorderColor::FloatOpaqueBlack) => true,
                            Some(BorderColor::FloatOpaqueWhite) => true,
                            Some(_) => false,
                            None => true,
                        },
                        usable_with_int_formats: match border_color {
                            Some(BorderColor::IntTransparentBlack) => true,
                            Some(BorderColor::IntOpaqueBlack) => true,
                            Some(BorderColor::IntOpaqueWhite) => true,
                            Some(_) => false,
                            None => true,
                        },
                        usable_with_swizzling: match border_color {
                            Some(BorderColor::FloatOpaqueBlack) => false,
                            Some(BorderColor::IntOpaqueBlack) => false,
                            _ => true,
                        },
                    }))
    }
pub fn unnormalized ( device : Arc < Device > , filter : Filter , address_u : UnnormalizedSamplerAddressMode , address_v : UnnormalizedSamplerAddressMode ) -> Result < Arc < Sampler > , SamplerCreationError > { let vk = device . pointers ( ) ; let border_color = address_u . border_color ( ) ; let border_color = match ( border_color , address_v . border_color ( ) ) { ( Some ( b1 ) , Some ( b2 ) ) => { assert_eq ! ( b1 b2 ) ; Some ( b1 ) } , ( None , b ) => b , ( b , None ) => b , } ; let sampler = unsafe { let infos = vk :: SamplerCreateInfo { sType : vk :: STRUCTURE_TYPE_SAMPLER_CREATE_INFO , pNext : ptr :: null ( ) , flags : 0 , // reserved magFilter : filter as u32 , minFilter : filter as u32 , mipmapMode : vk :: SAMPLER_MIPMAP_MODE_NEAREST , addressModeU : address_u . to_vk ( ) , addressModeV : address_v . to_vk ( ) , addressModeW : vk :: SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE , // unused by the impl mipLodBias : 0.0 , anisotropyEnable : vk :: FALSE , maxAnisotropy : 1.0 , compareEnable : vk :: FALSE , compareOp : vk :: COMPARE_OP_NEVER , minLod : 0.0 , maxLod : 0.0 , borderColor : border_color . map ( | b | b as u32 ) . unwrap_or ( 0 ) , unnormalizedCoordinates : vk :: TRUE , } ; let mut output = mem :: uninitialized ( ) ; check_errors ( vk . CreateSampler ( device . internal_object ( ) , & infos , ptr :: null ( ) , & mut output ) ) ? ; output } ; Ok ( Arc :: new ( Sampler { sampler : sampler , device : device . clone ( ) , compare_mode : false , unnormalized : true , usable_with_float_formats : match border_color { Some ( BorderColor :: FloatTransparentBlack ) => true , Some ( BorderColor :: FloatOpaqueBlack ) => true , Some ( BorderColor :: FloatOpaqueWhite ) => true , Some ( _ ) => false , None => true , } , usable_with_int_formats : match border_color { Some ( BorderColor :: IntTransparentBlack ) => true , Some ( BorderColor :: IntOpaqueBlack ) => true , Some ( BorderColor :: IntOpaqueWhite ) => true , Some ( _ ) => false , None => true , } , usable_with_swizzling : match border_color { Some ( BorderColor :: FloatOpaqueBlack ) => false , Some ( BorderColor :: IntOpaqueBlack ) => false , _ => true , } , } ) ) }
Creates a sampler with unnormalized coordinates.
Creates a sampler with unnormalized coordinates .
device
Arc<Device>
filter
Filter
address_u
UnnormalizedSamplerAddressMode
address_v
UnnormalizedSamplerAddressMode
device
Arc<Device>
filter
Filter
address_u
UnnormalizedSamplerAddressMode
address_v
UnnormalizedSamplerAddressMode
panic
Panics if multiple `ClampToBorder` values are passed and the border color is different.
Panics if multiple ` ClampToBorder ` values are passed and the border color is different .