diff options
| author | 2020-06-11 21:24:45 -0300 | |
|---|---|---|
| committer | 2020-09-06 05:28:48 -0300 | |
| commit | 9e871937250cb92a13336c6c06186c41f19e1738 (patch) | |
| tree | 5151b85f8c4c26e7a5971b32584723f9910ea67b /src/video_core/query_cache.h | |
| parent | Merge pull request #4596 from FearlessTobi/port-5495 (diff) | |
| download | yuzu-9e871937250cb92a13336c6c06186c41f19e1738.tar.gz yuzu-9e871937250cb92a13336c6c06186c41f19e1738.tar.xz yuzu-9e871937250cb92a13336c6c06186c41f19e1738.zip | |
video_core: Remove all Core::System references in renderer
Now that the GPU is initialized when video backends are initialized,
it's no longer needed to query components once the game is running: it
can be done when yuzu is booting.
This allows us to pass components between constructors and in the
process remove all Core::System references in the video backend.
Diffstat (limited to 'src/video_core/query_cache.h')
| -rw-r--r-- | src/video_core/query_cache.h | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 0d3a88765..d13a66bb6 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -95,10 +95,12 @@ template <class QueryCache, class CachedQuery, class CounterStream, class HostCo | |||
| 95 | class QueryPool> | 95 | class QueryPool> |
| 96 | class QueryCacheBase { | 96 | class QueryCacheBase { |
| 97 | public: | 97 | public: |
| 98 | explicit QueryCacheBase(Core::System& system, VideoCore::RasterizerInterface& rasterizer) | 98 | explicit QueryCacheBase(VideoCore::RasterizerInterface& rasterizer_, |
| 99 | : system{system}, rasterizer{rasterizer}, streams{{CounterStream{ | 99 | Tegra::Engines::Maxwell3D& maxwell3d_, |
| 100 | static_cast<QueryCache&>(*this), | 100 | Tegra::MemoryManager& gpu_memory_) |
| 101 | VideoCore::QueryType::SamplesPassed}}} {} | 101 | : rasterizer{rasterizer_}, maxwell3d{maxwell3d_}, |
| 102 | gpu_memory{gpu_memory_}, streams{{CounterStream{static_cast<QueryCache&>(*this), | ||
| 103 | VideoCore::QueryType::SamplesPassed}}} {} | ||
| 102 | 104 | ||
| 103 | void InvalidateRegion(VAddr addr, std::size_t size) { | 105 | void InvalidateRegion(VAddr addr, std::size_t size) { |
| 104 | std::unique_lock lock{mutex}; | 106 | std::unique_lock lock{mutex}; |
| @@ -118,29 +120,27 @@ public: | |||
| 118 | */ | 120 | */ |
| 119 | void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) { | 121 | void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) { |
| 120 | std::unique_lock lock{mutex}; | 122 | std::unique_lock lock{mutex}; |
| 121 | auto& memory_manager = system.GPU().MemoryManager(); | 123 | const std::optional<VAddr> cpu_addr = gpu_memory.GpuToCpuAddress(gpu_addr); |
| 122 | const std::optional<VAddr> cpu_addr_opt = memory_manager.GpuToCpuAddress(gpu_addr); | 124 | ASSERT(cpu_addr); |
| 123 | ASSERT(cpu_addr_opt); | ||
| 124 | VAddr cpu_addr = *cpu_addr_opt; | ||
| 125 | 125 | ||
| 126 | CachedQuery* query = TryGet(cpu_addr); | 126 | CachedQuery* query = TryGet(*cpu_addr); |
| 127 | if (!query) { | 127 | if (!query) { |
| 128 | ASSERT_OR_EXECUTE(cpu_addr_opt, return;); | 128 | ASSERT_OR_EXECUTE(cpu_addr, return;); |
| 129 | const auto host_ptr = memory_manager.GetPointer(gpu_addr); | 129 | u8* const host_ptr = gpu_memory.GetPointer(gpu_addr); |
| 130 | 130 | ||
| 131 | query = Register(type, cpu_addr, host_ptr, timestamp.has_value()); | 131 | query = Register(type, *cpu_addr, host_ptr, timestamp.has_value()); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | query->BindCounter(Stream(type).Current(), timestamp); | 134 | query->BindCounter(Stream(type).Current(), timestamp); |
| 135 | if (Settings::values.use_asynchronous_gpu_emulation.GetValue()) { | 135 | if (Settings::values.use_asynchronous_gpu_emulation.GetValue()) { |
| 136 | AsyncFlushQuery(cpu_addr); | 136 | AsyncFlushQuery(*cpu_addr); |
| 137 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. | 140 | /// Updates counters from GPU state. Expected to be called once per draw, clear or dispatch. |
| 141 | void UpdateCounters() { | 141 | void UpdateCounters() { |
| 142 | std::unique_lock lock{mutex}; | 142 | std::unique_lock lock{mutex}; |
| 143 | const auto& regs = system.GPU().Maxwell3D().regs; | 143 | const auto& regs = maxwell3d.regs; |
| 144 | Stream(VideoCore::QueryType::SamplesPassed).Update(regs.samplecnt_enable); | 144 | Stream(VideoCore::QueryType::SamplesPassed).Update(regs.samplecnt_enable); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| @@ -270,8 +270,9 @@ private: | |||
| 270 | static constexpr std::uintptr_t PAGE_SIZE = 4096; | 270 | static constexpr std::uintptr_t PAGE_SIZE = 4096; |
| 271 | static constexpr unsigned PAGE_BITS = 12; | 271 | static constexpr unsigned PAGE_BITS = 12; |
| 272 | 272 | ||
| 273 | Core::System& system; | ||
| 274 | VideoCore::RasterizerInterface& rasterizer; | 273 | VideoCore::RasterizerInterface& rasterizer; |
| 274 | Tegra::Engines::Maxwell3D& maxwell3d; | ||
| 275 | Tegra::MemoryManager& gpu_memory; | ||
| 275 | 276 | ||
| 276 | std::recursive_mutex mutex; | 277 | std::recursive_mutex mutex; |
| 277 | 278 | ||