mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-09 13:36:35 +00:00
[TEST] Sync and copy buffer hazards
This commit is contained in:
@@ -207,12 +207,22 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
|
|||||||
std::optional<WindowBufferRef> src_window;
|
std::optional<WindowBufferRef> src_window;
|
||||||
std::optional<WindowBufferRef> dst_window;
|
std::optional<WindowBufferRef> dst_window;
|
||||||
if constexpr (USE_UNIFIED_DIRECT_BINDING) {
|
if constexpr (USE_UNIFIED_DIRECT_BINDING) {
|
||||||
src_window = TryObtainWindowBuffer(*cpu_src_address, static_cast<u32>(amount),
|
if (amount <= (std::numeric_limits<u32>::max)()) {
|
||||||
UNIFIED_COPY_BINDING_ALIGNMENT,
|
src_window = TryObtainWindowBuffer(*cpu_src_address, static_cast<u32>(amount),
|
||||||
ObtainBufferOperation::DoNothing);
|
UNIFIED_COPY_BINDING_ALIGNMENT,
|
||||||
dst_window = TryObtainWindowBuffer(*cpu_dest_address, static_cast<u32>(amount),
|
ObtainBufferOperation::DoNothing);
|
||||||
UNIFIED_COPY_BINDING_ALIGNMENT,
|
dst_window = TryObtainWindowBuffer(*cpu_dest_address, static_cast<u32>(amount),
|
||||||
ObtainBufferOperation::DoNothing);
|
UNIFIED_COPY_BINDING_ALIGNMENT,
|
||||||
|
ObtainBufferOperation::DoNothing);
|
||||||
|
if (src_window && dst_window &&
|
||||||
|
src_window->window_index == dst_window->window_index) {
|
||||||
|
const u64 src_begin = src_window->offset;
|
||||||
|
const u64 dst_begin = dst_window->offset;
|
||||||
|
if (src_begin < dst_begin + amount && dst_begin < src_begin + amount) {
|
||||||
|
dst_window.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearDownload(*cpu_dest_address, amount);
|
ClearDownload(*cpu_dest_address, amount);
|
||||||
@@ -364,11 +374,10 @@ void BufferCache<P>::MarkGpuWrittenRange(DAddr device_addr, u32 size) {
|
|||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const BufferId buffer_id = FindBuffer(device_addr, size);
|
memory_tracker.MarkRegionAsGpuModified(device_addr, size);
|
||||||
if (buffer_id == NULL_BUFFER_ID) {
|
gpu_modified_ranges.Add(device_addr, size);
|
||||||
return;
|
uncommitted_gpu_modified_ranges.Add(device_addr, size);
|
||||||
}
|
in_place_gpu_written_ranges.Subtract(device_addr, size);
|
||||||
MarkWrittenBuffer(buffer_id, device_addr, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@@ -1868,14 +1877,6 @@ void BufferCache<P>::ForgetGpuModifiedRange(DAddr device_addr, u64 size) {
|
|||||||
in_place_gpu_written_ranges.Subtract(device_addr, size);
|
in_place_gpu_written_ranges.Subtract(device_addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
|
||||||
bool BufferCache<P>::IsRegionWrittenInPlace(DAddr device_addr, u64 size) {
|
|
||||||
u64 covered = 0;
|
|
||||||
in_place_gpu_written_ranges.ForEachInRange(
|
|
||||||
device_addr, size, [&](DAddr start, DAddr end) { covered += end - start; });
|
|
||||||
return covered == size;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool BufferCache<P>::IntersectsInPlaceWrites(DAddr device_addr, u64 size) {
|
bool BufferCache<P>::IntersectsInPlaceWrites(DAddr device_addr, u64 size) {
|
||||||
bool intersects = false;
|
bool intersects = false;
|
||||||
@@ -2212,8 +2213,7 @@ bool BufferCache<P>::ResolveUnifiedDirectBinding([[maybe_unused]] DAddr device_a
|
|||||||
}
|
}
|
||||||
contiguous += Core::DEVICE_PAGESIZE;
|
contiguous += Core::DEVICE_PAGESIZE;
|
||||||
}
|
}
|
||||||
if (IsRegionGpuModified(device_addr, size) &&
|
if (IsRegionGpuModified(device_addr, size)) {
|
||||||
!IsRegionWrittenInPlace(device_addr, size)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
window_index = relative / window_size;
|
window_index = relative / window_size;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
@@ -449,8 +450,6 @@ private:
|
|||||||
|
|
||||||
void ForgetGpuModifiedRange(DAddr device_addr, u64 size);
|
void ForgetGpuModifiedRange(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
[[nodiscard]] bool IsRegionWrittenInPlace(DAddr device_addr, u64 size);
|
|
||||||
|
|
||||||
[[nodiscard]] bool IntersectsInPlaceWrites(DAddr device_addr, u64 size);
|
[[nodiscard]] bool IntersectsInPlaceWrites(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
void WaitForInPlaceWrites();
|
void WaitForInPlaceWrites();
|
||||||
|
|||||||
Reference in New Issue
Block a user