summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache/texture_cache.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-01-20 01:59:53 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-06-16 21:35:02 +0200
commita11bc4a382ebca52bdf0aab1a9474351e8d85cef (patch)
tree6392fde60f5ee2e414733a193329e18d7f7fde42 /src/video_core/texture_cache/texture_cache.h
parentvulkan_memory_allocator: Release allocations with no commits (diff)
downloadyuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.tar
yuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.tar.gz
yuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.tar.bz2
yuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.tar.lz
yuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.tar.xz
yuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.tar.zst
yuzu-a11bc4a382ebca52bdf0aab1a9474351e8d85cef.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/texture_cache/texture_cache.h44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 59b7c678b..45ef155b5 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -353,6 +353,7 @@ private:
u64 modification_tick = 0;
u64 frame_tick = 0;
+ typename SlotVector<Image>::Iterator deletion_iterator;
};
template <class P>
@@ -373,10 +374,41 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
// This way the null resource becomes a compile time constant
void(slot_image_views.insert(runtime, NullImageParams{}));
void(slot_samplers.insert(runtime, sampler_descriptor));
+
+ deletion_iterator = slot_images.begin();
}
template <class P>
void TextureCache<P>::TickFrame() {
+ static constexpr u64 ticks_to_destroy = 120;
+ int num_iterations = 32;
+ for (; num_iterations > 0; --num_iterations) {
+ if (deletion_iterator == slot_images.end()) {
+ deletion_iterator = slot_images.begin();
+ if (deletion_iterator == slot_images.end()) {
+ break;
+ }
+ }
+ const auto [image_id, image] = *deletion_iterator;
+ if (image->frame_tick + ticks_to_destroy < frame_tick) {
+ if (image->IsSafeDownload() &&
+ std::ranges::none_of(image->aliased_images, [&](const AliasedImage& alias) {
+ return slot_images[alias.id].modification_tick > image->modification_tick;
+ })) {
+ auto map = runtime.DownloadStagingBuffer(image->unswizzled_size_bytes);
+ const auto copies = FullDownloadCopies(image->info);
+ image->DownloadMemory(map, copies);
+ runtime.Finish();
+ SwizzleImage(gpu_memory, image->gpu_addr, image->info, copies, map.mapped_span);
+ }
+ if (True(image->flags & ImageFlagBits::Tracked)) {
+ UntrackImage(*image);
+ }
+ UnregisterImage(image_id);
+ DeleteImage(image_id);
+ }
+ ++deletion_iterator;
+ }
// Tick sentenced resources in this order to ensure they are destroyed in the right order
sentenced_images.Tick();
sentenced_framebuffers.Tick();
@@ -568,17 +600,7 @@ template <class P>
void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) {
std::vector<ImageId> images;
ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) {
- // Skip images that were not modified from the GPU
- if (False(image.flags & ImageFlagBits::GpuModified)) {
- return;
- }
- // Skip images that .are. modified from the CPU
- // We don't want to write sensitive data from the guest
- if (True(image.flags & ImageFlagBits::CpuModified)) {
- return;
- }
- if (image.info.num_samples > 1) {
- LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
+ if (!image.IsSafeDownload()) {
return;
}
image.flags &= ~ImageFlagBits::GpuModified;