Commit Graph
826 Commits
Author SHA1 Message Date
Zachary HarroldandConnor Fitzgerald f04391d916 [naga]: Add no_std polyfill for round_ties_even for f32 and f64 (#7585)
* Rely on `libm` for a `no_std` alternative to `round_ties_even`

Update comments around `no_std` CI task

* Update Cargo.toml

* Feedback

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-05-08 09:59:19 -04:00
Andy Leiserson 2a924a330a [naga] Ensure test functions in glsl snapshots are reachable from the entry point (#7672) 2025-05-07 15:39:10 -04:00
Zachary HarroldandConnor Fitzgerald 285fa48cec [naga]: Switch off of LazyLock to once_cell::racy::OnceBox (#7587)
* Switch off of `LazyLock` to a custom `RacyLock`

* Formatting

* Switch to `OnceBox` internally

* Clippy

* Simplify `trunc` usage

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Switch to `expect`

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Fix expectation conditions

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Update documentation

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-04-30 11:12:04 -04:00
Andy Leiserson 850c3d4310 [naga] Write only the current entrypoint (#7626)
Changes the MSL and HLSL backends to support writing only a single entry
point, and uses them that way in wgpu-hal.

This is working towards a fix for #5885.

* Increase the limit in test_stack_size
2025-04-30 09:59:41 +02:00
Robert Bamler bb83976ddb Optimize dot4{I, U}8Packed for all spv versions
Emit optimized code for `dot4{I, U}8Packed` regardless of SPIR-V version
as long as the required capabilities are available. On SPIR-V < 1.6,
require the extension "SPV_KHR_integer_dot_product" for this. On
SPIR-V >= 1.6, don't require the extension because the corresponding
capabilities are part of SPIR-V >= 1.6 proper.
2025-04-28 16:37:45 +02:00
Robert Bamler 065d6546c4 Check for spv language version
When checking for capabilities in SPIR-V,
`capabilities_available == None` indicates that all capabilities are
available. However, some capabilities are not even defined for all
language versions, so we still need to check if the requested
capabilities even exist in the language version we're using.
2025-04-28 16:37:45 +02:00
Robert Bamler 5b20979e9b Use intrinsics for dot4{I, U}8Packed on spv 2025-04-28 16:37:45 +02:00
Robert Bamler fe05765602 Use intrinsics for dot4{I, U}8Packed in HLSL 2025-04-28 16:37:45 +02:00
Connor Fitzgerald 9c32742dbe Move xtask dependencies into Cargo.toml 2025-04-27 18:34:52 +02:00
Connor Fitzgerald eb4a2b77d7 Bring xtasks back into workspace 2025-04-27 18:34:52 +02:00
Connor Fitzgerald 8235cd2932 Use no_main to allow xtasks to compile on wasm 2025-04-27 18:34:52 +02:00
Connor Fitzgerald fa702f9141 Move everything to workspace dependencies 2025-04-27 18:34:52 +02:00
Wouter de Bruijnandteoxoy 30b247a8d1 [naga glsl-out] Differentiate between support for std140 and std430 (#7579)
* [naga glsl-out] Differentiate between support for `std140` and `std430` layout, and emit `std140` in Uniforms when possible

* [naga glsl-out] Remove storage buffer std140 layout fallback, and error when we are unable to assign an explicit memory layout for uniform and storage globals

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>

---------

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2025-04-26 13:55:02 +02:00
Kevin Reid 9727e75ad7 Update Cargo.toml to direct-minimal-versions consistency. 2025-04-25 14:40:12 -04:00
renovate[bot] 5f3f7028fc chore(deps): update cargo.lock (#7635)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-25 14:53:30 +00:00
Jim Blandy 5bc3c9da3c [naga] Constrain textureLoad array index args to i32 or u32.
In `naga::valid::expression`, require that
`Expression::ImageLoad::array_index` be either `i32` or `u32`, not
just an integral type of any size.
2025-04-24 13:45:12 -07:00
Jim Blandy 7c5f705580 [naga] Allow textureLoad's sample index arg to be unsigned.
Permit the `sample_index` argument of `textureLoad` overloads to be
either `i32` or `u32`.
2025-04-24 13:45:12 -07:00
renovate[bot] 1d6c1d020c Update Rust crate which to v7 (#7619)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-23 22:00:17 +00:00
renovate[bot] 3727b67253 Update Rust crate env_logger to 0.11.0 (#7609)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-23 21:38:52 +00:00
renovate[bot] 20d5da7e07 Update Minor Updates (#7607)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-23 20:59:26 +00:00
Zachary Harrold 35f131ff10 Remove default features from petgraph (#7591) 2025-04-23 03:30:36 +00:00
Zachary Harrold c809aefb8d Allow serialize and deserialize in Naga no_std (#7590) 2025-04-22 11:07:35 -04:00
Jim Blandy 5573c57393 [naga wgsl-in] Properly convert arguments to atomic operations. (#7573) 2025-04-21 12:27:02 -04:00
Zachary Harrold f79cf6ed23 Remove indexmap/std from wgsl-in (#7586) 2025-04-21 10:57:01 -04:00
Phena Ildanach d2ab981a76 [naga spv-in] Update supported capabilities list (#7575) 2025-04-18 21:26:45 +00:00
bf8cc43a15 Add stderr and termcolor features to Naga (#7482)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2025-04-18 21:06:22 +00:00
Jim Blandy a9a3ea3a41 [naga wgsl-in] Convert textureStore values correctly.
Apply necessary automatic conversions to the `value` argument of
`textureStore`.
2025-04-18 12:56:51 -07:00
Jim Blandy de1b9a0899 [naga] Reduce indentation in ImageLoad expression validation.
In `naga::valid::expression::validate_expression`, use a let-else
statement so that the outermost control flow follows the success path,
and errors are close to the conditions that trigger them.
2025-04-18 12:56:51 -07:00
Jim Blandy 5304c3ca4a [naga wgsl-in] Apply automatic conversions to sampling arguments.
Properly apply WGSL's automatic conversions to the arguments
to texture sampling functions.

Introduce helper function `Lowerer::expression_with_leaf_scalar`.

Although this can't affect behavior, use
`Lowerer::expression_for_abstract` for the `image` and `sampler`
arguments, simply because we want to move away from
`Lower::expression`'s automatic concretization, and move towards
having callers say explicitly what sort of conversions they need.

Although this can't affect behavior, use
`Lowerer::expression_with_leaf_scalar` for the `offset` argument, so
that the code spells out that this requires an `i32` value, rather
than depending on blind concretization giving it that.

Continue to use `Lowerer::expression` for `gather` and `array_index`,
since those happen to behave correctly with blind concretization, and
can be cleaned up later.

Fixes #7427.
2025-04-18 11:56:34 -07:00
Jim Blandy 6cd6561884 [naga wgsl-in] Minor cleanup to Lowerer::texture_sample_helper.
Use deferred initialization instead of building tuples, so that match
arms can provide values by name, not by position within a tuple.
2025-04-18 11:56:34 -07:00
Erich Gubler c7330a8b49 style(naga): add whitespace b/w items in naga::error (#7558) 2025-04-17 00:47:33 -04:00
Erich Gubler 65c06c2b21 feat(naga): add pack4x{I,U}8Clamp built-ins 2025-04-16 15:07:11 -04:00
Erich Gubler 2aa8a830fb refactor(msl-out): Pack4x{I,U}8: make was_signed use `matches!(…) 2025-04-16 15:07:11 -04:00
Erich Gubler 97c30046bc refactor(glsl-out): Pack4x{I,U}8: make was_signed use `matches!(…) 2025-04-16 15:07:11 -04:00
Erich Gubler bb12f6287f refactor(naga): factor out write_arg 2025-04-16 15:07:11 -04:00
Jim Blandy fd4eb67877 [naga wgsl-in] Try out new use convention.
Change `naga::front::wgsl::lower` to `use` `ir` and `proc`,
and then qualify identifiers with that instead of `crate`.

This is strictly fiddling with `use` directives and name
qualification, with the concomitant formatting changes; there should
be no change to the module's behavior or meaning.
2025-04-16 08:25:14 -07:00
bernhlandErich Gubler 06ee718ddd [naga] Allow Scalar for MathFunction::Distance (#7530)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2025-04-16 08:24:32 -07:00
Andy Leiserson 09178f2400 [naga] Track globals used directly by a named expression (#7540) 2025-04-15 15:01:19 -04:00
Teodor Tanasoaia ffc920b9ae [hlsl-out] error on unimplemented non-struct push constants (#7545) 2025-04-15 17:12:28 +00:00
Teodor Tanasoaia 3805768cb4 [naga] mark readonly_and_readwrite_storage_textures & packed_4x8_integer_dot_product language extensions as implemented (#7543) 2025-04-15 09:30:56 -04:00
Jim Blandy 936aa4d9dc [naga xtask] Update Cargo.lock. (#7522) 2025-04-11 17:55:42 -04:00
Connor Fitzgerald e45013645f [naga] Use racy::OnceBox for Namer::default (#7517) 2025-04-11 14:12:25 -04:00
Robert Bamler 7a66927460 Const eval of dot4I8Packed and dot4U8Packed
Prompted by rebasing on #7487.
2025-04-11 13:32:10 +02:00
Robert Bamler c7d0af156d Implement dot4I8Packed and dot4U8Packed
Closes #7481.

This implementation roughly follows approach 2 outlined in #7481, i.e.,
it adds a polyfill for the signed and unsigned dot product of packed
vectors for each platform. It doesn't use the specialized instructions
that are available for this operation on SPIR-V (with capability
DotProductInput4x8BitPacked).
2025-04-11 13:32:10 +02:00
Vecvec 65c56fdee4 [spv-out] Prevent ray intersection functions overwriting each other. (#7497) 2025-04-11 11:18:45 +02:00
Jim Blandy 22c4033cb3 [naga] Properly evaluate abs(most negative abstract int).
Have constant evaluator use `wrapping_abs` instead of `abs` when
applying `MathFunction::Abs` to AbstractInt values. WGSL says that
applying `abs` to the most negative AbstractInt value must return it
unchanged, which is what Rust's `i64::wrapping_abs` does.
2025-04-10 22:59:22 -04:00
Connor Fitzgerald 45d8f42513 Use workspace package information everywhere 2025-04-10 20:41:28 -04:00
Andy Leiserson 2a2c851c40 [naga] Two structs with the same members are not equivalent
Fixes #5796
2025-04-10 19:11:56 +02:00
Andy Leiserson 19429a1dc9 [naga] Refactor BlockContext type resolution methods
Change `resolve_type` and `resolve_type_impl` to return
`TypeResolution`s. Add a new method `resolve_type_inner` that returns a
`TypeInner` (i.e. what `resolve_type` used to do).
2025-04-10 19:11:56 +02:00
Andy Leiserson 14b5838a00 [naga] Rename TypeInner::equivalent to non_struct_equivalent 2025-04-10 19:11:56 +02:00