From 2f158765240623d5aea916cafca71b86be2d6fd4 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 28 Apr 2023 23:53:46 +0200 Subject: QueryCache: Fix write invalidation. --- src/video_core/fence_manager.h | 1 + src/video_core/query_cache.h | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h index 19bbdd547..3b2f6aab6 100644 --- a/src/video_core/fence_manager.h +++ b/src/video_core/fence_manager.h @@ -64,6 +64,7 @@ public: } void SignalFence(std::function&& func) { + rasterizer.InvalidateGPUCache(); bool delay_fence = Settings::IsGPULevelHigh(); if constexpr (!can_async_check) { TryReleasePendingFences(); diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 9c6f57817..941de95c1 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -310,16 +310,22 @@ private: std::function operation([this, new_async_job_id, timestamp] { std::unique_lock local_lock{mutex}; AsyncJob& async_job = slot_async_jobs[new_async_job_id]; + u64 value = async_job.value; + VAddr address = async_job.query_location; + slot_async_jobs.erase(new_async_job_id); + local_lock.unlock(); if (timestamp) { u64 timestamp_value = *timestamp; - cpu_memory.WriteBlockUnsafe(async_job.query_location + sizeof(u64), - ×tamp_value, sizeof(8)); - cpu_memory.WriteBlockUnsafe(async_job.query_location, &async_job.value, sizeof(8)); + cpu_memory.WriteBlockUnsafe(address + sizeof(u64), ×tamp_value, sizeof(u64)); + cpu_memory.WriteBlockUnsafe(address, &value, sizeof(u64)); + rasterizer.InvalidateRegion(address, sizeof(u64) * 2, + VideoCommon::CacheType::NoQueryCache); } else { - u32 small_value = static_cast(async_job.value); - cpu_memory.WriteBlockUnsafe(async_job.query_location, &small_value, sizeof(u32)); + u32 small_value = static_cast(value); + cpu_memory.WriteBlockUnsafe(address, &small_value, sizeof(u32)); + rasterizer.InvalidateRegion(address, sizeof(u32), + VideoCommon::CacheType::NoQueryCache); } - slot_async_jobs.erase(new_async_job_id); }); rasterizer.SyncOperation(std::move(operation)); } -- cgit v1.2.3