Skip to content

Switch to wgpu as default backend of eframe? #5889

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

Open
emilk opened this issue Apr 8, 2025 · 0 comments
Open

Switch to wgpu as default backend of eframe? #5889

emilk opened this issue Apr 8, 2025 · 0 comments

Comments

@emilk
Copy link
Owner

emilk commented Apr 8, 2025

Summary

I'd like to switch the default backend of eframe from glow to wgpu, making glow opt-in.

Background

eframe currently has two backends: glow and wgpu (pronounced "wiggipu").

glow is lightweight (few dependencies, compiles quickly), and wgpu is powerful (allows integrating more advanced 3D rendering alongside egui).

Having two backends is annoying for several reasons:

  • Duplicated code
  • Duplicated maintenance burden
  • We're spreading our resources

The last point in particular is what I want to address with this issue.

Why wgpu?

The broader graphics and GUI community is converging on wgpu as the standard graphics library for Rust. Bug fixes and improvements to wgpu makes everyones lives better.

Switching over to wgpu can also become a forcing function to improve the wgpu backend. For instance, if switching to wgpu increases the .wasm binary size, maybe that will motivate someone to fix it.

Worries with using wgpu as the backend

Increased compile times

This one sucks. I like light-weight crates, but it is hard to be light-weight and also powerful. We should measure and see how much worse it gets.

Increased wasm binary

wgpu shaders are written in WGSL (pronounces "wixel") and then transpiled to GLSL (never pronounced) when targetting the WebGL backend. This transpiling is done with naga. Naga is a chonky beast, because it has to be able to transpile any shader. This means the wasm binary size increases a lot.

I see two primary remedies:

  • Pre-compile the egui shaders to glsl so we don't need to ship naga
  • Only target WebGPU (no tranpilation needed)

WebGPU support is not yet universal, but its getting there: https://caniuse.com/webgpu

@emilk emilk added this to egui Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant