mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-15 08:14:54 +00:00
[video_core] readback for nce invalidations (#4490) optimization
This commit is contained in:
@@ -227,17 +227,17 @@ struct GPU::Impl {
|
||||
|
||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||
void InvalidateRegion(DAddr addr, u64 size, bool preserve_gpu_writes) {
|
||||
if (Settings::values.nce_invalidation_gpu_readback.GetValue()) {
|
||||
if (preserve_gpu_writes) {
|
||||
VideoCore::RasterizerInterface* rasterizer = renderer->ReadRasterizer();
|
||||
if (preserve_gpu_writes && rasterizer->MustFlushRegion(addr, size, VideoCommon::CacheType::BufferCache)) {
|
||||
if (!rasterizer->TryCacheInvalidation(addr, size)) {
|
||||
const u64 fence = RequestSyncOperation([rasterizer, addr, size] {
|
||||
rasterizer->FlushRegion(addr, size, VideoCommon::CacheType::BufferCache);
|
||||
rasterizer->OnCacheInvalidation(addr, size);
|
||||
});
|
||||
gpu_thread.TickGPU(is_async);
|
||||
WaitForSyncOperation(fence);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
gpu_thread.InvalidateRegion(addr, size);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,12 @@ public:
|
||||
/// Notify rasterizer that any caches of the specified region are desync with guest
|
||||
virtual void OnCacheInvalidation(PAddr addr, u64 size) = 0;
|
||||
|
||||
virtual bool TryCacheInvalidation(DAddr addr, u64 size) {
|
||||
if (MustFlushRegion(addr, size, VideoCommon::CacheType::BufferCache)) return false;
|
||||
OnCacheInvalidation(addr, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnCPUWrite(PAddr addr, u64 size) = 0;
|
||||
|
||||
/// Sync memory between guest and host.
|
||||
|
||||
@@ -798,6 +798,18 @@ void RasterizerVulkan::OnCacheInvalidation(DAddr addr, u64 size) {
|
||||
pipeline_cache.InvalidateRegion(addr, size);
|
||||
}
|
||||
|
||||
bool RasterizerVulkan::TryCacheInvalidation(DAddr addr, u64 size) {
|
||||
if (addr == 0 || size == 0) return true;
|
||||
{
|
||||
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||
if (buffer_cache.IsRegionGpuModified(addr, size)) return false;
|
||||
texture_cache.WriteMemory(addr, size);
|
||||
buffer_cache.WriteMemory(addr, size);
|
||||
}
|
||||
pipeline_cache.InvalidateRegion(addr, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RasterizerVulkan::InvalidateGPUCache() {
|
||||
gpu.InvalidateGPUCache();
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ public:
|
||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||
void InnerInvalidation(std::span<const std::pair<DAddr, std::size_t>> sequences) override;
|
||||
void OnCacheInvalidation(DAddr addr, u64 size) override;
|
||||
bool TryCacheInvalidation(DAddr addr, u64 size) override;
|
||||
bool OnCPUWrite(DAddr addr, u64 size) override;
|
||||
void InvalidateGPUCache() override;
|
||||
void UnmapMemory(DAddr addr, u64 size) override;
|
||||
|
||||
Reference in New Issue
Block a user