我正在寻找对如何在客户端应用程序中实现 dri3 和当前扩展具有经验/知识的人。
我的用例是:我在我的应用程序中生成了一个 dma 缓冲区,并希望使用当前扩展将其呈现到屏幕上。
感谢 Sharvil111 和 Gray 的及时回复。我从 xf86-intel-driver - test/present-test.c 中找到了一个当前测试。我将以下代码移植到我的应用程序中。最后我得到一个黑屏。我希望创建的像素图是空的,因此预计会出现黑屏。
如果我错了,请纠正我。
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;
}