summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2022-03-26 12:39:31 -0700
committerGravatar GitHub2022-03-26 12:39:31 -0700
commite043cc0bc39def1596f9054c879dd0ef5a65be72 (patch)
tree65e18a33eda02f6a18cb32b5f492aa72fca0ed2a
parentMerge pull request #8041 from Morph1984/inline-swkbd (diff)
parentRevert "Memory GPU <-> CPU: reduce infighting in the texture cache by adding ... (diff)
downloadyuzu-e043cc0bc39def1596f9054c879dd0ef5a65be72.tar.gz
yuzu-e043cc0bc39def1596f9054c879dd0ef5a65be72.tar.xz
yuzu-e043cc0bc39def1596f9054c879dd0ef5a65be72.zip
Merge pull request #8092 from yuzu-emu/revert-8080-yo-momma-so-fat-that
Revert "Memory GPU <-> CPU: reduce infighting in the texture cache by adding CPU Cached memory."
Diffstat (limited to '')
-rw-r--r--src/core/memory.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp6
-rw-r--r--src/video_core/texture_cache/image_base.h3
-rw-r--r--src/video_core/texture_cache/texture_cache.h41
-rw-r--r--src/video_core/texture_cache/texture_cache_base.h11
6 files changed, 4 insertions, 65 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 3fed51400..28d30eee2 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -322,7 +322,7 @@ struct Memory::Impl {
322 } 322 }
323 323
324 if (Settings::IsFastmemEnabled()) { 324 if (Settings::IsFastmemEnabled()) {
325 const bool is_read_enable = !Settings::IsGPULevelExtreme() || !cached; 325 const bool is_read_enable = Settings::IsGPULevelHigh() || !cached;
326 system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); 326 system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached);
327 } 327 }
328 328
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 7e06d0069..4d632d211 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -352,7 +352,7 @@ void RasterizerOpenGL::OnCPUWrite(VAddr addr, u64 size) {
352 shader_cache.OnCPUWrite(addr, size); 352 shader_cache.OnCPUWrite(addr, size);
353 { 353 {
354 std::scoped_lock lock{texture_cache.mutex}; 354 std::scoped_lock lock{texture_cache.mutex};
355 texture_cache.CachedWriteMemory(addr, size); 355 texture_cache.WriteMemory(addr, size);
356 } 356 }
357 { 357 {
358 std::scoped_lock lock{buffer_cache.mutex}; 358 std::scoped_lock lock{buffer_cache.mutex};
@@ -364,10 +364,6 @@ void RasterizerOpenGL::SyncGuestHost() {
364 MICROPROFILE_SCOPE(OpenGL_CacheManagement); 364 MICROPROFILE_SCOPE(OpenGL_CacheManagement);
365 shader_cache.SyncGuestHost(); 365 shader_cache.SyncGuestHost();
366 { 366 {
367 std::scoped_lock lock{texture_cache.mutex};
368 texture_cache.FlushCachedWrites();
369 }
370 {
371 std::scoped_lock lock{buffer_cache.mutex}; 367 std::scoped_lock lock{buffer_cache.mutex};
372 buffer_cache.FlushCachedWrites(); 368 buffer_cache.FlushCachedWrites();
373 } 369 }
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index dd6e0027e..fa87d37f8 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -408,7 +408,7 @@ void RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) {
408 pipeline_cache.OnCPUWrite(addr, size); 408 pipeline_cache.OnCPUWrite(addr, size);
409 { 409 {
410 std::scoped_lock lock{texture_cache.mutex}; 410 std::scoped_lock lock{texture_cache.mutex};
411 texture_cache.CachedWriteMemory(addr, size); 411 texture_cache.WriteMemory(addr, size);
412 } 412 }
413 { 413 {
414 std::scoped_lock lock{buffer_cache.mutex}; 414 std::scoped_lock lock{buffer_cache.mutex};
@@ -419,10 +419,6 @@ void RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) {
419void RasterizerVulkan::SyncGuestHost() { 419void RasterizerVulkan::SyncGuestHost() {
420 pipeline_cache.SyncGuestHost(); 420 pipeline_cache.SyncGuestHost();
421 { 421 {
422 std::scoped_lock lock{texture_cache.mutex};
423 texture_cache.FlushCachedWrites();
424 }
425 {
426 std::scoped_lock lock{buffer_cache.mutex}; 422 std::scoped_lock lock{buffer_cache.mutex};
427 buffer_cache.FlushCachedWrites(); 423 buffer_cache.FlushCachedWrites();
428 } 424 }
diff --git a/src/video_core/texture_cache/image_base.h b/src/video_core/texture_cache/image_base.h
index cc7999027..dd0106432 100644
--- a/src/video_core/texture_cache/image_base.h
+++ b/src/video_core/texture_cache/image_base.h
@@ -39,9 +39,6 @@ enum class ImageFlagBits : u32 {
39 Rescaled = 1 << 13, 39 Rescaled = 1 << 13,
40 CheckingRescalable = 1 << 14, 40 CheckingRescalable = 1 << 14,
41 IsRescalable = 1 << 15, 41 IsRescalable = 1 << 15,
42
43 // Cached CPU
44 CachedCpuModified = 1 << 16, ///< Contents have been modified from the CPU
45}; 42};
46DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) 43DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits)
47 44
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 099b2ae1b..efc1c4525 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -438,23 +438,6 @@ void TextureCache<P>::WriteMemory(VAddr cpu_addr, size_t size) {
438} 438}
439 439
440template <class P> 440template <class P>
441void TextureCache<P>::CachedWriteMemory(VAddr cpu_addr, size_t size) {
442 const VAddr new_cpu_addr = Common::AlignDown(cpu_addr, CPU_PAGE_SIZE);
443 const size_t new_size = Common::AlignUp(size + cpu_addr - new_cpu_addr, CPU_PAGE_SIZE);
444 ForEachImageInRegion(new_cpu_addr, new_size, [this](ImageId image_id, Image& image) {
445 if (True(image.flags & ImageFlagBits::CachedCpuModified)) {
446 return;
447 }
448 image.flags |= ImageFlagBits::CachedCpuModified;
449 cached_cpu_invalidate.insert(image_id);
450
451 if (True(image.flags & ImageFlagBits::Tracked)) {
452 UntrackImage(image, image_id);
453 }
454 });
455}
456
457template <class P>
458void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) { 441void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) {
459 std::vector<ImageId> images; 442 std::vector<ImageId> images;
460 ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) { 443 ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) {
@@ -512,18 +495,6 @@ void TextureCache<P>::UnmapGPUMemory(GPUVAddr gpu_addr, size_t size) {
512} 495}
513 496
514template <class P> 497template <class P>
515void TextureCache<P>::FlushCachedWrites() {
516 for (ImageId image_id : cached_cpu_invalidate) {
517 Image& image = slot_images[image_id];
518 if (True(image.flags & ImageFlagBits::CachedCpuModified)) {
519 image.flags &= ~ImageFlagBits::CachedCpuModified;
520 image.flags |= ImageFlagBits::CpuModified;
521 }
522 }
523 cached_cpu_invalidate.clear();
524}
525
526template <class P>
527void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, 498void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst,
528 const Tegra::Engines::Fermi2D::Surface& src, 499 const Tegra::Engines::Fermi2D::Surface& src,
529 const Tegra::Engines::Fermi2D::Config& copy) { 500 const Tegra::Engines::Fermi2D::Config& copy) {
@@ -1589,9 +1560,6 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) {
1589template <class P> 1560template <class P>
1590void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { 1561void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) {
1591 ASSERT(False(image.flags & ImageFlagBits::Tracked)); 1562 ASSERT(False(image.flags & ImageFlagBits::Tracked));
1592 if (True(image.flags & ImageFlagBits::CachedCpuModified)) {
1593 return;
1594 }
1595 image.flags |= ImageFlagBits::Tracked; 1563 image.flags |= ImageFlagBits::Tracked;
1596 if (False(image.flags & ImageFlagBits::Sparse)) { 1564 if (False(image.flags & ImageFlagBits::Sparse)) {
1597 rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); 1565 rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1);
@@ -1648,9 +1616,6 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) {
1648 tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); 1616 tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format);
1649 } 1617 }
1650 total_used_memory -= Common::AlignUp(tentative_size, 1024); 1618 total_used_memory -= Common::AlignUp(tentative_size, 1024);
1651 if (True(image.flags & ImageFlagBits::CachedCpuModified)) {
1652 cached_cpu_invalidate.erase(image_id);
1653 }
1654 const GPUVAddr gpu_addr = image.gpu_addr; 1619 const GPUVAddr gpu_addr = image.gpu_addr;
1655 const auto alloc_it = image_allocs_table.find(gpu_addr); 1620 const auto alloc_it = image_allocs_table.find(gpu_addr);
1656 if (alloc_it == image_allocs_table.end()) { 1621 if (alloc_it == image_allocs_table.end()) {
@@ -1817,11 +1782,7 @@ template <class P>
1817void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool invalidate) { 1782void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool invalidate) {
1818 Image& image = slot_images[image_id]; 1783 Image& image = slot_images[image_id];
1819 if (invalidate) { 1784 if (invalidate) {
1820 if (True(image.flags & ImageFlagBits::CachedCpuModified)) { 1785 image.flags &= ~(ImageFlagBits::CpuModified | ImageFlagBits::GpuModified);
1821 cached_cpu_invalidate.erase(image_id);
1822 }
1823 image.flags &= ~(ImageFlagBits::CpuModified | ImageFlagBits::GpuModified |
1824 ImageFlagBits::CachedCpuModified);
1825 if (False(image.flags & ImageFlagBits::Tracked)) { 1786 if (False(image.flags & ImageFlagBits::Tracked)) {
1826 TrackImage(image, image_id); 1787 TrackImage(image, image_id);
1827 } 1788 }
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index ad5978a33..b1324edf3 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -8,7 +8,6 @@
8#include <span> 8#include <span>
9#include <type_traits> 9#include <type_traits>
10#include <unordered_map> 10#include <unordered_map>
11#include <unordered_set>
12#include <vector> 11#include <vector>
13#include <queue> 12#include <queue>
14 13
@@ -51,9 +50,6 @@ class TextureCache {
51 /// Address shift for caching images into a hash table 50 /// Address shift for caching images into a hash table
52 static constexpr u64 PAGE_BITS = 20; 51 static constexpr u64 PAGE_BITS = 20;
53 52
54 static constexpr u64 CPU_PAGE_BITS = 12;
55 static constexpr u64 CPU_PAGE_SIZE = 1ULL << CPU_PAGE_BITS;
56
57 /// Enables debugging features to the texture cache 53 /// Enables debugging features to the texture cache
58 static constexpr bool ENABLE_VALIDATION = P::ENABLE_VALIDATION; 54 static constexpr bool ENABLE_VALIDATION = P::ENABLE_VALIDATION;
59 /// Implement blits as copies between framebuffers 55 /// Implement blits as copies between framebuffers
@@ -140,9 +136,6 @@ public:
140 /// Mark images in a range as modified from the CPU 136 /// Mark images in a range as modified from the CPU
141 void WriteMemory(VAddr cpu_addr, size_t size); 137 void WriteMemory(VAddr cpu_addr, size_t size);
142 138
143 /// Mark images in a range as modified from the CPU
144 void CachedWriteMemory(VAddr cpu_addr, size_t size);
145
146 /// Download contents of host images to guest memory in a region 139 /// Download contents of host images to guest memory in a region
147 void DownloadMemory(VAddr cpu_addr, size_t size); 140 void DownloadMemory(VAddr cpu_addr, size_t size);
148 141
@@ -152,8 +145,6 @@ public:
152 /// Remove images in a region 145 /// Remove images in a region
153 void UnmapGPUMemory(GPUVAddr gpu_addr, size_t size); 146 void UnmapGPUMemory(GPUVAddr gpu_addr, size_t size);
154 147
155 void FlushCachedWrites();
156
157 /// Blit an image with the given parameters 148 /// Blit an image with the given parameters
158 void BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, 149 void BlitImage(const Tegra::Engines::Fermi2D::Surface& dst,
159 const Tegra::Engines::Fermi2D::Surface& src, 150 const Tegra::Engines::Fermi2D::Surface& src,
@@ -375,8 +366,6 @@ private:
375 366
376 std::unordered_map<ImageId, std::vector<ImageViewId>> sparse_views; 367 std::unordered_map<ImageId, std::vector<ImageViewId>> sparse_views;
377 368
378 std::unordered_set<ImageId> cached_cpu_invalidate;
379
380 VAddr virtual_invalid_space{}; 369 VAddr virtual_invalid_space{};
381 370
382 bool has_deleted_images = false; 371 bool has_deleted_images = false;