From eea68eae18ba0d7a3d6828c0920a09bd0303ac47 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 13 May 2022 00:17:38 -0400 Subject: [PATCH 1/4] command_generator: Use u8 for tap index lut Using this smaller type saves 1024 bytes in the compiled executable. --- src/audio_core/command_generator.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/audio_core/command_generator.cpp b/src/audio_core/command_generator.cpp index ae4efafb6..ff20ed00f 100644 --- a/src/audio_core/command_generator.cpp +++ b/src/audio_core/command_generator.cpp @@ -129,17 +129,17 @@ s32 ToS32(float sample) { return static_cast(rescaled_sample); } -constexpr std::array REVERB_TAP_INDEX_1CH{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +constexpr std::array REVERB_TAP_INDEX_1CH{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -constexpr std::array REVERB_TAP_INDEX_2CH{0, 0, 0, 1, 1, 1, 1, 0, 0, 0, - 1, 1, 1, 0, 0, 0, 0, 1, 1, 1}; +constexpr std::array REVERB_TAP_INDEX_2CH{0, 0, 0, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 1, 1, 1}; -constexpr std::array REVERB_TAP_INDEX_4CH{0, 0, 0, 1, 1, 1, 1, 2, 2, 2, - 1, 1, 1, 0, 0, 0, 0, 3, 3, 3}; +constexpr std::array REVERB_TAP_INDEX_4CH{0, 0, 0, 1, 1, 1, 1, 2, 2, 2, + 1, 1, 1, 0, 0, 0, 0, 3, 3, 3}; -constexpr std::array REVERB_TAP_INDEX_6CH{4, 0, 0, 1, 1, 1, 1, 2, 2, 2, - 1, 1, 1, 0, 0, 0, 0, 3, 3, 3}; +constexpr std::array REVERB_TAP_INDEX_6CH{4, 0, 0, 1, 1, 1, 1, 2, 2, 2, + 1, 1, 1, 0, 0, 0, 0, 3, 3, 3}; template void ApplyReverbGeneric( From b3f8c7ce58cf3fa47be881e1dabea996657b8b76 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 13 May 2022 00:23:41 -0400 Subject: [PATCH 2/4] codecs/vp9: Use u8 for norm and map luts Using this smaller type saves 1536 bytes in the compiled executable. --- src/video_core/command_classes/codecs/vp9.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video_core/command_classes/codecs/vp9.cpp b/src/video_core/command_classes/codecs/vp9.cpp index a95618913..c01431441 100644 --- a/src/video_core/command_classes/codecs/vp9.cpp +++ b/src/video_core/command_classes/codecs/vp9.cpp @@ -153,7 +153,7 @@ constexpr Vp9EntropyProbs default_probs{ .high_precision{128, 128}, }; -constexpr std::array norm_lut{ +constexpr std::array norm_lut{ 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -164,7 +164,7 @@ constexpr std::array norm_lut{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -constexpr std::array map_lut{ +constexpr std::array map_lut{ 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 2, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 3, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, @@ -232,7 +232,7 @@ constexpr std::array map_lut{ std::max(0, RecenterNonNeg(0xff - 1 - new_prob, 0xff - 1 - old_prob) - 1)); } - return map_lut[index]; + return static_cast(map_lut[index]); } } // Anonymous namespace @@ -819,7 +819,7 @@ void VpxRangeEncoder::Write(bool bit, s32 probability) { local_range = range - split; } - s32 shift = norm_lut[local_range]; + s32 shift = static_cast(norm_lut[local_range]); local_range <<= shift; count += shift; From 370d3fa1e3114662a6e28e41b3d0a412d860d1a3 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 13 May 2022 00:40:12 -0400 Subject: [PATCH 3/4] video_core/surface: Use u8 for PixelFormat block tables Using this smaller type saves 33280 bytes in the compiled executable. --- src/video_core/surface.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video_core/surface.h b/src/video_core/surface.h index 86fea61ae..75e055592 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h @@ -147,7 +147,7 @@ enum class SurfaceTarget { TextureCubeArray, }; -constexpr std::array BLOCK_WIDTH_TABLE = {{ +constexpr std::array BLOCK_WIDTH_TABLE = {{ 1, // A8B8G8R8_UNORM 1, // A8B8G8R8_SNORM 1, // A8B8G8R8_SINT @@ -249,7 +249,7 @@ constexpr u32 DefaultBlockWidth(PixelFormat format) { return BLOCK_WIDTH_TABLE[static_cast(format)]; } -constexpr std::array BLOCK_HEIGHT_TABLE = {{ +constexpr std::array BLOCK_HEIGHT_TABLE = {{ 1, // A8B8G8R8_UNORM 1, // A8B8G8R8_SNORM 1, // A8B8G8R8_SINT @@ -351,7 +351,7 @@ constexpr u32 DefaultBlockHeight(PixelFormat format) { return BLOCK_HEIGHT_TABLE[static_cast(format)]; } -constexpr std::array BITS_PER_BLOCK_TABLE = {{ +constexpr std::array BITS_PER_BLOCK_TABLE = {{ 32, // A8B8G8R8_UNORM 32, // A8B8G8R8_SNORM 32, // A8B8G8R8_SINT From 36d44bf52f598d31d94343c238ad45d21b63c390 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 13 May 2022 00:50:40 -0400 Subject: [PATCH 4/4] time_zone_manager: Use s8 for month length tables Using this smaller type saves 512 bytes in the compiled executable. --- src/core/hle/service/time/time_zone_manager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp index 449a5ac96..eeec34436 100644 --- a/src/core/hle/service/time/time_zone_manager.cpp +++ b/src/core/hle/service/time/time_zone_manager.cpp @@ -110,10 +110,9 @@ static constexpr s64 GetLeapDaysFromYear(s64 year) { } } -static constexpr int GetMonthLength(bool is_leap_year, int month) { - constexpr std::array month_lengths{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - constexpr std::array month_lengths_leap{31, 29, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31}; +static constexpr s8 GetMonthLength(bool is_leap_year, int month) { + constexpr std::array month_lengths{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + constexpr std::array month_lengths_leap{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; return is_leap_year ? month_lengths_leap[month] : month_lengths[month]; }