gfx-rs / wgpu

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

Inconsistent rendering between Web and Native on 0.19 #5468

Open sotrh opened 7 months ago

sotrh commented 7 months ago

Description I'm working on updating my tutorial to 0.19 and I got the native code working, but when I test it out on web SRGB surface textures aren't available and certain examples no longer render as expected.

Native: image

Web: image

Repro steps

Expected vs observed behavior Running the code on web should behave the same as on native, but the web version isn't working.

Extra materials I have some screenshots above

Platform

kpreid commented 7 months ago

… when I test it out on web SRGB surface textures aren't available …

You need to use the srgb format as a view format:

NOTE: Canvas configuration cannot use srgb formats like "bgra8unorm-srgb". Instead, use the non-srgb equivalent ("bgra8unorm"), specify the srgb format in the viewFormats, and use createView() to create a view with an srgb format.

https://www.w3.org/TR/webgpu/#canvas-configuration

sotrh commented 6 months ago

Is there any reason why the code works as expected on native and WebGL?

grovesNL commented 6 months ago

I believe we allow sRGB surfaces on any GL device through emulation (https://github.com/gfx-rs/wgpu/blob/v0.19/wgpu-hal/src/gles/shaders/srgb_present.frag). That was probably before that language existed in the spec though, so maybe we should reconsider it for WebGL for consistency.