Vulkan not honoring dynamically settting DPI aware on Windows 10

I’m getting incorrect rendering on an AMD driver, but I suspect from a 2019 report that Vulkan isn’t honoring setting the DPI at runtime. We don’t have a manifest file, so before we create the HWND, I set the following. The surface is reported as the correct size at 200% scaling, but draws way outside the window at 2x the dimensions. But the pixels are already 2x, so this is 4x size.

Vulkan should not require a manifest file for this, and surface creation/preset should respond to the manifest and/or the dynamic setting . I’ll see if I can figure out how to use the manifest from the 2019 post where the poster said setting Process dpi settings didn’t work, and the issue was closed. This needs to be fixed.

auto oldContext = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 );

Also the manifest property settings don’t include “per monitor aware v2” at least in VS 2019. So setting that dynamically seems to be the only way to set it. Can set “per monitor aware”.

For completeness, since Alecazam is new, they were unable to post this link.

The surface is reported as the correct size at 200% scaling

What is the “correct size” in this case? Can you give a more specific example of how the problem shows itself?

Vulkan works with pixels. If the only way to get true pixels out of a particular platform requires a manifest file, that’s the platform’s fault, not Vulkan’s.

What is the “correct size” in this case? Can you give a more specific example of how the problem shows itself?

The surface is 1280x720x2. The surface is reported the correct size, shows up in RenderDoc with the UI correct in the framebuffer of the same dimension. But when the surface is displayed it’s 2x bigger than it should be. So somehow the surface thinks the dpi is 96, but at 200% scale, the Windows dpi is 192.

Vulkan works with pixels. If the only way to get true pixels out of a particular platform requires a manifest file, that’s the platform’s fault, not Vulkan’s.

One can set the dpi awareness dynamically or via manifest. And you can only set “per monitor v2” behavior dynamically, since it’s not in the popup for Windows. Or hardcode the value in a manifest file without using the VS property page.

There’s barely any references to this in the Vulkan docs either. This is Win32 surface specific, but this needs to work properly in the AMD driver (running under Bootcamp). I’m trying on Nvidia/Intel to see if the same behavior occurs there.

So this call seems to work. So for now we’ll just use this. Not sure if this is a bug in the Vulkan driver from AMD for Bootcamp. Perhaps the thread setting isn’t for the same thread that Vulkan uses, but this is the same code we call CreateWindow on. But at least we can skip the manifest entry this way.

SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 );

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.