-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm32: non-spirv shader specialization #843
Conversation
The one thing: maybe we should change |
stage: self.stage, | ||
} | ||
} | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
pub fn get_spirv_shader(&self, macros: Option<&[String]>) -> Shader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(where i think we would use the other variant of this function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or delegate this to RenderResourceContext too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that seems reasonable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
# endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ab76efd
to
38d93aa
Compare
It implements shader specialization for
wasm32
(where spirv is not available), by adding preprocessor's #define statements to shader source.