-1

I am looking for someone who has experience/knowledge on how to implement dri3 and present extension in client application.

My use case will be: I have a dma buffer generated at my application and want to use present extension to render it to screen.

Kinux
  • 1
  • 2
  • Tried to look for example online but hardly to find one. – Kinux Nov 23 '15 at 02:43
  • Right now the question is unclear. To avoid having it flagged for closure, you should show what you have tried so far and narrow the focus of the question – Greg Nov 23 '15 at 03:45

1 Answers1

0

Thanks Sharvil111 and Grey for the prompt response. I found a present test from xf86-intel-driver - test/present-test.c. I ported the below code to my app. I am getting a black screen at the end. I would expect the pixmap created is empty and therefore a black screen is expected.

Correct me if I am wrong.

static int test_dri3(Display *dpy)
{
    Window win = DefaultRootWindow(dpy);
    Pixmap pixmap;
    Window root;
    unsigned int width, height;
    unsigned border, depth;
    unsigned stride, size;
    int x, y, ret = 1;
    int device, handle;
    int bpp;

    device = dri3_open(dpy);
    if (device < 0)
            return 0;

    if (!is_intel(device))
            return 0;

    printf("Opened Intel DRI3 device\n");

    XGetGeometry(dpy, win, &root, &x, &y,
                 &width, &height, &border, &depth);

    switch (depth) {
    case 8: bpp = 8; break;
    case 15: case 16: bpp = 16; break;
    case 24: case 32: bpp = 32; break;
    default: return 0;
    }

    stride = width * bpp/8;
    size = PAGE_ALIGN(stride * height);
    printf("Creating DRI3 %dx%d (source stride=%d, size=%d) for GTT\n",
           width, height, stride, size);

    pixmap = 0;
    handle = gem_create(device, size);
    if (handle) {
            pixmap = dri3_create_pixmap(dpy, root,
                                         width, height, depth,
                                         gem_export(device, handle), bpp, stride, size);
            gem_close(device, handle);
    }
    if (pixmap == 0)
            goto fail;

    xcb_present_pixmap(XGetXCBConnection(dpy),
                       win, pixmap,
                       0, /* sbc */
                       0, /* valid */
                       0, /* update */
                       0, /* x_off */
                       0, /* y_off */
                       None,
                       None, /* wait fence */
                       None,
                       XCB_PRESENT_OPTION_NONE,
                       0, /* target msc */
                       0, /* divisor */
                       0, /* remainder */
                       0, NULL);
    XFreePixmap(dpy, pixmap);

    XSync(dpy, True);
    if (_x_error_occurred)
            goto fail;

fail:
    close(device);
    return ret;
}
Kinux
  • 1
  • 2