wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Render To Texture Example Panics on WebGL

Open LennyPhoenix opened this issue 2 years ago • 11 comments

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

LennyPhoenix avatar Oct 18 '23 22:10 LennyPhoenix

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

cwfitzgerald avatar Oct 18 '23 22:10 cwfitzgerald

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

LennyPhoenix avatar Oct 18 '23 22:10 LennyPhoenix

Ah fun, alright :)

cwfitzgerald avatar Oct 18 '23 22:10 cwfitzgerald

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

cwfitzgerald avatar Oct 18 '23 22:10 cwfitzgerald

Seems happy: image

LennyPhoenix avatar Oct 18 '23 22:10 LennyPhoenix

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

cwfitzgerald avatar Oct 18 '23 23:10 cwfitzgerald

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

LennyPhoenix avatar Oct 19 '23 12:10 LennyPhoenix

Same issue here on Linux Mint 21.2 and Chrome 117.0.5938.132.

Merlin-Brandt avatar Oct 20 '23 17:10 Merlin-Brandt

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.

cwfitzgerald avatar Oct 20 '23 23:10 cwfitzgerald

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

LennyPhoenix avatar Oct 21 '23 20:10 LennyPhoenix

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.

zetanumbers avatar May 11 '24 10:05 zetanumbers