Commit Graph
814 Commits
Author SHA1 Message Date
Evan Mark Hopkins a80967f860 Add support for the saturate function (#2025)
uses clamp in place of saturate in spv and glsl
2022-08-16 10:43:41 +00:00
João Capucho 6f4003ca9b Fix clippy lints for 1.63 (#2026) 2022-08-15 21:53:14 -04:00
SpaceCat~Chan f2624ea378 [glsl-in] add support for .length() (#2017)
Adds parsing support for methods on the glsl frontend, while `.length` is the only method in the base extensions, there might be more in extensions.

Adds support for the `.length` method and tests for it.
2022-08-08 18:09:22 +01:00
Christofer Nolander cfbc91d6cf add emit_to_{stderr,string} helpers for validation errors (#2012)
Mirrors those already found for parse errors.

Also removes the `StringErrorBuffer` writer in favor of the existing `NoColor` writer (from `codespan`) and added the emit_to_string_with_path method to complete the set.
2022-08-06 22:48:07 +01:00
João Capucho b746e0a420 spv-in: Fix incorrect translation of SMod (#1995)
Since spirv's SMod doesn't map to naga's IR modulo operator the
instruction is mapped into it's direct formula, this formula requires
some casts from int to float and back.

These casts were present but their `convert` field was left to `None`
which implied that they were bitcasts, causing some wildly incorrect
results.

This commit fixes it by setting the `convert` field to the same size as
the result type.
2022-06-30 11:34:42 -04:00
João Capucho 67ef37ae99 Add support for 'break if' to IR, wgsl-in, and all backends. 2022-06-24 17:47:07 -07:00
teoxoy ad536ce0df [wgsl-in] remove unused code 2022-06-16 12:13:08 -07:00
teoxoy 531d563f0e [wgsl-in] implement complete validation for size and align attributes 2022-06-16 12:13:08 -07:00
teoxoy 46387e90ce unify alignment related functionality 2022-06-16 12:13:08 -07:00
João Capucho ae50f31d4f glsl-in: Don't allow empty last case in switch
The GLSL spec forbids switch statements with an empty last case, so we
check that now and throw an error if necessary
2022-06-14 22:31:27 +01:00
João Capucho dab932e8ce glsl-in: Fix last case falltrough and empty switch
GLSL allows the last case of a switch statement to not have a `break`
statement causing it to be marked as fall-trough, naga's IR on the other
hand doesn't allow the last case to be fall-trough, this is fixed by
force marking it in the glsl frontend as not fall-trough.

GLSL also allows empty switch statements and without default cases,
naga's IR requires there be a default case, this is fixed by adding an
empty default case in the glsl frontend if no default case was present
in the switch statement.
2022-06-14 22:31:27 +01:00
João Capucho 52bb25179b glsl-in: Splat inputs for smoothstep if needed
Glsl defines two overloads for smoothstep that accept `min` and `max` as
scalars and the value as a vector, naga's IR is stricter and only allows
operators with the same dimensions, so this inputs must be splatted.
2022-06-14 13:15:08 -07:00
João Capucho 3d3e5ae00d glsl-in: Fix parameter not changing to depth
The conversion from sampled images to depth changed the `argument` type
but didn't change the `parameter` type (`argument` without pointer
indirection) causing 2+ deep propagation of depth images with function
arguments to fail.
2022-06-14 13:11:30 -07:00
teoxoy 53aa3e2df5 [wgsl-in] overhaul number lexing / parsing
Bring the lexer's parsing of numeric literals in line with the WGSL
specification as of 86a23b83 (2022-05-10).
2022-06-10 10:36:07 -07:00
João Capucho e461d30865 glsl-in: Fix matrix multiplication check
The previous check compared rows to rows and columns to columns but
multiplication of matrices only needs the columns of the left matrix to
be equal to the rows of the right matrix.
2022-05-30 22:54:14 +01:00
João Capucho cff744dc89 spv-in: Implement OpBitReverse and OpBitCount 2022-05-30 22:51:50 +01:00
Jim Blandy 6a3f526c12 [spv-in] Finish truncated comment. 2022-05-30 14:31:26 -07:00
João Capucho 9e75332283 glsl-in: Stop emitter in conditional
This wasn't being done when there were no implicit conversions, causing
the emitter to panic.
2022-05-30 13:27:06 -07:00
Jim Blandy f035854dac Doc tweaks. 2022-05-25 17:17:47 -07:00
Nicolas Silva f9dfc38c40 Add a helper for getting the location of a span in some textual source. 2022-05-25 17:17:47 -07:00
Ashley Ruglys 196c9981bc Run cargo fmt 2022-05-22 08:42:20 -07:00
Ashley Ruglys fea733f58e Add MultiView to SUPPORTED_CAPABILITIES 2022-05-22 08:42:20 -07:00
grovesNL 60ae549fe1 Add error for non-floating-point matrix 2022-05-14 17:00:15 +02:00
teoxoy 6dae3ac7e0 [wgsl-in] support partial vector & matrix identity constructors 2022-05-12 22:15:45 -07:00
teoxoy fea33c682e [wgsl-in] fix incr/decr not matching ValuePointer 2022-05-11 20:01:46 -07:00
teoxoy ceb92921c2 remove named expression entry for phony assignment 2022-05-10 10:43:25 +02:00
teoxoy ecd6d4e4aa [spv-in] translate OpSMod correctly 2022-05-09 20:48:09 -07:00
teoxoy 0d4098d634 [spv-in] translate OpFMod correctly 2022-05-09 20:48:09 -07:00
teoxoy c03d840755 [glsl-in] translate mod fn correctly 2022-05-09 20:48:09 -07:00
João Capucho 883a88580f glsl-in: Apply comments 2022-05-01 13:52:04 -07:00
João Capucho 6a62d009ea glsl-in: Improve the context emitter interface
Adds a new method `emit_restart` to perform the common operation of flushing
the `emitter` to the body and starting it again.

Adds documentation to all context emitter related methods
2022-05-01 13:52:04 -07:00
João Capucho 1c02de537b glsl-in: Fix the ternary to behave as an if
The GLSL specification defines that only one of the branches should be
evaluated making the ternary operator syntatic sugar for an `if`.
2022-05-01 13:52:04 -07:00
Jim Blandy fae939f537 [glsl-in] Simplify control flow in search for main. 2022-05-01 00:29:17 +01:00
Jim Blandy 115a810981 [glsl-in] Use std::mem::take as appropriate. (#1878) 2022-04-30 15:09:35 -04:00
Noel Tautges a99fc27dc1 Change !0 to <type>::MAX or -1, depending on signedness 2022-04-30 10:36:00 -07:00
Teodor Tanasoaia f2e7818e71 [wgsl-in] implement firstTrailingBit/firstLeadingBit u32 overloads (#1865)
* [wgsl-in] implement firstTrailingBit/firstLeadingBit u32 overloads

* fix MSL type issue

reverts https://github.com/gfx-rs/naga/pull/1473/commits/b9162e443dd58cf95c2d7930e9c42b0e0e00ede7
2022-04-26 22:25:53 -07:00
teoxoy 062b66ca31 implement phony assignment 2022-04-26 21:40:31 -07:00
Connor Fitzgerald ad28396851 Implement Binding Arrays (#1845) 2022-04-19 14:23:07 -04:00
teoxoy 850565243d replace unicode-id with unicode-xid 2022-04-18 13:03:37 -07:00
teoxoy 0e2bb0194b refactor consume_token fn body 2022-04-17 21:01:01 -07:00
teoxoy 90b3c18fae fix being able to match ~= as LogicalOperation 2022-04-17 21:01:01 -07:00
teoxoy 340bfcc33a remove unused code 2022-04-17 21:01:01 -07:00
teoxoy 743c8aa387 update lexer to match more unicode characters 2022-04-17 21:01:01 -07:00
Teodor Tanasoaia 7ce98dcc7d Make use of new language features (#1841)
* use strip_prefix

* make fn const (resolving TODO)

* make use of nested OR patterns in match arms

* warn on clippy::missing_const_for_fn

* constify functions

* ignore clippy::missing_const_for_fn for into_inner functions
2022-04-17 03:39:54 -04:00
teoxoy c942a9011b update doc of clamp fn 2022-04-16 08:32:31 -07:00
Igor Shaposhnik fbb77aa0dc [wgsl-in] Update entry point stage attributes 2022-04-15 18:02:48 +01:00
Jakob Hellermann 6427a661f7 add methods on the error types for reusability in wgsl-analyzer (#1827) 2022-04-15 11:13:39 +02:00
teoxoy dd75579d7c fix typos 2022-04-14 13:47:18 -07:00
Jim Blandy 170faab6db Move invariant bit from Binding::Builtin to Builtin::Position. (#1822)
Use the type system to enforce the rule that the invariant attribute
may only appear on `Position` builtins.
2022-04-13 14:57:05 -07:00
João Capucho 954c1f6f4b glsl-in: Add tests for constants NaN handling (#1817) 2022-04-11 16:53:03 -07:00