Commit Graph

19 Commits

Author SHA1 Message Date
Jim Blandy
ed3006ccc6 [naga spv-out] Spill arrays and matrices for runtime indexing.
Improve handling of `Access` expressions whose base is an array or
matrix (not a pointer to such), and whose index is not known at
compile time. SPIR-V does not have instructions that can do this
directly, so spill such values to temporary variables, and perform the
accesses using `OpAccessChain` instructions applied to the
temporaries.

When performing chains of accesses like `a[i].x[j]`, do not reify
intermediate values; generate a single `OpAccessChain` for the entire
thing.

Remove special cases for arrays; the same code now handles arrays and
matrices.

Update validation to permit dynamic indexing of matrices.

For details, see the comments on the new tracking structures in
`naga:🔙:spv::Function`.

Add snapshot test `index-by-value.wgsl`.

Fixes #6358.
Fixes #4337.
Alternative to #6362.
2024-10-11 08:27:15 -07:00
sagudev
2d82054ae4 [wgsl-in, spv-out] Allow dynamic indexing of arrays by value.
Bring https://github.com/gfx-rs/naga/pull/723 back from the dead.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2024-10-02 18:07:02 -07:00
Samson
4e9a2a5003
[naga wgsl] Impl const_assert (#6198)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-09-02 17:37:04 +00:00
Samson
105cb9db31
[naga wgsl-in] Proper singular generic in vec and matrix (#6189)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-09-02 14:04:51 +02:00
Samson
585f4a1036
[naga wgsl] all swizzle components must be either color or dimension (#6187) 2024-08-31 11:08:34 +02:00
Samson
34bb9e4ceb
[naga wgsl] Implement local const declarations (#6156) 2024-08-30 11:55:03 +02:00
Teodor Tanasoaia
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
Erich Gubler
b21a3265de fix(wgsl-in)!: limit brace recursion 2024-04-03 15:54:43 -04:00
vero
4e6f873da5
Add shader I64 and U64 support (#5154)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-03-12 12:34:06 +01:00
dependabot[bot]
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
faed98b45c
Add typos to Repository CI (#5191)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-02-05 12:30:29 -05:00
Jim Blandy
d9d051b7a5 [naga wgsl] Let unary operators accept and produce abstract types.
Fixes #4445.
Fixes #4492.
Fixes #4435.
2023-12-14 10:54:46 +01:00
Jim Blandy
1676ee0dc0 [naga wgsl-in] Automatic conversions for global var initializers. 2023-12-06 10:35:21 +01:00
Teodor Tanasoaia
dd7e33250b fix expected error message 2023-12-04 14:06:33 +01:00
Jim Blandy
33339e46ce [naga wgsl-in] Drop spanless labels from front-end error messages.
When a label in a WGSL front end error has an undefined span, omit the
label from the error message. This is not great, but because of the
way Naga IR represents local variable references it is hard to get the
right span, and omitting the label better than panicking in `unwrap`,
since the error message has a general message anyway.
2023-12-04 12:22:13 +01:00
Jim Blandy
07b83ab6c0 [naga wgsl-in] Use a better span for errors in constructors.
When reporting errors in construction expressions, use the span of the
constructor itself (that is, the type name) in preference to the span
of the overall expression. This makes errors easier to follow.
2023-12-04 12:20:22 +01:00
Jim Blandy
5a3887a49f [naga wgsl-in] Constructors with types don't make abstract values.
When a constructor builtin has an explicit type parameter, like
`mat2x2<f32>`, it should not produce an abstract matrix, even if its
arguments are abstract.
2023-11-29 08:58:47 +01:00
Jim Blandy
601f235b34 [naga wgsl-in] Implement abstract types for consts, constructors. 2023-11-29 08:58:47 +01:00
Connor Fitzgerald
06e9876adf
Move to A Single Example Executable (#4756)
* Move to combined examples

* Fix paths

* Curtail some tests

* Format

* Clippy

* Fix wasm

* Refactor main for wasm

* Style sheet

* Readme

* Lock
2023-11-23 05:26:42 -05:00