mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
GS Hotkeys: Improve upscale and downscale hotkeys
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run
This commit is contained in:
parent
e379c8317d
commit
babb985e9e
@ -185,8 +185,8 @@ static void GSClampUpscaleMultiplier(Pcsx2Config::GSOptions& config)
|
|||||||
if (config.UpscaleMultiplier <= static_cast<float>(max_upscale_multiplier))
|
if (config.UpscaleMultiplier <= static_cast<float>(max_upscale_multiplier))
|
||||||
{
|
{
|
||||||
// Shouldn't happen, but just in case.
|
// Shouldn't happen, but just in case.
|
||||||
if (config.UpscaleMultiplier < 1.0f)
|
if (config.UpscaleMultiplier < 0.0f)
|
||||||
config.UpscaleMultiplier = 1.0f;
|
config.UpscaleMultiplier = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1067,15 +1067,52 @@ std::pair<u8, u8> GSGetRGBA8AlphaMinMax(const void* data, u32 width, u32 height,
|
|||||||
static_cast<u8>(maxc.maxv_u32() >> 24));
|
static_cast<u8>(maxc.maxv_u32() >> 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HotkeyAdjustUpscaleMultiplier(s32 delta)
|
static void HotkeyAdjustUpscaleMultiplier(const float delta)
|
||||||
{
|
{
|
||||||
const u32 new_multiplier = static_cast<u32>(std::clamp(static_cast<s32>(EmuConfig.GS.UpscaleMultiplier) + delta, 1, 8));
|
if (!g_gs_renderer)
|
||||||
Host::AddKeyedOSDMessage("UpscaleMultiplierChanged",
|
return;
|
||||||
fmt::format(TRANSLATE_FS("GS", "Upscale multiplier set to {}x."), new_multiplier), Host::OSD_QUICK_DURATION);
|
|
||||||
EmuConfig.GS.UpscaleMultiplier = new_multiplier;
|
|
||||||
|
|
||||||
// this is pretty slow. we only really need to flush the TC and recompile shaders.
|
if (GSCurrentRenderer == GSRendererType::SW || GSCurrentRenderer == GSRendererType::Null)
|
||||||
|
{
|
||||||
|
Host::AddIconOSDMessage("UpscaleMultiplierChanged", ICON_FA_ARROW_UP_RIGHT_FROM_SQUARE,
|
||||||
|
TRANSLATE_STR("GS", "Upscaling can only be changed while using the Hardware Renderer."), Host::OSD_QUICK_DURATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clamp logic mirrors GraphicsSettingsWidget::populateUpscaleMultipliers().
|
||||||
|
float candidate_multiplier = EmuConfig.GS.UpscaleMultiplier + delta;
|
||||||
|
const float max_multiplier = static_cast<float>(std::clamp(GSGetMaxUpscaleMultiplier(g_gs_device->GetMaxTextureSize()),
|
||||||
|
10u, EmuConfig.GS.ExtendedUpscalingMultipliers ? 25u : 12u));
|
||||||
|
|
||||||
|
std::string osd_message;
|
||||||
|
if (candidate_multiplier <= 1)
|
||||||
|
{
|
||||||
|
candidate_multiplier = 1;
|
||||||
|
osd_message = TRANSLATE_STR("GS", "Upscale multiplier set to native resolution.");
|
||||||
|
}
|
||||||
|
else if (candidate_multiplier >= max_multiplier)
|
||||||
|
{
|
||||||
|
candidate_multiplier = max_multiplier;
|
||||||
|
osd_message = fmt::format(TRANSLATE_FS("GS", "Upscale multiplier maximized to {}x."), max_multiplier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
osd_message = fmt::format(TRANSLATE_FS("GS", "Upscale multiplier {} to {}x."),
|
||||||
|
delta > 0 ? TRANSLATE_STR("GS", "increased") : TRANSLATE_STR("GS", "decreased"), candidate_multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to calculate our own target resolution. Reading after applying settings is a race condition.
|
||||||
|
const GSVector2i base_resolution = g_gs_renderer ? g_gs_renderer->PCRTCDisplays.GetResolution() : GSVector2i(0, 0);
|
||||||
|
const int target_iwidth = static_cast<int>(std::round(static_cast<float>(base_resolution.x) * candidate_multiplier));
|
||||||
|
const int target_iheight = static_cast<int>(std::round(static_cast<float>(base_resolution.y) * candidate_multiplier));
|
||||||
|
|
||||||
|
//: Leftmost value is an OSD message about the upscale multiplier. Values in parentheses are a resolution width (left) and height (right).
|
||||||
|
Host::AddIconOSDMessage("UpscaleMultiplierChanged", ICON_FA_ARROW_UP_RIGHT_FROM_SQUARE,
|
||||||
|
fmt::format(TRANSLATE_FS("GS", "{} ({} x {})"), osd_message, target_iwidth, target_iheight), Host::OSD_QUICK_DURATION);
|
||||||
|
|
||||||
|
// This is pretty slow. We only really need to flush the TC and recompile shaders.
|
||||||
// TODO(Stenzek): Make it faster at some point in the future.
|
// TODO(Stenzek): Make it faster at some point in the future.
|
||||||
|
EmuConfig.GS.UpscaleMultiplier = candidate_multiplier;
|
||||||
MTGS::ApplySettings();
|
MTGS::ApplySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,13 +1184,13 @@ BEGIN_HOTKEY_LIST(g_gs_hotkeys){"Screenshot", TRANSLATE_NOOP("Hotkeys", "Graphic
|
|||||||
TRANSLATE_NOOP("Hotkeys", "Increase Upscale Multiplier"),
|
TRANSLATE_NOOP("Hotkeys", "Increase Upscale Multiplier"),
|
||||||
[](s32 pressed) {
|
[](s32 pressed) {
|
||||||
if (!pressed)
|
if (!pressed)
|
||||||
HotkeyAdjustUpscaleMultiplier(1);
|
HotkeyAdjustUpscaleMultiplier(1.0f);
|
||||||
}},
|
}},
|
||||||
{"DecreaseUpscaleMultiplier", TRANSLATE_NOOP("Hotkeys", "Graphics"),
|
{"DecreaseUpscaleMultiplier", TRANSLATE_NOOP("Hotkeys", "Graphics"),
|
||||||
TRANSLATE_NOOP("Hotkeys", "Decrease Upscale Multiplier"),
|
TRANSLATE_NOOP("Hotkeys", "Decrease Upscale Multiplier"),
|
||||||
[](s32 pressed) {
|
[](s32 pressed) {
|
||||||
if (!pressed)
|
if (!pressed)
|
||||||
HotkeyAdjustUpscaleMultiplier(-1);
|
HotkeyAdjustUpscaleMultiplier(-1.0f);
|
||||||
}},
|
}},
|
||||||
{"ToggleOSD", TRANSLATE_NOOP("Hotkeys", "Graphics"), TRANSLATE_NOOP("Hotkeys", "Toggle On-Screen Display"),
|
{"ToggleOSD", TRANSLATE_NOOP("Hotkeys", "Graphics"), TRANSLATE_NOOP("Hotkeys", "Toggle On-Screen Display"),
|
||||||
[](s32 pressed) {
|
[](s32 pressed) {
|
||||||
|
|||||||
@ -54,7 +54,7 @@ namespace MTGS
|
|||||||
/// the current frame with the correct proportions. Should only be called from the CPU thread.
|
/// the current frame with the correct proportions. Should only be called from the CPU thread.
|
||||||
void PresentCurrentFrame();
|
void PresentCurrentFrame();
|
||||||
|
|
||||||
// Waits for the GS to empty out the entire ring buffer contents.
|
/// Waits for the GS to empty out the entire ring buffer contents.
|
||||||
void WaitGS(bool syncRegs = true, bool weakWait = false, bool isMTVU = false);
|
void WaitGS(bool syncRegs = true, bool weakWait = false, bool isMTVU = false);
|
||||||
void ResetGS(bool hardware_reset);
|
void ResetGS(bool hardware_reset);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user