From f2d6b52561ced66199017418911357c2db2d4dc5 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 1 Jun 2021 20:28:49 +0300 Subject: [PATCH] Fix span copy after refactoring - Add range check at fast path. - Fix typo in element by element copying. Should fix #10385 --- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 8643eb9795..505bb8dedc 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -36,7 +36,7 @@ struct copy_unmodified_block { // Fast copy const auto data_length = src_pitch_in_block * words_per_block * row_count * depth; - std::copy_n(src.begin(), data_length, dst.begin()); + std::copy_n(src.begin(), std::min({data_length, src.size(), dst.size()}), dst.begin()); return; } @@ -55,7 +55,7 @@ struct copy_unmodified_block for (int row = 0; row < row_count; ++row) { - // NNOTE: src_offset is already shifted along the border at initialization + // NOTE: src_offset is already shifted along the border at initialization std::copy_n(src.begin() + src_offset, width_in_words, dst.begin() + dst_offset); src_offset += src_pitch_in_words; @@ -151,7 +151,7 @@ struct copy_unmodified_block_vtc for (u32 i = 0; i < row_element_count; i += 1) { // Copy one span (8 bytes for DXT1 or 16 bytes for DXT5) - dst[dst_offset + i] = src[src_offset + i]; + dst[dst_offset + i] = src[src_offset + i * 4]; } dst_offset += row_element_count;