-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
egl: implement interfaces for
EGL_EXT_device_drm
This extension (together with the optional `EGL_EXT_device_drm_render_node` extension) allows querying the DRM primary and render device node filenames from `EGLDevice`, to help associating them with DRM devices. Additionally a platform display _can_ be created with a DRM file descriptor with master permissions, but this is only useful in situations where EGL might fail to open a file descriptor itself or will fail to acquire master permissions (which are only required when the implementation needs to "modify output attributes": but no behaviour is defined by this extension that requires this). This file descriptor will be duplicated by the implementation if it needs to use it beyond the call to `eglGetPlatformDisplayEXT()`, and does not need to be kept alive by the caller. Note that `EGL_EXT_output_drm` is omitted for now, because it relies on the equally unimplemented `EGL_EXT_output_base` extension.
- Loading branch information
Showing
6 changed files
with
154 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::fs::OpenOptions; | ||
use std::os::fd::AsRawFd; | ||
|
||
use glutin::api::egl; | ||
use raw_window_handle::{DrmDisplayHandle, RawDisplayHandle}; | ||
|
||
fn main() { | ||
let devices = egl::device::Device::query_devices().expect("Query EGL devices"); | ||
for egl_device in devices { | ||
dbg!(&egl_device); | ||
dbg!(egl_device.drm_render_device_node_path()); | ||
let Some(drm) = dbg!(egl_device.drm_device_node_path()) else { | ||
continue; | ||
}; | ||
let fd = OpenOptions::new() | ||
.read(true) | ||
.write(true) | ||
.open(drm) | ||
.expect("Open DRM device with Read/Write permissions"); | ||
|
||
// https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_device_drm.txt: | ||
// Providing DRM_MASTER_FD is only to cover cases where EGL might fail to open | ||
// it itself. | ||
let rdh = RawDisplayHandle::Drm(DrmDisplayHandle::new(fd.as_raw_fd())); | ||
|
||
let egl_display = unsafe { egl::display::Display::with_device(&egl_device, Some(rdh)) } | ||
.expect("Create EGL Display"); | ||
dbg!(&egl_display); | ||
} | ||
} |