Skip to content
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

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

armansito
Copy link
Collaborator

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.

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.
Copy link
Member

@DJMcNab DJMcNab left a 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)
Copy link
Member

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
Copy link
Member

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?

Copy link
Collaborator Author

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.

@armansito
Copy link
Collaborator Author

Seems like a big pile of hacks, but also seems reasonable enough

Indeed, though hopefully we can remove it before long.

@armansito armansito enabled auto-merge April 19, 2024 16:40
@armansito armansito added this pull request to the merge queue Apr 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Apr 19, 2024
@armansito armansito added this pull request to the merge queue Apr 19, 2024
Merged via the queue into main with commit 6c1e8b8 Apr 19, 2024
15 checks passed
@armansito armansito deleted the enable-directive branch April 19, 2024 19:21
@waywardmonkeys waywardmonkeys added this to the Vello 0.2 release milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants