зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1730936 - Use EGL_DRM_RENDER_NODE_FILE_EXT in glxtest, r=gfx-reviewers,aosmond
We have a custom render node discovery code (needed for DMABUF) that predates the `EGL_DRM_RENDER_NODE_FILE_EXT` extension. It has additional value that it helps us discover the right vendor and device ID on multi-GPU setups (there's a EGL extension far that backing, but not ready yet). In case our custom code fails - notably split display/render SoCs, which are common in the ARM world - lets use `EGL_DRM_RENDER_NODE_FILE_EXT` as fallback. This will ensure we get a valid render node path on all devices, assuming the driver supports that extension right. These SoCs are usually no multi-GPU systems. If they are, we still don't get the right IDs - but an extension for that is in the making. Note: Mesa does *not* implement this right for such SoCs, i.e. it will fail just as our own custom code. However, there's a MR in review - once it lands, things should start working, see https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12796 Depends on D134254 Differential Revision: https://phabricator.services.mozilla.com/D134322
This commit is contained in:
Родитель
18318a8003
Коммит
e9a79329b7
|
@ -111,6 +111,7 @@ typedef void* (*PFNEGLGETPROCADDRESS)(const char*);
|
|||
#define EGL_OPENGL_API 0x30A2
|
||||
#define EGL_DEVICE_EXT 0x322C
|
||||
#define EGL_DRM_DEVICE_FILE_EXT 0x3233
|
||||
#define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377
|
||||
|
||||
// stuff from xf86drm.h
|
||||
#define DRM_NODE_RENDER 2
|
||||
|
@ -350,11 +351,11 @@ static bool device_has_name(const drmDevice* device, const char* name) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static void get_render_name(const char* name) {
|
||||
static bool get_render_name(const char* name) {
|
||||
void* libdrm = dlopen(LIBDRM_FILENAME, RTLD_LAZY);
|
||||
if (!libdrm) {
|
||||
record_warning("Failed to open libdrm");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef int (*DRMGETDEVICES2)(uint32_t, drmDevicePtr*, int);
|
||||
|
@ -369,7 +370,7 @@ static void get_render_name(const char* name) {
|
|||
record_warning(
|
||||
"libdrm missing methods for drmGetDevices2 or drmFreeDevice");
|
||||
dlclose(libdrm);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
|
@ -377,20 +378,20 @@ static void get_render_name(const char* name) {
|
|||
if (devices_len < 0) {
|
||||
record_warning("drmGetDevices2 failed");
|
||||
dlclose(libdrm);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
drmDevice** devices = (drmDevice**)calloc(devices_len, sizeof(drmDevice*));
|
||||
if (!devices) {
|
||||
record_warning("Allocation error");
|
||||
dlclose(libdrm);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
devices_len = drmGetDevices2(flags, devices, devices_len);
|
||||
if (devices_len < 0) {
|
||||
free(devices);
|
||||
record_warning("drmGetDevices2 failed");
|
||||
dlclose(libdrm);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const drmDevice* match = nullptr;
|
||||
|
@ -401,6 +402,7 @@ static void get_render_name(const char* name) {
|
|||
}
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
if (!match) {
|
||||
record_warning("Cannot find DRM device");
|
||||
} else if (!(match->available_nodes & (1 << DRM_NODE_RENDER))) {
|
||||
|
@ -411,6 +413,7 @@ static void get_render_name(const char* name) {
|
|||
"MESA_VENDOR_ID\n0x%04x\n"
|
||||
"MESA_DEVICE_ID\n0x%04x\n",
|
||||
match->deviceinfo.pci->vendor_id, match->deviceinfo.pci->device_id);
|
||||
result = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < devices_len; i++) {
|
||||
|
@ -419,6 +422,7 @@ static void get_render_name(const char* name) {
|
|||
free(devices);
|
||||
|
||||
dlclose(libdrm);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -543,8 +547,12 @@ static bool get_gles_status(EGLDisplay dpy,
|
|||
#ifdef MOZ_WAYLAND
|
||||
const char* deviceString =
|
||||
eglQueryDeviceStringEXT(device, EGL_DRM_DEVICE_FILE_EXT);
|
||||
if (deviceString) {
|
||||
get_render_name(deviceString);
|
||||
if (!deviceString || !get_render_name(deviceString)) {
|
||||
const char* renderNodeString =
|
||||
eglQueryDeviceStringEXT(device, EGL_DRM_RENDER_NODE_FILE_EXT);
|
||||
if (renderNodeString) {
|
||||
record_value("DRM_RENDERDEVICE\n%s\n", renderNodeString);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче