summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/texture_cache/image_info.h1
-rw-r--r--src/video_core/texture_cache/texture_cache.h32
2 files changed, 30 insertions, 3 deletions
diff --git a/src/video_core/texture_cache/image_info.h b/src/video_core/texture_cache/image_info.h
index cfb85a3dc..8a4cb0cbd 100644
--- a/src/video_core/texture_cache/image_info.h
+++ b/src/video_core/texture_cache/image_info.h
@@ -40,6 +40,7 @@ struct ImageInfo {
40 bool rescaleable = false; 40 bool rescaleable = false;
41 bool downscaleable = false; 41 bool downscaleable = false;
42 bool forced_flushed = false; 42 bool forced_flushed = false;
43 bool dma_downloaded = false;
43}; 44};
44 45
45} // namespace VideoCommon 46} // namespace VideoCommon
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index fb8ffc002..762e8a52f 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -709,18 +709,43 @@ void TextureCache<P>::CommitAsyncFlushes() {
709 download_info.async_buffer_id = last_async_buffer_id; 709 download_info.async_buffer_id = last_async_buffer_id;
710 } 710 }
711 } 711 }
712
712 if (any_none_dma) { 713 if (any_none_dma) {
714 bool all_pre_sync = true;
713 auto download_map = runtime.DownloadStagingBuffer(total_size_bytes, true); 715 auto download_map = runtime.DownloadStagingBuffer(total_size_bytes, true);
714 for (const PendingDownload& download_info : download_ids) { 716 for (const PendingDownload& download_info : download_ids) {
715 if (download_info.is_swizzle) { 717 if (download_info.is_swizzle) {
716 Image& image = slot_images[download_info.object_id]; 718 Image& image = slot_images[download_info.object_id];
719 all_pre_sync &= image.info.dma_downloaded;
720 image.info.dma_downloaded = true;
717 const auto copies = FullDownloadCopies(image.info); 721 const auto copies = FullDownloadCopies(image.info);
718 image.DownloadMemory(download_map, copies); 722 image.DownloadMemory(download_map, copies);
719 download_map.offset += Common::AlignUp(image.unswizzled_size_bytes, 64); 723 download_map.offset += Common::AlignUp(image.unswizzled_size_bytes, 64);
720 } 724 }
721 } 725 }
722 uncommitted_async_buffers.emplace_back(download_map); 726 if (!all_pre_sync) {
727 runtime.Finish();
728 auto it = download_ids.begin();
729 while (it != download_ids.end()) {
730 const PendingDownload& download_info = *it;
731 if (download_info.is_swizzle) {
732 const ImageBase& image = slot_images[download_info.object_id];
733 const auto copies = FullDownloadCopies(image.info);
734 download_map.offset -= Common::AlignUp(image.unswizzled_size_bytes, 64);
735 std::span<u8> download_span =
736 download_map.mapped_span.subspan(download_map.offset);
737 SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span,
738 swizzle_data_buffer);
739 it = download_ids.erase(it);
740 } else {
741 it++;
742 }
743 }
744 } else {
745 uncommitted_async_buffers.emplace_back(download_map);
746 }
723 } 747 }
748
724 async_buffers.emplace_back(std::move(uncommitted_async_buffers)); 749 async_buffers.emplace_back(std::move(uncommitted_async_buffers));
725 uncommitted_async_buffers.clear(); 750 uncommitted_async_buffers.clear();
726 } 751 }
@@ -820,8 +845,9 @@ ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand) {
820 // No need to waste time on an image that's synced with guest 845 // No need to waste time on an image that's synced with guest
821 return NULL_IMAGE_ID; 846 return NULL_IMAGE_ID;
822 } 847 }
823 if (!image.info.forced_flushed) { 848 if (!image.info.dma_downloaded) {
824 image.info.forced_flushed = true; 849 // Force a full sync.
850 image.info.dma_downloaded = true;
825 return NULL_IMAGE_ID; 851 return NULL_IMAGE_ID;
826 } 852 }
827 const auto base = image.TryFindBase(operand.address); 853 const auto base = image.TryFindBase(operand.address);