Compare commits

..

2 commits

Author SHA1 Message Date
23f5a22b2c
game: Use utility for scale state 2025-07-06 15:37:19 +02:00
8b3784d956
config: Fix mismatched tooltips 2025-07-06 15:36:49 +02:00
2 changed files with 37 additions and 32 deletions

View file

@ -257,7 +257,7 @@ RR {dev->RequestRender} 0x{(long) dev->ImmediateContext->IfNonZeroSkipPostTickPr
CurrentHeight = rtm->Resolution_Height;
}
private void GetScaledWidthHeight(uint width, uint height, float scale, out uint widthS, out uint heightS)
private static void GetScaledWidthHeight(uint width, uint height, float scale, out uint widthS, out uint heightS)
{
heightS = (uint) MathF.Round(height * scale);
widthS = (width * heightS) / height;
@ -311,18 +311,10 @@ RR {dev->RequestRender} 0x{(long) dev->ImmediateContext->IfNonZeroSkipPostTickPr
var dev = (DeviceEx*) Device.Instance();
var rtm = (RenderTargetManagerEx*) RenderTargetManager.Instance();
var _Width = dev->Width;
var _Height = dev->Height;
var scale = MathF.Max(1f, cfg.Scale);
GetScaledWidthHeight(_Width, _Height, scale, out dev->Width, out dev->Height);
using var scale = new ScaleState();
Service.PluginLog.Debug($"Regenerating RTM resources: {dev->Width} x {dev->Height}");
_rtmRegenAfterResizeHook.OriginalDisposeSafe();
Service.PluginLog.Debug($"After: 0x{(long) (nint) rtm->_.Unk20[0].Value->D3D11Texture2D:X16}");
dev->Width = _Width;
dev->Height = _Height;
}
private void ICDX11ProcessCommandsDetour(ImmediateContext* ctx, RenderCommandBufferGroup* cmds, uint count)
@ -349,18 +341,8 @@ RR {dev->RequestRender} 0x{(long) dev->ImmediateContext->IfNonZeroSkipPostTickPr
lock (_renderLock)
{
var dev = (DeviceEx*) Device.Instance();
var _Width = dev->Width;
var _Height = dev->Height;
var scale = MathF.Max(1f, cfg.Scale);
GetScaledWidthHeight(_Width, _Height, scale, out dev->Width, out dev->Height);
using var scale = new ScaleState();
_taskRenderGraphicsRenderHook.OriginalDisposeSafe();
dev->Width = _Width;
dev->Height = _Height;
}
}
@ -370,6 +352,29 @@ RR {dev->RequestRender} 0x{(long) dev->ImmediateContext->IfNonZeroSkipPostTickPr
_1_FakeInv,
_2_ToScale
}
private struct ScaleState : IDisposable
{
public uint Width;
public uint Height;
public ScaleState()
{
var dev = (DeviceEx*) Device.Instance();
Width = dev->Width;
Height = dev->Height;
var scale = MathF.Max(1f, Service.Config._.Game.Scale);
GetScaledWidthHeight(Width, Height, scale, out dev->Width, out dev->Height);
}
public void Dispose()
{
var dev = (DeviceEx*) Device.Instance();
dev->Width = Width;
dev->Height = Height;
}
}
}

View file

@ -247,15 +247,8 @@ This is still being worked on before the v1.0 release.");
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(@"Fixes DXVK borderless window causing black screens when alt-tabbing.
This can *possibly* impact performance, depending on your Windows version and GPU.
Feel free to experiment with this toggle.
Make sure to switch the game to windowed and then back to borderless windowed when changing.
Works even with the scaling above disabled.
Not intended to be used with proper fullscreen.");
ImGui.SetTooltip(@"Smaller tweaks and fixes, f.e. for DXVK on Windows,
or to allow making the window smaller than 1024x768.");
}
if (!imTab.Success)
@ -283,8 +276,15 @@ Not intended to be used with proper fullscreen.");
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(@"Smaller tweaks and fixes, f.e. for DXVK on Windows,
or to allow making the window smaller than 1024x768.");
ImGui.SetTooltip(@"Fixes DXVK borderless window causing black screens when alt-tabbing.
This can *possibly* impact performance, depending on your Windows version and GPU.
Feel free to experiment with this toggle.
Make sure to switch the game to windowed and then back to borderless windowed when changing.
Works even with the scaling above disabled.
Not intended to be used with proper fullscreen.");
}
if (ImGui.BeginCombo("Minimum window size", _.MinSizeMode.ToHumanNameString()))