From 69e9ee26f67a2d18501fcc20dccc892e5466e0d1 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 27 Oct 2019 22:55:19 +0100 Subject: [PATCH] rsx: Make input_is_swizzled a template parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This lowers the relative cost of this function from ~2.25% to ~1.80% on gcc 9 which I found quite surprising, some of it probably gets inlined better in the callers, but I haven’t been able to isolate which parts. --- rpcs3/Emu/RSX/rsx_methods.cpp | 6 +++--- rpcs3/Emu/RSX/rsx_utils.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 0504c666a7..3f9f326b29 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -1263,13 +1263,13 @@ namespace rsx switch (out_bpp) { case 1: - convert_linear_swizzle(linear_pixels, swizzled_pixels, sw_width, sw_height, in_pitch, false); + convert_linear_swizzle(linear_pixels, swizzled_pixels, sw_width, sw_height, in_pitch); break; case 2: - convert_linear_swizzle(linear_pixels, swizzled_pixels, sw_width, sw_height, in_pitch, false); + convert_linear_swizzle(linear_pixels, swizzled_pixels, sw_width, sw_height, in_pitch); break; case 4: - convert_linear_swizzle(linear_pixels, swizzled_pixels, sw_width, sw_height, in_pitch, false); + convert_linear_swizzle(linear_pixels, swizzled_pixels, sw_width, sw_height, in_pitch); break; } } diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 79d88c912c..8e20f1666a 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -330,8 +330,8 @@ namespace rsx * Restriction: It has mixed results if the height or width is not a power of 2 * Restriction: Only works with 2D surfaces */ - template - void convert_linear_swizzle(void* input_pixels, void* output_pixels, u16 width, u16 height, u32 pitch, bool input_is_swizzled) + template + void convert_linear_swizzle(void* input_pixels, void* output_pixels, u16 width, u16 height, u32 pitch) { u32 log2width = ceil_log2(width); u32 log2height = ceil_log2(height); @@ -357,7 +357,7 @@ namespace rsx u32 adv = pitch / sizeof(T); - if (!input_is_swizzled) + if constexpr (!input_is_swizzled) { for (int y = 0; y < height; ++y) { @@ -414,7 +414,7 @@ namespace rsx { if (depth == 1) { - convert_linear_swizzle(input_pixels, output_pixels, width, height, width * sizeof(T), true); + convert_linear_swizzle(input_pixels, output_pixels, width, height, width * sizeof(T)); return; }