Skip to content
Snippets Groups Projects
Commit 07cc7e0c authored by Fernando Sahmkow's avatar Fernando Sahmkow Committed by ReinUsesLisp
Browse files

texture_cache: Add ASync Protections

parent 1bbc9deb
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <mutex>
#include <set> #include <set>
#include <tuple> #include <tuple>
#include <unordered_map> #include <unordered_map>
...@@ -56,12 +57,16 @@ public: ...@@ -56,12 +57,16 @@ public:
} }
void InvalidateRegion(CacheAddr addr, std::size_t size) { void InvalidateRegion(CacheAddr addr, std::size_t size) {
std::lock_guard lock{mutex};
for (const auto& surface : GetSurfacesInRegion(addr, size)) { for (const auto& surface : GetSurfacesInRegion(addr, size)) {
Unregister(surface); Unregister(surface);
} }
} }
void FlushRegion(CacheAddr addr, std::size_t size) { void FlushRegion(CacheAddr addr, std::size_t size) {
std::lock_guard lock{mutex};
auto surfaces = GetSurfacesInRegion(addr, size); auto surfaces = GetSurfacesInRegion(addr, size);
if (surfaces.empty()) { if (surfaces.empty()) {
return; return;
...@@ -220,6 +225,8 @@ protected: ...@@ -220,6 +225,8 @@ protected:
const Common::Rectangle<u32>& dst_rect) = 0; const Common::Rectangle<u32>& dst_rect) = 0;
void Register(TSurface surface) { void Register(TSurface surface) {
std::lock_guard lock{mutex};
const GPUVAddr gpu_addr = surface->GetGpuAddr(); const GPUVAddr gpu_addr = surface->GetGpuAddr();
const CacheAddr cache_ptr = ToCacheAddr(memory_manager->GetPointer(gpu_addr)); const CacheAddr cache_ptr = ToCacheAddr(memory_manager->GetPointer(gpu_addr));
const std::size_t size = surface->GetSizeInBytes(); const std::size_t size = surface->GetSizeInBytes();
...@@ -237,6 +244,8 @@ protected: ...@@ -237,6 +244,8 @@ protected:
} }
void Unregister(TSurface surface) { void Unregister(TSurface surface) {
std::lock_guard lock{mutex};
if (surface->IsProtected()) { if (surface->IsProtected()) {
return; return;
} }
...@@ -579,6 +588,7 @@ private: ...@@ -579,6 +588,7 @@ private:
FramebufferTargetInfo depth_buffer; FramebufferTargetInfo depth_buffer;
std::vector<u8> staging_buffer; std::vector<u8> staging_buffer;
std::recursive_mutex mutex;
}; };
} // namespace VideoCommon } // namespace VideoCommon
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment