[GPU] Added flush helper to detect when FlusRegion must be flushed

This commit is contained in:
CamilleLaVey
2026-07-01 21:16:16 -04:00
committed by crueter
parent 672432372d
commit 54ce017b10
3 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -754,7 +754,7 @@ struct Memory::Impl {
};
auto& gpu = system.GPU();
gpu_device_memory->ApplyOpOnPointer(p, scratch_buffers[core], [&](DAddr addr) {
if (flush) {
if (flush && gpu.MustFlushRegion(addr, size)) {
void(gpu.OnCPURead(addr, size));
}
gpu.InvalidateRegion(addr, size);
+8
View File
@@ -219,6 +219,10 @@ struct GPU::Impl {
return renderer->ReadRasterizer()->OnCPUWrite(addr, size);
}
bool MustFlushRegion(DAddr addr, u64 size) {
return renderer->ReadRasterizer()->MustFlushRegion(addr, size);
}
/// Notify rasterizer that any caches of the specified region should be flushed and invalidated
void FlushAndInvalidateRegion(DAddr addr, u64 size) {
gpu_thread.FlushAndInvalidateRegion(addr, size, is_async);
@@ -480,6 +484,10 @@ void GPU::InvalidateRegion(DAddr addr, u64 size) {
impl->InvalidateRegion(addr, size);
}
bool GPU::MustFlushRegion(DAddr addr, u64 size) {
return impl->MustFlushRegion(addr, size);
}
bool GPU::OnCPUWrite(DAddr addr, u64 size) {
return impl->OnCPUWrite(addr, size);
}
+3
View File
@@ -246,6 +246,9 @@ public:
/// Notify rasterizer that any caches of the specified region should be invalidated
void InvalidateRegion(DAddr addr, u64 size);
/// Check if the specified memory area requires flushing to CPU memory
[[nodiscard]] bool MustFlushRegion(DAddr addr, u64 size);
/// Notify rasterizer that CPU is trying to write this area. It returns true if the area is
/// sensible, false otherwise, addr and size must be a valid combination
bool OnCPUWrite(DAddr addr, u64 size);