gfx-rs / wgpu

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

Render To Texture Example Panics on WebGL #4266

Open LennyPhoenix opened 11 months ago

LennyPhoenix commented 11 months ago

Description Attempting to run the render-to-texture example using WebGPU seems to panic on the client-side:

localhost-1697667788390.log

It appears that the returned adapter is None.

Repro steps Clone the repo on the trunk branch, then run cargo xtask run-wasm --bin render-to-texture.

Expected vs observed behavior Adapter to not be None, and example to run.

Extra materials image

image

Platform Arch Linux, Rust v1.70.0

cwfitzgerald commented 11 months ago

This appears to be an issue with your WebGPU implementation. Note the warning "failed to create WebGPU context provider". WebGPU isn't supported on linux on chrome yet, so if you want to run the examples, you need to run them with --features webgl

LennyPhoenix commented 11 months ago

I'm getting the same error even with --features webgl: (cargo xtask run-wasm --bin render-to-texture --features webgl) image

cwfitzgerald commented 11 months ago

Ah fun, alright :)

cwfitzgerald commented 11 months ago

Could you check to make sure https://webglreport.com/?v=2 reports no problem with webgl2?

LennyPhoenix commented 11 months ago

Seems happy: image

cwfitzgerald commented 11 months ago

Oh, the reason is that render-to-texture only works with WebGPU right now.

LennyPhoenix commented 11 months ago

I see, so is there no way to get an adapter with compatible_surface set to None on linux?

Merlin-Brandt commented 11 months ago

Same issue here on Linux Mint 21.2 and Chrome 117.0.5938.132.

cwfitzgerald commented 11 months ago

On WebGL2, we need to get the WebGL2RenderingContext from a canvas, so you need to register a canvas surface with us before you enumerate adapters so we have a WebGL2RenderingContext to pull from.

This example does not do this, so only works on WebGPU.

LennyPhoenix commented 11 months ago

Makes sense, I can confirm that after enabling experimental WebGPU support (brave --enable-unsafe-webgpu --enable-features=Vulkan,UseSkiaRenderer) the example works fine.

zetanumbers commented 4 months ago

I have modified render_to_texture example and it works fine with WebGL. I had to pretty much just lower required limits and use a canvas for the adapter request.