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

Re-add ability to switch render modes under Qt 6 #917

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

Cuperino
Copy link
Member

Fixes #880, where QSG_VISUALIZE overdraw, and other modes, were not working under Plasma. It does this by re-enabling RenderModeRequest::apply() when using the OpenGL variants or the Software renderer. Other modes, such as Vulkan, are yet to be implemented.

Testing was done under Plasma Wayland, by combining:

  • setting QSG_RHI_BACKEND to opengl, vulkan, and software
  • setting QSG_RHI_PREFER_SOFTWARE_RENDERER to 0 and 1

@Cuperino Cuperino added the bug label Jan 12, 2024
@Cuperino Cuperino added this to the 3.1 milestone Jan 12, 2024
@Cuperino Cuperino self-assigned this Jan 12, 2024
@Cuperino
Copy link
Member Author

Cuperino commented Jan 15, 2024

quickinspector test is failing on Windows because of the following reasons:

  • The overlay that states "DirectX is not supported yet, please use OpenGL or Software backend" dims color values, making color compare fail. A solution for this is to make this overlay a little smaller, so we can get a glimpse of the original colors from the corners we pick colors from in this test.
  • The output image's canvas is scaled according to display scaling, but the contents of the image itself remain at its original, non-scaled, resolution. There's a slim chance, that I roughly estimate to approximate 1/100, that the image is scaled to fit the scaled canvas, and the test passes. Most of the time however, the test will fail with display scaling on.

Qt 5 out: note resolution of 232x100, with the image staying at 100x00
qt5-out

Qt 6 out: note resolution of 232x200, and how the image stays at 100x00
qt6-out

By solving the first problem, the one with the presence of an overlay, we get the following image:
qt6-wrongscale-out

For the test to pass on a system with display scaling, the image should instead produce this output that only happens rarely:
qt6-scaled-out

@Cuperino
Copy link
Member Author

Cuperino commented Jan 15, 2024

From inspecting quickscreengrabber.cpp:810, I suspect this could potentially be a bug with the grabWindow() function in Qt 6.

Edit: It could also be a race condition between the image signaling being captured and it being scaled by Qt.

@Cuperino Cuperino marked this pull request as draft January 15, 2024 04:41
@Waqar144
Copy link
Contributor

A solution for this is to make this overlay a little smaller, so we can get a glimpse of the original colors

Yeah, but we don't support DirectX/Vulkan so making the test pass is meaningless and misguiding. I would rather skip it.

@Cuperino
Copy link
Member Author

A solution for this is to make this overlay a little smaller, so we can get a glimpse of the original colors

Yeah, but we don't support DirectX/Vulkan so making the test pass is meaningless and misguiding. I would rather skip it.

Here the image behind the overlay wasn't loading at the correct scale, so I would leave the scale fix and remove the change to the overlay.

See:

0e9cfa3
grabbedFrame.image is sized according to display scaling, but
the contents of the image itself remain at their original,
non-scaled, resolution. There's a slim chance that the image is
scaled to fit the scaled canvas, and the quickinspectortest
passes. Most of the times, however, the image won't be scaled
to fit the canvas.

In this change we manually scale the image according to
devicePixelRatio to fit the image's canvas.

Alternatively, we could leave both, and use the test to catch when the image from the window grab loads with 4x scale instead of 2x. In other words, we could use the test to find out when the bug with the scaling factor and window.grabImage gets fixed in a future Qt version.

Right now the only test failing appears to be quickinspectortest when OpenGL is used Windows.
@Waqar144, Is OpenGL use supported on Windows?

@Waqar144
Copy link
Contributor

@Waqar144, Is OpenGL use supported on Windows?

Afaik, yes. It should work on windows

Fixes #880, where QSG_VISUALIZE overdraw, and other modes, were
not working under Plasma.  Note, other render modes, such as
Vulkan, are yet to be implemented.
quickinspectortext was failing on windows because the overlay that
states "DirectX is not supported yet, please use OpenGL or Software
backend" dims color values, making color compare fail. A solution
for this is to make this overlay a little smaller, so we can get a
glimpse of the original colors from the corners we pick colors from
in this test.
grabbedFrame.image is sized according to display scaling, but
the contents of the image itself remain at their original,
non-scaled, resolution. There's a slim chance that the image is
scaled to fit the scaled canvas, and the quickinspectortest
passes. Most of the times, however, the image won't be scaled
to fit the canvas.

In this change we manually scale the image according to
devicePixelRatio to fit the image's canvas. This allows the test
to pass while keeping it unmodified.
QSGRendererInterface::Software appears to be the culprit, and
QSGRendererInterface::OpenVG wasn't supposed to be used, thus
they were both removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QSG_VISUALIZE overdraw not working
2 participants