Commit Graph
70 Commits
Author SHA1 Message Date
Brad Werth fe72235a7e Add missing closing parentheses to some msl unpack functions. 2024-06-18 10:08:50 +02: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
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 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
Jim Blandy aaefc7c10d [naga] Fix cargo doc --document-private-items. Add to CI. 2024-05-24 10:38:06 +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
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 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
vero 4e77762a32 Refactor MSL atomic writing (#5533) 2024-04-18 12:23:45 +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
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 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 3abdfde0ba evaluate override-expressions in functions 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
teoxoy 4ede83929c [valid] make sure overrides are not present after evaluation 2024-04-05 18:07:41 +02:00
teoxoy e9eb703941 rename const_expressions to global_expressions 2024-04-05 18:07:41 +02:00
teoxoy fa5406fbb9 rename ExpressionConstnessTracker to ExpressionKindTracker 2024-04-05 18:07:41 +02:00
teoxoy d6ebd88f42 implement override-expression evaluation for initializers of override declarations 2024-04-05 18:07:41 +02:00
teoxoy 2929ec333c [spv/msl/hlsl-out] support pipeline constant value replacements 2024-04-05 18:07:41 +02:00
Teodor TanasoaiaandJim Blandy f949ea69c4 [wgsl-in] add support for override declarations (#4793)
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2024-04-05 18:07:41 +02:00
teoxoy 3bda381812 add pipeline constants plumbing 2024-04-05 18:07:41 +02:00
Dzmitry Malyshau 3a467ad93d spv-out: Support arrayLength of a dynamically indexed bindings array 2024-04-02 19:22:34 +02:00
Dzmitry Malyshau bfe0b90740 spv-out: implement OpArrayLength on array buffer bindings 2024-04-02 19:22:34 +02:00
Christian Legnitto 1fd47b54ab Expose all items in naga::back.
This helps out-of-tree backends.

Fixes https://github.com/gfx-rs/wgpu/issues/5398.
2024-04-02 17:14:13 +02:00
Vecvec 1ead28701d Fix unused acceleration structures causing invalid SPIR-V (#5463) 2024-04-02 11:06:28 +00:00
veroandConnor Fitzgerald 4e6f873da5 Add shader I64 and U64 support (#5154)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-03-12 12:34:06 +01:00
Teodor Tanasoaia 3107f5e148 [mtl-out] Add "assert" to reserved words 2024-03-12 10:52:37 +01:00
Erik Zivkovic d417433e0c Naga: GLSL 410 does not support layout(binding = ...)
Naga assumed that GLSL 410 supported layout(binding = ...) but it does not,
it only supports layout(location = ...). It is not possible to enable only
layout(location = ...) currently, so we need to predicate the feature on GLSL
420 instead.
2024-03-07 12:28:26 +01:00
Connor Fitzgerald a5c0181c3a Bitfield Fixes (#5305) 2024-02-29 20:50:42 +00:00
dependabot[bot]andConnor Fitzgerald 744454b9e2 Bump Many Dependencies and MSRV (#5241)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-27 14:43:05 -05:00
Connor Fitzgerald 38419a9cf2 Fix Integer Clamp (#5300)
* Fix Integer Clamp

* Changelog
2024-02-26 20:28:23 +01:00
JMS55 5b9ade8223 Add AccelerationStructure to WGSL write_value_type (#5261) 2024-02-24 02:41:37 -05:00
Christian Schwarz 2382c8e74f Fix glsl backend errors regarding samplerCubeArrayShadow (#5171)
* add GL_EXT_texture_shadow_lod feature detection

* allow more cases of cube depth texture sampling in glsl

* add test for sampling a cubemap array depth texture with lod

* add test for chosing GL_EXT_texture_shadow_lod over the grad workaround if instructed

* add changelog entry for GL_EXT_texture_shadow_lod

* fix criteria for requiring and using TEXTURE_SHADOW_LOD

* require gles 320 for textureSampling over cubeArrayShadow

* prevent false positives in TEXTURE_SHADOW_LOD in checks

* make workaround_lod_with_grad usecase selection less context dependant

* move 3d array texture error into the validator

* correct ImageSample logic errors
2024-02-08 18:27:58 +01:00
Connor FitzgeraldandAndreas Reich faed98b45c Add typos to Repository CI (#5191)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-02-05 12:30:29 -05:00