mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-20 16:50:05 +02:00
[video_core] readback for nce invalidations (#4490) optimization
This commit is contained in:
parent
e0d47f2790
commit
8d10c788c4
4 changed files with 25 additions and 3 deletions
|
|
@ -227,17 +227,17 @@ struct GPU::Impl {
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||||
void InvalidateRegion(DAddr addr, u64 size, bool preserve_gpu_writes) {
|
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();
|
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] {
|
const u64 fence = RequestSyncOperation([rasterizer, addr, size] {
|
||||||
rasterizer->FlushRegion(addr, size, VideoCommon::CacheType::BufferCache);
|
rasterizer->FlushRegion(addr, size, VideoCommon::CacheType::BufferCache);
|
||||||
rasterizer->OnCacheInvalidation(addr, size);
|
rasterizer->OnCacheInvalidation(addr, size);
|
||||||
});
|
});
|
||||||
gpu_thread.TickGPU(is_async);
|
gpu_thread.TickGPU(is_async);
|
||||||
WaitForSyncOperation(fence);
|
WaitForSyncOperation(fence);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
gpu_thread.InvalidateRegion(addr, size);
|
gpu_thread.InvalidateRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
@ -111,6 +114,12 @@ public:
|
||||||
/// Notify rasterizer that any caches of the specified region are desync with guest
|
/// Notify rasterizer that any caches of the specified region are desync with guest
|
||||||
virtual void OnCacheInvalidation(PAddr addr, u64 size) = 0;
|
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;
|
virtual bool OnCPUWrite(PAddr addr, u64 size) = 0;
|
||||||
|
|
||||||
/// Sync memory between guest and host.
|
/// Sync memory between guest and host.
|
||||||
|
|
|
||||||
|
|
@ -798,6 +798,18 @@ void RasterizerVulkan::OnCacheInvalidation(DAddr addr, u64 size) {
|
||||||
pipeline_cache.InvalidateRegion(addr, 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() {
|
void RasterizerVulkan::InvalidateGPUCache() {
|
||||||
gpu.InvalidateGPUCache();
|
gpu.InvalidateGPUCache();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ public:
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
void InnerInvalidation(std::span<const std::pair<DAddr, std::size_t>> sequences) override;
|
void InnerInvalidation(std::span<const std::pair<DAddr, std::size_t>> sequences) override;
|
||||||
void OnCacheInvalidation(DAddr addr, u64 size) override;
|
void OnCacheInvalidation(DAddr addr, u64 size) override;
|
||||||
|
bool TryCacheInvalidation(DAddr addr, u64 size) override;
|
||||||
bool OnCPUWrite(DAddr addr, u64 size) override;
|
bool OnCPUWrite(DAddr addr, u64 size) override;
|
||||||
void InvalidateGPUCache() override;
|
void InvalidateGPUCache() override;
|
||||||
void UnmapMemory(DAddr addr, u64 size) override;
|
void UnmapMemory(DAddr addr, u64 size) override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue