|
@@ -7,7 +7,6 @@
|
|
|
#include <unordered_map>
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "common/assert.h"
|
|
#include "common/assert.h"
|
|
|
-#include "common/cityhash.h"
|
|
|
|
|
#include "video_core/renderer_vulkan/declarations.h"
|
|
#include "video_core/renderer_vulkan/declarations.h"
|
|
|
#include "video_core/renderer_vulkan/maxwell_to_vk.h"
|
|
#include "video_core/renderer_vulkan/maxwell_to_vk.h"
|
|
|
#include "video_core/renderer_vulkan/vk_sampler_cache.h"
|
|
#include "video_core/renderer_vulkan/vk_sampler_cache.h"
|
|
@@ -28,39 +27,20 @@ static std::optional<vk::BorderColor> TryConvertBorderColor(std::array<float, 4>
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-std::size_t SamplerCacheKey::Hash() const {
|
|
|
|
|
- static_assert(sizeof(raw) % sizeof(u64) == 0);
|
|
|
|
|
- return static_cast<std::size_t>(
|
|
|
|
|
- Common::CityHash64(reinterpret_cast<const char*>(raw.data()), sizeof(raw) / sizeof(u64)));
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-bool SamplerCacheKey::operator==(const SamplerCacheKey& rhs) const {
|
|
|
|
|
- return raw == rhs.raw;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
VKSamplerCache::VKSamplerCache(const VKDevice& device) : device{device} {}
|
|
VKSamplerCache::VKSamplerCache(const VKDevice& device) : device{device} {}
|
|
|
|
|
|
|
|
VKSamplerCache::~VKSamplerCache() = default;
|
|
VKSamplerCache::~VKSamplerCache() = default;
|
|
|
|
|
|
|
|
-vk::Sampler VKSamplerCache::GetSampler(const Tegra::Texture::TSCEntry& tsc) {
|
|
|
|
|
- const auto [entry, is_cache_miss] = cache.try_emplace(SamplerCacheKey{tsc});
|
|
|
|
|
- auto& sampler = entry->second;
|
|
|
|
|
- if (is_cache_miss) {
|
|
|
|
|
- sampler = CreateSampler(tsc);
|
|
|
|
|
- }
|
|
|
|
|
- return *sampler;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-UniqueSampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) {
|
|
|
|
|
- const float max_anisotropy = tsc.GetMaxAnisotropy();
|
|
|
|
|
- const bool has_anisotropy = max_anisotropy > 1.0f;
|
|
|
|
|
|
|
+UniqueSampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) const {
|
|
|
|
|
+ const float max_anisotropy{tsc.GetMaxAnisotropy()};
|
|
|
|
|
+ const bool has_anisotropy{max_anisotropy > 1.0f};
|
|
|
|
|
|
|
|
- const auto border_color = tsc.GetBorderColor();
|
|
|
|
|
- const auto vk_border_color = TryConvertBorderColor(border_color);
|
|
|
|
|
|
|
+ const auto border_color{tsc.GetBorderColor()};
|
|
|
|
|
+ const auto vk_border_color{TryConvertBorderColor(border_color)};
|
|
|
UNIMPLEMENTED_IF_MSG(!vk_border_color, "Unimplemented border color {} {} {} {}",
|
|
UNIMPLEMENTED_IF_MSG(!vk_border_color, "Unimplemented border color {} {} {} {}",
|
|
|
border_color[0], border_color[1], border_color[2], border_color[3]);
|
|
border_color[0], border_color[1], border_color[2], border_color[3]);
|
|
|
|
|
|
|
|
- constexpr bool unnormalized_coords = false;
|
|
|
|
|
|
|
+ constexpr bool unnormalized_coords{false};
|
|
|
|
|
|
|
|
const vk::SamplerCreateInfo sampler_ci(
|
|
const vk::SamplerCreateInfo sampler_ci(
|
|
|
{}, MaxwellToVK::Sampler::Filter(tsc.mag_filter),
|
|
{}, MaxwellToVK::Sampler::Filter(tsc.mag_filter),
|
|
@@ -73,9 +53,13 @@ UniqueSampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc)
|
|
|
tsc.GetMaxLod(), vk_border_color.value_or(vk::BorderColor::eFloatTransparentBlack),
|
|
tsc.GetMaxLod(), vk_border_color.value_or(vk::BorderColor::eFloatTransparentBlack),
|
|
|
unnormalized_coords);
|
|
unnormalized_coords);
|
|
|
|
|
|
|
|
- const auto& dld = device.GetDispatchLoader();
|
|
|
|
|
- const auto dev = device.GetLogical();
|
|
|
|
|
|
|
+ const auto& dld{device.GetDispatchLoader()};
|
|
|
|
|
+ const auto dev{device.GetLogical()};
|
|
|
return dev.createSamplerUnique(sampler_ci, nullptr, dld);
|
|
return dev.createSamplerUnique(sampler_ci, nullptr, dld);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+vk::Sampler VKSamplerCache::ToSamplerType(const UniqueSampler& sampler) const {
|
|
|
|
|
+ return *sampler;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
} // namespace Vulkan
|
|
} // namespace Vulkan
|