2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

query_cache: Add a recursive mutex for concurrent usage

This commit is contained in:
ReinUsesLisp 2020-02-13 14:28:22 -03:00
parent bcd348f238
commit cc0694559f

View file

@ -9,6 +9,7 @@
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
#include <memory> #include <memory>
#include <mutex>
#include <optional> #include <optional>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
@ -98,10 +99,12 @@ public:
VideoCore::QueryType::SamplesPassed}}} {} VideoCore::QueryType::SamplesPassed}}} {}
void InvalidateRegion(CacheAddr addr, std::size_t size) { void InvalidateRegion(CacheAddr addr, std::size_t size) {
std::unique_lock lock{mutex};
FlushAndRemoveRegion(addr, size); FlushAndRemoveRegion(addr, size);
} }
void FlushRegion(CacheAddr addr, std::size_t size) { void FlushRegion(CacheAddr addr, std::size_t size) {
std::unique_lock lock{mutex};
FlushAndRemoveRegion(addr, size); FlushAndRemoveRegion(addr, size);
} }
@ -112,6 +115,7 @@ public:
* @param timestamp Timestamp, when empty the flushed query is assumed to be short. * @param timestamp Timestamp, when empty the flushed query is assumed to be short.
*/ */
void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) { void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) {
std::unique_lock lock{mutex};
auto& memory_manager = system.GPU().MemoryManager(); auto& memory_manager = system.GPU().MemoryManager();
const auto host_ptr = memory_manager.GetPointer(gpu_addr); const auto host_ptr = memory_manager.GetPointer(gpu_addr);
@ -219,6 +223,8 @@ private:
Core::System& system; Core::System& system;
VideoCore::RasterizerInterface& rasterizer; VideoCore::RasterizerInterface& rasterizer;
std::recursive_mutex mutex;
std::unordered_map<u64, std::vector<CachedQuery>> cached_queries; std::unordered_map<u64, std::vector<CachedQuery>> cached_queries;
std::array<CounterStream, VideoCore::NumQueryTypes> streams; std::array<CounterStream, VideoCore::NumQueryTypes> streams;