From d0013679c09b2e5a36e9ac7b56d785e54b278c0f Mon Sep 17 00:00:00 2001 From: Jake Date: Thu, 7 Dec 2017 01:31:18 -0600 Subject: [PATCH] rsx: fix image_in swizzled texture crash --- rpcs3/Emu/RSX/rsx_methods.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 5a8be5090a..d1bf8850a1 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -837,21 +837,25 @@ namespace rsx u8* linear_pixels = pixels_src; u8* swizzled_pixels = temp2.get(); + // restrict output to size of swizzle + const u16 sw_in_w = std::min(out_w, sw_width); + const u16 sw_in_h = std::min(out_h, sw_height); + // Check and pad texture out if we are given non square texture for swizzle to be correct - if (sw_width != out_w || sw_height != out_h) + if (sw_width != sw_in_w || sw_height != sw_in_h) { sw_temp.reset(new u8[out_bpp * sw_width * sw_height]); switch (out_bpp) { case 1: - pad_texture(linear_pixels, sw_temp.get(), out_w, out_h, sw_width, sw_height); + pad_texture(linear_pixels, sw_temp.get(), sw_in_w, sw_in_h, sw_width, sw_height); break; case 2: - pad_texture(linear_pixels, sw_temp.get(), out_w, out_h, sw_width, sw_height); + pad_texture(linear_pixels, sw_temp.get(), sw_in_w, sw_in_h, sw_width, sw_height); break; case 4: - pad_texture(linear_pixels, sw_temp.get(), out_w, out_h, sw_width, sw_height); + pad_texture(linear_pixels, sw_temp.get(), sw_in_w, sw_in_h, sw_width, sw_height); break; }