summaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-12-23 01:40:45 +0100
committerGravatar Fernando Sahmkow2022-10-06 21:00:52 +0200
commit9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee (patch)
treeb213e143366041f07ac9389e91801384f698b0d8 /src/video_core/texture_cache
parentRefactor VideoCore to use AS sepparate from Channel. (diff)
downloadyuzu-9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee.tar.gz
yuzu-9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee.tar.xz
yuzu-9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee.zip
Texture cache: Fix dangling references on multichannel.
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r--src/video_core/texture_cache/texture_cache.h45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 89c5faf88..5ef07d18f 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -41,9 +41,6 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
41 sampler_descriptor.mipmap_filter.Assign(Tegra::Texture::TextureMipmapFilter::Linear); 41 sampler_descriptor.mipmap_filter.Assign(Tegra::Texture::TextureMipmapFilter::Linear);
42 sampler_descriptor.cubemap_anisotropy.Assign(1); 42 sampler_descriptor.cubemap_anisotropy.Assign(1);
43 43
44 // Setup channels
45 current_channel_id = UNSET_CHANNEL;
46
47 // Make sure the first index is reserved for the null resources 44 // Make sure the first index is reserved for the null resources
48 // This way the null resource becomes a compile time constant 45 // This way the null resource becomes a compile time constant
49 void(slot_images.insert(NullImageParams{})); 46 void(slot_images.insert(NullImageParams{}));
@@ -886,13 +883,15 @@ void TextureCache<P>::InvalidateScale(Image& image) {
886 } 883 }
887 image.image_view_ids.clear(); 884 image.image_view_ids.clear();
888 image.image_view_infos.clear(); 885 image.image_view_infos.clear();
889 auto& channel_info = channel_storage[image.channel]; 886 for (size_t c : active_channel_ids) {
890 if constexpr (ENABLE_VALIDATION) { 887 auto& channel_info = channel_storage[c];
891 std::ranges::fill(channel_info.graphics_image_view_ids, CORRUPT_ID); 888 if constexpr (ENABLE_VALIDATION) {
892 std::ranges::fill(channel_info.compute_image_view_ids, CORRUPT_ID); 889 std::ranges::fill(channel_info.graphics_image_view_ids, CORRUPT_ID);
890 std::ranges::fill(channel_info.compute_image_view_ids, CORRUPT_ID);
891 }
892 channel_info.graphics_image_table.Invalidate();
893 channel_info.compute_image_table.Invalidate();
893 } 894 }
894 channel_info.graphics_image_table.Invalidate();
895 channel_info.compute_image_table.Invalidate();
896 has_deleted_images = true; 895 has_deleted_images = true;
897} 896}
898 897
@@ -1690,26 +1689,30 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) {
1690 if (alloc_images.empty()) { 1689 if (alloc_images.empty()) {
1691 image_allocs_table.erase(alloc_it); 1690 image_allocs_table.erase(alloc_it);
1692 } 1691 }
1693 for (auto& this_state : channel_storage) { 1692 for (size_t c : active_channel_ids) {
1693 auto& channel_info = channel_storage[c];
1694 if constexpr (ENABLE_VALIDATION) { 1694 if constexpr (ENABLE_VALIDATION) {
1695 std::ranges::fill(this_state.graphics_image_view_ids, CORRUPT_ID); 1695 std::ranges::fill(channel_info.graphics_image_view_ids, CORRUPT_ID);
1696 std::ranges::fill(this_state.compute_image_view_ids, CORRUPT_ID); 1696 std::ranges::fill(channel_info.compute_image_view_ids, CORRUPT_ID);
1697 } 1697 }
1698 this_state.graphics_image_table.Invalidate(); 1698 channel_info.graphics_image_table.Invalidate();
1699 this_state.compute_image_table.Invalidate(); 1699 channel_info.compute_image_table.Invalidate();
1700 } 1700 }
1701 has_deleted_images = true; 1701 has_deleted_images = true;
1702} 1702}
1703 1703
1704template <class P> 1704template <class P>
1705void TextureCache<P>::RemoveImageViewReferences(std::span<const ImageViewId> removed_views) { 1705void TextureCache<P>::RemoveImageViewReferences(std::span<const ImageViewId> removed_views) {
1706 auto it = channel_state->image_views.begin(); 1706 for (size_t c : active_channel_ids) {
1707 while (it != channel_state->image_views.end()) { 1707 auto& channel_info = channel_storage[c];
1708 const auto found = std::ranges::find(removed_views, it->second); 1708 auto it = channel_info.image_views.begin();
1709 if (found != removed_views.end()) { 1709 while (it != channel_info.image_views.end()) {
1710 it = channel_state->image_views.erase(it); 1710 const auto found = std::ranges::find(removed_views, it->second);
1711 } else { 1711 if (found != removed_views.end()) {
1712 ++it; 1712 it = channel_info.image_views.erase(it);
1713 } else {
1714 ++it;
1715 }
1713 } 1716 }
1714 } 1717 }
1715} 1718}