As title says using nvidia xorg driver, I have problem to get working EGL using xcb, is there something missing (I read https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_platform_xcb.txt and there are nothing to indicate additional parameters)?
Although if I create with XLIB it works fine. I’m using 580.159.04 as it is latest drivers with GTX 1080 support.
Here minimal reproducer:
// compile with: gcc -ggdb3 -lepoxy -lEGL -lxcb test.c -o test
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#define MESA_EGL_NO_X11_HEADERS
#define EGL_NO_X11
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <epoxy/gl.h>
#include <epoxy/egl.h>
#ifndef EGL_PLATFORM_XCB_EXT
#define EGL_PLATFORM_XCB_EXT 0x31DC
#endif
int main(int argc,char *argv[]) {
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT = (void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
printf("getPlatformDisplayEXT %p\n",getPlatformDisplayEXT);
if (argc < 2) {
fprintf(stderr,"usage: %s xcb|x11\n",argv[0]);
return 1;
}
int egl_major, egl_minor;
EGLint platform;
void *platform_param;
char *what = "";
if (strcmp(argv[1],"xcb") == 0) {
what = "xcb";
platform = EGL_PLATFORM_XCB_EXT;
xcb_connection_t *conn = xcb_connect(NULL, NULL);
platform_param = conn;
} else {
what = "xlib";
platform = EGL_PLATFORM_X11_EXT;
void *lib = dlopen("libX11.so", RTLD_LOCAL | RTLD_LAZY);
void *(*x_open_display)(void *) =
(void *) dlsym(lib, "XOpenDisplay");
void *xdpy = x_open_display(NULL);
platform_param = xdpy;
}
printf("Trying %s\n",what);
EGLDisplay dpy = getPlatformDisplayEXT(platform, platform_param, NULL);
printf("dpy %p\n",dpy);
eglInitialize(dpy,&egl_major,&egl_minor);
printf("EGL vendor: %s\n",eglQueryString(dpy, EGL_VENDOR));
return 0;
}
When getPlatformDisplayEXT requested with EGL_PLATFORM_XCB_EXT I getting:
$ ./test xcb
getPlatformDisplayEXT 0x7ffff7e5f180
Trying xcb
dpy 0x5555556b0340
libEGL warning: pci id for fd 4: 10de:2702, driver (null)
pci id for fd 5: 10de:2702, driver (null)
pci id for fd 6: 10de:2702, driver (null)
libEGL warning: egl: failed to create dri2 screen
EGL vendor: Mesa Project
The libglvnd fail to load nvidia vendor and fallbacks to mesa software render.
On other hand calling with xlib (x11 parameter) it works:
$ ./test x11
getPlatformDisplayEXT 0x7ffff7e5f180
Trying xlib
dpy 0x555555661d80
EGL vendor: NVIDIA
note: if I using X11 modesetting driver it behaves correctly