-
Notifications
You must be signed in to change notification settings - Fork 952
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
EGL BadDisplay when using Wayland #5505
Comments
I'm getting a similar issue.
|
Okay I THINK I have acquired the arcane knowledge of what I got it working, but I have committed some very cursed crimes in the process. Essentially the problem is exactly what the error is saying: By "special unsafe debugging tricks" I mean I stored the display handle in a static beforehand, to be able to access it there. Obviously, a proper solution remains to be found. I also tried modifying Sooo... I'm thinking the play might be to delay |
I'm sure this must be obvious to most, but I got the examples working with: I'm on Asahi Linux (ie ARM64 and no Vulkan support) and just wanted to see the examples running, even though they're merely being emulated on the CPU ( My own wpgu project works fine using OpenGL, it's just the majority of the examples that seem to have a problem. |
Bump ^^ Same issue
|
@MarijnS95 I don't want to distract you from the good work you're doing with #6152 and related topics, but: do you have any idea how we could make progress on this? Is this just an upstream winit problem that we can't do anything about? |
@jimblandy I can surely take a look and comment on the implementation, when booted back into Linux in the coming days. It sounds like @Friz64 already grasped the problem in that passing I did run |
Theoretically On a side-note, it's equally strange that All in all it looks like To whomever is planning to fix these bugs, I recommend starting by deleting the entire EDIT: Just above the hack there's a call to |
Accessing the raw texture for sharing via DMA-BUF would still be possible after rewriting the Some poc code for what I am using itpub fn export_to_opengl_texture(texture: &Texture) -> Option<NativeTexture> {
let mut native_texture: Option<NativeTexture> = None;
unsafe {
texture.as_hal::<hal::api::Gles, _, _>(|hal_texture| {
if let Some(hal_texture) = hal_texture {
if let wgpu_hal::gles::TextureInner::Texture { raw, target: _target } = hal_texture.inner {
native_texture = Some(raw);
}
}
});
}
return native_texture;
} pub fn export_to_dma_buf(adapter: &wgpu::Adapter, native_texture: NativeTexture, width: u32, height: u32) -> (TextureStorageMetadata, RawFd) {
unsafe {
adapter.as_hal::<hal::api::Gles, _, _>(|hal_adapter| {
match hal_adapter {
Some(adapter) => {
let raw_display = adapter.adapter_context().raw_display().unwrap().as_ptr();
let raw_context = adapter.adapter_context().raw_context();
let egl_instance = adapter.adapter_context().egl_instance().unwrap();
let fn_egl_create_image_khr = egl_instance.get_proc_address("eglCreateImageKHR");
let egl_create_image_khr = fn_egl_create_image_khr.expect("eglCreateImageKHR not present!");
let egl_function = std::mem::transmute_copy::<_, PFNEGLCREATEIMAGEKHRPROC>(&egl_create_image_khr);
let egl_image_khr: EGLImageKHR = (egl_function.unwrap())(
raw_display,
raw_context,
EGL_GL_TEXTURE_2D_KHR,
native_texture.0.get() as EGLClientBuffer,
std::ptr::null()
);
assert!(!egl_image_khr.is_null(), "eglCreateImageKHR failed");
... |
@BartBM the Depending on what your needs are, DMA-BUF sharing is also possible with Vulkan. Note that your repository appears to be private, I cannot access it. |
@MarijnS95 yes rewriting it is what I meant. Slint only supports displaying textures via GL, not Vulkan: https://releases.slint.dev/1.7.0/docs/rust/slint/struct.borrowedopengltexturebuilder that's why I was asking.. The other option is copying data via a |
I'm not sure if this is helpful, but for context some of the original workarounds were attempting to support surfaceless/headless GL contexts for initial queries, then being able to optionally associate the context with a surface afterwards through whatever context-specific APIs were available for that platform (e.g., context sharing). The implementation may have drifted over time but that was the original intent at least. glutin and surfman didn't support this use case at the time, so wgpu would have needed a separate API for GL to fit glutin's API. Maybe glutin supports this now though? Some other background: |
@BartBM it doesn't look like that relies on DMA-BUF (otherwise they should take file descriptors and DRM modifiers?), but instead uses the given texture as a render target when Slint renders its output using OpenGL? Note that its safety constraints - which describe soundness when other safe-to-call functions are called, or callbacks are invoked - are exactly the ones that @ErichDonGubler shot down in #6152 (comment) / #6211 🤭 @grovesNL Thanks for that backstory, yeah it seems quite common to create a dummy window or surface to get this done. New Specifically on EGL, this might be tricky if the select EDIT: Being all honest, I'm still completely oblivious to |
@MarijnS95 The |
It's similar to the kind of information you'd get during Vulkan initialization so you can select which device to use, e.g., driver information, features, limits (https://docs.rs/wgpu-hal/22.0.0/wgpu_hal/struct.ExposedAdapter.html) |
@BartBM thanks for making the repository public so that we can have a look. Going through DMA-BUF is quite extensive and may only be necessary for interop between APIs and/or when transferring resources across process boundaries. If all you need is sharing resources between two GL contexts inside the same process (especially This is currently not at all possible with @grovesNL thanks for the link - preliminary reading shows that there's no |
Description
When running any example on Wayland using
WGPU_BACKEND=gl
it crashes with:Repro steps
WGPU_BACKEND=gl cargo run --bin wgpu-examples
Expected vs observed behavior
Running like it does on GL/Vulkan on X11 and Vulkan onWayland
Extra materials
backtrace.txt
Platform
The text was updated successfully, but these errors were encountered: