diff options
| author | 2023-12-03 14:02:20 -0500 | |
|---|---|---|
| committer | 2023-12-03 16:43:54 -0500 | |
| commit | 382cf087a09e1095f07c14aabc8e432ec0a1a2c1 (patch) | |
| tree | d028d018e39466e041992d2aad804914355758ae /src/video_core/texture_cache | |
| parent | Merge pull request #12094 from ameerj/gl-buffer-cache-batch-vtx (diff) | |
| download | yuzu-382cf087a09e1095f07c14aabc8e432ec0a1a2c1.tar.gz yuzu-382cf087a09e1095f07c14aabc8e432ec0a1a2c1.tar.xz yuzu-382cf087a09e1095f07c14aabc8e432ec0a1a2c1.zip | |
renderer_vulkan: do not recreate swapchain for srgb
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 35 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 3 |
2 files changed, 28 insertions, 10 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index dade38b18..c36ecece2 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -712,14 +712,15 @@ bool TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | |||
| 712 | } | 712 | } |
| 713 | 713 | ||
| 714 | template <class P> | 714 | template <class P> |
| 715 | typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_addr) { | 715 | typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView( |
| 716 | const Tegra::FramebufferConfig& config, VAddr cpu_addr) { | ||
| 716 | // TODO: Properly implement this | 717 | // TODO: Properly implement this |
| 717 | const auto it = page_table.find(cpu_addr >> YUZU_PAGEBITS); | 718 | const auto it = page_table.find(cpu_addr >> YUZU_PAGEBITS); |
| 718 | if (it == page_table.end()) { | 719 | if (it == page_table.end()) { |
| 719 | return nullptr; | 720 | return nullptr; |
| 720 | } | 721 | } |
| 721 | const auto& image_map_ids = it->second; | 722 | const auto& image_map_ids = it->second; |
| 722 | boost::container::small_vector<const ImageBase*, 4> valid_images; | 723 | boost::container::small_vector<ImageId, 4> valid_image_ids; |
| 723 | for (const ImageMapId map_id : image_map_ids) { | 724 | for (const ImageMapId map_id : image_map_ids) { |
| 724 | const ImageMapView& map = slot_map_views[map_id]; | 725 | const ImageMapView& map = slot_map_views[map_id]; |
| 725 | const ImageBase& image = slot_images[map.image_id]; | 726 | const ImageBase& image = slot_images[map.image_id]; |
| @@ -729,18 +730,34 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_ad | |||
| 729 | if (image.image_view_ids.empty()) { | 730 | if (image.image_view_ids.empty()) { |
| 730 | continue; | 731 | continue; |
| 731 | } | 732 | } |
| 732 | valid_images.push_back(&image); | 733 | valid_image_ids.push_back(map.image_id); |
| 733 | } | 734 | } |
| 734 | 735 | ||
| 735 | if (valid_images.size() == 1) [[likely]] { | 736 | const auto view_format = [&]() { |
| 736 | return &slot_image_views[valid_images[0]->image_view_ids.at(0)]; | 737 | switch (config.pixel_format) { |
| 738 | case Service::android::PixelFormat::Rgb565: | ||
| 739 | return PixelFormat::R5G6B5_UNORM; | ||
| 740 | case Service::android::PixelFormat::Bgra8888: | ||
| 741 | return PixelFormat::B8G8R8A8_UNORM; | ||
| 742 | default: | ||
| 743 | return PixelFormat::A8B8G8R8_UNORM; | ||
| 744 | } | ||
| 745 | }(); | ||
| 746 | |||
| 747 | const auto GetImageViewForFramebuffer = [&](ImageId image_id) { | ||
| 748 | const ImageViewInfo info{ImageViewType::e2D, view_format}; | ||
| 749 | return &slot_image_views[FindOrEmplaceImageView(image_id, info)]; | ||
| 750 | }; | ||
| 751 | |||
| 752 | if (valid_image_ids.size() == 1) [[likely]] { | ||
| 753 | return GetImageViewForFramebuffer(valid_image_ids.front()); | ||
| 737 | } | 754 | } |
| 738 | 755 | ||
| 739 | if (valid_images.size() > 0) [[unlikely]] { | 756 | if (valid_image_ids.size() > 0) [[unlikely]] { |
| 740 | std::ranges::sort(valid_images, [](const auto* a, const auto* b) { | 757 | auto most_recent = std::ranges::max_element(valid_image_ids, [&](auto a, auto b) { |
| 741 | return a->modification_tick > b->modification_tick; | 758 | return slot_images[a].modification_tick > slot_images[b].modification_tick; |
| 742 | }); | 759 | }); |
| 743 | return &slot_image_views[valid_images[0]->image_view_ids.at(0)]; | 760 | return GetImageViewForFramebuffer(*most_recent); |
| 744 | } | 761 | } |
| 745 | 762 | ||
| 746 | return nullptr; | 763 | return nullptr; |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index a40825c9f..cbe56e166 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -209,7 +209,8 @@ public: | |||
| 209 | const Tegra::Engines::Fermi2D::Config& copy); | 209 | const Tegra::Engines::Fermi2D::Config& copy); |
| 210 | 210 | ||
| 211 | /// Try to find a cached image view in the given CPU address | 211 | /// Try to find a cached image view in the given CPU address |
| 212 | [[nodiscard]] ImageView* TryFindFramebufferImageView(VAddr cpu_addr); | 212 | [[nodiscard]] ImageView* TryFindFramebufferImageView(const Tegra::FramebufferConfig& config, |
| 213 | VAddr cpu_addr); | ||
| 213 | 214 | ||
| 214 | /// Return true when there are uncommitted images to be downloaded | 215 | /// Return true when there are uncommitted images to be downloaded |
| 215 | [[nodiscard]] bool HasUncommittedFlushes() const noexcept; | 216 | [[nodiscard]] bool HasUncommittedFlushes() const noexcept; |