I am working on the qt app where I need to draw lines on the screen. The problem is that lines I am drawing with the standard qt methods are completelly wrong – they are tearing without any movement. I also have my own algorithm to draw lines so I am sure that coordinates of each pixel are correct, but they are not correctly represented on screen.
I’ve run my code on other OS’s and it works perfect. It also works perfect if I switch from X11 to Wayland, but I don’t want to use the last one because it works awful with everything else. I’ve also tried to switch from qt5 to qt6 and it didn’t help at all.
So I assumed that the problem is not in qt but in my system and created a file /etc/X11/xorg.conf.d/20-amdgpu.conf with the contents:
Section “Device”
Identifier “AMD Graphics”
Driver “amdgpu”
Option “TearFree” “true”
Option “TripleBuffer” “true”
Option “AccelMethod” “uxa”
EndSection
Unfortunately, I am not allowed to add screenshot here, but I will try to describe:
I am drawing a 45 degree line from the top left to the bottom right. So if the starting point is (x, y), I expect next pixel to appear on the (x + 1, y + 1) and so on. But on screen I have several correct pixels, than at this thing: (x + 1, y), (x + 1, y + 1), (x + 1, y + 2). Then the line is right again for a short period. And It all goes over and over.
> Installed PCI configs:
--------------------------------------------------------------------------------
NAME VERSION FREEDRIVER TYPE
--------------------------------------------------------------------------------
video-linux 2018.05.04 true PCI
Warning: No installed USB configs!
> 0000:03:00.0 (0300:1002:164c) Display controller ATI Technologies Inc:
--------------------------------------------------------------------------------
NAME VERSION FREEDRIVER TYPE
--------------------------------------------------------------------------------
video-linux 2018.05.04 true PCI
video-modesetting 2020.01.13 true PCI
video-vesa 2017.03.12 true PCI
I am not sure that it is everything that might be useful.
Depending on the graphics system used, qt has to implement the “internal” paint and draw commands differently. Qt has a whole range of settings for this. Some of these affect the thickness of a line, or how it is rendered…
As far as I know, there is no routine that sets a single point directly without going through the entire graphics system. Transformations are applied, antialiasing…
You can get a lot of unexpected effects there. Of course also those that are only visible on a specific backend.
So if you want to call it a bug… I would rather say that it is a misunderstanding between you and qt.
It’s better to use the routines from the Qt library. Not only is it easier, but they really work.
I’ve already said that standard library functions don’t work on this operation system in particular. My task as a student is to implement functions to draw lines myself, and I mentioned it only to let you know that I now for a fact that I am providing standard qt methods with right coordinates.
Why does this misunderstanding happens only on Manjaro with X11 then?