Bug 406196 - When Angle is enabled, images painted by QPainter have Red and Blue channels swapped
Summary: When Angle is enabled, images painted by QPainter have Red and Blue channels ...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: OpenGL Canvas (show other bugs)
Version: git master (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL: https://bugreports.qt.io/projects/QTB...
Keywords: regression, release_blocker, triaged
Depends on:
Blocks:
 
Reported: 2019-04-03 19:05 UTC by Halla Rempt
Modified: 2019-04-04 16:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Halla Rempt 2019-04-03 19:05:03 UTC
I'm not sure whether this is a Qt 5.12 issue or something that started happening with the HDR patches, but when using an Intel GPU on Windows 10 with Angle, any image that is painted through QPainter on the OpenGL canvas has the R and B channels swapped, like the transform tool preview or the reference images.
Comment 1 wolthera 2019-04-03 19:13:32 UTC
thanks for reporting this, we were wondering if you were going to during the meeting :)

Now to find someone to confirm :)
Comment 2 Alvin Wong 2019-04-04 09:11:28 UTC
I can reproduce it with my local build (4689792).

R and B channels are swapped when using ANGLE. It happens on both the Intel UHD 620 and the NVIDIA MX150 GPUs.

Everything's normal when using OpenGL.

Image is 16-bit integer, canvas display format is sRGB (8bit). I don't have HDR.
Comment 3 Alvin Wong 2019-04-04 09:24:00 UTC
(In reply to Alvin Wong from comment #2)
> I can reproduce it with my local build (4689792).
> 
> R and B channels are swapped when using ANGLE. It happens on both the Intel
> UHD 620 and the NVIDIA MX150 GPUs.
> 
> Everything's normal when using OpenGL.
> 
> Image is 16-bit integer, canvas display format is sRGB (8bit). I don't have
> HDR.

Sorry, I should clarify that the channels are flipped for the reference images. The image itself is displayed normally.

Converting the image to 8-bit integer or 16-bit float doesn't change anything. (Couldn't try 32-bit float 'cause it crashed...)

I remember adding some code to do colour swizzling with certain surface formats for ANGLE; perhaps it has something to do with this (though the code must have changed a lot by now).
Comment 4 Halla Rempt 2019-04-04 09:25:31 UTC
This happens when painting QImages using QPainter on the opengl/angle canvas: I wonder whether it isn't just something caused by a change in Qt 5.12...
Comment 5 Dmitry Kazakov 2019-04-04 12:54:51 UTC
Yes, I can confirm on ATI GPU as well. It might be my HDR patches...
Comment 6 Dmitry Kazakov 2019-04-04 16:41:27 UTC
Git commit 0cf7c069e3dcf09b82e9ab53be72aa3fff9c7d4e by Dmitry Kazakov.
Committed on 04/04/2019 at 16:40.
Pushed by dkazakov into branch 'master'.

Fix swizzling when rendering QPainter on QOpenGLWidget with Angle

OpenGLES specification does not support GL_TEXTURE_SWIZZLE_RGBA,
it supports only per-channel calls. And since Qt supports QpenGLES,
it should use the latter approach only.

See the upstream patch review:
https://codereview.qt-project.org/#/c/258193/

A  +120  -0    3rdparty/ext_qt/0006-Fix-swizzling-when-rendering-QPainter-on-QOpenGLWidg.patch
M  +2    -0    3rdparty/ext_qt/CMakeLists.txt

https://commits.kde.org/krita/0cf7c069e3dcf09b82e9ab53be72aa3fff9c7d4e