From 26a1a4418e64df645a2c7e2b41d02d82ca711f19 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 13 Aug 2024 02:55:10 +0300 Subject: [PATCH] rsx: Fix crash when CPU blit is enabled --- rpcs3/Emu/RSX/NV47/HW/nv3089.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/NV47/HW/nv3089.cpp b/rpcs3/Emu/RSX/NV47/HW/nv3089.cpp index 4498b7e0ac..19cb43c970 100644 --- a/rpcs3/Emu/RSX/NV47/HW/nv3089.cpp +++ b/rpcs3/Emu/RSX/NV47/HW/nv3089.cpp @@ -628,10 +628,20 @@ namespace rsx } else { + // Swizzle_copy_1 prepares usable output buffer from our original source. It mostly deals with cropping and scaling the input pixels so that the final swizzle does not need to apply that. const auto swz_temp = swizzled_copy_1(dst, src, out_w, out_h, slice_h, in_format, out_format, need_convert, need_clip, interpolate); - auto pixels_src = swz_temp.empty() ? src.pixels : swz_temp.data(); + const u8* pixels_src = src.pixels; + auto src_pitch = src.pitch; - swizzled_copy_2(const_cast(pixels_src), dst.pixels, src.pitch, out_w, out_h, dst.bpp); + // NOTE: Swizzled copy routine creates temp output buffer that uses dst pitch, not source pitch. We need to account for this if using that output as intermediary buffer. + if (!swz_temp.empty()) + { + pixels_src = swz_temp.data(); + src_pitch = dst.pitch; + } + + // Swizzle_copy_2 only pads the data and encodes it as a swizzled output. Transformation (scaling, rotation, etc) is done in swizzle_copy_1 + swizzled_copy_2(const_cast(pixels_src), dst.pixels, src_pitch, out_w, out_h, dst.bpp); } if (tiled_region)