Commit Graph

197 Commits

Author SHA1 Message Date
teoxoy
a730236b68 [wgsl-in] eagerly evaluate const-expressions
[wgsl-in] support const-expressions in attributes

allow `Splat` as an evaluated const-expression type
2023-10-12 13:13:26 +02:00
Jim Blandy
5af7ebc955 snapshots: Consolidate path handling.
Add a new type, `Input`, representing a particular Naga input file,
with methods to generate related paths - output files with a
particular extension, parameter files, and the input file itself.
Use this throughout `snapshots.rs` to generate paths.

Give `Input` utility methods for reading and writing files.
2023-09-25 07:59:41 -07:00
Jim Blandy
bc0fc97b26 Delete output files no longer generated by snapshot tests. 2023-09-25 07:59:41 -07:00
Jim Blandy
8b267218a4 Implement module compaction.
Add a new Naga feature, `"compact"`, which adds a new function
`naga::compact::compact`, which removes unused expressions, types, and
constants from a `Module`.
2023-09-20 18:46:33 +02:00
Theo
1281c1156c [spv-out] Always give structs with runtime arrays a Block decoration (#2455) 2023-09-12 19:59:31 +02:00
Fredrik Fornwall
a0eb1f5462 [wgsl-in] Allow sign() to take int argument (#2463) 2023-09-06 09:29:35 -07:00
Fredrik Fornwall
5329aa2bd5 [wgsl-in] Handle modf and frexp (#2454) 2023-09-02 08:55:35 +02:00
Fredrik Fornwall
f49314dbbd Fix validation and glsl parsing of ldexp (#2449)
Fixes #1908.
2023-09-01 18:44:48 +02:00
Frederik Magnus Johansen Vestre
0491d39232 Support dual source blending (#2427)
Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-08-30 21:00:35 +02:00
Fredrik Fornwall
3bd2834b4f [wgsl-in] Handle all(bool) and any(bool) (#2445)
Fixes #1911.
2023-08-29 21:34:55 +02:00
teoxoy
c3e35df576 [spv-out] decorate the result of the OpLoad with NonUniform (not the access chain) when loading images/samplers (resources in the Handle address space) 2023-08-04 10:45:36 -04:00
Evan Mark Hopkins
f7de1942c1 [spv-out] Cache OpConstantNull (#2414) 2023-08-02 18:05:16 +02:00
Evan Mark Hopkins
5f8e4f6dea [spv] Fix OpImageQueries to allow Uints (#2404) 2023-07-24 21:25:45 +02:00
teoxoy
ee81f569df add constructors test file 2023-07-17 16:26:08 -07:00
teoxoy
d348d843e1 implement const-expressions (phase 1) 2023-07-17 16:26:08 -07:00
wicast
25e4f17a69 add debug info for spv-out (#2379) 2023-06-28 14:30:25 +02:00
Eduard-Mihai Burtescu
f915d39a87 [spv-out] Use IndexSet instead of HashSet for iterated sets (capabilities/extensions). 2023-06-21 13:30:01 -07:00
Igor Shaposhnik
f31093fb3b Add array-in-function-return-type test 2023-06-15 14:53:19 +02:00
teoxoy
08105461ce omit non referenced expressions 2023-06-12 17:49:06 -07:00
Teodor Tanasoaia
5206c59509 update snapshots (#2363) 2023-05-30 14:03:10 +02:00
Daniel McNab
907b7c7cda Workgroup uniform load (#2201)
Implement the WGSL `workgroupUniformLoad` function.
2023-05-26 13:32:22 -07:00
Teodor Tanasoaia
62b287e761 Change type of constant sized arrays to NonZeroU32 (#2337) 2023-05-12 14:38:50 +02:00
Jim Blandy
412d5aa62e [wgsl-in] Generate Expression::Literal. 2023-05-11 07:09:53 -07:00
Teodor Tanasoaia
4d87401fac Use Expression::ZeroValue in SPIR-V and WGSL front ends. 2023-05-10 19:30:03 -07:00
Evan Mark Hopkins
9befaed7e9 [hlsl-out] Fix return type for firstbitlow/high (#2315) 2023-04-25 14:49:26 +02:00
Dzmitry Malyshau
37b3c36a8f Support array bindings of buffers (#2282)
* Support buffer resource arrays in IR, wgsl-in, and spv-out

* spv-out: refactor non-uniform indexing semantics to support buffers

* Update the doc comment on BindingArray type

* Improve TypeInfo restrictions on binding arrays

* Strip DATA out of binding arrays

* Include suggested documentation, more binding array tests, enforce structs
2023-04-24 21:30:49 -07:00
teoxoy
b9c5cb5a78 validate vertex stage returns the position built-in 2023-04-12 10:48:18 -07:00
daxpedda
f59668ccfa Allow array_index to be unsigned (#2298) 2023-04-07 16:01:55 +02:00
Erich Gubler
99a7773e65 fix(hlsl-out): use Interlocked<op> intrinsic for atomic integers (#2294)
We currently assume that we are using raw `RWByteAddressBuffer` methods for all atomic operations (`<pointer>.Interlocked<op>(<raw_byte_offset>, …)`), which is only true when we use `var<storage, read_write>` globals. For `var<workgroup>` globals, we need `Interlocked<op>(<pointer>, …)`, using the original expression as the first argument.

Fix this by branching on the `pointer`'s address space in `Atomic` statements, and implementing the workgroup address space case with intrinsics.

Remove atomic ops from `access`, add new `atomicOps` test.

Fixes #2284
2023-04-05 19:37:22 -07:00
PyryM
52043be004 [spv-out] Fix invalid spirv being generated from integer dot products (#2291)
* Fix invalid spirv generation in int dotprod

constants cannot be declared inside of a function block, so instead use `write_constant_null` to produce a correctly-declared constant 0.

* autogenerated test snapshots
2023-03-30 16:02:54 +02:00
Jim Blandy
53d62b9ede Clean up handling of RayDesc builtin type, somewhat. 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau
024c197cc8 ray query: validation, better test 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau
22e341b039 wgsl: handle RayDesc/RayIntersection at the type decl level instead of an AST constructor 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau
ab9c36441f fill up the ray query intersection struct 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau
67d31b8e8c spv-out: basic ray query support 2023-03-22 17:23:07 -07:00
Erich Gubler
0b87d1918a fix(hlsl): emit constructor functions for arrays (#2281)
* test(hlsl-out): add failing case for array as ctor arg

See issue #2184.

* fix(hlsl): emit constructor functions for arrays
2023-03-20 17:21:52 +01:00
Andreas Reich
67c081bebe [spirv-out] Fix adding illegal decorators on fragment outputs. (#2286)
* [spirv-out] Fix adding illegal decorators on fragment outputs.

Furthermore, fix allowing to add `Centroid` and `Sample` decorator to vertex inputs.
Fixes #2270

* Add test for fragment outputs

* Fix fragment-output.wgsl test using more than 8 outputs in a single shader
Breaks HLSL & MSL validation

* formatting
2023-03-20 13:43:13 +01:00
Evan Mark Hopkins
6db8da72ca Add partial derivative builtins (#2277)
* Add partial derivative builtins

* [dot] emit derivative control

* Fix fmt

---------

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-03-17 00:15:44 +01:00
Teodor Tanasoaia
9742f1616c fix zero initialization of workgroup memory (#2259)
Use the local (not global) invocation id to decide which invocation should do the initialization, so that every workgroup gets initialized, not just the first.
2023-02-20 19:56:24 -08:00
Teodor Tanasoaia
cde457cedd [spv-out] fix countLeadingZeros impl (#2258) 2023-02-20 20:40:26 +00:00
Mauro Gentile
810e9d26fc Add countTrailingZeros (#2243)
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-02-20 20:40:59 +01:00
Evan Mark Hopkins
60c0fc0284 [spv-out] Cache constant composites (#2257) 2023-02-20 15:24:20 +01:00
Leah
58105a06e2 [glsl/hlsl-out] Write sizes of arrays behind pointers in function arguments (#2250)
arrays can be put behind pointers in inout and out parameters in GLSL and HLSL,
whose dimensions must be specified to let array access
compile. so, we specify their dimensions.

fixes #2248
2023-02-17 00:40:21 +00:00
Evan Mark Hopkins
1ad47f732d Fix texture built-ins where u32 was expected (#2245)
- The Typifier was updated to expect `uint`
- Both `glsl` and `spv` frontends where updated to cast the result to `sint`.
- Both `glsl` and `spv` backends where updated to cast the result to `uint`.
- Remove cast in `msl` backend.
2023-02-13 14:13:58 +01:00
Evan Mark Hopkins
fb2d438dbd [msl-out] Update firstLeadingBit for signed integers (#2235)
The prior code only supported unsigned integers.

Also fixes #2236.

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2023-02-02 09:47:17 -08:00
Dzmitry Malyshau
16be1a9237 spv-out: support version 1.4 (#2230)
* spv-out: support version 1.4

* Extract SPV version numner from the comment
2023-02-01 12:24:05 +01:00
Evan Mark Hopkins
6be394dac3 Add countLeadingZeros (#2226)
* Add countLeadingZeros

* [glsl-out] Bake countLeadingZeros

* [hlsl-out] Bake countLeadingZeros

* [hlsl-out] Update Baked expressions

* Remove unnecessary bake for sints

* [glsl-out] CountLeadingZeros without findMSB

* Don't check negatives when uint

* Perform the type conv after mix

* use log2

* fix clippy lints

---------

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-01-31 21:31:05 +01:00
teoxoy
c7d02151f0 add support for zero-initializing workgroup memory 2023-01-25 18:07:48 +01:00
teoxoy
3ace8b81cb fix array being flagged as constructible when its base isn't 2023-01-25 18:07:48 +01:00
Evan Mark Hopkins
9f182ade30 [wgsl] Add refract built-in 2023-01-23 11:50:50 +01:00