Create sampler.
1012{
1013 size_t hash = 0;
1015 seed ^=
value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1016 };
1017
1020 hash_combine(hash, std::hash<float> {}(max_anisotropy));
1021
1025 "Reusing cached sampler (hash: 0x{:X})", hash);
1026 return it->second;
1027 }
1028
1029 vk::SamplerCreateInfo sampler_info;
1030 sampler_info.magFilter = filter;
1031 sampler_info.minFilter = filter;
1032 sampler_info.mipmapMode = vk::SamplerMipmapMode::eLinear;
1033 sampler_info.addressModeU = address_mode;
1034 sampler_info.addressModeV = address_mode;
1035 sampler_info.addressModeW = address_mode;
1036 sampler_info.mipLodBias = 0.0F;
1037 sampler_info.anisotropyEnable = max_anisotropy > 0.0F;
1038 sampler_info.maxAnisotropy = max_anisotropy;
1039 sampler_info.compareEnable = VK_FALSE;
1040 sampler_info.compareOp = vk::CompareOp::eAlways;
1041 sampler_info.minLod = 0.0F;
1042 sampler_info.maxLod = VK_LOD_CLAMP_NONE;
1043 sampler_info.borderColor = vk::BorderColor::eFloatOpaqueBlack;
1044 sampler_info.unnormalizedCoordinates = VK_FALSE;
1045
1046 vk::Sampler sampler;
1047 try {
1049 } catch (const vk::SystemError& e) {
1051 "Failed to create sampler: {}", e.what());
1052 return nullptr;
1053 }
1054
1056
1058 "Created sampler (filter: {}, address: {}, anisotropy: {}, hash: 0x{:X})",
1059 vk::to_string(filter), vk::to_string(address_mode), max_anisotropy, hash);
1060
1061 return sampler;
1062}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< size_t, vk::Sampler > m_sampler_cache
vk::Device get_device() const
Get logical device.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.
void hash_combine(size_t &seed, size_t value)
Combine a hash into an existing seed, FNV-style.