Commit Graph
809 Commits
Author SHA1 Message Date
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
Connor Fitzgerald 8c2c2ce203 Release v25 (#7505) 2025-04-10 16:13:02 +00:00
Jamie Nicol 08d3bb5196 [naga msl-out hlsl-out] Ensure wrapper functions for integer division and modulo avoid using minimum value literals
As we know that minimum value integer literals can cause problems for
some compilers. (See #7437)

Make the code which generates these functions call
msl::Writer::put_literal() and hlsl::Writer::write_literal()
respectively to output the minimum value integer literals instead of
just writing them directly, ensuring we only have to handle this
workaround in a single location (per backend).
2025-04-10 10:36:27 -04:00
Jamie Nicol 6dc3b7186c [naga hlsl-out] Emit most-negative integer value literals as 2nd-most-negative value minus one
As we did for MSL in #7437. eg `-2147483648` becomes `-2147483647 - 1`.

Neither FXC nor DXC currently have any issues parsing the most negative
value literals. However, we have been informed this is not guaranteed to
always be the case, so are making this change as a precaution.
2025-04-10 10:36:27 -04:00
Andy LeisersonandErich Gubler a0dbe5ebc6 refactor(msl-out): create a type for bounds check iter items
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-04-09 18:45:27 -04:00
Andy Leiserson a7afb56276 [msl-out] Fix ReadZeroSkipWrite bounds check mode for pointer arguments
Fixes #4541

--
Co-authored-by: Liam Murphy <liampm32@gmail.com>
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-04-09 18:45:27 -04:00
Andy Leiserson 7cf3e2f3cc refactor(msl-out): extract puts_local helper
--
Co-authored-by: Liam Murphy <liampm32@gmail.com>
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-04-09 18:45:27 -04:00
Andy Leiserson dbb36cc556 chore(msl-out): remove TRACE-level logging of expressions 2025-04-09 18:45:27 -04:00
Andy Leiserson e03c55b236 docs(msl-out): add missing docs. for msl::Writer::access_needs_check
--
Co-authored-by: Liam Murphy <liampm32@gmail.com>
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-04-09 18:45:27 -04:00
Andy Leiserson fc9c8bfba7 refactor(msl-out): add NamedKeyExt trait with local helper method
--
Co-authored-by: Liam Murphy <liampm32@gmail.com>
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-04-09 18:45:27 -04:00
Andy Leiserson 587aea2da6 refactor(msl-out): extract bounds_check_iter helper
--
Co-authored-by: Liam Murphy <liampm32@gmail.com>
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-04-09 18:45:27 -04:00
Jim Blandy aad187f52f [naga wgsl] New TypeContext method write_unnamed_struct.
When asked to generate WGSL for `TypeInner::Struct`, rather than
unconditionally calling `unreachable!`, defer to a new `TypeContext`
method, `write_unnamed_struct`.

Provide appropriate `write_unnamed_struct` implementations:

- In the WGSL backend, implement this as `unreachable!`, since the WGSL
  backend should always know the proper name to use for a struct.

- For diagnostic messages, generate something human-readable that
  indicates that some struct type was encountered.

- For logging and debugging, defer to `TypeInner`'s `Debug`
  implementation.
2025-04-09 16:48:49 -04:00
Jim Blandy 25f03960e1 [naga] Delete DiagnosticDisplay impl for for TypeInner.
Delete the implementation of `core::fmt::Display` for
`naga::common::DiagnosticDisplay`, as it is a footgun wherever
`Struct` types can arise.

Document that it should not be implemented for `TypeInner`.

Although it is possible to put a dummy implementation in the way of
people adding real implementations, that would also turn attempts to
use it into dynamic errors rather than compile-time errors. Make do
with a comment for now.
2025-04-09 16:48:49 -04:00
Jim Blandy 6150576a77 [naga] Use TypeContext::write_type_resolution where appropriate.
Simplify the implementation of `Display` for
`DiagnosticDisplay<(TypeResolution, GlobalCtx)>` by calling
`GlobalCtx`'s implementation of `write_type_resolution` directly,
rather than duplicating its code. Provide a fallback for non-wgsl
builds.
2025-04-09 16:48:49 -04:00
Jim Blandy 7f08498069 [naga wgsl-out] Stop using TypeContext::write_type_inner.
In `naga::back::wgsl`, prefer `TypeContext::write_type_resolution`
over `write_type_inner`, since the former is actually what we need,
and the latter can be troublesome if asked to write a `struct` type.
2025-04-09 16:48:49 -04:00
Jim Blandy dd60ce30e4 [naga] Remove TypeContext::type_inner_to_string.
In `naga::common::wgsl`, delete the method
`TypeContext::type_inner_to_string`, since it's a footgun: anyone
trying to convert a `TypeInner::Struct` to a string will hit
"unreachable" code.
2025-04-09 16:48:49 -04:00
Jim Blandy e3b005ea82 [naga wgsl-in] Avoid crashes when logging types.
In `naga::front::wgsl::lower`, change logging in
`ExpressionContext::automatic_conversion_consensus` to use
`TypeResolution`s instead of `TypeInner`s, so that structs don't cause
a crash.
2025-04-09 16:48:49 -04:00
Jim Blandy 59db4a6d62 [naga wgsl-in] Don't panic printing struct types for initializers.
When an initializer has the wrong type and it's a struct, don't panic
trying to format its type for the error message.
2025-04-09 16:48:49 -04:00