Skip to content

glamor: created pixmap is not clean on intel #3466

Description

@cepelinas9000

Select the version

Git master branch

Describe your issue

There where multiple reports and I saw myself window with random artifacts and glitches. I writing here because i think found a reproducer for big part of them.

Didn't deeply investigate, problem is on intel mesa (tried on nvidia with modesetting dirver it was clear - but it can be because lucky) created glamor pixmap gpu memory is not cleared and contains what previously was in that region. For example using my minimal code i get:

Image

Or similar

Image

Steps to reproduce

  1. Have intel gpu for desktop rendering
  2. Blit just created pixmap:
// compile with: gcc -o main main.c `pkg-config --cflags --libs xcb`

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>

#include <assert.h>
#include <math.h>


#include <gbm.h>
#include <epoxy/egl.h>


#include <xcb/xproto.h>
#include <xcb/dri3.h>


xcb_window_t create_xcb_window(xcb_connection_t *conn, xcb_screen_t *screen){
    xcb_window_t window = xcb_generate_id(conn);
    uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
    uint32_t values[2] = {
        screen->black_pixel,
        XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS
    };

    xcb_create_window(conn,
                      XCB_COPY_FROM_PARENT,   // depth
                      window,                 // window id
                      screen->root,           // parent window
                      0, 0,                   // x, y
                      640, 640,               // width, height
                      1,                      // border width
                      XCB_WINDOW_CLASS_INPUT_OUTPUT,
                      screen->root_visual,
                      mask,
                      values
                      );

    // 4. Map (show) the window
    xcb_map_window(conn, window);
    xcb_flush(conn);

    return window;
}


int main(int argc,char *argv[])
{
    xcb_connection_t *conn = xcb_connect(NULL, NULL);
    xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
    xcb_window_t window = create_xcb_window(conn,screen);
    xcb_gcontext_t gc;

    gc = xcb_generate_id(conn);
    xcb_create_gc(conn, gc, window, 0, NULL);

    int img_width = 400;
    int img_height = 400;

    // 6. Create a pixmap to hold the image
    //    The pixmap must have the same depth as the window
    xcb_pixmap_t pixmap = xcb_generate_id(conn);
    xcb_create_pixmap(conn,
                      screen->root_depth,     // depth
                      pixmap,                 // pixmap id
                      window,                 // drawable (used for depth/visual)
                      img_width,
                      img_height
                      );

    while (1) {
        xcb_generic_event_t *event = xcb_wait_for_event(conn);
        if (!event) break;

        switch (event->response_type & ~0x80) {
        case XCB_EXPOSE: {
            // Draw the pixmap onto the window using xcb_copy_area
            xcb_copy_area(conn,
                          pixmap,     // source drawable
                          window,     // destination drawable
                          gc,         // graphics context
                          0, 0,       // source x, y
                          0, 0,     // destination x, y
                          img_width,
                          img_height
                          );
            xcb_flush(conn);
            break;
        }

        case XCB_KEY_PRESS:
            // Exit on any key press
            free(event);
            goto out;
        }
        free(event);
    }

    out:
    return 0;
}
  1. compile it and enjoy random artifacts

What did you expect?

Have clear window without artifacts.

Additional Information

No response

Extra fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions