Dxvk: Scale ratio for DXVK_HUD

Created on 16 Nov 2018  路  12Comments  路  Source: doitsujin/dxvk

This is a feature request.

Would be great if it would be possible to set Font Size for DXVK_HUD

At the moment when running games with DXVK_HUD at high resolutions (like 3840x2160) the text is very tiny and hard to read. Some sort of scale ratio would be great!

enhancement

Most helpful comment

I just added an option to do this manually via the already existing env var, DXVK_HUD=fps,scale=1.5.

Doing this automatically would be iffy on wine since things tend to break if you try to set wine's own scaling to anything other than 96 DPI, but this should do.

All 12 comments

How would you want this to be implemented though? Introducing yet another environment variable is horrible.

I guess just adding a scaling factor based on the current resolution should be possible.

Well scaling factor which depends on resolution would be great.

I would suggest:
2560x1440 - ratio 1.5
3840x2160 - ratio 2
Higher resolutions for the future - ratio 3

Another way would be var for DXVK_HUD, for example DXVK_HUD=scale would set ratio of 2

@doitsujin Instead of hardcoding it, the user-specified percentage should be decoupled from the physical panel defaults; you can get the correct scaling ratio by calling GetDpiForWindow(), which is implemented by Wine.

As long as the game is (at least) per-monitor DPI aware (this is set in the .exe manifest or dynamically configured through one of the messy SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); cousins) it should return the correct number (or return 96 as fallback).

To turn it into a proper GUI scale you only need to divide by the base DPI value (96), keep in mind that the base is 72 on macOS.

This is what Blender does, a pretty sane implementation using pure (and configurable) scaling ratios and dynamically loading the function pointers from user32.dll: https://github.com/dfelinto/blender/commit/fe3fb236970ce30733381ad1ae8b89c55266c517

__Example__: Windows 10 set to 150% UI scaling:

float getWindowScalingRatio(HWND hwndGame)
{
  typedef UINT(WINAPI *LPGETDPIFORWINDOW)(HWND);

  UINT                     windowDpi = 96;
  LPGETDPIFORWINDOW pGetDpiForWindow = NULL;

  HMODULE hUser32 = LoadLibrary("User32.dll");

  if (hUser32)
  {
    pGetDpiForWindow = (LPGETDPIFORWINDOW) GetProcAddress(hUser32, "GetDpiForWindow");

    if (pGetDpiForWindow)
      windowDpi = pGetDpiForWindow(hwndGame); /* <- returns 144 (or 0, if the HWND is invalid) */
  }

  return (windowDpi ? windowDpi : 96) / 96.f; /* <- returns 1.5f */
}

__PS__: GetDpiForWindow() is a Windows 10 function, but we don't care about Windows 8 compat.
__PS2__: Also, the correct unit for screens is technically PPI, DPI is a vestigial unit, so in practice it's a misnomer. The entire thing is a bit of a mess, be my guest:

As long as the game is (at least) per-monitor DPI aware

How common is that, though? I'd imagine that especially older games do not care about DPI. In theory, this sounds like a reasonable idea, but I'm afraid we'd end up with a horrible mess where it would scale correctly in some games but not in others.

I don't know how Wine does it, but unless the game has some kind of DPI awareness most Win32 display mode functions won't even return 4K+ resolutions to maintain emulation/compatibility in oblivious apps.

I'll give it a try, thanks for the suggestion.

@Swyter they don't return 4K resolutions because DXGI/Whatever is DPI aware and is only showing resolutions that would fit post-scale.

Games very rarely do DPI awareness at all, nevermind correctly interpreting or reading any scale info after saying its DPI aware (although thats better than having a blurry scaled mess).

I'd highly advise against using that as a metric for UI scale. A fixed scale based on height/1080 would probably be best IMO.

Eh, I don't know how that contradicts what I said. If the game isn't DPI-aware you won't be getting any hi-DPI resolutions listed by default, unless you force them via configuration file. If it is, it will work out of the box using the correct multiplier, I ship some AA game and we do support 4K via SDL_GetDisplayDPI(), it's not rocket science.

I'm not against adding an override, but doing it properly doesn't seem that hard in the first place.
If you think scaling should be proportional to the panel dimensions you don't understand it.

DPI != Resolution

Plus that will only get you the ""DPI"" in terms of the user-chosen scale provided by Windows.

Necro'ing this... :sweat_drops:

Maybe something like font_size=24 where the number is the point size for the font.

Necro'ing this...

Maybe something like font_size=24 where the number is the point size for the font.

Like doitsujin wrote in the second comment "Introducing yet another environment variable is horrible." So in my opinion this should be done automatically, by detecting screen DPI or resolution dependent. Still hope to get this thing into DXVK_HUD, but lack of interest seems to be stopping the thing

For now there is a great alternative, MangoHud: https://github.com/flightlessmango/MangoHud

I just added an option to do this manually via the already existing env var, DXVK_HUD=fps,scale=1.5.

Doing this automatically would be iffy on wine since things tend to break if you try to set wine's own scaling to anything other than 96 DPI, but this should do.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThePiggyBanks picture ThePiggyBanks  路  5Comments

EnigmaRaptor picture EnigmaRaptor  路  5Comments

fls2018 picture fls2018  路  4Comments

AuroransSolis picture AuroransSolis  路  3Comments

mozo78 picture mozo78  路  5Comments