Skip to content

Commit

Permalink
Add an option for experimental hardware texture scaling(Vulkan) and s…
Browse files Browse the repository at this point in the history
…olve issues:

- realtime scaling enabled disabling scaling in other backends,
- discord presence setting not saving correctly.
  • Loading branch information
LunaMoo committed Oct 8, 2019
1 parent 8565e44 commit a488fe1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static ConfigSetting generalSettings[] = {
ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, false),
ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion),
ConfigSetting("ForceLagSync2", &g_Config.bForceLagSync, false, true, true),
ConfigSetting("DiscordPresence", &g_Config.bDiscordPresence, false, false, false), // Or maybe it makes sense to have it per-game? Race conditions abound...
ConfigSetting("DiscordPresence", &g_Config.bDiscordPresence, false, true, false), // Or maybe it makes sense to have it per-game? Race conditions abound...

ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers, true, true),
ConfigSetting("AutoLoadSaveState", &g_Config.iAutoLoadSaveState, 0, true, true),
Expand Down
6 changes: 4 additions & 2 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sCl
}
}
// addr is set to nullptr for framebuffers
if (addr && g_Config.bRealtimeTexScaling && g_Config.iTexScalingLevel != 1) {
if (addr && (g_Config.bRealtimeTexScaling && g_Config.iGPUBackend == (int)GPUBackend::DIRECT3D11) && g_Config.iTexScalingLevel != 1) {
forceNearest = true;
}
if (forceNearest) {
Expand Down Expand Up @@ -954,8 +954,10 @@ bool TextureCacheCommon::SetOffsetTexture(u32 offset) {
void TextureCacheCommon::NotifyConfigChanged() {
int scaleFactor;

if (g_Config.bRealtimeTexScaling) {
if (g_Config.bRealtimeTexScaling && g_Config.iGPUBackend == (int)GPUBackend::DIRECT3D11) {
scaleFactor = 1;
} else if (g_Config.bTexHardwareScaling && g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
scaleFactor = 4;
} else {
// 0 means automatic texture scaling, up to 5x, based on resolution.
if (g_Config.iTexScalingLevel == 0) {
Expand Down
24 changes: 23 additions & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,17 @@ void GameSettingsScreen::CreateViews() {
return UI::EVENT_CONTINUE;
});
texScalingChoice->SetDisabledPtr(&g_Config.bSoftwareRendering);
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
texScalingChoice->SetDisabledPtr(&g_Config.bTexHardwareScaling);
}

if (!g_Config.bSimpleUI) {
static const char *texScaleAlgos[] = { "xBRZ", "Hybrid", "Bicubic", "Hybrid + Bicubic", "4xBRZ (Realtime Scaling)", "xBR (Realtime Scaling)", "SABR (Realtime Scaling)", "Gaussian (Realtime Scaling)", "Cosine (Realtime Scaling)" };
PopupMultiChoice *texScalingType = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingType, gr->T("Upscale Type"), texScaleAlgos, 0, ARRAY_SIZE(texScaleAlgos), gr->GetName(), screenManager()));
texScalingType->SetDisabledPtr(&g_Config.bSoftwareRendering);
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
texScalingType->SetDisabledPtr(&g_Config.bTexHardwareScaling);
}

CheckBox *deposterize = graphicsSettings->Add(new CheckBox(&g_Config.bTexDeposterize, gr->T("Deposterize")));
deposterize->OnClick.Add([=](EventParams &e) {
Expand All @@ -458,6 +464,19 @@ void GameSettingsScreen::CreateViews() {
Choice *realtimeScaling = graphicsSettings->Add(new Choice(gr->T("Realtime Scaling requires D3D11 backend!")));
realtimeScaling->SetEnabled(false);
}
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
CheckBox* hardware4xBRZScaling = graphicsSettings->Add(new CheckBox(&g_Config.bTexHardwareScaling, gr->T("Hardware 4xBRZ Scaling(experimental)")));
hardware4xBRZScaling->OnClick.Add([=](EventParams& e) {
if (g_Config.bTexHardwareScaling == true) {
settingInfo_->Show(gr->T("Hardware 4xBRZ Scaling Tip", "Apply 4xBRZ texture scaling filter with compute shader"), e.v);
}
return UI::EVENT_CONTINUE;
});
hardware4xBRZScaling->SetDisabledPtr(&g_Config.bSoftwareRendering);
} else {
Choice* hardware4xBRZScaling = graphicsSettings->Add(new Choice(gr->T("Hardware 4xBRZ Scaling(experimental) requires Vulkan backend!")));
hardware4xBRZScaling->SetEnabled(false);
}
graphicsSettings->Add(new ItemHeader(gr->T("Texture Filtering")));
static const char *anisoLevels[] = { "Off", "2x", "4x", "8x", "16x" };
PopupMultiChoice *anisoFiltering = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAnisotropyLevel, gr->T("Anisotropic Filtering"), anisoLevels, 0, ARRAY_SIZE(anisoLevels), gr->GetName(), screenManager()));
Expand Down Expand Up @@ -1464,9 +1483,12 @@ void OtherSettingsScreen::CreateViews() {
list->Add(new CheckBox(&g_Config.bFrameSkipUnthrottle, gr->T("Frameskip unthrottle(good for CPU benchmark)")));
list->Add(new CheckBox(&g_Config.bShowFrameProfiler, gr->T("Display frame profiler(heavy!)")));
list->Add(new CheckBox(&g_Config.bSimpleFrameStats, gr->T("Display simple frame stats(heavy!)")));
list->Add(new CheckBox(&g_Config.bFullscreenOnDoubleclick, gr->T("Doubleclick fullscreen(only when no mouse or touch control is used)")));
list->Add(new CheckBox(&g_Config.bHideSlowWarnings, gr->T("Hide performance warnings")));
list->Add(new CheckBox(&g_Config.bSavestateScreenshotResLimit, gr->T("Limit resolution of savestates screenshots")));
list->Add(new CheckBox(&g_Config.bEnableStateUndo, gr->T("Backup existing state on save")));
list->Add(new CheckBox(&g_Config.bDiscordPresence, n->T("Send Discord(3rd party software) Presence information")));
list->Add(new CheckBox(&g_Config.bUnlockCachedScaling, n->T("Disable texture scaling limiters. Only for testing, this WILL cause stutter even at max FPS! Strongly recommend real time scaling instead!)")));
list->Add(new CheckBox(&g_Config.bUnlockCachedScaling, n->T("Disable texture scaling limiters. Only for testing, this WILL cause stutter even at max FPS! Strongly recommend real time(D3D11) or hardware(Vulkan) scaling instead!")));
#if defined(USING_WIN_UI)
list->Add(new CheckBox(&g_Config.bDisableWinMenu, n->T("Disable Windows menu bar")))->OnClick.Handle(this, &OtherSettingsScreen::OnDisableWinBorders);
list->Add(new CheckBox(&g_Config.bDisableWinBorders, n->T("Disable Windows borders")))->OnClick.Handle(this, &OtherSettingsScreen::OnDisableWinBorders);
Expand Down

0 comments on commit a488fe1

Please sign in to comment.