-
Notifications
You must be signed in to change notification settings - Fork 58
Add a DRM/KMS backend #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This backend uses DUMB buffers to render to the CRTC. cc #42
Signed-off-by: John Nunley <[email protected]>
Signed-off-by: John Nunley <[email protected]>
I've tested this on my computer and it seems to work for my use case, so I think it's ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff, btw! Two small comments inside.
#[inline] | ||
pub fn pixels(&self) -> &[u32] { | ||
// drm-rs doesn't let us have the immutable reference... so just use a bunch of zeroes. | ||
// TODO: There has to be a better way of doing this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the BorrowStack
hack would work here.
But it looks like DumbMapping
is already just a wrapper around a &'a mut [u8]
, so could just open a PR for drm-rs to implement AsRef<[u8]>
in addition to the AsMut<[u8]>
implementation.
Signed-off-by: John Nunley <[email protected]>
I was previously using the wrong framebuffer to page flip. This also adds an implementation of buffer aging. Signed-off-by: John Nunley <[email protected]>
Apparently I was setting up the connectors wrong. Signed-off-by: John Nunley <[email protected]>
So I believe like on Wayland, ...but would Winit or another "windowing" backend using DRM also poll the same fd? Is there any way to manage this? |
The example currently fails on the laptop I'm using since it has an Nvidia card, which for some reason is There isn't a good way to determine the right output, and the display probably shouldn't try to deal with setting all connected outputs, but maybe it should iterate over cards and chose the first one it finds a connector on? |
I'm not sure if there is a way to do this on DRM. Please tell me if I'm wrong, but I think the current way of doing things is the only way. |
- Add a mechanism that uses udev to find a card - Poll the fd before receiving events Signed-off-by: John Nunley <[email protected]>
Signed-off-by: John Nunley <[email protected]>
In softbuffer's DRM implementation, we need to have a way to get a [u8] slice for our Deref implementation. Right now, we just create an entire buffer of zeroes and read from that. As that is unidiomatic, this PR adds an AsRef impl to DumbMapping to get a reference to the underlying memory. See: rust-windowing/softbuffer#135 (comment) Signed-off-by: John Nunley <[email protected]>
I guess Looking at https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/egl/drivers/dri2/platform_drm.c and https://github.com/libsdl-org/SDL/blob/main/src/video/kmsdrm/SDL_kmsdrmopengles.c, it seems like EGL manages this in some way with functions called |
Signed-off-by: John Nunley <[email protected]>
Signed-off-by: John Nunley <[email protected]>
Done. I was mostly following rust-windowing/glutin#1403, which appears to use fencing in a way that I don't know how to accommodate in |
Signed-off-by: John Nunley <[email protected]>
Signed-off-by: John Nunley <[email protected]>
Seems like I guess that's expected with some drivers? Don't know if simply ignoring |
Signed-off-by: John Nunley <[email protected]>
This adds a DRM/KMS based backend to the system, as per #42. This system finds a CRTC and a connector, then uses that to create a frame buffer and a DUMB buffer that it can render to.
All of this is untested, hence the draft status.I'm not going to be the maintainer for this backend, as I'm self-imposing a limit of two backends on myself. If anyone else with DRM/KMS experience or a motivating use case wants to maintain this backend, let me know. Otherwise I've marked it as unmaintained.
Closes #42