diff options
| author | 2023-04-23 23:47:05 +0200 | |
|---|---|---|
| committer | 2023-04-24 12:38:47 +0200 | |
| commit | e4dc73f61e2546c07280abbd9bc098358a204c49 (patch) | |
| tree | afda43f7c8a2a91975417a473b1bd5d8d3bf14af /src | |
| parent | QueryCache: rework async downloads. (diff) | |
| download | yuzu-e4dc73f61e2546c07280abbd9bc098358a204c49.tar.gz yuzu-e4dc73f61e2546c07280abbd9bc098358a204c49.tar.xz yuzu-e4dc73f61e2546c07280abbd9bc098358a204c49.zip | |
Clang format and ddress feedback
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/query_cache.h | 39 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_fence_manager.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 6 |
3 files changed, 30 insertions, 16 deletions
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 2a14cc36a..9c6f57817 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <algorithm> | 6 | #include <algorithm> |
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstring> | 8 | #include <cstring> |
| 9 | #include <functional> | ||
| 9 | #include <iterator> | 10 | #include <iterator> |
| 10 | #include <list> | 11 | #include <list> |
| 11 | #include <memory> | 12 | #include <memory> |
| @@ -101,10 +102,10 @@ class QueryCacheBase : public VideoCommon::ChannelSetupCaches<VideoCommon::Chann | |||
| 101 | public: | 102 | public: |
| 102 | explicit QueryCacheBase(VideoCore::RasterizerInterface& rasterizer_, | 103 | explicit QueryCacheBase(VideoCore::RasterizerInterface& rasterizer_, |
| 103 | Core::Memory::Memory& cpu_memory_) | 104 | Core::Memory::Memory& cpu_memory_) |
| 104 | : rasterizer{rasterizer_}, cpu_memory{cpu_memory_}, streams{ | 105 | : rasterizer{rasterizer_}, |
| 105 | {CounterStream{static_cast<QueryCache&>(*this), | 106 | cpu_memory{cpu_memory_}, streams{{CounterStream{static_cast<QueryCache&>(*this), |
| 106 | VideoCore::QueryType::SamplesPassed}}} { | 107 | VideoCore::QueryType::SamplesPassed}}} { |
| 107 | (void) slot_async_jobs.insert(); // Null value | 108 | (void)slot_async_jobs.insert(); // Null value |
| 108 | } | 109 | } |
| 109 | 110 | ||
| 110 | void InvalidateRegion(VAddr addr, std::size_t size) { | 111 | void InvalidateRegion(VAddr addr, std::size_t size) { |
| @@ -136,7 +137,7 @@ public: | |||
| 136 | query = Register(type, *cpu_addr, host_ptr, timestamp.has_value()); | 137 | query = Register(type, *cpu_addr, host_ptr, timestamp.has_value()); |
| 137 | } | 138 | } |
| 138 | 139 | ||
| 139 | auto result = query->BindCounter(Stream(type).Current()); | 140 | auto result = query->BindCounter(Stream(type).Current(), timestamp); |
| 140 | if (result) { | 141 | if (result) { |
| 141 | auto async_job_id = query->GetAsyncJob(); | 142 | auto async_job_id = query->GetAsyncJob(); |
| 142 | auto& async_job = slot_async_jobs[async_job_id]; | 143 | auto& async_job = slot_async_jobs[async_job_id]; |
| @@ -294,15 +295,17 @@ private: | |||
| 294 | void AsyncFlushQuery(CachedQuery* query, std::optional<u64> timestamp, | 295 | void AsyncFlushQuery(CachedQuery* query, std::optional<u64> timestamp, |
| 295 | std::unique_lock<std::recursive_mutex>& lock) { | 296 | std::unique_lock<std::recursive_mutex>& lock) { |
| 296 | const AsyncJobId new_async_job_id = slot_async_jobs.insert(); | 297 | const AsyncJobId new_async_job_id = slot_async_jobs.insert(); |
| 297 | AsyncJob& async_job = slot_async_jobs[new_async_job_id]; | 298 | { |
| 298 | query->SetAsyncJob(new_async_job_id); | 299 | AsyncJob& async_job = slot_async_jobs[new_async_job_id]; |
| 299 | async_job.query_location = query->GetCpuAddr(); | 300 | query->SetAsyncJob(new_async_job_id); |
| 300 | async_job.collected = false; | 301 | async_job.query_location = query->GetCpuAddr(); |
| 302 | async_job.collected = false; | ||
| 301 | 303 | ||
| 302 | if (!uncommitted_flushes) { | 304 | if (!uncommitted_flushes) { |
| 303 | uncommitted_flushes = std::make_shared<std::vector<AsyncJobId>>(); | 305 | uncommitted_flushes = std::make_shared<std::vector<AsyncJobId>>(); |
| 306 | } | ||
| 307 | uncommitted_flushes->push_back(new_async_job_id); | ||
| 304 | } | 308 | } |
| 305 | uncommitted_flushes->push_back(new_async_job_id); | ||
| 306 | lock.unlock(); | 309 | lock.unlock(); |
| 307 | std::function<void()> operation([this, new_async_job_id, timestamp] { | 310 | std::function<void()> operation([this, new_async_job_id, timestamp] { |
| 308 | std::unique_lock local_lock{mutex}; | 311 | std::unique_lock local_lock{mutex}; |
| @@ -408,11 +411,20 @@ public: | |||
| 408 | // When counter is nullptr it means that it's just been reset. We are supposed to write a | 411 | // When counter is nullptr it means that it's just been reset. We are supposed to write a |
| 409 | // zero in these cases. | 412 | // zero in these cases. |
| 410 | const u64 value = counter ? counter->Query(async) : 0; | 413 | const u64 value = counter ? counter->Query(async) : 0; |
| 414 | if (async) { | ||
| 415 | return value; | ||
| 416 | } | ||
| 417 | std::memcpy(host_ptr, &value, sizeof(u64)); | ||
| 418 | |||
| 419 | if (timestamp) { | ||
| 420 | std::memcpy(host_ptr + TIMESTAMP_OFFSET, &*timestamp, sizeof(u64)); | ||
| 421 | } | ||
| 411 | return value; | 422 | return value; |
| 412 | } | 423 | } |
| 413 | 424 | ||
| 414 | /// Binds a counter to this query. | 425 | /// Binds a counter to this query. |
| 415 | std::optional<u64> BindCounter(std::shared_ptr<HostCounter> counter_) { | 426 | std::optional<u64> BindCounter(std::shared_ptr<HostCounter> counter_, |
| 427 | std::optional<u64> timestamp_) { | ||
| 416 | std::optional<u64> result{}; | 428 | std::optional<u64> result{}; |
| 417 | if (counter) { | 429 | if (counter) { |
| 418 | // If there's an old counter set it means the query is being rewritten by the game. | 430 | // If there's an old counter set it means the query is being rewritten by the game. |
| @@ -420,6 +432,7 @@ public: | |||
| 420 | result = std::make_optional(Flush()); | 432 | result = std::make_optional(Flush()); |
| 421 | } | 433 | } |
| 422 | counter = std::move(counter_); | 434 | counter = std::move(counter_); |
| 435 | timestamp = timestamp_; | ||
| 423 | return result; | 436 | return result; |
| 424 | } | 437 | } |
| 425 | 438 | ||
diff --git a/src/video_core/renderer_vulkan/vk_fence_manager.cpp b/src/video_core/renderer_vulkan/vk_fence_manager.cpp index 3bba8aeb0..fad9e3832 100644 --- a/src/video_core/renderer_vulkan/vk_fence_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_fence_manager.cpp | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include "video_core/renderer_vulkan/vk_texture_cache.h" | 10 | #include "video_core/renderer_vulkan/vk_texture_cache.h" |
| 11 | #include "video_core/vulkan_common/vulkan_device.h" | 11 | #include "video_core/vulkan_common/vulkan_device.h" |
| 12 | 12 | ||
| 13 | |||
| 14 | namespace Vulkan { | 13 | namespace Vulkan { |
| 15 | 14 | ||
| 16 | InnerFence::InnerFence(Scheduler& scheduler_, bool is_stubbed_) | 15 | InnerFence::InnerFence(Scheduler& scheduler_, bool is_stubbed_) |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 2d865729a..2d5ef89f0 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -172,7 +172,8 @@ RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra | |||
| 172 | buffer_cache(*this, cpu_memory_, buffer_cache_runtime), | 172 | buffer_cache(*this, cpu_memory_, buffer_cache_runtime), |
| 173 | pipeline_cache(*this, device, scheduler, descriptor_pool, update_descriptor_queue, | 173 | pipeline_cache(*this, device, scheduler, descriptor_pool, update_descriptor_queue, |
| 174 | render_pass_cache, buffer_cache, texture_cache, gpu.ShaderNotify()), | 174 | render_pass_cache, buffer_cache, texture_cache, gpu.ShaderNotify()), |
| 175 | query_cache{*this, cpu_memory_, device, scheduler}, accelerate_dma(buffer_cache, texture_cache, scheduler), | 175 | query_cache{*this, cpu_memory_, device, scheduler}, |
| 176 | accelerate_dma(buffer_cache, texture_cache, scheduler), | ||
| 176 | fence_manager(*this, gpu, texture_cache, buffer_cache, query_cache, device, scheduler), | 177 | fence_manager(*this, gpu, texture_cache, buffer_cache, query_cache, device, scheduler), |
| 177 | wfi_event(device.GetLogical().CreateEvent()) { | 178 | wfi_event(device.GetLogical().CreateEvent()) { |
| 178 | scheduler.SetQueryCache(query_cache); | 179 | scheduler.SetQueryCache(query_cache); |
| @@ -675,7 +676,8 @@ bool RasterizerVulkan::AccelerateConditionalRendering() { | |||
| 675 | const GPUVAddr condition_address{maxwell3d->regs.render_enable.Address()}; | 676 | const GPUVAddr condition_address{maxwell3d->regs.render_enable.Address()}; |
| 676 | Maxwell::ReportSemaphore::Compare cmp; | 677 | Maxwell::ReportSemaphore::Compare cmp; |
| 677 | if (gpu_memory->IsMemoryDirty(condition_address, sizeof(cmp), | 678 | if (gpu_memory->IsMemoryDirty(condition_address, sizeof(cmp), |
| 678 | VideoCommon::CacheType::BufferCache | VideoCommon::CacheType::QueryCache)) { | 679 | VideoCommon::CacheType::BufferCache | |
| 680 | VideoCommon::CacheType::QueryCache)) { | ||
| 679 | return true; | 681 | return true; |
| 680 | } | 682 | } |
| 681 | return false; | 683 | return false; |