@@ -4,7 +4,7 @@ use ash::version::DeviceV1_0;
44use smallvec:: SmallVec ;
55
66use hal:: { buffer, device as d, format, image, mapping, pass, pso, query, queue} ;
7- use hal:: { Backbuffer , MemoryTypeId , SwapchainConfig } ;
7+ use hal:: { Backbuffer , Features , MemoryTypeId , SwapchainConfig } ;
88use hal:: error:: HostExecutionError ;
99use hal:: memory:: Requirements ;
1010use hal:: pool:: CommandPoolCreateFlags ;
@@ -768,7 +768,18 @@ impl d::Device<B> for Device {
768768 fn create_sampler ( & self , sampler_info : image:: SamplerInfo ) -> n:: Sampler {
769769 use hal:: pso:: Comparison ;
770770
771- let ( min_filter, mag_filter, mipmap_mode, aniso) = conv:: map_filter ( sampler_info. filter ) ;
771+ let ( min_filter, mag_filter, mipmap_mode) = conv:: map_filter ( sampler_info. filter ) ;
772+ let ( anisotropy_enable, max_anisotropy) = match sampler_info. filter {
773+ image:: FilterMethod :: Anisotropic ( aniso) => {
774+ if self . raw . 1 . contains ( Features :: SAMPLER_ANISOTROPY ) {
775+ ( vk:: VK_TRUE , aniso as f32 )
776+ } else {
777+ warn ! ( "Anisotropy({}) was requested on a device with disabled anisotropy feature" , aniso) ;
778+ ( vk:: VK_FALSE , 0.0 )
779+ }
780+ }
781+ _ => ( vk:: VK_FALSE , 0.0 )
782+ } ;
772783 let info = vk:: SamplerCreateInfo {
773784 s_type : vk:: StructureType :: SamplerCreateInfo ,
774785 p_next : ptr:: null ( ) ,
@@ -780,8 +791,8 @@ impl d::Device<B> for Device {
780791 address_mode_v : conv:: map_wrap ( sampler_info. wrap_mode . 1 ) ,
781792 address_mode_w : conv:: map_wrap ( sampler_info. wrap_mode . 2 ) ,
782793 mip_lod_bias : sampler_info. lod_bias . into ( ) ,
783- anisotropy_enable : if aniso > 1.0 { vk :: VK_TRUE } else { vk :: VK_FALSE } ,
784- max_anisotropy : aniso ,
794+ anisotropy_enable,
795+ max_anisotropy,
785796 compare_enable : if sampler_info. comparison . is_some ( ) { vk:: VK_TRUE } else { vk:: VK_FALSE } ,
786797 compare_op : conv:: map_comparison ( sampler_info. comparison . unwrap_or ( Comparison :: Never ) ) ,
787798 min_lod : sampler_info. lod_range . start . into ( ) ,
0 commit comments