diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-03-12 20:57:03 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-03-13 00:20:57 +0100 |
commit | aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f (patch) | |
tree | db24e62b8d523488b1ac028e8816e7792fbf5638 /src/video_core/renderer_vulkan/vk_sampler_cache.h | |
parent | video_core/texture: Add a raw representation of TSCEntry (diff) | |
download | yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.tar yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.tar.gz yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.tar.bz2 yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.tar.lz yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.tar.xz yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.tar.zst yuzu-aa59d77c3bd7745f03e9bc1d1dca17bb0c338c1f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_sampler_cache.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_sampler_cache.h b/src/video_core/renderer_vulkan/vk_sampler_cache.h new file mode 100644 index 000000000..c6394dc87 --- /dev/null +++ b/src/video_core/renderer_vulkan/vk_sampler_cache.h @@ -0,0 +1,56 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <unordered_map> + +#include "common/common_types.h" +#include "video_core/renderer_vulkan/declarations.h" +#include "video_core/textures/texture.h" + +namespace Vulkan { + +class VKDevice; + +struct SamplerCacheKey final : public Tegra::Texture::TSCEntry { + std::size_t Hash() const; + + bool operator==(const SamplerCacheKey& rhs) const; + + bool operator!=(const SamplerCacheKey& rhs) const { + return !operator==(rhs); + } +}; + +} // namespace Vulkan + +namespace std { + +template <> +struct hash<Vulkan::SamplerCacheKey> { + std::size_t operator()(const Vulkan::SamplerCacheKey& k) const noexcept { + return k.Hash(); + } +}; + +} // namespace std + +namespace Vulkan { + +class VKSamplerCache { +public: + explicit VKSamplerCache(const VKDevice& device); + ~VKSamplerCache(); + + vk::Sampler GetSampler(const Tegra::Texture::TSCEntry& tsc); + +private: + UniqueSampler CreateSampler(const Tegra::Texture::TSCEntry& tsc); + + const VKDevice& device; + std::unordered_map<SamplerCacheKey, UniqueSampler> cache; +}; + +} // namespace Vulkan |