-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[naga wgsl] Add to_wgsl
functions for some Naga IR types.
#7180
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
Conversation
3e875d7
to
27d8268
Compare
I've tried to tidy this up a bit by introducing a trait, and trying to get some mileage out of that in error handling. |
d479b03
to
5498b85
Compare
Sorry for the churn in this non-draft PR. I found a few more things I needed. |
f306a9d
to
5e26ca1
Compare
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've taken too long to feel comfortable blocking this review. I think the new trait
is handy, but have some (non-blocking) concerns with its durability over time.
4c17a35
to
05c8ad7
Compare
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.
Still LGTM! Added a couple of nits again. 😈
05c8ad7
to
76043e8
Compare
Introduce a new variant of `naga::back::wgsl::Error`, `Unsupported`, and let it subsume `UnsupportedMathFunction` and various uses of `Custom`. Introduce a helper function, `Error::unsupported`, for building these errors.
Define new traits in `common::wgsl`, `ToWgsl` and `TryToWgsl`, for getting the WGSL representation of some Naga IR types as `&'static str` values: - `MathFunction` - `BuiltIn` - `Interpolation` - `Sampling` - `StorageFormat` Use these functions in the WGSL backend, taking advantage of `TryToWgsl` to consolidate error reporting.
Move `back::vector_size_str` to `common`, so that front ends can use it too. This commit is code motion and `use` adjustment only, there should be no change in behavior.
Replace `naga::back::wgsl::writer::scalar_kind_str` with a `TryToWgsl` implementation for `Scalar` in `common::wgsl`. Use this where needed in the WGSL backend.
Replace `naga::back::wgsl::writer::image_dimension_str` with a `ToWgsl` implementation for `ImageDimension` in `common::wgsl`. Use this where needed in the WGSL backend.
Move `back::wgsl::address_space_str` to `common::wgsl`, so that the front end can use it too. This commit is code motion and `use` adjustment only; there should be no change in behavior.
76043e8
to
4ecd313
Compare
Add
to_wgsl
functions that return the WGSL representations of the following types as&'static str
values:MathFunction
BuiltIn
Interpolation
Sampling
Use these functions in the WGSL backend.
Also add
to_wgsl_debug
functions that return some legible string for all possible values, not just those that are defined by the WGSL standard.There are other types that it would make sense to do this for, like
ImageDimension
, but these are some of the types I ended up needing for diagnostics and logging in #6833, from which I'm trying to spin them out.