gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.06k stars 874 forks source link

Tracking issue for documenting platform dependent Surface behavior #3672

Open i509VCB opened 1 year ago

i509VCB commented 1 year ago

There was a matrix discussion a few days related to wezterm using wgpu directly from Wayland (instead of using winit, although nothing really prevents you from making that mistake in winit either). The particular issue there was SurfaceTexture::present submitting a wl_surface.commit message under the hood.

There may be similar issues to this on other platforms as well, so we should document what SurfaceTexture::present and other surface related functions do under the hood for each platform.

When I find some time I will write up the platform dependent stuff around SurfaceTexture::present for Wayland.

I know on macOS wgpu will set a CALayer but I am not familiar with that.

wez commented 1 year ago

Here's the change that fixed wezterm: https://github.com/wez/wezterm/commit/0eeca6c2c52b626fc9d4c9ccf22ee72330e2106a

The summary is: it is important to issue WlSurface::frame prior to calling SurfaceTexture::present, as the present call implicitly submits a commit. If the two are called in the opposite order, the WlSurface::frame is not committed at the right time, leading to lagging/stalling rendering.