Commit Graph

784 Commits

Author SHA1 Message Date
teoxoy
fe7bc01d27 [glsl-in] const eval as soon as possible 2023-10-12 13:13:26 +02:00
teoxoy
3fb4c333a7 use LocalVariable init 2023-10-12 13:13:26 +02:00
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
fe484b3a1b Require that Function and Private variables be CONSTRUCTIBLE.
Change the validator to enforce WGSL's requirement that all variables
in the `function` and `private` address spaces must have constructible
types.

Mark the `RayQuery` type as `CONSTRUCTIBLE`, since it is intended to
be used for local variables.

Add a regression test.
2023-10-09 12:27:05 +02:00
Teodor Tanasoaia
f37db5affc
[wgsl] remove outerProduct (#2535) 2023-10-05 19:14:52 +02:00
Evan Mark Hopkins
9f3cdb61aa
[msl-out] Make varyings' struct members unique (#2521) 2023-09-29 12:26:23 +02:00
Teodor Tanasoaia
f72489be00
validate variable initializer for address spaces (#2513) 2023-09-28 20:32:46 +02:00
Jim Blandy
a17a93ef8f
snapshots: convert_wgsl: Remove redundant cubeArrayShadow entry. (#2514)
The duplicate entry was introduced accidentally in #1845.
2023-09-28 09:09:57 +02:00
Evan Mark Hopkins
a898522e10
Rename identifiers containing double underscores (#2510) 2023-09-26 16:46:02 +02:00
Jim Blandy
3bcb114adb snapshots: Change messages for generating output.
Change printlns in the backend functions to say "generating" instead
of "writing" before calling the Naga backends. "Writing" suggests
writing output to a file; "generating" seems more accurate for calling
a backend.
2023-09-25 07:59:41 -07: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
4329a6a51b snapshots: Name convert_glsl_variations_check output consistently.
Rather than adding a `-glsl` suffix to the name, just rely on
`check_targets`' standard naming behavior, treating
`tests/in/variations.glsl` like any other snapshot input.
2023-09-25 07:59:41 -07:00
Jim Blandy
0c69735f59 Change naga:🔙:spv::DebugInfo::file_name to a &Path.
This makes it a bit easier to use in the CLI and snapshot tests.
2023-09-25 07:59:41 -07:00
Jim Blandy
7060246357 Give convert_glsl_folder's output more consistent names.
Don't replace dots with dashes in the output filenames for no reason.
Instead, give them names consistent with those generated by
`write_output_glsl`.
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
711aa1a834 snapshots: convert_spv: Don't validate the module twice.
Remove the call to `Validator::validate` in `convert_spv`, since it
directly follows the call to `check_targets`, which also called
`Validator::validate`.

The only difference between the two is whether `Parameters::god_mode`
is respected, but this difference doesn't seem to have been
deliberate: at the time the call to `check_targets` was added to
`convert_spv` (5f21cf360, 2021-02-17), the two calls were exactly the
same.
2023-09-25 12:25:15 +02:00
Jim Blandy
57bebbcd20 [wgsl-in] Use deterministic ordering for dependency ordering.
Use `FastIndexSet`, rather than `FastHashSet`, for tracking global
declarations' dependencies, so that the order in which functions are
inserted into the `Module` is not dependent on the hash function.
2023-09-21 23:18:18 -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
Jim Blandy
0f36a745cf
[wgsl-out] Don't include type parameter in splat expressions. (#2469)
Generate `vec4(1.0)` instead of `vec4<f32>(1.0)`, since WGSL requires
us to infer the type parameter anyway.
2023-09-12 19:34:24 +02:00
Jim Blandy
b17eaf76a3
snapshots::convert_spv: Print input name before processing. (#2467)
When `convert_spv` fails, this makes it easier to tell which file it
was trying to process.
2023-09-11 18:32:56 +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
Teodor Tanasoaia
46951a09c0
Validate storage buffer access (#2415)
* validate storage buffer access

* remove GLSL writeonly buffer test
2023-07-31 15:59:17 +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
Fredrik Fornwall
dfd88ee485
[glsl-in] Support commas in structure definitions (#2400) 2023-07-17 16:22:25 +01:00
Teodor Tanasoaia
a550b0b499
Split image bounds check policy (#2265) 2023-06-29 14:59:37 +00:00
wicast
25e4f17a69
add debug info for spv-out (#2379) 2023-06-28 14:30:25 +02:00
Elabajaba
adf1cca68d
Implement Pack/Unpack for HLSL (#2353) 2023-06-23 15:52:22 +02:00
Teodor Tanasoaia
ffe2308a60
rename allow_point_size to allow_and_force_point_size (#2280) 2023-06-22 06:36:54 -07: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
Erich Gubler
91d48b2923 build: move from make to cargo xtask workflows
Re-implement `naga` development workflows using [`cargo xtask`]. Convert
`make` logic and shader test configuration as file with Bash variables
into an `xtask` crate and YAML files, respectively.

Pros:

* We now have a _portable_ workflow everywhere, which means Windows
  folks and people who don't install `make` don't have to suffer.
  😮‍💨
* Workflow logic is now relatively easy to inspect and change. Whew!
  💁🏻‍♂️💦
* Contributors can use their existing Rust knowledge to contribute to
  developer experience. 🎉
* `cargo xtask` is a relatively well-known convention for workflows in
  the ecosystem.
* We can do fancy things like allow folks to run at different log levels
  for workflows, depending on their tastes.

Cons:

* There's now a non-trivial compile step to project workflow.
  Incremental rebuilds seem to be pretty short, though!
* Code is much more verbose than the (very) terse `make` implementation.

[`cargo xtask`]: https://github.com/matklad/cargo-xtask
2023-06-08 16:56:57 +02:00
daxpedda
b7f4006e46
Bump bitflags to v2 (#2358) 2023-06-01 15:40:47 +02:00
Pieter-Jan Briers
544ccf88da
Handle case insensitive FXC HLSL keywords. (#2347)
There are a few keywords like "pass" in HLSL that are actually case-insensitive for FXC. This can be disabled with strict mode, but even if you do that FXC will continue to give an error if you try to use them in identifiers (at all, with any casing).

This changes the namer code to escape these keywords even if the casing is different.

If you're wondering where I got the list from: I looked at the list of strings in D3DCompiler_47.dll.
2023-05-31 15:00:23 +02: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
Shaye Garg
1c17fa82d4
[wgsl-in] Error on param redefinition (#2342)
* error on param redefinition

* also fix #2312
2023-05-25 13:13:27 +02:00
Ashley
ce48588d74
[front/spir-v] Obey the is_depth field of OpTypeImage (#2341)
* [front/spir-v] Obey the is_depth field of OpTypeImage

* Add changed tests
2023-05-22 09:35:58 -07:00
Eduard-Mihai Burtescu
423a069dcd [spv-in] Convert conditional backedges to break if. 2023-05-12 13:59:08 -07:00
Teodor Tanasoaia
62b287e761
Change type of constant sized arrays to NonZeroU32 (#2337) 2023-05-12 14:38:50 +02:00
Jim Blandy
959c84f039 [glsl-in] Generate Expression::Literal. 2023-05-11 07:09:53 -07:00