Commit Graph

9200 Commits

Author SHA1 Message Date
Kevin Reid
8a27fabc78
Fix raw-window-handle dependency being too lenient (#7526) 2025-04-12 22:21:57 -04:00
Jim Blandy
936aa4d9dc
[naga xtask] Update Cargo.lock. (#7522) 2025-04-11 17:55:42 -04:00
Connor Fitzgerald
303b0db00e Update release checklist 2025-04-11 15:18:28 -04:00
Connor Fitzgerald
700f235378 Update changelog for 25.0.1
# Conflicts:
#	CHANGELOG.md
2025-04-11 15:18:28 -04:00
Connor Fitzgerald
f1c496523f
[d3d12] Fix bug with committed resource allocation (#7519) 2025-04-11 18:18:43 +00:00
Connor Fitzgerald
e45013645f
[naga] Use racy::OnceBox for Namer::default (#7517) 2025-04-11 14:12:25 -04:00
Connor Fitzgerald
27115f7d57
Add bindless support to changelog (#7516) 2025-04-11 17:39:16 +00: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
e5a2e440b2 Add f16 to changelog 2025-04-10 20:41:28 -04:00
Connor Fitzgerald
47bc85f884 Update release-checklist.md 2025-04-10 20:41:28 -04:00
Connor Fitzgerald
45d8f42513 Use workspace package information everywhere 2025-04-10 20:41:28 -04:00
Bruce Mitchener
dde9422114
Fix build with profiling enabled (#7509) 2025-04-11 00:34:05 +00:00
Bruce Mitchener
fec411cf2d
Remove MaintainBase (#7508) 2025-04-10 15:09:29 -04:00
Bruce Mitchener
3081c4f094
Fix typos (#7510) 2025-04-10 15:09:03 -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
Vecvec
8010203281 Rework acceleration structure build tracking. 2025-04-09 22:27:04 -04:00
Vecvec
382a1e3c9b Make submission index lockable. 2025-04-09 22:27:04 -04:00
Christian Legnitto
09a641bdf4
Fix include_spirv_raw macro (#7503) 2025-04-09 20:56:22 -04:00
Andy Leiserson
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:🔙: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
Jim Blandy
2f7698d390 [naga wgsl-in] Don't panic printing struct types for conversions.
When a type conversion expression is ill-formed and the operand is a
struct type, don't panic trying to format the operand's type for the
error message.
2025-04-09 16:48:49 -04:00
Jim Blandy
b837db37ad [naga wgsl-in] Handle struct types in error messages properly.
Don't try to use `&TypeInner` values to generate error messages, since
`&TypeInner` cannot represent struct types in WGSL - they must be
referred to by name, and only `Type` knows the type's name. Using
`Handle<Type>` or `TypeResolution` works fine, so use that instead.

Add a new `Display` impl for `DiagnosticDisplay` for `TypeResolution`.

Fixes #7495.
2025-04-09 16:48:49 -04:00
Vecvec
1c4b73c098
Implement as_hal for BLASes and TLASes (#7303) 2025-04-09 14:50:43 -04:00
Christian Legnitto
6ef9b8256a [naga msl-out] invalid code emitted for minimum i32/i64 value literal.
The literal `-2147483648` is parsed by Metal as negation of positive
2147483648. As 2147483648 is too large for a int, the expression is
silently promoted to a long. Sometimes this does not matter as it will
often be implicitly converted back to an int after the negation.
However, if the expression is used in a bitcast then we hit a compiler
error due to mismatched bitwidths.

Similarily for `-9223372036854775808`, as 9223372036854775808 is too
large for a long, metal emits a `-Wconstant-conversion` warning and
changes the value to -9223372036854775808. This would then be negated
again, possibly causing undefined behaviour.

In both cases we can avoid the issue by expressing the literals as the
second most negative value expressible by the type, minus one.

eg `-2147483647 - 1` and `-9223372036854775807L - 1L`.

We have added a test which uses the most negative i32 literal in an
addition. Because we bitcast addition operands to unsigned in metal,
this would cause a validation error without this fix. For the i64 case
existing tests already make use of the minimum literal value. Passing
the flag `-Werror=constant-conversion` to Metal during validation will
therefore catch this issue.
2025-04-09 14:13:03 -04:00
Jamie Nicol
e3828fcc18 [naga wgsl-out] Improve representation of minimum int64 literal
In #7424 we fixed a bug where the representation of the minimum int64
literal generated by naga was invalid WGSL. It changed us from
expressing it as `-9223372036854775808` which was invalid, to
`-9223372036854775807li - 1li`.

This is valid WGSL. However, as the values are concrete i64 types if the
shader is parsed again by naga the expression does not get const
evaluated away, leading to suboptimal code generated by the
backends. This patch makes us perform the subtraction using abstract
integers before casting to i64, solving this problem.

Additionally the input WGSL test is updated to use the same construct.
2025-04-09 14:13:03 -04:00
Zachary Harrold
4761e27da5
[naga] Fix improper feature gates (#7484) 2025-04-09 12:10:40 -04:00
Andy Leiserson
be16f8ce18 Use ty.for_debug 2025-04-09 08:15:47 -07:00
Andy Leiserson
d223bb582f [naga] Disallow logical operators && and || on vectors
Fixes #6856
2025-04-09 08:15:47 -07:00
Sylvain Benner
14690470bb
[metal] Metal compute shader passthrough (#7326)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-04-09 14:25:41 +00:00
Connor Fitzgerald
3ba97bc3b7
Fix CI flakes (#7491) 2025-04-08 11:15:31 -04:00