Skip to content
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

Create WGPU widget similar to Gtk.GLArea #1278

Open
nixigaj opened this issue Jan 23, 2023 · 6 comments
Open

Create WGPU widget similar to Gtk.GLArea #1278

nixigaj opened this issue Jan 23, 2023 · 6 comments
Labels
enhancement New feature or request gtk help wanted Extra attention is needed

Comments

@nixigaj
Copy link

nixigaj commented Jan 23, 2023

I've been wanting to create a GUI app using WGPU and use GTK for window decorations on Linux/BSD. Using OpenGL this can be done using GLArea covering the entire window with the widget. I have seen requests for this but not seen any implementation.

@nixigaj nixigaj added the enhancement New feature or request label Jan 23, 2023
@sdroege
Copy link
Member

sdroege commented Jan 24, 2023

That's certainly possible but it would probably make sense for this to either a) be just an example in this repo, or b) an external crate that provides such a widget in a general way.

Do you intend to work on this?

@i509VCB
Copy link

i509VCB commented Jan 24, 2023

It would be possible to use the gles backend quite easily for this (wgpu-hal has a way to create an Adapter from a glGetProcAddress like function). But there are limitations with the gles backend and the Vulkan backend would be preferred. However the Vulkan backend would either force gtk to initialize with Vulkan or share memory objects between apis.

For a minimum viable product using the gles backend would be fine, but long term some work will be needed in wgpu (or an auxillary crate) to import memory objects from other apis.

@bilelmoussaoui bilelmoussaoui added help wanted Extra attention is needed gtk labels Jan 30, 2023
@bilelmoussaoui
Copy link
Member

If someone wants to work on this, we could potentially have a crate that has useful "integration" widgets with the rest of the rust ecosystem. See also #1163

@bilelmoussaoui bilelmoussaoui changed the title [FEATURE REQUEST] Create WGPU widget similar to Gtk.GLArea Create WGPU widget similar to Gtk.GLArea Jan 30, 2023
@ThrashAbaddon
Copy link

I'm interested in this for Linux and Windows.

@Doublonmousse
Copy link

Doublonmousse commented Jun 29, 2024

I was thinking that using the gtk webkit would get us some of the way there (even if not necessarily ideal).

Epiphany (gnome's web browser) is using gtk4 as the ui toolkit and some of the demos of wgpu.rs work (only webgl2 though, not WebGPU).

So using WebKitGTK inside a gtk4 app would allow for webgl2-based wgpu applications to run. And maybe WebGPU later if support is added in the future.

@Doublonmousse
Copy link

I think there's a working implementation (at least on the architecture side) here : https://github.com/BartBM/wgpu-dma-buf
that we could adapt for gtk.

What it does is
wgpu -> dma-buf -> glcontext -> slint window
or
wgpu -> dma-buf -> glutin -> winit window
Using dma-buf to go from wgpu to gl.

As gtk 4.14 and gtk-rs 0.9 exposes the dma-buf graphics offloading on linux, it should be possible to make the same thing work on linux with wgpu -> dma-buf -> gtk using the graphics offload feature.

Though that's linux-only for the moment (although it may come to windows in the future : https://gitlab.gnome.org/GNOME/gtk/-/issues/6869)

Maybe it's possible to adapt the other part and do
wgpu -> dma-buf -> glutin -> glcontext (gtk) -> gtk window.

Now there are probably some things to adapt between OS to have this work on all platforms (with or without graphics offload) but it seems doable given that the same trick works with slint and glutin and it doesn't seem like there's too much conceptual difference between these and gtk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gtk help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants