Commit Graph
545 Commits
Author SHA1 Message Date
Schell Carl Scivally e78c33b309 Add cfg features wgsl-in and wgsl-out to spv atomic upgrade test. Fixes #5816 2024-06-14 13:28:39 -07:00
Vecvec 73401ede25 Fix double decoration if a binding array contains a struct with a runtime array (#5776) 2024-06-10 11:20:33 +02:00
Jim Blandy 5790514e63 [naga] Document which Arena each Handle<Expression> refers to. 2024-06-10 11:02:43 +02:00
Atlas Dostal abba12ae4e Add support for 64 bit integer atomic operations in shaders.
Add the following flags to `wgpu_types::Features`:

- `SHADER_INT64_ATOMIC_ALL_OPS` enables all atomic operations on `atomic<i64>` and
  `atomic<u64>` values.

- `SHADER_INT64_ATOMIC_MIN_MAX` is a subset of the above, enabling only
  `AtomicFunction::Min` and `AtomicFunction::Max` operations on `atomic<i64>` and
  `atomic<u64>` values in the `Storage` address space. These are the only 64-bit
  atomic operations available on Metal as of 3.1.

Add corresponding flags to `naga::valid::Capabilities`. These are supported by the
WGSL front end, and all Naga backends.

Platform support:

- On Direct3d 12, in `D3D12_FEATURE_DATA_D3D12_OPTIONS9`, if
  `AtomicInt64OnTypedResourceSupported` and `AtomicInt64OnGroupSharedSupported` are
  both available, then both wgpu features described above are available.

- On Metal, `SHADER_INT64_ATOMIC_MIN_MAX` is available on Apple9 hardware, and on
  hardware that advertises both Apple8 and Mac2 support. This also requires Metal
  Shading Language 2.4 or later. Metal does not yet support the more general
  `SHADER_INT64_ATOMIC_ALL_OPS`.

- On Vulkan, if the `VK_KHR_shader_atomic_int64` extension is available with both the
  `shader_buffer_int64_atomics` and `shader_shared_int64_atomics` features, then both
  wgpu features described above are available.
2024-06-08 18:36:26 -07:00
Jim Blandy 583cc6ab04 [naga] Ensure that FooResult expressions are correctly populated.
Make Naga module validation require that `CallResult` and
`AtomicResult` expressions are indeed visited by exactly one `Call` /
`Atomic` statement.
2024-06-04 14:39:29 +02:00
Jim Blandy badcaee6e3 [naga] Make BlockContext::resolve_pointer_type infallible.
Since `BlockContext::resolve_pointer_type` never returns an error,
change its result type from a `Result` to a `&TypeInner`. Adjust
callers accordingly.

Remove calls (well, there's only one) to `resolve_pointer_type`
entirely when the caller does not need the value, since
`resolve_pointer_type` is now infallible and has no side effects.
2024-06-03 11:30:28 +02:00
Jim Blandy 049db89039 [naga] Remove ExpressionError::DoesntExist.
Remove `valid::expression::ExpressionError::DoesntExist`. This error is reported
when expression validation encounters an invalid `Handle<Expression>`, but we
have already verified that the module is free of invalid handles in
`Validator::validate_module_handles`, so this condition should never arise.
2024-06-03 11:30:28 +02:00
Jim Blandy 91e4be314c [naga doc] Fix broken links in Naga bitflags types.
Fix links in documentation for types defined using the `bitflags!` macro.

As described in [bitflags#407], for some reason, `cargo doc` doesn't
check for broken links in documentation for types or members defined
using `bitflags::bitflags!`.

[bitflags#407]: https://github.com/bitflags/bitflags/issues/407
2024-06-03 10:26:47 +02:00
Brad Werth 9b7a965667 Add an experimental vertex pulling flag to Metal pipelines.
This proves a flag in msl::PipelineOptions that attempts to write all
Metal vertex entry points to use a vertex pulling technique. It does
this by:

1) Forcing the _buffer_sizes structure to be generated for all vertex
entry points. The structure has additional buffer_size members that
contain the byte sizes of the vertex buffers.
2) Adding new args to vertex entry points for the vertex id and/or
the instance id and for the bound buffers. If there is an existing
@builtin(vertex_index) or @builtin(instance_index) param, then no
duplicate arg is created.
3) Adding code at the beginning of the function for vertex entry points
to compare the vertex id or instance id against the lengths of all the
bound buffers, and force an early-exit if the bounds are violated.
4) Extracting the raw bytes from the vertex buffer(s) and unpacking
those bytes into the bound attributes with the expected types.
5) Replacing the varyings input and instead using the unpacked
attributes to fill any structs-as-args that are rebuilt in the entry
point.

A new naga test is added which exercises this flag and demonstrates the
effect of the transform. The msl generated by this test passes
validation.

Eventually this transformation will be the default, always-on behavior
for Metal pipelines, though the flag may remain so that naga
translation tests can be run with and without the tranformation.
2024-05-30 13:08:59 +02:00
Schell Carl Scivally 480d4dbd73 spv-in parsing Op::AtomicIIncrement (#5702)
Parse spirv::Op::AtomicIIncrement, add atomic_i_increment test.
2024-05-30 04:39:32 +00:00
Jim Blandy 59cd0e964b [naga] Validate CallResult and AtomicResult population.
Validate that `CallResult` and `AtomicResult` expressions actually
have their values provided by `Call` and `Atomic` statements, and not
`Emit` statements.

Fixes #5740.
2024-05-28 09:17:16 +02:00
Jim Blandy aaefc7c10d [naga] Fix cargo doc --document-private-items. Add to CI. 2024-05-24 10:38:06 +02:00
Jim Blandy b898cdf908 [naga spv-in] Doc fix: Parser -> Frontend
Fix documentation left unchanged when `Parser` was renamed to
`Frontend`.
2024-05-23 12:59:11 +02:00
Jim Blandy 7fc7f58280 [naga spv-in] Delete misplaced, outdated comment.
This comment had become misplaced - it belongs on
`lookup_sampled_image` - but also, that table is no longer "storing
flags on how they are used". So the name of the field and type are
probably documentation enough.
2024-05-22 08:38:31 +02:00
Connor Fitzgerald eeb1a9d7b7 Add Benchmarks (#5694) 2024-05-16 09:05:41 -04:00
Vladislav 00456cfb37 Add parsing support for un/pack4xI/U8 2024-05-14 17:57:04 +02:00
teoxoy 66d7387f0d [msl] refactor chain of if blocks to match 2024-05-14 17:57:04 +02:00
Erich Gubler ca91744955 chore: apply unused_qualifications lint via cargo +1.78.0 fix && cargo fmt 2024-05-13 10:10:54 -04:00
Erich Gubler bfe96d87b2 chore(spv): remove unused MergeInstruction 2024-05-13 10:10:54 -04:00
Erich Gubler 78a208b005 chore: satisfy clippy::empty_docs 2024-05-13 10:10:54 -04:00
Erich Gubler b4193d50db chore: satisfy clippy::multiple_bound_locations 2024-05-13 10:10:54 -04:00
stefnotch f874ed061c Add get_compilation_info (#5410)
* Add get_compilation_info API

* Rename glsl ParseError to ParseErrors

* Document ParseError label order

* Update line_position to count UTF-8 bytes
2024-04-29 11:35:36 +02:00
Erich Gubler e8e33ede11 refactor(naga): remove extraneous leading path qualifiers (#5612)
Implemented by `cargo fix -p naga --lib`.
2024-04-28 16:33:13 +02:00
teoxoy 55c9d69ba0 [naga] fix the way we adjust constant initializers when processing overrides
This fixes 2 issues:
- we used to index `adjusted_global_expressions` with the handle index of the constant instead of its initializer
- we used to adjust the initializer multiple times if the arena contained multiple `Expression::Constant`s pointing to the same constant
2024-04-25 11:04:09 -07:00
vero 18ceb5183c [spv-out] Move request_type_capabilities outside of LocalType lookup 2024-04-25 11:17:23 +02:00
Imbris 82fa580152 [hlsl-out] Fix accesses on zero value expressions (#5587) 2024-04-24 10:40:08 +02:00
teoxoy c2e520c52c [naga] add Expression::Override to needs_pre_emit 2024-04-22 08:38:31 -07:00
teoxoy ca729cc607 Introduce HashableLiteral
The only reason `Literal` had to implement `Eq` and `Hash` was due to the SPV backend having to cache those in a `HashMap`.

The `PartialEq` impl was error prone due to the match not being exhaustive.
2024-04-18 12:26:24 -07:00
Teodor Tanasoaia d08a069573 Fix vectors being unconditionally host shareable (#5556) 2024-04-18 10:02:18 -04:00
vero 4e77762a32 Refactor MSL atomic writing (#5533) 2024-04-18 12:23:45 +02:00
vero 163ffa6d63 Refactor WGSL atomic writing (#5534) 2024-04-18 10:57:35 +02:00
ea77d5674d Subgroup Operations (#5301)
Co-authored-by: Jacob Hughes <j@distanthills.org>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: atlas dostal <rodol@rivalrebels.com>
2024-04-17 15:25:52 -04:00
vero c6efbef8a6 Make scalar_width return size in bytes (#5532) 2024-04-15 20:05:42 +02:00
teoxoy 9df68197a4 [spv-in] add support for specialization constants 2024-04-11 09:46:55 -07:00
wicast 17ef6cac90 fix(spv-out): OpSourceContinued for large source (gfx-rs#5390) 2024-04-08 11:27:18 +02:00
vero 911baf3e8c Add DirectX ShaderModel 6.1-6.7 detection (#5498) 2024-04-06 11:35:59 +02:00
Jim Blandy 2ad95b2774 [naga wgsl-in] Allow override expressions as local var initializers.
Allow `LocalVariable::init` to be an override expression.

Note that this is unrelated to WGSL compliance. The WGSL front end
already accepts any sort of expression as an initializer for
`LocalVariable`s, but initialization by an override expression was
handled in the same way as initialization by a runtime expression, via
an explicit `Store` statement.

This commit merely lets us skip the `Store` when the initializer is an
override expression, producing slightly cleaner output in some cases.
2024-04-05 18:07:41 +02:00
teoxoy 7df0aa6364 move the burden of evaluating override-expressions to users of naga's API 2024-04-05 18:07:41 +02:00
Jim Blandy ba19d8df34 [naga] Adjust RayQuery statements in override processing. 2024-04-05 18:07:41 +02:00
Jim Blandy 906ed128de [naga] Spell out members in adjust_expr. 2024-04-05 18:07:41 +02:00
Jim Blandy 8a2bc07f11 [naga] Handle comparison operands in pipeline constant evaluation.
Properly adjust `AtomicFunction::Exchange::compare` after pipeline
constant evaluation.
2024-04-05 18:07:41 +02:00
Jim Blandy 8107f80b7f [naga] Tweak comments in ConstantEvaluator::try_eval_and_append.
I found I needed a little bit more detail here.
2024-04-05 18:07:41 +02:00
Jim Blandy bb15286df2 [naga] Let filter_emits_with_block operate on a &mut Block.
This removes some clones and collects, simplifies call sites, and
isn't any more complicated to implement.
2024-04-05 18:07:41 +02:00
Jim Blandy aaf3b17623 [naga] Hoist ConstantEvaluator construction in process_function.
There's no need to build a fresh `ConstantEvaluator` for every
expression; just build it once and reuse it.
2024-04-05 18:07:41 +02:00
Jim Blandy f464598646 [naga] Simplify uses of replace in back::pipeline_constants. 2024-04-05 18:07:41 +02:00
Jim Blandy 58d1e1f745 [naga] Doc tweaks for back::pipeline_constants. 2024-04-05 18:07:41 +02:00
teoxoy ca252b9e74 allow private variables to have an override-expression initializer 2024-04-05 18:07:41 +02:00
teoxoy 3abdfde0ba evaluate override-expressions in functions 2024-04-05 18:07:41 +02:00
teoxoy fd5c4db606 refactor try_eval_and_append body 2024-04-05 18:07:41 +02:00
Jim Blandy dd315ee39a [naga] Add some documentation to process_overrides and subroutines. 2024-04-05 18:07:41 +02:00