-
Notifications
You must be signed in to change notification settings - Fork 142
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
[shaders] Support "enable" via post-process directive #550
Conversation
The WGSL source currently cannot contain the "enable" directive as naga doesn't support it (see gfx-rs/wgpu#5476). This patch works around this limitation by introducing the "#enable" post-process directive. Lines that start with "#enable" get turned into an inline comment during the pre-process stage and converted to a standard "enable" directive following the intermediate module compilation step. This allows us to pass the WGSL shaders with enable directives on to other WebGPU implementations.
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.
Seems like a big pile of hacks, but also seems reasonable enough
@@ -142,6 +144,11 @@ pub fn preprocess(input: &str, defines: &HashSet<String>, imports: &HashMap<&str | |||
} | |||
continue; | |||
} | |||
"enable" => { | |||
// Ignore post-process directive. This is only supported by the shaders crate | |||
// (see #467) |
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.
Linking to #467
So that this can be seen as a backlink on that issue
shader/fine.wgsl
Outdated
@@ -7,6 +7,12 @@ | |||
// To enable multisampled rendering, turn on both the msaa ifdef and one of msaa8 | |||
// or msaa16. | |||
|
|||
#ifdef r8 | |||
// The R8 variant is only available via an internal extension in Dawn |
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.
Might be worth making even clearer that it's not exposed to the web?
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. Changed this to say "Dawn native", which should be clear enough.
Indeed, though hopefully we can remove it before long. |
The WGSL source currently cannot contain the "enable" directive as naga doesn't support it (see gfx-rs/wgpu#5476). This patch introduces the "#enable" post-process directive to work around this limitation.
Lines that start with "#enable" get turned into an inline comment during the pre-process stage and converted to a standard "enable" directive following the intermediate module compilation step. This allows us to pass the WGSL shaders with enable directives on to other WebGPU implementations.