summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/texture_cache/texture_cache.h8
-rw-r--r--src/video_core/texture_cache/texture_cache_base.h5
-rw-r--r--src/video_core/texture_cache/util.cpp6
-rw-r--r--src/video_core/texture_cache/util.h3
4 files changed, 12 insertions, 10 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 6d7d8226f..27c82cd20 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -42,8 +42,8 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
42 // These values were chosen based on typical peak swizzle data sizes seen in some titles 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; 43 static constexpr size_t SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 8_MiB;
44 static constexpr size_t UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 1_MiB; 44 static constexpr size_t UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 1_MiB;
45 swizzle_data_buffer.reserve(SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY); 45 swizzle_data_buffer.resize_destructive(SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY);
46 unswizzle_data_buffer.reserve(UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY); 46 unswizzle_data_buffer.resize_destructive(UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY);
47 47
48 // Make sure the first index is reserved for the null resources 48 // Make sure the first index is reserved for the null resources
49 // This way the null resource becomes a compile time constant 49 // This way the null resource becomes a compile time constant
@@ -746,11 +746,11 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging)
746 return; 746 return;
747 } 747 }
748 const size_t guest_size_bytes = image.guest_size_bytes; 748 const size_t guest_size_bytes = image.guest_size_bytes;
749 swizzle_data_buffer.resize(guest_size_bytes); 749 swizzle_data_buffer.resize_destructive(guest_size_bytes);
750 gpu_memory->ReadBlockUnsafe(gpu_addr, swizzle_data_buffer.data(), guest_size_bytes); 750 gpu_memory->ReadBlockUnsafe(gpu_addr, swizzle_data_buffer.data(), guest_size_bytes);
751 751
752 if (True(image.flags & ImageFlagBits::Converted)) { 752 if (True(image.flags & ImageFlagBits::Converted)) {
753 unswizzle_data_buffer.resize(image.unswizzled_size_bytes); 753 unswizzle_data_buffer.resize_destructive(image.unswizzled_size_bytes);
754 auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, swizzle_data_buffer, 754 auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, swizzle_data_buffer,
755 unswizzle_data_buffer); 755 unswizzle_data_buffer);
756 ConvertImage(unswizzle_data_buffer, image.info, mapped_span, copies); 756 ConvertImage(unswizzle_data_buffer, image.info, mapped_span, copies);
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index 67e8acf25..4fd677a80 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -17,6 +17,7 @@
17#include "common/literals.h" 17#include "common/literals.h"
18#include "common/lru_cache.h" 18#include "common/lru_cache.h"
19#include "common/polyfill_ranges.h" 19#include "common/polyfill_ranges.h"
20#include "common/scratch_buffer.h"
20#include "video_core/compatible_formats.h" 21#include "video_core/compatible_formats.h"
21#include "video_core/control/channel_state_cache.h" 22#include "video_core/control/channel_state_cache.h"
22#include "video_core/delayed_destruction_ring.h" 23#include "video_core/delayed_destruction_ring.h"
@@ -417,8 +418,8 @@ private:
417 418
418 std::unordered_map<GPUVAddr, ImageAllocId> image_allocs_table; 419 std::unordered_map<GPUVAddr, ImageAllocId> image_allocs_table;
419 420
420 std::vector<u8> swizzle_data_buffer; 421 Common::ScratchBuffer<u8> swizzle_data_buffer;
421 std::vector<u8> unswizzle_data_buffer; 422 Common::ScratchBuffer<u8> unswizzle_data_buffer;
422 423
423 u64 modification_tick = 0; 424 u64 modification_tick = 0;
424 u64 frame_tick = 0; 425 u64 frame_tick = 0;
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index 7999a7f06..03acc68d9 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -505,7 +505,7 @@ void SwizzlePitchLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr
505 505
506void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, 506void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr,
507 const ImageInfo& info, const BufferImageCopy& copy, 507 const ImageInfo& info, const BufferImageCopy& copy,
508 std::span<const u8> input, std::vector<u8>& tmp_buffer) { 508 std::span<const u8> input, Common::ScratchBuffer<u8>& tmp_buffer) {
509 const Extent3D size = info.size; 509 const Extent3D size = info.size;
510 const LevelInfo level_info = MakeLevelInfo(info); 510 const LevelInfo level_info = MakeLevelInfo(info);
511 const Extent2D tile_size = DefaultBlockSize(info.format); 511 const Extent2D tile_size = DefaultBlockSize(info.format);
@@ -534,7 +534,7 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr
534 tile_size.height, info.tile_width_spacing); 534 tile_size.height, info.tile_width_spacing);
535 const size_t subresource_size = sizes[level]; 535 const size_t subresource_size = sizes[level];
536 536
537 tmp_buffer.resize(subresource_size); 537 tmp_buffer.resize_destructive(subresource_size);
538 const std::span<u8> dst(tmp_buffer); 538 const std::span<u8> dst(tmp_buffer);
539 539
540 for (s32 layer = 0; layer < info.resources.layers; ++layer) { 540 for (s32 layer = 0; layer < info.resources.layers; ++layer) {
@@ -978,7 +978,7 @@ std::vector<SwizzleParameters> FullUploadSwizzles(const ImageInfo& info) {
978 978
979void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info, 979void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info,
980 std::span<const BufferImageCopy> copies, std::span<const u8> memory, 980 std::span<const BufferImageCopy> copies, std::span<const u8> memory,
981 std::vector<u8>& tmp_buffer) { 981 Common::ScratchBuffer<u8>& tmp_buffer) {
982 const bool is_pitch_linear = info.type == ImageType::Linear; 982 const bool is_pitch_linear = info.type == ImageType::Linear;
983 for (const BufferImageCopy& copy : copies) { 983 for (const BufferImageCopy& copy : copies) {
984 if (is_pitch_linear) { 984 if (is_pitch_linear) {
diff --git a/src/video_core/texture_cache/util.h b/src/video_core/texture_cache/util.h
index 2c991b4d2..d103db8ae 100644
--- a/src/video_core/texture_cache/util.h
+++ b/src/video_core/texture_cache/util.h
@@ -7,6 +7,7 @@
7#include <span> 7#include <span>
8 8
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/scratch_buffer.h"
10 11
11#include "video_core/surface.h" 12#include "video_core/surface.h"
12#include "video_core/texture_cache/image_base.h" 13#include "video_core/texture_cache/image_base.h"
@@ -78,7 +79,7 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
78 79
79void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info, 80void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info,
80 std::span<const BufferImageCopy> copies, std::span<const u8> memory, 81 std::span<const BufferImageCopy> copies, std::span<const u8> memory,
81 std::vector<u8>& tmp_buffer); 82 Common::ScratchBuffer<u8>& tmp_buffer);
82 83
83[[nodiscard]] bool IsBlockLinearSizeCompatible(const ImageInfo& new_info, 84[[nodiscard]] bool IsBlockLinearSizeCompatible(const ImageInfo& new_info,
84 const ImageInfo& overlap_info, u32 new_level, 85 const ImageInfo& overlap_info, u32 new_level,