wasm32: non-spirv shader specialization#843
Conversation
|
The one thing: maybe we should change |
| } | ||
|
|
||
| #[cfg(target_arch = "wasm32")] | ||
| pub fn get_spirv_shader(&self, macros: Option<&[String]>) -> Shader { |
There was a problem hiding this comment.
I'd like to future-proof this for an eventual WebGPU backend if possible. I don't want to conflate "wasm" with "webgl"
There was a problem hiding this comment.
(where i think we would use the other variant of this function)
There was a problem hiding this comment.
Yes, I also don't like these target_arch = "wasm32" checks here. Maybe we should check presence of some spirv feature or so?
There was a problem hiding this comment.
or delegate this to RenderResourceContext too?
There was a problem hiding this comment.
done - shader specialization delegated to RenderResourceContext.get_specialized_shader
64b3c31 to
434a3e6
Compare
| let macros: Vec<String> = macros | ||
| .unwrap_or(&[]) | ||
| .iter() | ||
| .chain((&["WGPU".to_string()]).iter()) |
There was a problem hiding this comment.
i think id prefer to not insert shader defs for backends (as that encourages writing shaders that are backend-specific). if you need to do that for WebGL backend shaders, could you instead use something like:
# ifdef WEBGL
// do webgl things
# endif
# ifndef WEBGL
// do default bevy things
# endifab76efd to
38d93aa
Compare
It implements shader specialization for
wasm32(where spirv is not available), by adding preprocessor's #define statements to shader source.