Commit Graph
2123 Commits
Author SHA1 Message Date
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
Jim Blandy fa0fed100e compact: Don't assume Emitted expressions are live.
If an `Emit` statement covers an `Expression` that is not otherwise
used by any `Statement`, remove it from the `Arena` anyway. An `Emit`
statement controls when `Expression`s are evaluated, but it doesn't
have any side effects, so unless an expression is used by some other
statement, it's not necessary to the program.
2023-10-09 12:21:43 +02:00
Jim Blandy e820c33abf compact: Minor cleanups.
- Simplify visibility markings.

- Remove some testing comments. (Tests carried out.)

- Remove some commented-out code.
2023-10-09 12:21:43 +02:00
Jim Blandy c6716033da Improve docs for FunctionInfo::process_expression. 2023-10-06 18:43:22 +02:00
Jim Blandy 31f547580c Remove expression argument to FunctionInfo::process_expression.
We're already passing the handle and the arena, so it's superfluous.
2023-10-06 18:43:22 +02:00
Teodor Tanasoaia 4d6e0005f4 [valid] Disallow NaNs and infinities (#2508)
* [valid] disallow NaNs and infinities

* document literal float constraints
2023-10-05 12:50:36 -07:00
Teodor Tanasoaia f37db5affc [wgsl] remove outerProduct (#2535) 2023-10-05 19:14:52 +02:00
Teodor Tanasoaia 6668d0694c Add Rgb10a2Uint format (#2525) 2023-10-03 13:36:14 +02:00
Teodor Tanasoaia 613da72ac0 [spv-out] require ClipDistance & CullDistance capabilities if necessary (#2528) 2023-10-03 13:34:56 +02:00
Evan Mark Hopkins 9f3cdb61aa [msl-out] Make varyings' struct members unique (#2521) 2023-09-29 12:26:23 +02:00
Teodor Tanasoaia c927d3ec82 remove duplicated code 2023-09-28 15:16:18 -07:00
teoxoy e6a47ba262 disable uniformity analysis for the fragment stage 2023-09-28 20:33:11 +02:00
teoxoy ee236e6c9b [valid] make sure textureSampleBias is only used in the fragment stage 2023-09-28 20:33:11 +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::back::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
Evan Mark Hopkins dc3d2b1e78 [glsl-out] Polyfill frexp 2023-09-25 13:17:50 +02: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 1b1ea37f15 [spv-out] Use FastIndexMap for Frontend::switch_cases. 2023-09-21 21:37:32 -07:00
Jim Blandy 89523aec08 Use FastIndexMap for SpecialTypes::predeclared_types. 2023-09-21 21:37:32 -07:00
Jim Blandy 6a254d904d [wgsl-in] Use FastIndexMap for temporary named expressions table. 2023-09-21 21:37:32 -07:00
Jim Blandy ae0423835d Introduce FastIndexMap type alias, and use it for NamedExpressions. 2023-09-21 21:37:32 -07:00
Jim Blandy 9105036be7 Use FastIndexSet for UniqueArena. 2023-09-21 21:37:32 -07:00
Jim Blandy b586631efe Small cleanups to backend naming. (#2491)
Document `FunctionType` better.

Use `FunctionCtx` name key methods where appropriate in the WGSL and
HLSL backends.
2023-09-20 19:20:47 +02: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
Jim Blandy 0b7afb3943 cli: Move file output into its own function. 2023-09-20 18:46:33 +02:00
Jim Blandy 55a2ee445c cli: Gather up SPIR-V output options settings. 2023-09-20 18:46:33 +02:00
Jim Blandy 187aed8e11 cli: Put a full naga::front::spv::Options in Parameters.
This lets us gather up the code that influences SPV input.
2023-09-20 18:46:33 +02:00
Jim Blandy 23860c0e29 cli: Change --generate-debug-symbols from option to switch.
Change `--generate-debug-symbols` from an option that requires a
value, "true" or "false", to a switch, whose mere presence enables the
feature.
2023-09-20 18:46:33 +02:00
Jim Blandy 2a47a15f03 cli: Populate dot backend options in Parameters early.
This is a step towards having the output loop depend only on `params`,
rather than both `params` and `args`.
2023-09-20 18:46:33 +02:00
Jim Blandy 54df410b94 [wgsl-in] make RuntimeExpressionContext::local_table a shared ref. (#2481)
The `front::wgsl::lowerer::RuntimeExpressionContext::local_table`
field does not need to be a mutable reference, as expressions never
introduce new local bindings.
2023-09-20 05:12:48 +00:00
andriyDev d8b7573b9e Prevent using multiple push constant variables in one entry point. (#2484) 2023-09-19 12:59:32 +02:00
Jim Blandy df8107b788 Fix documentation comments for proc::Layouter::update. (#2478) 2023-09-15 16:10:25 +00:00
Bruce Mitchener 266634e822 clippy: Fix unnecessary_mut_passed warning. (#2476)
The `ModuleInfo` was not used mutably.
2023-09-13 16:11:10 +02:00
Bruce Mitchener ae9c1f7847 clippy: Remove extra Iterator bounds. (#2475)
`Iterator` is a supertrait of `ExactSizeIterator`, so specifying `ExactSizeIterator` is enough.
2023-09-13 15:45:50 +02:00
Bruce Mitchener d2c29f012e Remove useless calls to into_iter(). (#2474)
The `splice()` call takes `IntoIterator`, so calling `into_iter()` is not needed.
2023-09-13 15:44:50 +02:00
Bruce Mitchener 79c5cb2d04 spv-out: Remove empty else branch. (#2473) 2023-09-13 15:44:02 +02:00
Elie Michel 0ae0446f3a [cli] Add support for .{vert,frag,comp}.glsl files (#2462) 2023-09-13 15:23:58 +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
Jim Blandy cc87b8f9eb Don't warn about unused mut in tests when "validate" feature is off. (#2466) 2023-09-11 11:59:14 +02:00
Fredrik Fornwall a0eb1f5462 [wgsl-in] Allow sign() to take int argument (#2463) 2023-09-06 09:29:35 -07:00