Skip to content

Add extra EGL extensions#1668

Merged
kchibisov merged 1 commit into
rust-windowing:masterfrom
chrisduerr:more_egl
Jun 6, 2024
Merged

Add extra EGL extensions#1668
kchibisov merged 1 commit into
rust-windowing:masterfrom
chrisduerr:more_egl

Conversation

@chrisduerr

Copy link
Copy Markdown
Contributor

This patch adds multiple new EGL extensions which are useful for
implementing Wayland applications. These have been mostly implemented
manually, since gl_generator lacks support for these newer EGL
extensions (except for EGL_KHR_image_base).

The following extensions were added:

  • EGL_KHR_image_base
  • EGL_WL_bind_wayland_display
  • EGL_WL_create_wayland_buffer_from_image

Currently this PR doesn't really implement a good way to access this new functionality, instead it just exposes the EGL static publicly. Ideally there would be some abstraction that retrieves the Egl object, while automatically making sure it is initialized.

So I see two options, feedback appreciated:

  • Expose method that basically just does EGL.as_ref()? (does not ensure initialization)
  • Add method to Display (requires display creation)

@MarijnS95

Copy link
Copy Markdown
Member

Fwiw for #1658 I'd also like to use updated EGL bindings from gl_generator, which is very trivial to achieve: rust-windowing/gl-rs#546

Unfortunately it seems that efforts to transition ownership of gl-rs (which is still an important cornerstone in the Rust ecosystem) have stalled: rust-windowing/gl-rs#524

@kchibisov

Copy link
Copy Markdown
Member

I'm not sure how we should expose the ref to EGL and similar types, since we should have it for all the platforms where we use loader (so, except macOS).

Maybe we should have a method to manually load(which will return Option) and just a method to get a &'static Egl from the Display(this will always work)? And the manual loading will be present only for EGL, because the rest is a bit special and shouldn't be used anyway in the context of device extensions.

I'm also interested in solving the generator issue upstream, but I'll see what we can do

@chrisduerr

Copy link
Copy Markdown
Contributor Author

I added some functions to access the APIs for EGL and GLX. This works for my usecase at least, so maybe that's enough to just merge it?

Let me know if you want a cleaner/more elaborate solution.

@kchibisov kchibisov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do with wgl...

Comment thread glutin/src/api/egl/mod.rs
Comment thread glutin/src/api/egl/mod.rs Outdated
Comment thread glutin/src/display.rs Outdated
Comment thread glutin_egl_sys/src/egl.rs
This patch adds multiple new EGL extensions which are useful for
implementing Wayland applications. These have been mostly implemented
manually, since gl_generator lacks support for these newer EGL
extensions (except for `EGL_KHR_image_base`).

The following extensions were added:
 - EGL_KHR_image_base
 - EGL_WL_bind_wayland_display
 - EGL_WL_create_wayland_buffer_from_image

This also exposes EGL and GLX raw API calls on EGL and GLX displays.
@kchibisov
kchibisov merged commit 6af4c60 into rust-windowing:master Jun 6, 2024
Comment thread glutin_egl_sys/src/egl.rs
pub const TEXTURE_Y_XUXV_WL: i32 = 0x31D9;
pub const TEXTURE_EXTERNAL_WL: i32 = 0x31DA;
// Accepted in the <attribute> parameter of eglQueryWaylandBufferWL.
pub const EGL_TEXTURE_FORMAT: i32 = 0x3080;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarijnS95

Copy link
Copy Markdown
Member

For completeness, since I mentioned updating EGL headers in gl-generator above, here's a branch showcasing that everything is still there when generated with a newer generator:

https://github.com/MarijnS95/glutin/compare/gl-generator-update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants