Commit Graph

689 Commits

Author SHA1 Message Date
Ben Clayton c64ca23d94 tint: Deprecated module-scope 'let' for 'const'
Enable the parsing of 'const'.
Warn on use of module-scope 'let', and automatically replace with 'const'.

Fixed: tint:1580
Change-Id: I214aabca80686dc6b60ae21a7a57fbfb4898ea83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93786
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-29 00:55:36 +00:00
Ben Clayton 03f88e6f49 test/tint/expressions/type_ctor: Use 'var' instead of 'let'
Module-scope 'let' is getting replaced by 'const'. For all backends,
'const' will be inlined into the place of usage, making most of these
tests produce no output (if replaced with 'const'). Instead switch to
emitting with 'var'.

Bug: tint:1580
Change-Id: Ied5ddf9cdb7fbd3cef8e7b0c6f4983748aaa3d07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94688
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-29 00:51:46 +00:00
dan sinclair d23f296a9a tint: Implement acosh, asinh, atanh
Polyfill them completely for HLSL.

For the other backends, just add range checks for acosh and atanh.

Fixed: tint:1465
Change-Id: I3abda99b474d9f5ba09abf400381467dc28ea0bd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94380
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-28 15:27:44 +00:00
Zhaoming Jiang 6058882d4b tint/resolver: Add f16 types, constructor, and conversions
This patch add f16 types and their constructors and conversions in
resolver and intrinsic table. Also implement relating unit tests.

Bug: tint:1473, tint:1502
Change-Id: Ida1336193a72a73959e50e6a3eb12be44c0396b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94642
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-28 14:03:36 +00:00
Ben Clayton 53af158366 tint/reader: Allow module-scope 'var' type inferencing
Fixed: tint:1584
Change-Id: I193ad2c00faa4ae2001d981bb38a55d4d6a4c269
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94687
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-28 12:53:56 +00:00
Ben Clayton 19576e9015 tint/writer: Handle and emit 'const' variables
Bug: tint:1580
Change-Id: Ib3a5ff5c567e19eca1ba8fb3c2f7e83dee68e2a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94686
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-28 12:44:16 +00:00
dan sinclair 6c167a0dc7 msl: Promote local private vars to function scope
If a module-scope private variable is only referenced within a single
function, promote it to a function scope declaration instead of
passing it as a parameter. This reduces the number of a function
parameters that are needed in some cases.

Bug: tint:1509
Change-Id: I8951f6216bc7e4cf5abfda314bea1e9ed3ded560
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94002
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-28 02:06:05 +00:00
Antonio Maiorano ce466c0df3 tint: spir-v writer: Fix matrix constructor from matrix variable
Bug: tint:1603
Change-Id: I580a450daa9392316cb628ceeb16490ec591deba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94860
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2022-06-27 20:07:45 +00:00
Ben Clayton bd8449f37d tint/test: Regenerate expectations
Fix collision of two CLs landing with different expectations.

Change-Id: I44eb904b552f635e37dd51dcc94329fbc34af031
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94685
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-06-25 00:55:59 +00:00
Ben Clayton b4ff8c859a tint/resolver: Simplify array size evaluation
Use the constant evaluated value instead of manually traversing
variables to find the literal value. This is a small step towards
supporting 'const' values for array sizes.

Also make our OOB-byte related error diagnostics consistent.

Bug: tint:1580
Change-Id: Idf9eb22cdbf69d750218c554e9f826c30458c6b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94600
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-24 23:30:59 +00:00
Antonio Maiorano 268d7b8357 tint: Add support for atomic ops to spirv reader
The following operations are supported:

OpAtomicLoad
OpAtomicStore
OpAtomicExchange
OpAtomicCompareExchange
OpAtomicCompareExchangeWeak
OpAtomicIIncrement
OpAtomicIDecrement
OpAtomicIAdd
OpAtomicISub
OpAtomicSMin
OpAtomicUMin
OpAtomicSMax
OpAtomicUMax
OpAtomicAnd
OpAtomicOr
OpAtomicXor

These are not, but may be supported in the future:

OpAtomicFlagTestAndSet
OpAtomicFlagClear
OpAtomicFMinEXT
OpAtomicFMaxEXT
OpAtomicFAddEXT

Bug: tint:1441
Change-Id: Ifd53643b38d43664905a0dddfca609add4914670
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94121
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-06-24 22:28:23 +00:00
Ben Clayton 32cb9cf2f8 tint/writer: Disable constant inlining for lets
Once 'const' is introduced, let will no longer resolve to a
creation-time constant value.

Add temporary code into each of the writers to prevent constants that
originate from a 'let' from being inlined. This will reduce the amount
of noise in later CLs.

Bug: tint:1580
Change-Id: Id3493a43ac09fe9f042ff2d517d04b2ae854d43e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94541
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-24 18:15:39 +00:00
Zhaoming Jiang c5f7e8f0bc tint: Fix emitting identity matrix ctor in HLSL
This patch fix the issue of identity matrix constructors in HLSL. This
patch also fix dawn e2e tests for identity matrix constructors and zero
matrix constructors.

Bug: tint:1596, tint:1545
Change-Id: I6c41eb299c1d5f89cf18720611f450abae26d3f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94042
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-06-24 17:21:59 +00:00
Ben Clayton f47887d207 tint/writer/msl: Generate an array<T,N> helper
And remove the WrapArraysInStructs transform.

Wrapping arrays in structures becomes troublesome for `const` arrays, as
currently WGSL does not allow `const` structures.

MSL 2.0+ has a builtin array<> helper, but we're targetting MSL 1.2, so
we have to emit our own. Fortunately, it can be done with a few lines of
templated code.

This produces significantly cleaner output.

Change-Id: Ifc92ef21e09befa252a07c856c4b5afdc51cc2e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94540
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2022-06-24 17:01:59 +00:00
Ben Clayton 3c054304a8 tint/sem: Support arrays for sem::Constant
https://github.com/gpuweb/gpuweb/issues/3056 proposes that creation-time
constant expressions should support arrays. We have verbal agreement to
update to spec to support const arrays.

Bug: tint:1580
Change-Id: If460f729384d700a1c2149c5b7dbe8613a960184
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94330
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-06-24 15:28:28 +00:00
Ben Clayton 5041480715 tint/writer: Clean up EmitConstant() methods
Aside from more SPIR-V using OpConstantNull, this is a no-op change.
By refactoring these methods, they're easier to read, and contain less
lambda-heavy code.

Change-Id: I89c26b2b9f1cd0785d86fb3293f7cfda550bef2e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94331
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-24 08:06:19 +00:00
Ben Clayton c1cb9dc1a5 tint/resolver: Evaluate constant index accessors
If the object and index are both constant expressions, resolve the
index as a constant.

Note: Expectations have been updated for indexing on 'let's. Once
'const' is introduced, 'let' will no longer be treated as a constant
expression, and these expectations will be reverted.

Bug: tint:1580
Change-Id: I42793d36c1a5f82890ccaa5dbbb71b4346493bef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94329
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-23 15:46:54 +00:00
Antonio Maiorano f99671b830 tint: spir-v reader: fix atomicCompareExchangeWeak with var comparator
Also fix HLSL generator to unwrap the ref type when emitting the
comparator value.

Bug: tint:1185
Change-Id: I01d04ca6357e72fd5ead0f25012ab39794e65da5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94522
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-23 13:14:54 +00:00
jchen10 ef62b58cf9 Skip Gamma and Gamut conversions for BT.709->SRGB
This introduces a new field 'doYuvToRgbConversionOnly' in
ExternalTextureParams to have the WGSL only do yuv->rgb conversion for
better performance. User studies shows that users don't really care
about the Gamma difference between 2.4 and 2.2.
https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/color_space.cc;l=1022;drc=a1dbb594a6741a400db35fe3678e77bad2504ea4

Bug: dawn:1082
Bug: dawn:1466
Change-Id: I61c0fe65c5969d8a61c267c202c8dd64c259ed8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92901
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2022-06-22 03:14:26 +00:00
dan sinclair 42fdeb2c8c Remove test/tint/BUILD.gn
The Chrome side of this change has landed so we can remove the forwarding
BUILD.gn file.

Bug: dawn:1275
Change-Id: Iabf2ba1419d3ae670f712aec9d95c75f2c74e662
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94360
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-20 19:33:52 +00:00
dan sinclair 889a499ef4 Remove test/tint/BUILD.gn.
This Cl moves the contents of the test/tint/BUILD.gn file into the
src/tint/BUILD.gn file. This moves the tests into the same build file as
what is being tested. This is more in line with how the CMakeLists.txt
file is setup.

This removes the need to update 2 BUILD.gn files when adding new files
and tests to tint.

Bug: tint:1517
Change-Id: I9beb8a8bff7c10ac875647246ad4362f7e60f7da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94040
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-06-17 13:01:59 +00:00
Ben Clayton dcdf66ed5b tint/ast: Derive off `ast::Variable`
Add the new classes:
* `ast::Let`
* `ast::Override`
* `ast::Parameter`
* `ast::Var`

Limit the fields to those that are only applicable for their type.

Note: The resolver and validator is a tangled mess for each of the
variable types. This CL tries to keep the functionality exactly the
same. I'll clean this up in another change.

Bug: tint:1582
Change-Id: Iee83324167ffd4d92ae3032b2134677629c90079
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93780
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-17 12:48:51 +00:00
dan sinclair 4b88dbcf8e Fixup continue support in while loops.
The generators were not setting `emit_continuing_` when emitting while
loops. This caused a crash when a `continue` was encountered. This CL
adds the `emit_continuing_` setup to the while emission. It also guards
the `emit_continuing_` usage with making sure the function is setup.

Bug: tint:1490
Change-Id: Ia89c49e567acda71a1f851a582103723cff71d49
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93960
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-06-16 15:27:38 +00:00
dan sinclair 49d1a2d950 Add while statement parsing.
This CL adds parsing for the WGSL `while` statement.

Bug: tint:1425
Change-Id: Ibce5e28568935ca4f51b5ac33e7a60af7a916b4a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93540
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-06-16 12:01:27 +00:00
James Price 3e38d7effe tint: Remove support for smoothStep builtin
The new spelling `smoothstep` was introduced in M102.

Fixed: tint:1483
Change-Id: Ia5e1401f8f09450a3a767b0bb975216bd85be8db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93360
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-06-15 23:32:14 +00:00
dan sinclair b29892be09 Update src/tint unittests to new @stage format.
This CL updates all of the Tint unittests to the new @stage shorter
syntax. This also updates the WGSL writer to emit the new short forms
instead of using the deprecated form.

Bug: tint:1503
Change-Id: I8c49e5319a19cccb5b4b5078f3ab39c50f31a9a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92483
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-07 13:55:34 +00:00
Antonio Maiorano f25140fe6f tint: fix emitting duplicate structs for atomicCompareExchangeWeak
Bug: tint:1574
Change-Id: Id4ae2d2de9ac4678260f4ecfb3a0f779d170f9a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92280
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-06-03 14:47:01 +00:00
dan sinclair f0c150b01b Add parsing of shorter stage attributes.
This CL adds the ability to parse the `@compute`, `@fragment` and
`@vertex` attrbutes. The `@stage(...)` are still accepted and are not
marked as deprecated yet.

Most tests are still using `@stage(..)` except for a testing one.

Bug: tint:1503
Change-Id: I85cad5996605035e83109b021ffb13db98b1a144
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92480
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-06-03 02:47:40 +00:00
Ben Clayton c0af5c5c9c tint: Add builtin tests for arguments passed by var
Change-Id: I81b69d23e40675d7f525e6369afec9aa0659d043
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92321
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-02 14:36:10 +00:00
Ben Clayton eb29f81883 tint: Shuffle builtin test directories
mv test/tint/builtins/gen -> test/tint/builtins/gen/literal

We're going to add another set of these for builtins that use 'var' for
each argument.

Change-Id: I1b4ad1495ddccd48232603db2205bf50af9e36b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92320
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-01 19:49:50 +00:00
Ben Clayton b1d5bc8418 tint: Add tests showing tint:1332 is fixed
The abstract-numeric work has fixed this, by removing the error for
small floating point numbers.

Fixed: tint:1332
Change-Id: Ibf7382795210220d343d62fe22d201cf67db1ccc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92244
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-01 18:26:40 +00:00
Ben Clayton e593585e21 tint/transform: Remove FoldConstants
No longer used.

Bug: tint:1504
Change-Id: I48548afc421a2658b5367125bd63c80a7f4bc87f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92084
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-01 16:04:19 +00:00
Ben Clayton 8e3485248e tint/writer/spirv: Inline constant expressions
This is required to handle materialized values, and for constant
expressions.

Bug: tint:1504
Change-Id: If0a49e9b03566c06aa6e4e4c284fc427e1541e91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92082
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-01 15:57:22 +00:00
Ben Clayton e9f8b09063 tint/writer/hlsl: Inline constant expressions
This is required to handle materialized values, and for constant
expressions.

Bug: tint:1504
Change-Id: I79ad567954de2d1cfea09dda255894e4e2aa678e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92081
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-01 13:14:39 +00:00
Ben Clayton cb6ddd2aa6 tint/writer/msl: Inline constant expressions
This is required to handle materialized values, and for constant
expressions.

Bug: tint:1504
Change-Id: Ic3ac62317241fa6f7009360128f222aeb56f62e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92083
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-01 10:08:29 +00:00
Ben Clayton 25b7e98d11 tint/writer/glsl: Inline constant expressions
This is required to handle materialized values, and for constant
expressions.

Bug: tint:1504
Change-Id: Ie0177f148e08a0e1a3f4d7e06e283f121655804b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92080
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-06-01 01:11:59 +00:00
James Price 37d92ca244 tint/spirv: Fix atomicCompareExchangeWeak
We were missing an `UnwrapRef` when generating the return type, and
were generating invalid SPIR-V when the value being stored was a
reference. The auto-generated builtin tests only test with literal
values.

Fixed: tint:1573
Change-Id: If42280b3cc8ad3fba7355d333e02400c6db843fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92144
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-06-01 00:03:29 +00:00
Ben Clayton 16175ac2df tint: Remove use of inf / nans from e2e tests
We're not supporting these, even as hex-floats. Replace them with finite
float values.

Bug: tint:1504
Change-Id: Id5e304d2bdd79576b68b43a1afb5cce2cd6ad01a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91967
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-05-31 21:35:00 +00:00
Ben Clayton 8bd5fec482 tint/writer/wgsl: Emit 'f' suffix on FloatLiteralExpressions
If the literal was constructed with an 'f', make sure we print it.

Bug: tint:1504
Change-Id: I6f04e31a166919c07574db56b0a2063ce5b8ca5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91965
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-05-31 20:45:59 +00:00
Antonio Maiorano 08f4b557fc Implement atomicCompareExchangeWeak returning struct instead of vec2
Also fixed implementation of this atomic in GLSL. It was emitting code
that would not compile because, as for HLSL, we must pass in the
variable directly to atomic funcs, not via an in/out arg to a function.

Bug: tint:1185
Change-Id: Id0e9f99d6368717511ef3a94473634c512e10cb8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91881
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-05-31 13:20:28 +00:00
Ben Clayton 572eaf271e tint: Remove ConversionFailure::kTooSmall
Nothing errors on this. Simplifies code.
Also: Disable MSVC warnings about constant overflow.

Fixed: tint:1564
Change-Id: I5bb2c2ebb89966f5b3f7cbcd73672e110b1b98cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91622
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-27 20:22:26 +00:00
Antonio Maiorano b0d9c15821 tint: Remove skips for tests that now pass latest DXC
Bug I filed at
https://github.com/microsoft/DirectXShaderCompiler/issues/4422 has now
been fixed by
https://github.com/microsoft/DirectXShaderCompiler/pull/4446.

Kokoro always uses the latest DXC build, so this should now pass.

Bug: tint:1523
Change-Id: Ib19a04fc936b45001c3a56b0499fb4fd43e96db8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91600
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-26 13:06:55 +00:00
Ben Clayton 9707e6bb38 tint: Rework sem::Constant to be variant-of-vector
Instead of vector-of-variant.
This:
• Makes it impossible to produce a mix of scalar variant types, which
  would make no sense.
• Reduces the size of a Constant, by removing the union-tag from each
  element.

Also clean up terminology. Rename 'Constant::Scalar' to
 'Constant::Element'. Scalars are well-defined in WGSL, and with the
introduction of abstract-numerics, this no longer makes sense.

Bug: tint:1504
Change-Id: I599aa97ad1ea798b7db8e512a5990ba75827faad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91304
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-05-25 19:28:55 +00:00
Ben Clayton c2eccfc887 tint: Add more helpers to tint::Number
• Add tint::CheckedConvert for converting between Number values and
  checking that the value fits in the target type.
• Quantize the f16 values.
• Add tint::NumberUnwrapper<T> to obtain the underlying type of a
  number.
• Add ostream '<<' operator.
• Add inequality operators.

Bug: tint:1504
Change-Id: I7afa64867a8df0e55ccee16de14ce6a93fbe1965
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91303
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-05-25 15:04:24 +00:00
Ben Clayton 3c83be8a5b tint: Add utils::Result
A simple success / failure return value utility.

Change-Id: I704cb714b3f371520424926647a0bec1a186484f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91301
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-05-25 14:29:54 +00:00
Ben Clayton 932418ef46 tint: Implement abstract-numeric materialization
Implement materialization of abstract-numeric typed expressions to
concrete types.

TODO: Validation to ensure that the abstract-numeric values actually fit
in their materialized types.

Bug: tint:1504
Change-Id: I72b3a6a8801d872a4c4dfb85741073a05847ad48
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91028
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-05-24 21:42:03 +00:00
Antonio Maiorano ab4c035762 tint: fix HLSL countOneBits and reverseBits for i32 args
These two functions in HLSL only accept and return uint. Thus, if the
result of these calls is passed to a function that wants int, it will
fail, or call the uint overload if one exists. Fixed by casting the
result to int if the arg is int.

Bug: tint:1550
Change-Id: Id4c0970a29ac4c83ee5b78be8d2762e05e4a3f03
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91001
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-20 01:58:40 +00:00
Ben Clayton 2081ee43bf tint: Add sem::Materialize
A new semantic expression node that wraps another semantic node. Used to
indicate the point at which compile-time, abstract numeric typed
expressions are implicitly converted to a concrete type.

Bug: tint:1504
Change-Id: I52e256bbbdeaa9d9eff4cb93b6f937dd00bdc5cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90531
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-05-19 19:32:29 +00:00
Ben Clayton 7f2b8cd8fc tint: Refactor Extensions / Enables.
* Extract ast::Enable::ExtensionKind to ast::Extension.
* Move the parsing out of ast::Enable and next to ast/extension.h
* Change the ast::Enable constructor to take the Extension, instead of
  a std::string. It's the WGSL parser's responsibility to parse, not the
  AST nodes.
* Add ProgramBuilder::Enable() helper.
* Keep ast::Module simple - keep track of the declared AST Enable nodes,
  don't do any deduplicating of the enabled extensions.
* Add the de-duplicated ast::Extensions to the sem::Module.
* Remove the kInternalExtensionForTesting enum value - we have kF16
  now, which can be used instead for testing.
* Rename kNoExtension to kNone.

Bug: tint:1472
Change-Id: I9af635e95d36991ea468e6e0bf6798bb50937edc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90523
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-18 22:41:48 +00:00
Ben Clayton e0ff664a7f tint: Add sem::Type::ConversionRank()
Returns the implicit conversion rank as defined by:
https://www.w3.org/TR/WGSL/#conversion-rank

Bug: tint:1504
Change-Id: I17b17a1d3b4f0e5816a92ec0b86d364c288b59d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90663
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-05-18 08:20:31 +00:00