diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 26 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 5 | ||||
| -rw-r--r-- | src/video_core/texture_cache/util.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/texture_cache/util.h | 1 |
4 files changed, 28 insertions, 13 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 8e68a2e53..fccf4316d 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -39,6 +39,12 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface& | |||
| 39 | sampler_descriptor.mipmap_filter.Assign(Tegra::Texture::TextureMipmapFilter::Linear); | 39 | sampler_descriptor.mipmap_filter.Assign(Tegra::Texture::TextureMipmapFilter::Linear); |
| 40 | sampler_descriptor.cubemap_anisotropy.Assign(1); | 40 | sampler_descriptor.cubemap_anisotropy.Assign(1); |
| 41 | 41 | ||
| 42 | // These values were chosen based on typical peak swizzle data sizes seen in some titles | ||
| 43 | static constexpr size_t SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 8_MiB; | ||
| 44 | static constexpr size_t UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 1_MiB; | ||
| 45 | swizzle_data_buffer.reserve(SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY); | ||
| 46 | unswizzle_data_buffer.reserve(UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY); | ||
| 47 | |||
| 42 | // Make sure the first index is reserved for the null resources | 48 | // Make sure the first index is reserved for the null resources |
| 43 | // This way the null resource becomes a compile time constant | 49 | // This way the null resource becomes a compile time constant |
| 44 | void(slot_images.insert(NullImageParams{})); | 50 | void(slot_images.insert(NullImageParams{})); |
| @@ -734,13 +740,21 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging) | |||
| 734 | gpu_memory->ReadBlockUnsafe(gpu_addr, mapped_span.data(), mapped_span.size_bytes()); | 740 | gpu_memory->ReadBlockUnsafe(gpu_addr, mapped_span.data(), mapped_span.size_bytes()); |
| 735 | const auto uploads = FullUploadSwizzles(image.info); | 741 | const auto uploads = FullUploadSwizzles(image.info); |
| 736 | runtime.AccelerateImageUpload(image, staging, uploads); | 742 | runtime.AccelerateImageUpload(image, staging, uploads); |
| 737 | } else if (True(image.flags & ImageFlagBits::Converted)) { | 743 | return; |
| 738 | std::vector<u8> unswizzled_data(image.unswizzled_size_bytes); | 744 | } |
| 739 | auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, unswizzled_data); | 745 | const size_t guest_size_bytes = image.guest_size_bytes; |
| 740 | ConvertImage(unswizzled_data, image.info, mapped_span, copies); | 746 | swizzle_data_buffer.resize(guest_size_bytes); |
| 747 | gpu_memory->ReadBlockUnsafe(gpu_addr, swizzle_data_buffer.data(), guest_size_bytes); | ||
| 748 | |||
| 749 | if (True(image.flags & ImageFlagBits::Converted)) { | ||
| 750 | unswizzle_data_buffer.resize(image.unswizzled_size_bytes); | ||
| 751 | auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, swizzle_data_buffer, | ||
| 752 | unswizzle_data_buffer); | ||
| 753 | ConvertImage(unswizzle_data_buffer, image.info, mapped_span, copies); | ||
| 741 | image.UploadMemory(staging, copies); | 754 | image.UploadMemory(staging, copies); |
| 742 | } else { | 755 | } else { |
| 743 | const auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, mapped_span); | 756 | const auto copies = |
| 757 | UnswizzleImage(*gpu_memory, gpu_addr, image.info, swizzle_data_buffer, mapped_span); | ||
| 744 | image.UploadMemory(staging, copies); | 758 | image.UploadMemory(staging, copies); |
| 745 | } | 759 | } |
| 746 | } | 760 | } |
| @@ -910,7 +924,7 @@ void TextureCache<P>::InvalidateScale(Image& image) { | |||
| 910 | } | 924 | } |
| 911 | 925 | ||
| 912 | template <class P> | 926 | template <class P> |
| 913 | u64 TextureCache<P>::GetScaledImageSizeBytes(ImageBase& image) { | 927 | u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) { |
| 914 | const u64 scale_up = static_cast<u64>(Settings::values.resolution_info.up_scale * | 928 | const u64 scale_up = static_cast<u64>(Settings::values.resolution_info.up_scale * |
| 915 | Settings::values.resolution_info.up_scale); | 929 | Settings::values.resolution_info.up_scale); |
| 916 | const u64 down_shift = static_cast<u64>(Settings::values.resolution_info.down_shift + | 930 | const u64 down_shift = static_cast<u64>(Settings::values.resolution_info.down_shift + |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 587339a31..67e8acf25 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -368,7 +368,7 @@ private: | |||
| 368 | void InvalidateScale(Image& image); | 368 | void InvalidateScale(Image& image); |
| 369 | bool ScaleUp(Image& image); | 369 | bool ScaleUp(Image& image); |
| 370 | bool ScaleDown(Image& image); | 370 | bool ScaleDown(Image& image); |
| 371 | u64 GetScaledImageSizeBytes(ImageBase& image); | 371 | u64 GetScaledImageSizeBytes(const ImageBase& image); |
| 372 | 372 | ||
| 373 | Runtime& runtime; | 373 | Runtime& runtime; |
| 374 | 374 | ||
| @@ -417,6 +417,9 @@ private: | |||
| 417 | 417 | ||
| 418 | std::unordered_map<GPUVAddr, ImageAllocId> image_allocs_table; | 418 | std::unordered_map<GPUVAddr, ImageAllocId> image_allocs_table; |
| 419 | 419 | ||
| 420 | std::vector<u8> swizzle_data_buffer; | ||
| 421 | std::vector<u8> unswizzle_data_buffer; | ||
| 422 | |||
| 420 | u64 modification_tick = 0; | 423 | u64 modification_tick = 0; |
| 421 | u64 frame_tick = 0; | 424 | u64 frame_tick = 0; |
| 422 | }; | 425 | }; |
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index e8c908b42..4488fa9da 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp | |||
| @@ -765,8 +765,9 @@ bool IsValidEntry(const Tegra::MemoryManager& gpu_memory, const TICEntry& config | |||
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, | 767 | std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, |
| 768 | const ImageInfo& info, std::span<u8> output) { | 768 | const ImageInfo& info, std::span<const u8> input, |
| 769 | const size_t guest_size_bytes = CalculateGuestSizeInBytes(info); | 769 | std::span<u8> output) { |
| 770 | const size_t guest_size_bytes = input.size_bytes(); | ||
| 770 | const u32 bpp_log2 = BytesPerBlockLog2(info.format); | 771 | const u32 bpp_log2 = BytesPerBlockLog2(info.format); |
| 771 | const Extent3D size = info.size; | 772 | const Extent3D size = info.size; |
| 772 | 773 | ||
| @@ -789,10 +790,6 @@ std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, GP | |||
| 789 | .image_extent = size, | 790 | .image_extent = size, |
| 790 | }}; | 791 | }}; |
| 791 | } | 792 | } |
| 792 | const auto input_data = std::make_unique<u8[]>(guest_size_bytes); | ||
| 793 | gpu_memory.ReadBlockUnsafe(gpu_addr, input_data.get(), guest_size_bytes); | ||
| 794 | const std::span<const u8> input(input_data.get(), guest_size_bytes); | ||
| 795 | |||
| 796 | const LevelInfo level_info = MakeLevelInfo(info); | 793 | const LevelInfo level_info = MakeLevelInfo(info); |
| 797 | const s32 num_layers = info.resources.layers; | 794 | const s32 num_layers = info.resources.layers; |
| 798 | const s32 num_levels = info.resources.levels; | 795 | const s32 num_levels = info.resources.levels; |
diff --git a/src/video_core/texture_cache/util.h b/src/video_core/texture_cache/util.h index 5e28f4ab3..ddf0b3b06 100644 --- a/src/video_core/texture_cache/util.h +++ b/src/video_core/texture_cache/util.h | |||
| @@ -59,6 +59,7 @@ struct OverlapResult { | |||
| 59 | 59 | ||
| 60 | [[nodiscard]] std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, | 60 | [[nodiscard]] std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, |
| 61 | GPUVAddr gpu_addr, const ImageInfo& info, | 61 | GPUVAddr gpu_addr, const ImageInfo& info, |
| 62 | std::span<const u8> input, | ||
| 62 | std::span<u8> output); | 63 | std::span<u8> output); |
| 63 | 64 | ||
| 64 | [[nodiscard]] BufferCopy UploadBufferCopy(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, | 65 | [[nodiscard]] BufferCopy UploadBufferCopy(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, |