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

[naga] Introduce Scalar type to IR. #4673

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

jimblandy
Copy link
Member

@jimblandy jimblandy commented Nov 13, 2023

Introduce a new struct type, Scalar, combining a ScalarKind and a Bytes width, and use this whenever such pairs of values are passed around.

In particular, use Scalar in TypeInner variants Scalar, Vector, Atomic, and ValuePointer.

Introduce associated Scalar constants I32, U32, F32, BOOL and F64, for common cases.

Introduce a helper function Scalar::float for constructing Float scalars of a given width, for dealing with TypeInner::Matrix, which only supplies the scalar width of its elements, not a kind.

Introduce helper functions on Literal and TypeInner, to produce the Scalar describing elements' values.

Checklist

  • Run cargo clippy.
  • Run cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@jimblandy jimblandy requested a review from a team as a code owner November 13, 2023 00:10
@jimblandy jimblandy requested a review from a team as a code owner November 13, 2023 00:33
@jimblandy jimblandy marked this pull request as draft November 13, 2023 00:44
@jimblandy jimblandy changed the title Introduce Scalar type to IR. Introduce Scalar type to Naga IR. Nov 13, 2023
@jimblandy jimblandy changed the title Introduce Scalar type to Naga IR. [naga] Introduce Scalar type to IR. Nov 13, 2023
@jimblandy jimblandy force-pushed the introduce-scalar-struct branch 2 times, most recently from fb17406 to 8442dfd Compare November 14, 2023 00:48
Introduce a new struct type, `Scalar`, combining a `ScalarKind` and a
`Bytes` width, and use this whenever such pairs of values are passed
around.

In particular, use `Scalar` in `TypeInner` variants `Scalar`, `Vector`,
`Atomic`, and `ValuePointer`.

Introduce associated `Scalar` constants `I32`, `U32`, `F32`, `BOOL`
and `F64`, for common cases.

Introduce a helper function `Scalar::float` for constructing `Float`
scalars of a given width, for dealing with `TypeInner::Matrix`, which
only supplies the scalar width of its elements, not a kind.

Introduce helper functions on `Literal` and `TypeInner`, to produce
the `Scalar` describing elements' values.

Use `Scalar` in `wgpu_core::validation::NumericType` as well.
@jimblandy jimblandy marked this pull request as ready for review November 14, 2023 01:28
@teoxoy teoxoy merged commit 9f91c95 into gfx-rs:trunk Nov 14, 2023
27 checks passed
jimblandy added a commit to jimblandy/wgpu that referenced this pull request Nov 14, 2023
The first argument of the `dot`, `reflect`, `distance`, and `ldexp`
GLSL builtin functions may be either a float or a double, and thus the
argument type registered by `inject_common_builtin` must depend on the
`float_width` argument; it cannot simply be `Scalar::F32`.

Introduced by gfx-rs#4673.
jimblandy added a commit to jimblandy/wgpu that referenced this pull request Nov 15, 2023
The first argument of the `dot`, `reflect`, `distance`, and `ldexp`
GLSL builtin functions may be either a float or a double, and thus the
argument type registered by `inject_common_builtin` must depend on the
`float_width` argument; it cannot simply be `Scalar::F32`.

Introduced by gfx-rs#4673.
jimblandy added a commit that referenced this pull request Nov 15, 2023
The first argument of the `dot`, `reflect`, `distance`, and `ldexp`
GLSL builtin functions may be either a float or a double, and thus the
argument type registered by `inject_common_builtin` must depend on the
`float_width` argument; it cannot simply be `Scalar::F32`.

Introduced by #4673.
@jimblandy jimblandy deleted the introduce-scalar-struct branch December 13, 2023 16:35
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.

2 participants