ROCm / ROCK-Kernel-Driver

AMDGPU Driver with KFD used by the ROCm project. Also contains the current Linux Kernel that matches this base driver
Other
333 stars 101 forks source link

Possible flickering issue due to amgpu driver when cursors are to big on X11 #129

Closed schrmh closed 2 years ago

schrmh commented 2 years ago

I'm opening this bug here cause this repo is linked to at https://en.wikipedia.org/wiki/AMDgpu(Linux_kernelmodule) and I hope this is the correct place. Should I rather go to the linux kernel mailing list or to somewhere else?

When a XCursor with a size bigger than 128x128 is set, the cursor starts to flicker. I tried it on Xfce4/xfwm4 with compositors xfwm4, picom and no compositor. I have a RX560 (the cut down version with 14 Compute Units) and I'm using a pretty up to date (linux kernel 5.17.0-rc1) amdgpu as the driver. One other person using the nvidia driver had no flickering problems when they were using that DE/WM and those compositors, that's why we concluded it's a driver problem. However, there is also no flickering when I zoom in using Alt+Mousewheel but it might be that the hardware cursor is probably disabled when I zoom in (custom cursor rendering for zoom).

Why is this a relevant problem? Color picker software like https://github.com/Soft/xcolor and https://github.com/linuxdeepin/deepin-picker sets a cuts a magnified screenshot as the cursor and for that purpose a cursor that is big enough to have the flickering problem is created. I wrote a minimal example (without error handling code to keep it short) that you can use to test whether you get the flickering. Compile & run: gcc -o cur cur.c -lX11 && ./cur And then run it once again by using ./cur 128 You can stop the program by pressing Ctrl+c

#include <X11/Xcursor/Xcursor.h>
#include <stdlib.h>
static unsigned char bits[65536];

int main(int argc, char *argv[]){
    int size = argc==2 ? size=strtol(argv[1], NULL, 10) : 256;

    Display *dpy = XOpenDisplay (NULL);
    Window root = XDefaultRootWindow(dpy);

    Cursor cursor;
    XColor color = {0,32000,32000,32000};

    for (int x = 0; x < size*size; x++) {
        bits[x] = 0xff;
    } 

    Pixmap pix = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), (char *) bits, size, size);
    cursor = XCreatePixmapCursor(dpy, pix, pix, &color, &color, 0, 0);
    XFreePixmap(dpy, pix);

    XGrabPointer(dpy, root, False, OwnerGrabButtonMask, GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);

    while(1);
}

Without a parameter it sets a filled gray rectangular cursor with a size of 256x256 that flickers partly (small black horizontal bars that seem to move a bit up/down) when the mouse is moved. When you pass a number not bigger than 128 there is no flickering.

kentrussell commented 2 years ago

While we do have the entire amdgpu stack in our code here, this isn't the best spot for a bug regarding display bugs. For that, you can email amd-gfx@lists.freedesktop.org for inquiries, but I'd recommend opening a bug report for amdgpu at https://gitlab.freedesktop.org/drm/amd/-/issues . They have a better triaging process via gitlab and it gets eyes from the devs who work on the display components, instead of here which is primarily the Compute/KFD side (no graphics). Good luck!