-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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 size (+2.4 MiB)
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
Quick test:
./scripts/build_demo_web.sh --release
-> 5.9 MiB./scripts/build_demo_web.sh --release --wgpu
-> 8.3 MiB
Metadata
Metadata
Assignees
Labels
Projects
Status