-
Notifications
You must be signed in to change notification settings - Fork 2
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
naga-oil
directive evaluation
#38
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
...theoretically, at least. Not really sure how to test this.
e30786b
to
f737724
Compare
dae2234
to
8703bfb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update significantly expands support for
naga-oil
modules.The language server now accepts a
preprocessor
key, with this interface:An example configuration looks like this:
When WGSL documents are processed, conditional directives like the following are parsed and evaluated using the provided configuration:
Conditional branches that evaluate to
false
are marked inactive (withDiagnosticTag.Unnecessary
) and removed from the input that's passed to the WGSL parser, along with all lines containing conditional directives.Additionally, shader-def interpolations like the following are replaced with their configured values, with a helpful diagnostic if the server couldn't find a definition for the identifier:
Hovering over the
#{PER_OBJECT_BUFFER_BATCH_SIZE}
range in the editor displays a tooltip like the following, reflecting the value provided in the LSP configuration:Additionally, in-source
#define
statements like the example above are handled by the pre-parser in the same way.Remaining Work
This update does not make any changes to the handling of module imports — while the server still provides features like hover tooltips, go-to-definition and reference lookups for imported/exported symbols, these elements are not yet expanded to valid WGSL source code before passing to the Naga validator, so Naga will still emit a parse error and exit early in any modules that include a
#define_import_path
or#import
statement.