Skip to content

Conversation

kchandra22134
Copy link

This adds interface to graphics application to create EGLDisplay
directly over GPU device as enabled by EGLDevice extensions

Modifies in GLFW library to add egldevice-drm backend.

This includes modifying a few existing files and creating four new files which are
specific to the backend that we are adding. For eg. in our case these are
egldevice_platform.h, egldevice_init.c, egldevice_window.c, egldevice_monitor.c .

In the file "egl_context.c" change selects the EGL_SURFACE_TYPE config attribute value to
EGL_STREAM_BIT_KHR instead of EGL_WINDOW_BIT and specify the window surface to the surface which we created using EGLStreams.

Other files "egl_context.h" and "internal.h" has minor changes to include the header files.
Also there are changes in CMake code files to include the newly created files.

Links to the EGL extensions used:

  1. EGL_EXT_device_drm
    https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_device_drm.txt
  2. EGL_KHR_stream
    https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_stream.txt
  3. EGL_EXT_stream_consumer_egloutput
    https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_stream_consumer_egloutput.txt
  4. EGL_KHR_stream_producer_eglsurface
    https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_stream_producer_eglsurface.txt

@elmindreda elmindreda added enhancement Feature suggestions and PRs Nvidia Nvidia GPU specific (any OS or driver) labels Jun 15, 2016
@elmindreda elmindreda self-assigned this Jun 15, 2016
This adds interface to graphics application to create EGLDisplay
directly over GPU device as enabled by EGLDevice extensions
@elmindreda
Copy link
Member

This is an odd platform, but the impact on existing code is nicely small.

Are there any plans for input support? I won't reject it if there isn't, but it'd be good to know.

Is there any publicly available system where I could test this?

Do you know if you (personally or Nvidia) will be submitting updates as needed or if this is a one-time code drop? Again, I won't reject based on the answer but I need to know.

@elmindreda elmindreda added the Linux Linux specific (any window system) label Jul 31, 2016
@kchandra22134
Copy link
Author

  • For testing this backend you can:
  • Use NVIDIA Linux GPU driver release 364.12 or later.
  • Use a Linux 4.1 or later kernel with DRM support enabled.
  • Stop the X server, or any other potential DRM client. This backend requires the ability to become DRM master in order to do modesets.

You can also refer to this: https://github.com/aritger/eglstreams-kms-example
where EGLDevice backend is demonstrated.

We have plans to submit more updates in this, as this is only the minimal functionality required to run the application.

@elmindreda
Copy link
Member

@kchandra22134 Great, thank you!

@elmindreda elmindreda added this to the 3.3 milestone Aug 10, 2016
@elmindreda elmindreda changed the title Add EGLDevice backend to GLFW Add EGLDevice backend Dec 19, 2016
elmindreda pushed a commit that referenced this pull request Sep 7, 2017
This adds interface to graphics application to create EGLDisplay
directly over GPU device as enabled by EGLDevice extensions

Fixes #786.
elmindreda added a commit that referenced this pull request Sep 7, 2017
Some minor bitrot had occurred since the patch was made.

Related to #786.
elmindreda added a commit that referenced this pull request Sep 7, 2017
Related to #786.
elmindreda pushed a commit that referenced this pull request Sep 17, 2017
This adds interface to graphics application to create EGLDisplay
directly over GPU device as enabled by EGLDevice extensions

Fixes #786.
elmindreda added a commit that referenced this pull request Sep 17, 2017
Some minor bitrot had occurred since the patch was made.

Related to #786.
elmindreda added a commit that referenced this pull request Sep 17, 2017
Related to #786.
@elmindreda elmindreda mentioned this pull request Oct 17, 2017
6 tasks
@elmindreda elmindreda removed this from the 3.3 milestone Mar 20, 2018
@alecjacobson
Copy link

Is there any plan to integrate this?

@kivutar
Copy link

kivutar commented Mar 5, 2019

Supporting this would have a very positive effect for Raspberry Pi users. Linux distributions like Lakka, Retropie, LudOS and Recallbox could use GLFW and not have to package X11 or weston.
I case you decide to merge it for 3.3, I can participate in testing and maybe help maintaining this platform.

@elmindreda
Copy link
Member

@kivutar I would gladly add this platform if it comes with a maintainer. I did some work with the original PR but it didn't seem to work on the machine I had available. Have you been able to get this PR to run on a current system?

@kivutar
Copy link

kivutar commented Mar 6, 2019

Not yet, I will try it today and tell you the results. We've been using a similar approach in RetroArch for a few years in some of the contexts here https://github.com/libretro/RetroArch/tree/master/gfx/drivers_context
and I've always thought that this abstraction layer shouldn't be kept in our software where it can't benefit other projects. I like to see GLFW going this way.

@kivutar
Copy link

kivutar commented Mar 6, 2019

I had to add the include path for libdrm.
Now I'm stuck on a missing declaration for PFNEGLSTREAMCONSUMERACQUIREATTRIBEXTPROC.
Except this last issue, the rest of GLFW compiles fine. Any idea of where is this supposed to be defined?

In case you manage to fix the PFNEGLSTREAMCONSUMERACQUIREATTRIBEXTPROC issue on your side, you will have to launch the examples from one of the TTY, not a terminal emulator.

@elmindreda
Copy link
Member

I ran it from the console of a machine with no X server running. If I recall it failed to initialize or possibly there was a black screen. Tried some unrelated EGLDevice examples and they ran without issue.

See the egldevice branch for my initial attempt. It should have the declarations you need. I don't remember exactly what extension document I got them from.

@kivutar
Copy link

kivutar commented Mar 7, 2019

I'm also getting either Failed to initialize GLFW or Error: EGLDevice: Failed to find required extensions functions on either https://github.com/glfw/glfw/tree/egldevice or this current PR branch.
I have no issues launching other egldevice programs like retroarch.
So I will compare our implementation with this one.

But it looks quite different, as we're using EGL_PLATFORM_GBM_KHR or EGL_PLATFORM_X11_KHR and this PR is targeting EGL_PLATFORM_DEVICE_EXT.

@MadcowD
Copy link

MadcowD commented Oct 31, 2019

I am desperate to have this branch merge into master (it affects a down-stream project greatly!)

Is there anyway I can help get it in a good position?

What are the current blockers in pushing this forward?

@gsibley
Copy link

gsibley commented Jul 16, 2020

Just wanted to vote for this. Would love to see headless rendering without a windowing system.

@Fredrum
Copy link

Fredrum commented Sep 20, 2021

+1 for this!
(If I understand correctly and it allows drm rendering without X11?)

@moroslantia
Copy link

What is the current status of this?

It is mentioned in "New features in version 3.0"

(Experimental) EGL support
GLFW now has an experimental EGL context creation back end that can be selected through CMake options.

What are the supported function and how can they get accessed?

@xiaohuihuige
Copy link

太好了,爱你

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EGL EGL API specific enhancement Feature suggestions and PRs Linux Linux specific (any window system) Nvidia Nvidia GPU specific (any OS or driver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants