summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/texture_cache/texture_cache.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 4ac5668c8..1b8ada910 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <mutex>
8#include <set> 9#include <set>
9#include <tuple> 10#include <tuple>
10#include <unordered_map> 11#include <unordered_map>
@@ -56,12 +57,16 @@ public:
56 } 57 }
57 58
58 void InvalidateRegion(CacheAddr addr, std::size_t size) { 59 void InvalidateRegion(CacheAddr addr, std::size_t size) {
60 std::lock_guard lock{mutex};
61
59 for (const auto& surface : GetSurfacesInRegion(addr, size)) { 62 for (const auto& surface : GetSurfacesInRegion(addr, size)) {
60 Unregister(surface); 63 Unregister(surface);
61 } 64 }
62 } 65 }
63 66
64 void FlushRegion(CacheAddr addr, std::size_t size) { 67 void FlushRegion(CacheAddr addr, std::size_t size) {
68 std::lock_guard lock{mutex};
69
65 auto surfaces = GetSurfacesInRegion(addr, size); 70 auto surfaces = GetSurfacesInRegion(addr, size);
66 if (surfaces.empty()) { 71 if (surfaces.empty()) {
67 return; 72 return;
@@ -220,6 +225,8 @@ protected:
220 const Common::Rectangle<u32>& dst_rect) = 0; 225 const Common::Rectangle<u32>& dst_rect) = 0;
221 226
222 void Register(TSurface surface) { 227 void Register(TSurface surface) {
228 std::lock_guard lock{mutex};
229
223 const GPUVAddr gpu_addr = surface->GetGpuAddr(); 230 const GPUVAddr gpu_addr = surface->GetGpuAddr();
224 const CacheAddr cache_ptr = ToCacheAddr(memory_manager->GetPointer(gpu_addr)); 231 const CacheAddr cache_ptr = ToCacheAddr(memory_manager->GetPointer(gpu_addr));
225 const std::size_t size = surface->GetSizeInBytes(); 232 const std::size_t size = surface->GetSizeInBytes();
@@ -237,6 +244,8 @@ protected:
237 } 244 }
238 245
239 void Unregister(TSurface surface) { 246 void Unregister(TSurface surface) {
247 std::lock_guard lock{mutex};
248
240 if (surface->IsProtected()) { 249 if (surface->IsProtected()) {
241 return; 250 return;
242 } 251 }
@@ -579,6 +588,7 @@ private:
579 FramebufferTargetInfo depth_buffer; 588 FramebufferTargetInfo depth_buffer;
580 589
581 std::vector<u8> staging_buffer; 590 std::vector<u8> staging_buffer;
591 std::recursive_mutex mutex;
582}; 592};
583 593
584} // namespace VideoCommon 594} // namespace VideoCommon