diff options
author | bunnei <bunneidev@gmail.com> | 2020-06-13 19:48:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-13 19:48:27 +0200 |
commit | c2ea1e1bcb88f8e307e54cf588829a516b40258e (patch) | |
tree | 3975cb756ef9d289cc13f3f6dc2a302dacc2c758 /src/video_core/shader/registry.h | |
parent | Merge pull request #3986 from ReinUsesLisp/shader-cache (diff) | |
parent | shader/texture: Join separate image and sampler pairs offline (diff) | |
download | yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.tar yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.tar.gz yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.tar.bz2 yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.tar.lz yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.tar.xz yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.tar.zst yuzu-c2ea1e1bcb88f8e307e54cf588829a516b40258e.zip |
Diffstat (limited to 'src/video_core/shader/registry.h')
-rw-r--r-- | src/video_core/shader/registry.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/video_core/shader/registry.h b/src/video_core/shader/registry.h index 0c80d35fd..231206765 100644 --- a/src/video_core/shader/registry.h +++ b/src/video_core/shader/registry.h @@ -19,8 +19,39 @@ namespace VideoCommon::Shader { +struct SeparateSamplerKey { + std::pair<u32, u32> buffers; + std::pair<u32, u32> offsets; +}; + +} // namespace VideoCommon::Shader + +namespace std { + +template <> +struct hash<VideoCommon::Shader::SeparateSamplerKey> { + std::size_t operator()(const VideoCommon::Shader::SeparateSamplerKey& key) const noexcept { + return std::hash<u32>{}(key.buffers.first ^ key.buffers.second ^ key.offsets.first ^ + key.offsets.second); + } +}; + +template <> +struct equal_to<VideoCommon::Shader::SeparateSamplerKey> { + bool operator()(const VideoCommon::Shader::SeparateSamplerKey& lhs, + const VideoCommon::Shader::SeparateSamplerKey& rhs) const noexcept { + return lhs.buffers == rhs.buffers && lhs.offsets == rhs.offsets; + } +}; + +} // namespace std + +namespace VideoCommon::Shader { + using KeyMap = std::unordered_map<std::pair<u32, u32>, u32, Common::PairHash>; using BoundSamplerMap = std::unordered_map<u32, Tegra::Engines::SamplerDescriptor>; +using SeparateSamplerMap = + std::unordered_map<SeparateSamplerKey, Tegra::Engines::SamplerDescriptor>; using BindlessSamplerMap = std::unordered_map<std::pair<u32, u32>, Tegra::Engines::SamplerDescriptor, Common::PairHash>; @@ -73,6 +104,9 @@ public: std::optional<Tegra::Engines::SamplerDescriptor> ObtainBoundSampler(u32 offset); + std::optional<Tegra::Engines::SamplerDescriptor> ObtainSeparateSampler( + std::pair<u32, u32> buffers, std::pair<u32, u32> offsets); + std::optional<Tegra::Engines::SamplerDescriptor> ObtainBindlessSampler(u32 buffer, u32 offset); /// Inserts a key. @@ -128,6 +162,7 @@ private: Tegra::Engines::ConstBufferEngineInterface* engine = nullptr; KeyMap keys; BoundSamplerMap bound_samplers; + SeparateSamplerMap separate_samplers; BindlessSamplerMap bindless_samplers; u32 bound_buffer; GraphicsInfo graphics_info; |