ursus_core/vulkan/core/
sampler.rs1use ash::vk;
2
3fn base_linear() -> vk::SamplerCreateInfo<'static> {
4 vk::SamplerCreateInfo::default().mag_filter(vk::Filter::LINEAR).min_filter(vk::Filter::LINEAR)
5}
6
7pub fn create_linear_clamp_sampler(device: &ash::Device) -> anyhow::Result<vk::Sampler> {
8 Ok(unsafe {
9 device.create_sampler(
10 &base_linear()
11 .mipmap_mode(vk::SamplerMipmapMode::NEAREST)
12 .address_mode_u(vk::SamplerAddressMode::CLAMP_TO_EDGE)
13 .address_mode_v(vk::SamplerAddressMode::CLAMP_TO_EDGE),
14 None,
15 )?
16 })
17}
18
19pub fn create_linear_repeat_aniso_sampler(device: &ash::Device, max_anisotropy: f32) -> anyhow::Result<vk::Sampler> {
20 Ok(unsafe {
21 device.create_sampler(
22 &base_linear()
23 .mipmap_mode(vk::SamplerMipmapMode::LINEAR)
24 .address_mode_u(vk::SamplerAddressMode::REPEAT)
25 .address_mode_v(vk::SamplerAddressMode::REPEAT)
26 .address_mode_w(vk::SamplerAddressMode::REPEAT)
27 .anisotropy_enable(true)
28 .max_anisotropy(max_anisotropy)
29 .max_lod(vk::LOD_CLAMP_NONE),
30 None,
31 )?
32 })
33}