From c6590ad07b384762fd90ee8852796ec681a69286 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Mon, 19 Dec 2022 22:40:50 -0500 Subject: scratch_buffer: Explicitly defing resize and resize_destructive functions resize keeps previous data intact when the buffer grows resize_destructive destroys the previous data when the buffer grows --- src/video_core/engines/engine_upload.cpp | 4 ++-- src/video_core/engines/maxwell_dma.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/video_core/engines') diff --git a/src/video_core/engines/engine_upload.cpp b/src/video_core/engines/engine_upload.cpp index e4f8331ab..cea1dd8b0 100644 --- a/src/video_core/engines/engine_upload.cpp +++ b/src/video_core/engines/engine_upload.cpp @@ -24,7 +24,7 @@ void State::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) { void State::ProcessExec(const bool is_linear_) { write_offset = 0; copy_size = regs.line_length_in * regs.line_count; - inner_buffer.resize(copy_size); + inner_buffer.resize_destructive(copy_size); is_linear = is_linear_; } @@ -70,7 +70,7 @@ void State::ProcessData(std::span read_buffer) { const std::size_t dst_size = Tegra::Texture::CalculateSize( true, bytes_per_pixel, width, regs.dest.height, regs.dest.depth, regs.dest.BlockHeight(), regs.dest.BlockDepth()); - tmp_buffer.resize(dst_size); + tmp_buffer.resize_destructive(dst_size); memory_manager.ReadBlock(address, tmp_buffer.data(), dst_size); Tegra::Texture::SwizzleSubrect(tmp_buffer, read_buffer, bytes_per_pixel, width, regs.dest.height, regs.dest.depth, x_offset, regs.dest.y, diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index dc873732e..f73d7bf0f 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -184,8 +184,8 @@ void MaxwellDMA::CopyBlockLinearToPitch() { const size_t src_size = CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); - read_buffer.resize(src_size); - write_buffer.resize(dst_size); + read_buffer.resize_destructive(src_size); + write_buffer.resize_destructive(dst_size); memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); @@ -231,8 +231,8 @@ void MaxwellDMA::CopyPitchToBlockLinear() { CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); const size_t src_size = static_cast(regs.pitch_in) * regs.line_count; - read_buffer.resize(src_size); - write_buffer.resize(dst_size); + read_buffer.resize_destructive(src_size); + write_buffer.resize_destructive(dst_size); memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); if (Settings::IsGPULevelExtreme()) { @@ -261,8 +261,8 @@ void MaxwellDMA::FastCopyBlockLinearToPitch() { pos_x = pos_x % x_in_gob; pos_y = pos_y % 8; - read_buffer.resize(src_size); - write_buffer.resize(dst_size); + read_buffer.resize_destructive(src_size); + write_buffer.resize_destructive(dst_size); if (Settings::IsGPULevelExtreme()) { memory_manager.ReadBlock(regs.offset_in + offset, read_buffer.data(), src_size); @@ -321,10 +321,10 @@ void MaxwellDMA::CopyBlockLinearToBlockLinear() { const u32 pitch = x_elements * bytes_per_pixel; const size_t mid_buffer_size = pitch * regs.line_count; - read_buffer.resize(src_size); - write_buffer.resize(dst_size); + read_buffer.resize_destructive(src_size); + write_buffer.resize_destructive(dst_size); - intermediate_buffer.resize(mid_buffer_size); + intermediate_buffer.resize_destructive(mid_buffer_size); memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); -- cgit v1.2.3