Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DolphinQt: use default dpi rounding mode (passthrough) #11788

Merged
merged 1 commit into from Apr 25, 2023
Merged

DolphinQt: use default dpi rounding mode (passthrough) #11788

merged 1 commit into from Apr 25, 2023

Conversation

shuffle2
Copy link
Contributor

@shuffle2 shuffle2 commented Apr 23, 2023

Before this change, dolphin was using rounded mode, which rounds up to integer scale factor at .5 or down otherwise. This means that if dolphin was started on a screen with 150% scaling, dolphin would actually be at 200%, which causes it to be larger than expected/ other apps. However, dolphin would still react to dpi scaling changes - so changing to 150% after opening the app would cause it to change size in an odd way and look somewhat bad until it is restarted.

using pass through causes dolphin to always be at the screen’s actual dpi scaling.

@mbc07
Copy link
Contributor

mbc07 commented Apr 24, 2023

This means that if dolphin was started on a screen with 150% scaling, dolphin would actually be at 200%, which causes it to be larger than expected/ other apps.

Actually this was the behavior I was experiencing on Windows 11 right before we jumped to Qt 6, which AFAICT resulted in the current piece of code this PR removes being added. Current master seems to correctly render at 150% when Windows scaling is set to 150%, however ImGui elements on the render window displayed bigger and looked a bit blurred (likely 150% stretched to 200%).

Anyway, at least here (Windows 11, 150% scaling), this PR seems to fix ImGui scaling without reintroducing the "larger than expected" bug from when we used Qt 5 and earlier Qt 6 versions, so this LGTM...

@lioncash lioncash merged commit 6bdfcc6 into dolphin-emu:master Apr 25, 2023
14 checks passed
@AlexFilar
Copy link

Is this new DPI scaling configurable in settings? It causes issues with 125% custom scaling on Windows 11. Version before this commit (5.0-19291) was normal.
dolphin-19291

@shuffle2
Copy link
Contributor Author

shuffle2 commented Apr 25, 2023

Is this new DPI scaling configurable in settings? It causes issues with 125% custom scaling on Windows 11. Version before this commit (5.0-19291) was normal.
dolphin-19291

There are changes which effect the scaling split between a few commits, and it will be a while before master has all of them (and qt6.5). Wait until then. But, what you’re seeing is actually illustrating what I was saying: dolphin at 125% was really rendering at 100%

@AlexFilar
Copy link

@shuffle2, Yes, I will be using build 19291 for now. I just wanted to let you know that this change doesn't work equally well for everybody. And rather than having it forced on, I think adding a DPI scaling toggle in settings is preferable. With scaling it looks jagged for me, as you can see it on my screenshot above. I would like an option to make it back to 100% even when Windows has 125%.

@shuffle2
Copy link
Contributor Author

more options are always worse. just wait

@AlexFilar
Copy link

@shuffle2, I agree, that complex configuration is worse, but having a choice is better. How is it possible to fix this? Some kind of forced antialiasing, blurring the images? By the way, scaling also makes grid view game covers much bigger, and some of them do not fit in the screen after that. I really think that ability to cancel scaling should be an option.

@mbc07
Copy link
Contributor

mbc07 commented Apr 25, 2023

You'll very likely have proper scaling without bluryness (and even dark mode) when the Qt 6.5 transition is done. For now you have to wait...

@AlexFilar
Copy link

@shuffle2, Question, if this is a Qt issue, why is imgui affected? Imgui is rendered with graphics API like Vulkan or D3D, it has nothing to do with Qt, right?
dolphin-imgui
Also the main problem isn't jaggy images. I simply do not want to have huge scaled GUI, I prefer it like it was. It should be an option, not a forced decision. Just let users decide whether they want scaling or not.

@mbc07
Copy link
Contributor

mbc07 commented Apr 25, 2023

if this is a Qt issue, why is imgui affected? Imgui is rendered with graphics API like Vulkan or D3D, it has nothing to do with Qt, right?

The render window is managed by Qt, so some aspects of it will also affect ImGui...

@shuffle2
Copy link
Contributor Author

Using the build I posted here: #11785 (comment)
100%
image
125%
image
150%
image
175%
image

You can see, the toolbar icon scaling looks much better.

The imgui issues are surely fixable, the related code probably just has a bug / wasn't expecting to deal with fractional scaling.

@shuffle2
Copy link
Contributor Author

shuffle2 commented Apr 26, 2023

For imgui, the general suggestion is something like:

ImFontConfig cfg{};
cfg.SizePixels = 13.0f * scale;
ImGui::GetIO().Fonts->AddFontDefault(&cfg);

Here's how dolphin looks with that when the system dpi scaling is 200%:
image
I'm not actually sure if that is correct. However, dolphin can choose to scale the imgui font however it likes, it's just a texture atlas. Other projects definitely manage to use imgui with hidpi and nicely rendered fonts/ui...
Maybe @Sam-Belliveau or someone more experienced with imgui can do it?

edit: i'm assuming the above image winds up scaling the font by 400% (2x applied twice), since dolphin is already correctly scaling it. An improvement may just be that the texture atlas should be sampled with filtering or something.

@AlexFilar
Copy link

@shuffle2, Yes, I saw your build and tried it. In fact, screenshots of imgui I posted are from there. But you are ignoring my point, DPI scaling should be optional. I get it, Dolphin now handles scaling wrong, it rounds to integer like 100% when it should be 125%. But one thing all software developers must know is that when the behavior is incorrect for a significant time, users will rely on that incorrect behavior. When you actually fix it, users might want previous incorrect behavior back. Some users, like me, might not like when Dolphin GUI suddenly becomes huge, when scaling is fixed. Some apps allow user to configure scaling.
For example Blender:
blender
Or Factorio:
factorio
But they are rendering their own UI, and I don't know if Qt allows custom scaling. But if it's possible to do in Dolphin, it should definitely be an option!

@MayImilae
Copy link
Contributor

MayImilae commented Apr 26, 2023

Both of those examples are hella complex programs with GUIs that go WAY beyond Dolphin's. They aren't comparable.

Personally, a scaling override for Qt is fine with me. However, it's not something our Qt GUI users will need to change much if ever, so it should probably go into an INI and be left out of the GUI itself.

@shuffle2
Copy link
Contributor Author

The environment variable QT_SCALE_FACTOR should already do what you want. See the qt docs for more options.

@AlexFilar
Copy link

@shuffle2, Thanks, that's exactly what I was asking for. QT_SCALE_FACTOR=1.00 doesn't work for some reason, but QT_ENABLE_HIGHDPI_SCALING=0 does, and this is exactly what I wanted.

But environmental variables are inconvenient. To use them we need to create a bat file and launch it instead of Dolphin executable. Also none of the users know about those variables. My suggestion is to add an explicit option for custom scaling, and add a call to SetEnvironmentVariable or setenv before initializing Qt. This needs restart, but changing the language needs restart too, so it should not be a problem.

Of course, it's up to you to decide to implement it or not, but it is not a good solution to force scaling on users with no obvious way to change it. Again, none of the users know about those variables. Feature that exists but is not exposed to users is a bad design.

@AdmiralCurtiss
Copy link
Contributor

The entire point of having High-DPI support in your OS is so that it can tell applications the scale they should render at, so that you get a consistent experience (font size etc.) across all your applications. If you don't want applications to scale up, you should just configure your OS to not scale up applications. Or do you want eg. your browser to scale up but not Dolphin, and if yes why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants