diff options
Diffstat (limited to 'src/video_core/shader_cache.h')
| -rw-r--r-- | src/video_core/shader_cache.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/video_core/shader_cache.h b/src/video_core/shader_cache.h index 89a4bcc84..136fe294c 100644 --- a/src/video_core/shader_cache.h +++ b/src/video_core/shader_cache.h | |||
| @@ -4,14 +4,18 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <algorithm> | ||
| 8 | #include <array> | ||
| 7 | #include <memory> | 9 | #include <memory> |
| 8 | #include <mutex> | 10 | #include <mutex> |
| 11 | #include <span> | ||
| 9 | #include <unordered_map> | 12 | #include <unordered_map> |
| 10 | #include <utility> | 13 | #include <utility> |
| 11 | #include <vector> | 14 | #include <vector> |
| 12 | 15 | ||
| 13 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 14 | #include "video_core/rasterizer_interface.h" | 17 | #include "video_core/rasterizer_interface.h" |
| 18 | #include "video_core/shader_environment.h" | ||
| 15 | 19 | ||
| 16 | namespace Tegra { | 20 | namespace Tegra { |
| 17 | class MemoryManager; | 21 | class MemoryManager; |
| @@ -30,6 +34,8 @@ class ShaderCache { | |||
| 30 | static constexpr u64 PAGE_BITS = 14; | 34 | static constexpr u64 PAGE_BITS = 14; |
| 31 | static constexpr u64 PAGE_SIZE = u64(1) << PAGE_BITS; | 35 | static constexpr u64 PAGE_SIZE = u64(1) << PAGE_BITS; |
| 32 | 36 | ||
| 37 | static constexpr size_t NUM_PROGRAMS = 6; | ||
| 38 | |||
| 33 | struct Entry { | 39 | struct Entry { |
| 34 | VAddr addr_start; | 40 | VAddr addr_start; |
| 35 | VAddr addr_end; | 41 | VAddr addr_end; |
| @@ -58,6 +64,15 @@ public: | |||
| 58 | void SyncGuestHost(); | 64 | void SyncGuestHost(); |
| 59 | 65 | ||
| 60 | protected: | 66 | protected: |
| 67 | struct GraphicsEnvironments { | ||
| 68 | std::array<GraphicsEnvironment, NUM_PROGRAMS> envs; | ||
| 69 | std::array<Shader::Environment*, NUM_PROGRAMS> env_ptrs; | ||
| 70 | |||
| 71 | std::span<Shader::Environment* const> Span() const noexcept { | ||
| 72 | return std::span(env_ptrs.begin(), std::ranges::find(env_ptrs, nullptr)); | ||
| 73 | } | ||
| 74 | }; | ||
| 75 | |||
| 61 | explicit ShaderCache(VideoCore::RasterizerInterface& rasterizer_, | 76 | explicit ShaderCache(VideoCore::RasterizerInterface& rasterizer_, |
| 62 | Tegra::MemoryManager& gpu_memory_, Tegra::Engines::Maxwell3D& maxwell3d_, | 77 | Tegra::MemoryManager& gpu_memory_, Tegra::Engines::Maxwell3D& maxwell3d_, |
| 63 | Tegra::Engines::KeplerCompute& kepler_compute_); | 78 | Tegra::Engines::KeplerCompute& kepler_compute_); |
| @@ -65,17 +80,21 @@ protected: | |||
| 65 | /// @brief Update the hashes and information of shader stages | 80 | /// @brief Update the hashes and information of shader stages |
| 66 | /// @param unique_hashes Shader hashes to store into when a stage is enabled | 81 | /// @param unique_hashes Shader hashes to store into when a stage is enabled |
| 67 | /// @return True no success, false on error | 82 | /// @return True no success, false on error |
| 68 | bool RefreshStages(std::array<u64, 6>& unique_hashes); | 83 | bool RefreshStages(std::array<u64, NUM_PROGRAMS>& unique_hashes); |
| 69 | 84 | ||
| 70 | /// @brief Returns information about the current compute shader | 85 | /// @brief Returns information about the current compute shader |
| 71 | /// @return Pointer to a valid shader, nullptr on error | 86 | /// @return Pointer to a valid shader, nullptr on error |
| 72 | const ShaderInfo* ComputeShader(); | 87 | const ShaderInfo* ComputeShader(); |
| 73 | 88 | ||
| 89 | /// @brief Collect the current graphics environments | ||
| 90 | void GetGraphicsEnvironments(GraphicsEnvironments& result, | ||
| 91 | const std::array<u64, NUM_PROGRAMS>& unique_hashes); | ||
| 92 | |||
| 74 | Tegra::MemoryManager& gpu_memory; | 93 | Tegra::MemoryManager& gpu_memory; |
| 75 | Tegra::Engines::Maxwell3D& maxwell3d; | 94 | Tegra::Engines::Maxwell3D& maxwell3d; |
| 76 | Tegra::Engines::KeplerCompute& kepler_compute; | 95 | Tegra::Engines::KeplerCompute& kepler_compute; |
| 77 | 96 | ||
| 78 | std::array<const ShaderInfo*, 6> shader_infos{}; | 97 | std::array<const ShaderInfo*, NUM_PROGRAMS> shader_infos{}; |
| 79 | bool last_shaders_valid = false; | 98 | bool last_shaders_valid = false; |
| 80 | 99 | ||
| 81 | private: | 100 | private: |