From 0dfcdb1d34532e1ddcb8caf90fdb67d8eec4f312 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Sun, 23 Jun 2019 03:12:15 +0200 Subject: [PATCH] Add x6 texture scaling. --- GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/Common/TextureScalerCommon.cpp | 37 ++++++++++++++++++------------ UI/GameSettingsScreen.cpp | 2 +- Windows/MainWindow.h | 3 ++- Windows/MainWindowMenu.cpp | 4 +++- Windows/ppsspp.rc | 1 + Windows/resource.h | 1 + 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 6d62d475d6..8f04fc4db2 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -969,7 +969,7 @@ void TextureCacheCommon::NotifyConfigChanged() { } } - scaleFactor = std::min(5, scaleFactor); + scaleFactor = std::min(6, scaleFactor); } else { scaleFactor = g_Config.iTexScalingLevel; } diff --git a/GPU/Common/TextureScalerCommon.cpp b/GPU/Common/TextureScalerCommon.cpp index 9ea91f1cce..1adb605d35 100644 --- a/GPU/Common/TextureScalerCommon.cpp +++ b/GPU/Common/TextureScalerCommon.cpp @@ -214,18 +214,18 @@ inline float mitchell(float x, float B, float C) { // arrays for pre-calculating weights and sums (~20KB) // Dimensions: // 0: 0 = BSpline, 1 = mitchell -// 2: 2-5x scaling -// 2,3: 5x5 generated pixels -// 4,5: 5x5 pixels sampled from -float bicubicWeights[2][4][5][5][5][5]; -float bicubicInvSums[2][4][5][5]; +// 1: 2-6x scaling +// 2,3: 6x6 generated pixels +// 4,5: 6x6 pixels sampled from +float bicubicWeights[2][5][6][6][6][6]; +float bicubicInvSums[2][5][6][6]; // initialize pre-computed weights array void initBicubicWeights() { float B[2] = { 1.0f, 0.334f }; float C[2] = { 0.0f, 0.334f }; for (int type = 0; type < 2; ++type) { - for (int factor = 2; factor <= 5; ++factor) { + for (int factor = 2; factor <= 6; ++factor) { for (int x = 0; x < factor; ++x) { for (int y = 0; y < factor; ++y) { float sum = 0.0f; @@ -332,7 +332,8 @@ void scaleBicubicBSpline(int factor, u32* data, u32* out, int w, int h, int l, i case 3: scaleBicubicTSSE41<3, 0>(data, out, w, h, l, u); break; // it was even slower than I had expected case 4: scaleBicubicTSSE41<4, 0>(data, out, w, h, l, u); break; // turns out I had not included case 5: scaleBicubicTSSE41<5, 0>(data, out, w, h, l, u); break; // any of these break statements - default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 5"); + case 6: scaleBicubicTSSE41<6, 0>(data, out, w, h, l, u); break; // any of these break statements + default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 6"); } } else { #endif @@ -341,7 +342,8 @@ void scaleBicubicBSpline(int factor, u32* data, u32* out, int w, int h, int l, i case 3: scaleBicubicT<3, 0>(data, out, w, h, l, u); break; // it was even slower than I had expected case 4: scaleBicubicT<4, 0>(data, out, w, h, l, u); break; // turns out I had not included case 5: scaleBicubicT<5, 0>(data, out, w, h, l, u); break; // any of these break statements - default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 5"); + case 6: scaleBicubicT<6, 0>(data, out, w, h, l, u); break; // any of these break statements + default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 6"); } #if _M_SSE >= 0x401 } @@ -356,7 +358,8 @@ void scaleBicubicMitchell(int factor, u32* data, u32* out, int w, int h, int l, case 3: scaleBicubicTSSE41<3, 1>(data, out, w, h, l, u); break; case 4: scaleBicubicTSSE41<4, 1>(data, out, w, h, l, u); break; case 5: scaleBicubicTSSE41<5, 1>(data, out, w, h, l, u); break; - default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 5"); + case 6: scaleBicubicTSSE41<6, 1>(data, out, w, h, l, u); break; + default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 6"); } } else { #endif @@ -365,7 +368,8 @@ void scaleBicubicMitchell(int factor, u32* data, u32* out, int w, int h, int l, case 3: scaleBicubicT<3, 1>(data, out, w, h, l, u); break; case 4: scaleBicubicT<4, 1>(data, out, w, h, l, u); break; case 5: scaleBicubicT<5, 1>(data, out, w, h, l, u); break; - default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 5"); + case 6: scaleBicubicT<6, 1>(data, out, w, h, l, u); break; + default: ERROR_LOG(G3D, "Bicubic upsampling only implemented for factors 2 to 6"); } #if _M_SSE >= 0x401 } @@ -374,16 +378,17 @@ void scaleBicubicMitchell(int factor, u32* data, u32* out, int w, int h, int l, //////////////////////////////////////////////////////////////////// Bilinear scaling -const static u8 BILINEAR_FACTORS[4][3][2] = { +const static u8 BILINEAR_FACTORS[5][3][2] = { { { 44, 211 }, { 0, 0 }, { 0, 0 } }, // x2 { { 64, 191 }, { 0, 255 }, { 0, 0 } }, // x3 { { 77, 178 }, { 26, 229 }, { 0, 0 } }, // x4 { { 102, 153 }, { 51, 204 }, { 0, 255 } }, // x5 + { { 126, 129 }, { 74, 181 }, { 26, 229 } }, // x6 }; // integral bilinear upscaling by factor f, horizontal part template void bilinearHt(u32* data, u32* out, int w, int l, int u) { - static_assert(f > 1 && f <= 5, "Bilinear scaling only implemented for factors 2 to 5"); + static_assert(f > 1 && f <= 6, "Bilinear scaling only implemented for factors 2 to 6"); int outw = w*f; for (int y = l; y < u; ++y) { for (int x = 0; x < w; ++x) { @@ -407,14 +412,15 @@ void bilinearH(int factor, u32* data, u32* out, int w, int l, int u) { case 3: bilinearHt<3>(data, out, w, l, u); break; case 4: bilinearHt<4>(data, out, w, l, u); break; case 5: bilinearHt<5>(data, out, w, l, u); break; - default: ERROR_LOG(G3D, "Bilinear upsampling only implemented for factors 2 to 5"); + case 6: bilinearHt<6>(data, out, w, l, u); break; + default: ERROR_LOG(G3D, "Bilinear upsampling only implemented for factors 2 to 6"); } } // integral bilinear upscaling by factor f, vertical part // gl/gu == global lower and upper bound template void bilinearVt(u32* data, u32* out, int w, int gl, int gu, int l, int u) { - static_assert(f>1 && f <= 5, "Bilinear scaling only implemented for 2x, 3x, 4x, and 5x"); + static_assert(f>1 && f <= 6, "Bilinear scaling only implemented for 2x, 3x, 4x, 5x and 6x"); int outw = w*f; for (int xb = 0; xb < outw / BLOCK_SIZE + 1; ++xb) { for (int y = l; y < u; ++y) { @@ -441,7 +447,8 @@ void bilinearV(int factor, u32* data, u32* out, int w, int gl, int gu, int l, in case 3: bilinearVt<3>(data, out, w, gl, gu, l, u); break; case 4: bilinearVt<4>(data, out, w, gl, gu, l, u); break; case 5: bilinearVt<5>(data, out, w, gl, gu, l, u); break; - default: ERROR_LOG(G3D, "Bilinear upsampling only implemented for factors 2 to 5"); + case 6: bilinearVt<6>(data, out, w, gl, gu, l, u); break; + default: ERROR_LOG(G3D, "Bilinear upsampling only implemented for factors 2 to 6"); } } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 022d7f7106..79a3c86ea4 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -418,7 +418,7 @@ void GameSettingsScreen::CreateViews() { // graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gr->T("FXAA"))); graphicsSettings->Add(new ItemHeader(gr->T("Texture Scaling"))); #ifndef MOBILE_DEVICE - static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x", "4x", "5x"}; + static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x", "4x", "5x", "6x"}; #else static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x"}; #endif diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index ec90100a68..a79770cbb3 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -56,7 +56,8 @@ namespace MainWindow TEXSCALING_3X = 3, TEXSCALING_4X = 4, TEXSCALING_5X = 5, - TEXSCALING_MAX = TEXSCALING_5X, + TEXSCALING_6X = 6, + TEXSCALING_MAX = TEXSCALING_6X, }; void Init(HINSTANCE hInstance); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 3c7e8c4718..98135a0c5f 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -797,7 +797,8 @@ namespace MainWindow { case ID_TEXTURESCALING_2X: setTexScalingMultiplier(TEXSCALING_2X); break; case ID_TEXTURESCALING_3X: setTexScalingMultiplier(TEXSCALING_3X); break; case ID_TEXTURESCALING_4X: setTexScalingMultiplier(TEXSCALING_4X); break; - case ID_TEXTURESCALING_5X: setTexScalingMultiplier(TEXSCALING_MAX); break; + case ID_TEXTURESCALING_5X: setTexScalingMultiplier(TEXSCALING_5X); break; + case ID_TEXTURESCALING_6X: setTexScalingMultiplier(TEXSCALING_MAX); break; case ID_TEXTURESCALING_XBRZ: setTexScalingType(TextureScalerCommon::XBRZ); break; case ID_TEXTURESCALING_HYBRID: setTexScalingType(TextureScalerCommon::HYBRID); break; @@ -1232,6 +1233,7 @@ namespace MainWindow { ID_TEXTURESCALING_3X, ID_TEXTURESCALING_4X, ID_TEXTURESCALING_5X, + ID_TEXTURESCALING_6X, }; if (g_Config.iTexScalingLevel < TEXSCALING_AUTO) g_Config.iTexScalingLevel = TEXSCALING_AUTO; diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index f7c229702e..d3fa28fbf6 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -630,6 +630,7 @@ BEGIN MENUITEM "&3x", ID_TEXTURESCALING_3X MENUITEM "&4x", ID_TEXTURESCALING_4X MENUITEM "&5x", ID_TEXTURESCALING_5X + MENUITEM "&6x", ID_TEXTURESCALING_6X MENUITEM "", 0, MFT_SEPARATOR MENUITEM "xBRZ", ID_TEXTURESCALING_XBRZ MENUITEM "Hybrid", ID_TEXTURESCALING_HYBRID diff --git a/Windows/resource.h b/Windows/resource.h index d77f685b94..f1e05b95d8 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -383,6 +383,7 @@ // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 +#define ID_TEXTURESCALING_6X 40400 #define IDC_STEPOUT 40501 #define IDC_STATIC -1