narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
907 stars 69 forks source link

Doesn't play nice with high DPI monitors #134

Closed ekolis closed 1 year ago

ekolis commented 2 years ago

Thanks for making this great utility! I'm just having one issue with it - I want to play Space Empires V, but I have a high DPI monitor and everything looks tiny when I use the utility; the game has no built-in scaling and Windows' scaling doesn't work with the utility, only when I run SE5 without it. Is there any chance of getting this fixed so that Windows' scaling would work with it? Thanks again!

narzoul commented 2 years ago

I don't understand. DPI scaling doesn't seem to affect this game at all. Do you mean some other kind of scaling, like display scaling? Is the game screen centered on your monitor with black borders on all sides of it? If so, it should be fixable via your monitor or graphics control panel settings, depending on what kind of GPU you have.

ekolis commented 2 years ago

I'm talking about this scaling here:

image

With a 4K monitor, everything in SE5 appears tiny when using DDrawCompat, since the scaling I set is ignored.

narzoul commented 2 years ago

Yes, that's what I was talking about too when I mentioned DPI scaling. Changing it had no effect on the game before, but it seems it does after a system restart. However, now I have the opposite effect as you: things look larger with DDrawCompat than without it. Natively, 175% looks the exact same as 100%. At least in full screen mode. There is no difference when playing in windowed mode (with or without DDrawCompat).

Are you playing in windowed or full screen mode? Do you have some compatibility mode or DPI override set on the executable? Try turning those off.

narzoul commented 2 years ago

After a lot more further testing, I'm just a lot more confused. Apparently Windows itself isn't very consistent in applying DPI settings properly. Some of the results I've gotten I can no longer reproduce.

For example, when I had my monitor set to 1920x1080 175% scale, and the game resolution set to the same, and I was using DDrawCompat, I got the intended "zoom" that you're probably looking for. However, that was only because the game actually started at 1366x768 (confirmed from debug logs) instead of what I had it configured to. But after fiddling with settings more, I can't even reproduce it anymore, and it just starts at 1920x1080, no matter the DPI settings. I noticed that this had something to do with Windows sometimes lying about the desktop resolution. Whenever the game launched at 1366x768. GetSystemMetrics with SM_CXSCREEN and SM_CYSCREEN was returning 1366x768 instead of my real desktop resolution (1920x1080) before the game even changed the screen resolution. When the game launched properly at 1920x1080, then GetSystemMetrics was returning real resolution for the desktop too.

Toggling DPI override between "application" and disabled had no effect on DDrawCompat (it shouldn't, since it disables it internally for compatibility reasons anyway), but it did have an effect on native ddraw. With override set to application, it always worked at 1920x1080 (even while DDrawCompat made it run at 1366x768 in the same environment). But then with the override disabled, it upscaled both the launcher and the in game main menu screen, so much so that I could only see the top left corner of the main menu (scaled to the full screen) and had to use alt+f4 to exit.

Bottom line is, apparently Windows is quite inconsistent in whether it lies about the desktop metrics or not, and this can affect what resolution the game chooses to run at (overriding whatever is set in its config). So if you get a more zoomed in screen without DDrawCompat, that's most likely because the game is running at a lower resolution than what you configured. You could probably confirm this by running the game through e.g. API Monitor with DirectDraw tracing enabled in it.

What you probably really want in the end is the resolution scaling feature that e.g. dgVoodoo2 has, which allows the game to run at a lower resolution (for the larger UI) while still rendering 3D stuff at a higher resolution. This will be implemented in the next release of DDrawCompat.

narzoul commented 2 years ago

Actually, now I'm no longer sure if it was Windows lying about the resolution, or a bug in the game's config tool. The list of resolutions offered is different with and without DDrawCompat, and it seems that it remembers the selection not only by the resolution/color depth, but also by its index. So when going into the config tool, try to change the resolution and see if it still matches with what it's showing on the label. It seems like selecting 1920x1080 without DDrawCompat ends up setting 1366x768 with DDrawCompat for me, even though the label still shows 1920x1080. When trying to change the resolution, it has 1366x768 selected instead. So watch out for this bug too.

I'm still pretty sure you're just comparing two different resolutions, in the end, either due to this bug or due to DPI messing with it. Note that 4k resolution also shouldn't work without DDrawCompat, because native DX7 is limited to 2048x2048 for render targets. The game throws an error if I try to use 4k without DDrawCompat.

ekolis commented 2 years ago

Oh wow, thanks for all the research you've done into this issue! Yeah, I did notice that 4K doesn't work without DDrawCompat; it's nice to know why. I actually was running the game in windowed mode, because for whatever reason it performs worse in dedicated fullscreen mode, especially when rendering 2D user interface elements. Go figure! And it's not just the game itself that's shrunken on my screen; the launcher is as well... Hopefully we can get to the bottom of this!

narzoul commented 2 years ago

Hmm ok then, windowed mode is a different story. I'm not sure how much effort it would be to make DDrawCompat compatible with windowed mode DPI scaling, but I'll look into it.

But aren't you having performance issues in full screen mode because you're running it at a much higher resolution? In windowed mode it's rendering at 1024x768, which might be upscaled by Windows DPI scaling, but I'm pretty sure that's just a bilinear stretch on the final 1024x768 image, not a higher resolution rendering. Does it run slower in full screen 1024x768 resolution too?

ekolis commented 2 years ago

I haven't tried running it in a lower resolution fullscreen recently, but I do remember in the past, before I had a 4K monitor and had to worry about scaling, running it fullscreen was somehow slower than running it windowed, even if I set the window resolution to the full resolution of my monitor.

narzoul commented 1 year ago

Added a DpiAwareness setting in v0.4.0, which may or may not help with this issue. I'm afraid there is not much else I can do about it, so I hope it helps.