komadori / bevy_mod_outline

Apache License 2.0
119 stars 10 forks source link

WebGL Support #2

Closed erictuvesson closed 2 years ago

erictuvesson commented 2 years ago

Getting this exception when running in WASM / WebGL.

Caused by:
    In Device::create_render_pipeline
      note: label = `outline_stencil_pipeline`
    Downlevel flags BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED are required but not supported on the device.
This is not an invalid use of WebGPU: the underlying API or device does not support enough features to be a fully compliant implementation. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to work around this issue, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.

https://docs.rs/wgpu/latest/wgpu/struct.DownlevelFlags.html#associatedconstant.BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED

WebGL doesn’t support this.

komadori commented 2 years ago

I assume this would be fixed by adding #[align(16)] to all the ShaderType structs. I'll have to trying building something for WebGL and see. Ideally, the extra alignment could be optional since recent GPUs running natively don't appear to need it.

komadori commented 2 years ago

Per https://github.com/gfx-rs/wgpu/issues/2832 , this error is actually triggered by the struct definition in the shader, so it needed fixing with alignment annotations there too.

Fixed in 0.2.2.