diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index 6c05abd4..da96bc0c 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -1306,6 +1306,7 @@ static void BeginCommandList() g_pipelineState.renderTargetFormat = g_backBuffer->format; g_pipelineState.depthStencilFormat = RenderFormat::UNKNOWN; + g_swapChain->setVsyncEnabled(Config::VSync); g_swapChainValid &= !g_swapChain->needsResize(); if (!g_swapChainValid) @@ -3746,8 +3747,8 @@ void SetShadowResolutionMidAsmHook(PPCRegister& r11) static void SetResolution(be* device) { - uint32_t width = uint32_t(g_swapChain->getWidth() * Config::ResolutionScale); - uint32_t height = uint32_t(g_swapChain->getHeight() * Config::ResolutionScale); + uint32_t width = uint32_t(round(g_swapChain->getWidth() * Config::ResolutionScale)); + uint32_t height = uint32_t(round(g_swapChain->getHeight() * Config::ResolutionScale)); device[46] = width == 0 ? 880 : width; device[47] = height == 0 ? 720 : height; } @@ -3891,6 +3892,15 @@ void ParticleTestDrawIndexedPrimitiveMidAsmHook(PPCRegister& r7) r7.u64 = std::size(g_particleTestIndexBuffer); } +void VideoConfigValueChangedCallback(IConfigDef* config) +{ + // Config options that require internal resolution resize + g_needsResize |= + config == &Config::ResolutionScale || + config == &Config::AntiAliasing || + config == &Config::ShadowResolution; +} + GUEST_FUNCTION_HOOK(sub_82BD99B0, CreateDevice); GUEST_FUNCTION_HOOK(sub_82BE6230, DestructResource); diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 5072fafc..d7d1095a 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -371,6 +371,9 @@ static void DrawCategories() drawList->PushClipRect({ clipRectMin.x, clipRectMin.y + gridSize * 6.0f }, { clipRectMax.x - gridSize, clipRectMax.y - gridSize }); } +// extern definition to avoid including "video.h", the header is quite large +extern void VideoConfigValueChangedCallback(IConfigDef* config); + template static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* config, T valueMin = T(0), T valueCenter = T(0.5), T valueMax = T(1)) { @@ -417,6 +420,8 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf if (config->Callback) config->Callback(config); + + VideoConfigValueChangedCallback(config); } } else @@ -433,6 +438,12 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf // remember value s_oldValue = config->Value; } + else + { + // released lock, call video callbacks if value is different + if (config->Value != s_oldValue) + VideoConfigValueChangedCallback(config); + } } else if (padState.IsTapped(SWA::eKeyState_B)) {