Skip to content

Commit

Permalink
Allow glGetDeviceQueryString without display, use to display drm name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mcfletch committed Jan 1, 2020
1 parent c4cd5d0 commit 2f401a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions OpenGL/EGL/EXT/device_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
5 changes: 4 additions & 1 deletion OpenGL/EGL/EXT/device_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ def glInitDeviceQueryEXT():
return extensions.hasGLExtension( _EXTENSION_NAME )


### END AUTOGENERATED SECTION
### END AUTOGENERATED SECTION

eglQueryDeviceStringEXT.extension = None
eglQueryDeviceStringEXT.force_extension = True
27 changes: 27 additions & 0 deletions tests/os_egl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f401a0

Please # to comment.