vk_rasterizer: Control mapped_ranges access with shared lock.

This commit is contained in:
squidbus 2025-04-14 18:56:48 -07:00
parent 2b633fd3c5
commit 929679c13d
2 changed files with 15 additions and 4 deletions

View file

@ -930,12 +930,17 @@ bool Rasterizer::IsMapped(VAddr addr, u64 size) {
// There is no memory, so not mapped.
return false;
}
return mapped_ranges.find(boost::icl::interval<VAddr>::right_open(addr, addr + size)) !=
mapped_ranges.end();
const auto range = decltype(mapped_ranges)::interval_type::right_open(addr, addr + size);
std::shared_lock lock{mapped_ranges_mutex};
return boost::icl::contains(mapped_ranges, range);
}
void Rasterizer::MapMemory(VAddr addr, u64 size) {
mapped_ranges += boost::icl::interval<VAddr>::right_open(addr, addr + size);
{
std::unique_lock lock{mapped_ranges_mutex};
mapped_ranges += decltype(mapped_ranges)::interval_type::right_open(addr, addr + size);
}
page_manager.OnGpuMap(addr, size);
}
@ -943,7 +948,10 @@ void Rasterizer::UnmapMemory(VAddr addr, u64 size) {
buffer_cache.InvalidateMemory(addr, size);
texture_cache.UnmapMemory(addr, size);
page_manager.OnGpuUnmap(addr, size);
mapped_ranges -= boost::icl::interval<VAddr>::right_open(addr, addr + size);
{
std::unique_lock lock{mapped_ranges_mutex};
mapped_ranges -= decltype(mapped_ranges)::interval_type::right_open(addr, addr + size);
}
}
void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) const {

View file

@ -3,6 +3,8 @@
#pragma once
#include <shared_mutex>
#include "video_core/buffer_cache/buffer_cache.h"
#include "video_core/page_manager.h"
#include "video_core/renderer_vulkan/vk_pipeline_cache.h"
@ -106,6 +108,7 @@ private:
AmdGpu::Liverpool* liverpool;
Core::MemoryManager* memory;
boost::icl::interval_set<VAddr> mapped_ranges;
std::shared_mutex mapped_ranges_mutex;
PipelineCache pipeline_cache;
boost::container::static_vector<