From 2f401a0d65bb96ea702a39c7e9d1626b94a79f6e Mon Sep 17 00:00:00 2001 From: "Mike C. Fletcher" Date: Wed, 1 Jan 2020 00:05:47 -0500 Subject: [PATCH] Allow glGetDeviceQueryString without display, use to display drm name The DRM name is only available on the enumeration devices, but then those seem to show all of the devices on the modern ubuntu, so maybe that's all we need for now. --- OpenGL/EGL/EXT/device_base.py | 3 +++ OpenGL/EGL/EXT/device_query.py | 5 ++++- tests/os_egl.py | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/OpenGL/EGL/EXT/device_base.py b/OpenGL/EGL/EXT/device_base.py index d72eeb39..d782d87e 100644 --- a/OpenGL/EGL/EXT/device_base.py +++ b/OpenGL/EGL/EXT/device_base.py @@ -23,6 +23,9 @@ def glInitDeviceBaseEXT(): ### END AUTOGENERATED SECTION eglQueryDevicesEXT.extension = None eglQueryDevicesEXT.force_extension = True +eglQueryDeviceStringEXT.extension = None +eglQueryDeviceStringEXT.force_extension = True + def egl_get_devices(max_count=10): """Utility function that retrieves platform devices""" diff --git a/OpenGL/EGL/EXT/device_query.py b/OpenGL/EGL/EXT/device_query.py index 1b11e3d9..45549198 100644 --- a/OpenGL/EGL/EXT/device_query.py +++ b/OpenGL/EGL/EXT/device_query.py @@ -20,4 +20,7 @@ def glInitDeviceQueryEXT(): return extensions.hasGLExtension( _EXTENSION_NAME ) -### END AUTOGENERATED SECTION \ No newline at end of file +### END AUTOGENERATED SECTION + +eglQueryDeviceStringEXT.extension = None +eglQueryDeviceStringEXT.force_extension = True diff --git a/tests/os_egl.py b/tests/os_egl.py index e7a42a68..86e843e1 100644 --- a/tests/os_egl.py +++ b/tests/os_egl.py @@ -47,6 +47,13 @@ def platformDisplay(device): raise RuntimeError("Unable to create EGL display on %s" % (display)) else: raise RuntimeError("eglGetPlatformDisplay has no implementation") + if not created_device: + try: + name = get_device_name(device) + if name is not None: + log.debug("DRM Name: %s", name) + except EGLError: + log.debug("Unable to retrieve the DRM name") return display, created_device @@ -227,6 +234,26 @@ def debug_info(setup): log.info("Extensions: %s", glGetString(GL_EXTENSIONS)) glFinish() +def get_device_name(device): + """Try to get the display's DRM device name + + This is almost certainly not going to work on + anything other than Linux + """ + from OpenGL.EGL.EXT.device_query import ( + eglQueryDeviceStringEXT, + ) + from OpenGL.EGL.EXT.device_drm import ( + EGL_DRM_DEVICE_FILE_EXT, + ) + if eglQueryDeviceStringEXT: + name = eglQueryDeviceStringEXT( + device, + EGL_DRM_DEVICE_FILE_EXT + ) + return name.decode('ascii',errors='ignore') + return None + def main(): # NOTE: having two different implementations here is