early-access version 3584

This commit is contained in:
pineappleEA 2023-05-12 16:28:26 +02:00
parent 8bee2e20b4
commit 9dcfde44d5
4 changed files with 28 additions and 47 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3583. This is the source code for early-access 3584.
## Legal Notice ## Legal Notice

View File

@ -131,33 +131,15 @@ std::optional<VideoCore::RasterizerDownloadArea> BufferCache<P>::GetFlushArea(VA
template <class P> template <class P>
void BufferCache<P>::DownloadMemory(VAddr cpu_addr, u64 size) { void BufferCache<P>::DownloadMemory(VAddr cpu_addr, u64 size) {
WaitOnAsyncFlushes(cpu_addr, size);
ForEachBufferInRange(cpu_addr, size, [&](BufferId, Buffer& buffer) { ForEachBufferInRange(cpu_addr, size, [&](BufferId, Buffer& buffer) {
DownloadBufferMemory(buffer, cpu_addr, size); DownloadBufferMemory(buffer, cpu_addr, size);
}); });
} }
template <class P>
void BufferCache<P>::WaitOnAsyncFlushes(VAddr cpu_addr, u64 size) {
bool must_wait = false;
ForEachInOverlapCounter(async_downloads, cpu_addr, size,
[&](VAddr, VAddr, int) { must_wait = true; });
bool must_release = false;
ForEachInRangeSet(pending_ranges, cpu_addr, size, [&](VAddr, VAddr) { must_release = true; });
if (must_release) {
std::function<void()> tmp([]() {});
rasterizer.SignalFence(std::move(tmp));
}
if (must_wait || must_release) {
rasterizer.ReleaseFences();
}
}
template <class P> template <class P>
void BufferCache<P>::ClearDownload(IntervalType subtract_interval) { void BufferCache<P>::ClearDownload(IntervalType subtract_interval) {
RemoveEachInOverlapCounter(async_downloads, subtract_interval, -1024); RemoveEachInOverlapCounter(async_downloads, subtract_interval, -1024);
uncommitted_ranges.subtract(subtract_interval); uncommitted_ranges.subtract(subtract_interval);
pending_ranges.subtract(subtract_interval);
for (auto& interval_set : committed_ranges) { for (auto& interval_set : committed_ranges) {
interval_set.subtract(subtract_interval); interval_set.subtract(subtract_interval);
} }
@ -177,7 +159,6 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
} }
const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount}; const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount};
WaitOnAsyncFlushes(*cpu_src_address, static_cast<u32>(amount));
ClearDownload(subtract_interval); ClearDownload(subtract_interval);
BufferId buffer_a; BufferId buffer_a;
@ -205,7 +186,6 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
const IntervalType add_interval{new_base_address, new_base_address + size}; const IntervalType add_interval{new_base_address, new_base_address + size};
tmp_intervals.push_back(add_interval); tmp_intervals.push_back(add_interval);
uncommitted_ranges.add(add_interval); uncommitted_ranges.add(add_interval);
pending_ranges.add(add_interval);
}; };
ForEachInRangeSet(common_ranges, *cpu_src_address, amount, mirror); ForEachInRangeSet(common_ranges, *cpu_src_address, amount, mirror);
// This subtraction in this order is important for overlapping copies. // This subtraction in this order is important for overlapping copies.
@ -492,7 +472,6 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
} }
MICROPROFILE_SCOPE(GPU_DownloadMemory); MICROPROFILE_SCOPE(GPU_DownloadMemory);
pending_ranges.clear();
auto it = committed_ranges.begin(); auto it = committed_ranges.begin();
while (it != committed_ranges.end()) { while (it != committed_ranges.end()) {
auto& current_intervals = *it; auto& current_intervals = *it;
@ -1232,7 +1211,6 @@ void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, VAddr cpu_addr, u32 s
const IntervalType base_interval{cpu_addr, cpu_addr + size}; const IntervalType base_interval{cpu_addr, cpu_addr + size};
common_ranges.add(base_interval); common_ranges.add(base_interval);
uncommitted_ranges.add(base_interval); uncommitted_ranges.add(base_interval);
pending_ranges.add(base_interval);
} }
template <class P> template <class P>

View File

@ -381,8 +381,6 @@ private:
void RunGarbageCollector(); void RunGarbageCollector();
void WaitOnAsyncFlushes(VAddr cpu_addr, u64 size);
void BindHostIndexBuffer(); void BindHostIndexBuffer();
void BindHostVertexBuffers(); void BindHostVertexBuffers();
@ -547,7 +545,6 @@ private:
IntervalSet uncommitted_ranges; IntervalSet uncommitted_ranges;
IntervalSet common_ranges; IntervalSet common_ranges;
IntervalSet cached_ranges; IntervalSet cached_ranges;
IntervalSet pending_ranges;
std::deque<IntervalSet> committed_ranges; std::deque<IntervalSet> committed_ranges;
// Async Buffers // Async Buffers

View File

@ -1397,27 +1397,6 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA
return lhs_image.modification_tick < rhs_image.modification_tick; return lhs_image.modification_tick < rhs_image.modification_tick;
}); });
for (const ImageId overlap_id : overlap_ids) {
Image& overlap = slot_images[overlap_id];
if (True(overlap.flags & ImageFlagBits::GpuModified)) {
new_image.flags |= ImageFlagBits::GpuModified;
const auto& resolution = Settings::values.resolution_info;
const SubresourceBase base = new_image.TryFindBase(overlap.gpu_addr).value();
const u32 up_scale = can_rescale ? resolution.up_scale : 1;
const u32 down_shift = can_rescale ? resolution.down_shift : 0;
auto copies = MakeShrinkImageCopies(new_info, overlap.info, base, up_scale, down_shift);
if (overlap.info.num_samples != new_image.info.num_samples) {
runtime.CopyImageMSAA(new_image, overlap, std::move(copies));
} else {
runtime.CopyImage(new_image, overlap, std::move(copies));
}
}
if (True(overlap.flags & ImageFlagBits::Tracked)) {
UntrackImage(overlap, overlap_id);
}
UnregisterImage(overlap_id);
DeleteImage(overlap_id);
}
ImageBase& new_image_base = new_image; ImageBase& new_image_base = new_image;
for (const ImageId aliased_id : right_aliased_ids) { for (const ImageId aliased_id : right_aliased_ids) {
ImageBase& aliased = slot_images[aliased_id]; ImageBase& aliased = slot_images[aliased_id];
@ -1440,6 +1419,33 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA
new_image.flags |= ImageFlagBits::BadOverlap; new_image.flags |= ImageFlagBits::BadOverlap;
} }
} }
SynchronizeAliases(new_image_id);
for (const ImageId overlap_id : overlap_ids) {
Image& overlap = slot_images[overlap_id];
if (True(overlap.flags & ImageFlagBits::GpuModified) &&
overlap.modification_tick > new_image.modification_tick) {
new_image.flags |= ImageFlagBits::GpuModified;
const auto& resolution = Settings::values.resolution_info;
const SubresourceBase base = new_image.TryFindBase(overlap.gpu_addr).value();
const u32 up_scale = can_rescale ? resolution.up_scale : 1;
const u32 down_shift = can_rescale ? resolution.down_shift : 0;
auto copies = MakeShrinkImageCopies(new_info, overlap.info, base, up_scale, down_shift);
if (overlap.info.num_samples != new_image.info.num_samples) {
runtime.CopyImageMSAA(new_image, overlap, std::move(copies));
} else {
runtime.CopyImage(new_image, overlap, std::move(copies));
}
new_image.modification_tick = overlap.modification_tick;
}
if (True(overlap.flags & ImageFlagBits::Tracked)) {
UntrackImage(overlap, overlap_id);
}
UnregisterImage(overlap_id);
DeleteImage(overlap_id);
}
RegisterImage(new_image_id); RegisterImage(new_image_id);
return new_image_id; return new_image_id;
} }