diff options
| author | 2022-12-18 18:09:59 -0500 | |
|---|---|---|
| committer | 2022-12-19 18:08:04 -0500 | |
| commit | 4bc2d821300354e0d178c520b4b3520afbf8ff20 (patch) | |
| tree | 89c6eff1a2ac90fc106ea229de211411f5f4871b /src | |
| parent | common: Add ScratchBuffer class (diff) | |
| download | yuzu-4bc2d821300354e0d178c520b4b3520afbf8ff20.tar.gz yuzu-4bc2d821300354e0d178c520b4b3520afbf8ff20.tar.xz yuzu-4bc2d821300354e0d178c520b4b3520afbf8ff20.zip | |
video_core: Add usages of ScratchBuffer
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/engine_upload.h | 7 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 32 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.h | 8 | ||||
| -rw-r--r-- | src/video_core/host1x/vic.h | 7 |
4 files changed, 21 insertions, 33 deletions
diff --git a/src/video_core/engines/engine_upload.h b/src/video_core/engines/engine_upload.h index 94fafd9dc..7242d2529 100644 --- a/src/video_core/engines/engine_upload.h +++ b/src/video_core/engines/engine_upload.h | |||
| @@ -4,9 +4,10 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <span> | 6 | #include <span> |
| 7 | #include <vector> | 7 | |
| 8 | #include "common/bit_field.h" | 8 | #include "common/bit_field.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/scratch_buffer.h" | ||
| 10 | 11 | ||
| 11 | namespace Tegra { | 12 | namespace Tegra { |
| 12 | class MemoryManager; | 13 | class MemoryManager; |
| @@ -73,8 +74,8 @@ private: | |||
| 73 | 74 | ||
| 74 | u32 write_offset = 0; | 75 | u32 write_offset = 0; |
| 75 | u32 copy_size = 0; | 76 | u32 copy_size = 0; |
| 76 | std::vector<u8> inner_buffer; | 77 | Common::ScratchBuffer<u8> inner_buffer; |
| 77 | std::vector<u8> tmp_buffer; | 78 | Common::ScratchBuffer<u8> tmp_buffer; |
| 78 | bool is_linear = false; | 79 | bool is_linear = false; |
| 79 | Registers& regs; | 80 | Registers& regs; |
| 80 | MemoryManager& memory_manager; | 81 | MemoryManager& memory_manager; |
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index a189e60ae..dc873732e 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -184,12 +184,8 @@ void MaxwellDMA::CopyBlockLinearToPitch() { | |||
| 184 | const size_t src_size = | 184 | const size_t src_size = |
| 185 | CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); | 185 | CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); |
| 186 | 186 | ||
| 187 | if (read_buffer.size() < src_size) { | 187 | read_buffer.resize(src_size); |
| 188 | read_buffer.resize(src_size); | 188 | write_buffer.resize(dst_size); |
| 189 | } | ||
| 190 | if (write_buffer.size() < dst_size) { | ||
| 191 | write_buffer.resize(dst_size); | ||
| 192 | } | ||
| 193 | 189 | ||
| 194 | memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); | 190 | memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); |
| 195 | memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); | 191 | memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); |
| @@ -235,12 +231,8 @@ void MaxwellDMA::CopyPitchToBlockLinear() { | |||
| 235 | CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); | 231 | CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); |
| 236 | const size_t src_size = static_cast<size_t>(regs.pitch_in) * regs.line_count; | 232 | const size_t src_size = static_cast<size_t>(regs.pitch_in) * regs.line_count; |
| 237 | 233 | ||
| 238 | if (read_buffer.size() < src_size) { | 234 | read_buffer.resize(src_size); |
| 239 | read_buffer.resize(src_size); | 235 | write_buffer.resize(dst_size); |
| 240 | } | ||
| 241 | if (write_buffer.size() < dst_size) { | ||
| 242 | write_buffer.resize(dst_size); | ||
| 243 | } | ||
| 244 | 236 | ||
| 245 | memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); | 237 | memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); |
| 246 | if (Settings::IsGPULevelExtreme()) { | 238 | if (Settings::IsGPULevelExtreme()) { |
| @@ -269,12 +261,8 @@ void MaxwellDMA::FastCopyBlockLinearToPitch() { | |||
| 269 | pos_x = pos_x % x_in_gob; | 261 | pos_x = pos_x % x_in_gob; |
| 270 | pos_y = pos_y % 8; | 262 | pos_y = pos_y % 8; |
| 271 | 263 | ||
| 272 | if (read_buffer.size() < src_size) { | 264 | read_buffer.resize(src_size); |
| 273 | read_buffer.resize(src_size); | 265 | write_buffer.resize(dst_size); |
| 274 | } | ||
| 275 | if (write_buffer.size() < dst_size) { | ||
| 276 | write_buffer.resize(dst_size); | ||
| 277 | } | ||
| 278 | 266 | ||
| 279 | if (Settings::IsGPULevelExtreme()) { | 267 | if (Settings::IsGPULevelExtreme()) { |
| 280 | memory_manager.ReadBlock(regs.offset_in + offset, read_buffer.data(), src_size); | 268 | memory_manager.ReadBlock(regs.offset_in + offset, read_buffer.data(), src_size); |
| @@ -333,12 +321,8 @@ void MaxwellDMA::CopyBlockLinearToBlockLinear() { | |||
| 333 | const u32 pitch = x_elements * bytes_per_pixel; | 321 | const u32 pitch = x_elements * bytes_per_pixel; |
| 334 | const size_t mid_buffer_size = pitch * regs.line_count; | 322 | const size_t mid_buffer_size = pitch * regs.line_count; |
| 335 | 323 | ||
| 336 | if (read_buffer.size() < src_size) { | 324 | read_buffer.resize(src_size); |
| 337 | read_buffer.resize(src_size); | 325 | write_buffer.resize(dst_size); |
| 338 | } | ||
| 339 | if (write_buffer.size() < dst_size) { | ||
| 340 | write_buffer.resize(dst_size); | ||
| 341 | } | ||
| 342 | 326 | ||
| 343 | intermediate_buffer.resize(mid_buffer_size); | 327 | intermediate_buffer.resize(mid_buffer_size); |
| 344 | 328 | ||
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h index d40d3d302..c88191a61 100644 --- a/src/video_core/engines/maxwell_dma.h +++ b/src/video_core/engines/maxwell_dma.h | |||
| @@ -6,8 +6,10 @@ | |||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <cstddef> | 7 | #include <cstddef> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | |||
| 9 | #include "common/bit_field.h" | 10 | #include "common/bit_field.h" |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/scratch_buffer.h" | ||
| 11 | #include "video_core/engines/engine_interface.h" | 13 | #include "video_core/engines/engine_interface.h" |
| 12 | 14 | ||
| 13 | namespace Core { | 15 | namespace Core { |
| @@ -234,9 +236,9 @@ private: | |||
| 234 | MemoryManager& memory_manager; | 236 | MemoryManager& memory_manager; |
| 235 | VideoCore::RasterizerInterface* rasterizer = nullptr; | 237 | VideoCore::RasterizerInterface* rasterizer = nullptr; |
| 236 | 238 | ||
| 237 | std::vector<u8> read_buffer; | 239 | Common::ScratchBuffer<u8> read_buffer; |
| 238 | std::vector<u8> write_buffer; | 240 | Common::ScratchBuffer<u8> write_buffer; |
| 239 | std::vector<u8> intermediate_buffer; | 241 | Common::ScratchBuffer<u8> intermediate_buffer; |
| 240 | 242 | ||
| 241 | static constexpr std::size_t NUM_REGS = 0x800; | 243 | static constexpr std::size_t NUM_REGS = 0x800; |
| 242 | struct Regs { | 244 | struct Regs { |
diff --git a/src/video_core/host1x/vic.h b/src/video_core/host1x/vic.h index 2b78786e8..3d9753047 100644 --- a/src/video_core/host1x/vic.h +++ b/src/video_core/host1x/vic.h | |||
| @@ -4,8 +4,9 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <vector> | 7 | |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "common/scratch_buffer.h" | ||
| 9 | 10 | ||
| 10 | struct SwsContext; | 11 | struct SwsContext; |
| 11 | 12 | ||
| @@ -49,8 +50,8 @@ private: | |||
| 49 | /// size does not change during a stream | 50 | /// size does not change during a stream |
| 50 | using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>; | 51 | using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>; |
| 51 | AVMallocPtr converted_frame_buffer; | 52 | AVMallocPtr converted_frame_buffer; |
| 52 | std::vector<u8> luma_buffer; | 53 | Common::ScratchBuffer<u8> luma_buffer; |
| 53 | std::vector<u8> chroma_buffer; | 54 | Common::ScratchBuffer<u8> chroma_buffer; |
| 54 | 55 | ||
| 55 | GPUVAddr config_struct_address{}; | 56 | GPUVAddr config_struct_address{}; |
| 56 | GPUVAddr output_surface_luma_address{}; | 57 | GPUVAddr output_surface_luma_address{}; |