Commit Graph

859 Commits

Author SHA1 Message Date
dan sinclair c98ad87368 Add const-eval for `step`.
This CL adds const-eval for the `step` builtin.

Bug: tint:1581
Change-Id: Idbf773fb88892a8a5e620bcfe8b779dee148f746
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107281
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-27 15:32:45 +00:00
dan sinclair 59d9c89ff7 Add const-eval for `asin` and `asinh`.
This CL adds const-eval for the `asin` and `asinh` operators.

Bug: tint:1581
Change-Id: I18b2eeb4fb85b8979012b48551eefa773d1b980e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106980
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-27 15:10:20 +00:00
Ben Clayton a92f4259d5 tint/writer/msl: Move packed_vector hacks to transform
Attempting to paper over all the MSL standard library holes for packed_vector in the MSL writer added complexity to the writer, produced messy output, and didn't actually catch all the cases where casts were needed.

Add a new PackedVec3 transform that applies the packed_vector -> vec casts in a smarter, more precise way.

Fixed: tint:1534
Change-Id: I73ce7e5a62fbc9cb04e1093133070f5fb8965dce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107340
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-27 14:36:49 +00:00
Ben Clayton 2e376a9bb0 tint/intrinsics: Allow mixing of signed / unsigned integer arguments
Fixed: tint:1733
Change-Id: Id83c5c5a59df062320a9a9fde087a34b85fbaa2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107160
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-26 18:47:02 +00:00
Ben Clayton 13f089095f tint/intrinsics: Texture queries now return unsigned integer / vectors
To match the spec.

Also add a bunch of missing texture test cases to
src/tint/ast/builtin_texture_helper_test.cc. Fix all the tests that were
broken because these were not being exercised.

Fixed: tint:1526
Change-Id: I207b51d307bbdc054b595e0e0e0fd3330607e171
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106681
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-26 18:36:44 +00:00
dan sinclair b3b027d3cd Update lexer to not include `-` in numbers.
This CL removes the parsing of a `-` in front of numerics when lexed.
This will cause the number to become a UnaryOperator negation then the
number instead of a negative number.

Bug: tint:1679, tint:1141, tint:1570
Change-Id: I217c0ffcbe5be934c8d56bd83141b47ade83bc60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106463
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-26 15:20:47 +00:00
Zhaoming Jiang 4faf3581b8 Tint/builder/spirv: Fix atomicCompareExchangeWeak wrong return
This CL fix the spv code generated for atomicCompareExchangeWeak,
specifically the emulated `exchanged` field of the returned struct.
It should be true if and only if the `old_value`, i.e. the return value
of spv `OpAtomicCompareExchange`, equals to the comparator, rather than
equals to new value.

Fixed: tint:1663
Change-Id: I1cb0de6bb6b90ae681f5053b8bdd6f6b247146f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107180
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-10-26 08:23:25 +00:00
Antonio Maiorano 25fdff1ff8 Unrevert "tint: rhs of left shift is always u32 or vector of u32"
Was failing e2e tests. Bug fixed in a parent commit.

Bug: tint:1713
Change-Id: I5cf20e6fd21e6358bb418f2ede7f4a7e0a61f138
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107141
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-25 23:37:07 +00:00
dan sinclair 4c8401f33c Add const-eval for `atanh`.
This CL adds const-eval for the `atanh` operator.

Bug: tint:1581
Change-Id: I7d8989a348ad1d8ca463dae90233fd82d6faf2d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106849
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-25 18:03:56 +00:00
Ben Clayton bd5bd247f0 tint/resolver: Limit scope depth / if-chains.
DXC will bail if these get too deeply nested (~256).
This is also a risk for stack-overflows, so apply a limit agreed by the
WGSL working group.

Fixed: tint:1518
Change-Id: Idacdba85b36b27a0a89a3a7958fd4c6cce7dc84d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105964
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-10-25 16:53:06 +00:00
Ben Clayton 95dd428c75 tint/intrinsics.def: Add @test_value() annotation
Specifies the value to use for argument values when generating end-to-end tests.

Use this to provide a legal value for atanh().

Change-Id: I008050c856f9d687ab918c68e90678c4e74f3a1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106887
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 13:08:45 +00:00
Ben Clayton c3adc78cbc test/tint/builtins: Remove hack for 'level' parameter value
I'm sure this was needed at one point, but I can't seem to find the
requirement in either the spec or implementation. *shrug*

Change-Id: I8c139747c2a6864867ecda0b82a5f7991ad9d3ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106886
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 13:08:45 +00:00
Ben Clayton 6c33dce75a tint/test/builtins/gen: Fix i32 argument values
These were incorrectly abstract-int, instead of i32. Oops.

Change-Id: Iafac4883ee431b04fb473392f545ae26436f8343
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106885
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 13:08:45 +00:00
Ben Clayton da5424b617 tint: Allow signed / unsigned texture builtin params
Bug: tint:1526
Change-Id: I301a9ba6e94b162a1ffb436be3e3212b723b7401
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106682
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-24 23:58:53 +00:00
dan sinclair 20500b8e3a Add const-eval for `atan`.
This CL adds const-eval for the `atan` operator.

Bug: tint:1581
Change-Id: I3d9b417e86af010dc2f18c4e0424ddf971d55984
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106844
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 21:57:27 +00:00
Antonio Maiorano 087c355e08 Revert "tint: rhs of left shift is always u32 or vector of u32"
This reverts commit cc9ae5cae3.

Reason for revert: Kokoro failed on this CL

Original change's description:
> tint: rhs of left shift is always u32 or vector of u32
>
> Implements recent spec change:
> https://github.com/gpuweb/gpuweb/pull/3516
>
> Bug: tint:1713
> Change-Id: I678e3c15ec8ab010dca43fc814cf0bc79486f4b6
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106721
> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,amaiorano@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I9d2337b77e2853c9e26300d0bfdbfba744c54c48
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: tint:1713
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106847
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-24 20:30:12 +00:00
Antonio Maiorano cc9ae5cae3 tint: rhs of left shift is always u32 or vector of u32
Implements recent spec change:
https://github.com/gpuweb/gpuweb/pull/3516

Bug: tint:1713
Change-Id: I678e3c15ec8ab010dca43fc814cf0bc79486f4b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106721
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 18:30:11 +00:00
dan sinclair 3a1b799585 Review feeback from 106420
Change-Id: I9c1ec7f26b0fda25bcedc86fec66d174fe81ed5f
Bug: tint:1633, tint:1451
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106843
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 17:49:20 +00:00
dan sinclair b8b0c21918 Add break-if support.
This CL adds support for `break-if` to Tint.

Bug: tint:1633, tint:1451
Change-Id: I30dfd62a3e09255624ff76ebe0cdd3a3c7cf9c5f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106420
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
2022-10-20 22:45:50 +00:00
dan sinclair f8c07d4753 Add test for split of `--`.
An expression like `b--b` needs the `--` split into two symbols in
order to parse correctly. This change was done previously, adding
a test case to show the generated output.

Bug: tint:988
Change-Id: Id389224e33b7702a90e4c157b02031fb605c1b14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106580
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-20 18:40:53 +00:00
dan sinclair 882b38a2f5 Update fallthrough deprecation notice.
The `default` case selector has been implemented in Tint. This CL
updates the deprecation notice with that fact along with some more
information on replacements.

Bug: tint:1644
Change-Id: I883b4465d11d9696d46523d11e66c9a2dc2777ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106460
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-20 14:03:04 +00:00
dan sinclair 6e77b47ed9 Update internals to initializer instead of constructor.
This CL catches up the internals (along with a few error messages) to
say `initializer` instead of `constructor.

Bug: tint:1600
Change-Id: I8e56572c310d77da1130380bdd32b334f27c8e46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106462
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-20 13:38:28 +00:00
Antonio Maiorano 1c94938726 tint: implement updated spec rules for shift left of concrete values
Rules for shift left of concrete values are now split between signed and
unsigned. Shifting unsigned values no longer fails with "sign change"
errors. Furthermore, shifting unsigned values must only shift out 0s.

See https://github.com/gpuweb/gpuweb/pull/3539.

Bug: tint:1701
Bug: tint:1717
Change-Id: Iba2799f4b02cdc77cc58a6c7c104aaa408f0f0f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106381
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-19 17:46:12 +00:00
dan sinclair f148f0891b [WGSL] Allow default as a case selector
This CL updates the WGSL parser to parse `default` as a case selector
value.

Bug: tint:1633
Change-Id: I57661d25924e36bec5c03f96399c557fb7bbf760
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106382
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-19 15:55:02 +00:00
Antonio Maiorano b6e1bc7d5d tint: Fix C++ UB when shifting abstract 0 left by >= 64
In WGSL, we can shift left abstracts by >= 64, as long as the result is
representable in the data type we choose for it. When shifting 0, we can
shift by any positive u32 value (result is always 0), but in C++, it's
UB to shift by more than the bit width of the data type, so we need to
handle this. This bug was caught by ClusterFuzz.

Bug: chromium:1372963
Change-Id: I638ca190b93538908ca6472f3735627ea8531c5a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106266
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-18 20:17:55 +00:00
Antonio Maiorano 79195ca42a tint/uniformity: implement analysis for full and partial assignments
As per https://github.com/gpuweb/gpuweb/pull/3298

Bug: tint:1703
Change-Id: I88eb40764473fdae52962b36df1b4a1c929603f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105000
Reviewed-by: Alan Baker <alanbaker@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-17 21:47:38 +00:00
Ben Clayton d360c1f9f5 test/tint: Add tests showing tint:1474 is fixed
Fixed: tint:1474
Change-Id: I462ae7bdb17a394b0a4c185fc815fe9727044555
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105963
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-10-14 15:15:29 +00:00
Zhaoming Jiang 32718a5527 Tint/E2E: Fix testcases for bug/chromium/1367602
This CL rearranges testcases for E2E test/tint/bug/chromium/1367602,
now it has testcases for both function, private, and storage address
space array variable, with and without explicit initializer, and array
count less than 65536.

Bug: chromium:1367602
Change-Id: Ica0ec9c36586bc7eae0d46473575284e9b734092
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105282
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-14 02:50:38 +00:00
Ben Clayton 559a248233 tint/resolver: Allow texture 'offset' to be const-expr
This allows the value to be declared in a `const` expression, and to use arithmetic.

Fixed: tint:1636
Change-Id: Ie641a9d4183429c79c91605cd4df78f569be3579
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-13 17:06:29 +00:00
dan sinclair d5139b4463 [msl] Handle packed conversions in shift expressions.
Similar to the handling of packed values in the arithmetic operators
the shift operators need to cast to the unpacked type before doing the
as_type casts.

Bug: tint:1542
Change-Id: I4289c45ab0a067ce122f61675fe5e251a83b6f8b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-13 15:28:51 +00:00
Ben Clayton 51cc480b69 test/tint: add test case for tint:1563
Demonstrates that this is not an issue.

Fixed: tint:1563
Change-Id: I5a33e6805cf0a5c52a6306f6d7e5949cee5636a5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-13 12:55:52 +00:00
Ben Clayton ba384f0383 tint/transform: Fix array materialization when indexing with override
Fixed: tint:1697
Change-Id: I6de9ea520e8e8fcba281c8cf68ad77021eb3dd22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104825
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-12 19:18:25 +00:00
Ben Clayton d6daefc379 wgsl: Print abstract-floats with full precision.
Change-Id: Ie95547f065b896983b90ffd5455538fdd843b81a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104824
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-12 19:13:38 +00:00
Ben Clayton 933eb5159e tint: Add _tint_materialize internal builtin
Returns a materialization of the given argument.

Bug: tint:1697
Change-Id: Id25f7e10baa884047af21f89245884c551560f7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104822
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-06 19:54:07 +00:00
dan sinclair 8fd4ef26f5 Fix MSL packed_int casting.
In 104681 the vectors were cast to themselves to fixup an issue
with `packed_int`. That CL used an `as_type` which does a bit cast.
A `packed_int` can not be bitcast to an `int`. This CL changes to
a type cast, so instead of `as_type<int3>()` it does `int3()`.

Bug: tint:1677
Change-Id: I72218c06853e4e5ae1a0d34e2fc3e1ca597de993
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104682
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-05 17:49:00 +00:00
Antonio Maiorano 8800d885e7 tint: const eval of 'select' builtin
Bug: tint:1581
Change-Id: I222433acb6a30245ab319a15081811f691aca9ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104440
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-05 01:39:53 +00:00
Antonio Maiorano cf47d6147c tint: add parse_hlsl_errors.py to help triage hlsl errors
Change-Id: If160a8c72c407874060024c365faca83722b541f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103760
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-04 19:48:41 +00:00
dan sinclair 1dbda6f254 Update variables in address space template.
This CL updates the address space template to remove some usages of
`stoarge`.

Bug: tint:1404
Change-Id: I4c10f62886d2be4b03bce85dac9d58e3547ca60b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104423
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-04 19:44:48 +00:00
dan sinclair 66d3efb669 Limit array element count to less then 65536 elements.
This CL adds element count limits to arrays. In FXC there is a maximum
of 65536 elements in an array. This limit is not yet in WGSL, but adding
this here allows us to fix the issue with large arrays and GLSL.

Bug: chromium:1367602
Change-Id: I7df9d3e4f6c3e5107420d5f8e576d1f33e453161
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104240
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-03 17:25:42 +00:00
dan sinclair ff7cf21021 Rename StorageClass to AddressSpace.
This CL updates the internals to use AddressSpace instead of the old
StorageClass name.

Bug: tint:1404
Change-Id: Iecc208e839453437f4d630f65e0152206a52db7e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104420
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-03 14:05:23 +00:00
dan sinclair 2bcade246a Update MSL generator to handle casts of packed types.
Currently in the MSL backend we cast int values to uint in order to get
the correct WGSL behaviour for over/under flow. This fails in the case
of host shareable buffers as they use `packed` types which need to get
cast to the non-packed version first.

Bug: tint:1677
Change-Id: I57b70abaa8ca614472a26d63f19c1aef2bd64668
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103986
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-29 19:44:58 +00:00
Antonio Maiorano 06844a5e24 tint/hlsl: remove [loop] attribute on all loops
I added the forcing of the "loop" attribute to all loops to address FXC
failing on uniformity errors related to gradients in loops. Since then,
Tint now implements UA and it recently became an error, so we no longer
need this hack. As a result, FXC is now better able to cope with loops
that it determines executes 0 times.

Most e2e tests are affected because so many use loops, but 27 tests that
were previously failing are now passing with this change:

tint/bug/tint/1538.wgsl.expected.fxc.hlsl
tint/bug/tint/1604.wgsl.expected.fxc.hlsl
tint/bug/tint/1605.wgsl.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_ClassifyCFGEdges_LoopBreak_FromLoopHeader_SingleBlockLoop_TrueBranch.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_ComputeBlockOrder_Loop_HeaderHasBreakUnless.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_EmitBody_IfSelection_TrueBranch_LoopBreak.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_FindIfSelectionInternalHeaders_TrueBranch_LoopBreak_Ok.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserFunctionVarTest_EmitStatement_Phi_MultiBlockLoopIndex.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserFunctionVarTest_EmitStatement_Phi_SingleBlockLoopIndex.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/cov-dead-code-unreachable-merge/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/cov-dead-code-unreachable-merge/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/similar-nested-ifs/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/similar-nested-ifs/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/spv-load-from-frag-color/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/spv-load-from-frag-color/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-false-if-discard-loop/0.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-false-if-discard-loop/0.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/0.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/0.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/write-red-after-search/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/write-red-after-search/0-opt.wgsl.expected.fxc.hlsl

Bug: tint:1522
Bug: tint:1538
Bug: tint:1604
Bug: tint:1605
Change-Id: I530b846b6b8df122ab351ff7b85d3e1c9ac11526
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104121
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-29 16:53:58 +00:00
Antonio Maiorano dadb1fca0d tint: add e2e test for crbug.com/tint/1605
Bug: tint:1605
Change-Id: I6a94552110f4864dcd7fe011063fa35606104b48
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103984
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-28 14:03:49 +00:00
Antonio Maiorano 9b190f57c9 tint: add e2e test for crbug.com/tint/1604
Bug: tint:1604
Change-Id: I7005188a1b3b03934c55e54dc94f548c016166d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103983
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-28 14:03:49 +00:00
Antonio Maiorano 451dcac7bc tint: delete e2e test with invalid SPIR-V
As per dneto's comment
(https://bugs.chromium.org/p/tint/issues/detail?id=804#c27), this is no
 longer valid SPIR-V, and fails in our spirv reader when validating.

Change-Id: I7d2e17b9b5ab827af19e08cb66ad15595a5bb3f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103840
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-27 17:30:57 +00:00
Antonio Maiorano eea420871f tint: add e2e test for crbug.com/tint/1538
Bug: tint:1538
Change-Id: I3fecee57054813cbb7bc6b1343f373d504f631f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104021
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-27 17:30:57 +00:00
Antonio Maiorano 2323977745 tint: add e2e test for crbug.com/tint/1557
Bug: tint:1557
Change-Id: I48e09af3b265443a330248afe5377b76754aea33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104020
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-27 17:30:57 +00:00
Antonio Maiorano 4bffb56cca tint: Fix failing e2e tests due to updated spirv-val
These were marked as SKIP a couple months ago when vulkan-deps were
updated, and our spir-v reader started failing (see
https://dawn-review.googlesource.com/c/dawn/+/98020).

Change-Id: I1206fd5a941b38f00094ab00d0675cd46df77adf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103821
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-26 20:21:25 +00:00
Antonio Maiorano 5b0bab84be tint/fxc: regen e2e tests that are not actual FXC timeouts
- write-before-break/0-opt.wgsl/spvasm compiles correctly and quickly.
- cov-multiple-one-iteration-loops-global-counter-write-matrices\0-opt.wgsl/spvasm fails with a different FXC error.

Change-Id: Ic0d57494bac8d4ca423fbdcd7bca7e918935b522
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103761
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-26 15:17:45 +00:00
Antonio Maiorano f56d8954e3 tint/fxc: delete and regen skips for e2e tests to capture FXC error messages in expected file
Helps with triaging.

Change-Id: I596fb33d9d60e2e364175cdd0ff1966f71423e99
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103640
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-26 14:24:35 +00:00
Ben Clayton 4c70d7fff2 tint: Make uniformity analysis failures a hard error
These have been warnings for multiple months.
Time to properly turn this on.

Bug: tint:880
Change-Id: I3b38f672309b5acd48c12a38dc5a1675f3c62470
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103480
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-09-26 12:30:05 +00:00
Ben Clayton c4ebf2cc57 tint: Implement textureSampleBaseClampToEdge
Fixed: tint:1671
Change-Id: Iaae5b5d571a4401c0255de727245bf8dbbe06740
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102642
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-22 22:59:16 +00:00
dan sinclair 78f8067fd5 Fix overrides in array size.
This CL fixes the usage of overrides in array sizes. Currently
the usage will generate a validation error as we check that the
array size is const.

Bug: tint:1660
Change-Id: Ibf440905c30a73b581d55b0c071b8621b61605e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101900
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-09-22 22:28:21 +00:00
Ben Clayton f2c1d0aa5b tint: Add test cases for tint:1666
This change does not attempt to fix this issue.

Bug: tint:1665
Bug: tint:1666
Change-Id: I9b40a25279b939977c826f38592518b6b086c06b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101161
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-09-21 17:19:04 +00:00
Antonio Maiorano e14a27bc7f tint: remove LoopToForLoop and FoldTrivialSingleUseLets transforms for HLSL and GLSL
Change-Id: I18c807b2449dc2842cb9dbfaeba98dae640d2355
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102621
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-19 14:05:21 +00:00
Ben Clayton 90b29e500a tint/transform/std140: Correctly handle nested / bare matrices
Fixed tint:1673
Fixed tint:1674

Change-Id: Ifa5d2a69131cc1e4679d4d43143f857c7ba46dbd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102640
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-17 01:47:59 +00:00
Ben Clayton 84b43d61fa tint/writer: Handle unnested, uniform matCx2 matrices
Shuffle the transform orders to ensure that these are embedded in a structure before running the Std140 transform.

Add more end-to-end tests for these.

As pointed out in tint:1673, arrays of matrices are not correctly decomposed by the Std140 transform.
This will be addressed by a later change.

Bug: tint:1673
Change-Id: I47c93e458ff48578922d576819792e8ed3a5723c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102541
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-09-17 00:38:19 +00:00
David Neto a3f2bf6c60 spirv-reader: phis as a particular case of hoisting to a var
We already compute the "first" and "last" basic block that
uses a value, so we could know when to hoist a value into
a var declaration. You have to do this sometimes to make
sure all uses are in scope of the declaration.

Until now we tracked Phis with an entirely different mechanism.
But there are cases which broke down. That's what happens
in crbug.com/tint/1649.

Additionally, GraphicsFuzz cases generarte similar weirdness.

Also, be more careful about ensuring that the assignments
generated to feed phis behave as if they occur in parallel.
Within a single batch of such assignments, generate and
use intermediate let-declarations for phis that that batch
will overwrite.

Also, unwrap-references when rectifying the signedness of
binary operators.

Skip tests that fail due to crbug.comt/tint/98:
  test/tint/bug/tint/749.spvasm.*

Fixed: tint:1649
Change-Id: I7314c351b74a10bfa9a18011f3d80a520568011c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101220
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-16 20:18:39 +00:00
Antonio Maiorano ebc5bba671 tint: const eval of binary XOR
Bug: tint:1581
Change-Id: I5605426f0c4b9447ce770092de4ab2f639d0218d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102580
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-16 17:16:38 +00:00
Antonio Maiorano 6ab02659de tint/spirv-reader: add support for GLSLstd450MatrixInverse
Bug: tint:1670
Change-Id: I2faaec03117a00f55624c9a51419eb79cc6da40f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102261
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-15 17:22:25 +00:00
Ben Clayton 751e6686aa tint/intrinsics.def: Implement saturate()
Fixed: tint:1591
Change-Id: I0b1397d74abd49cd44caf326a2063e50c5cf07de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101480
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-13 22:57:52 +00:00
Antonio Maiorano 8a440ee3b4 tint: delete and regen SKIP e2e tests that were missing FXC error message
Change-Id: Id63cd40445bb9dab09ebcc67c5fef45ee29529e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102149
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-13 22:04:22 +00:00
Stephen White 05d8b02b0f GLSL: implement host-visible memory padding.
Since GLSL ES does not support the offset= attribute, struct members
with explicit @align or @size attributes require adding explicit
padding members.  This in turn requires rewriting any constructor
calls to initialize the new padding to zero, handled in the same
transform.

Note that this is currently overly-verbose, and will add padding where
GLSL doesn't technically need it (e.g., padding a vec3 out to 16 bytes).

Bug: tint:1415
Change-Id: Ia9ba513066a0e84f4c43247fcbbe02f5fadd6630
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101720
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-13 19:48:51 +00:00
Antonio Maiorano e53b6f9502 tint: const eval of binary bitwise AND and OR
Bug: tint:1581
Change-Id: Id6a7a1c8e45ee91bede8014dca03a59035b29678
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102060
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-13 18:13:01 +00:00
Antonio Maiorano 5b3707a2d7 tint: Implement const eval of unary not
Bug: tint:1581
Change-Id: If0a74b1f6739725a2284678aab97baf737d96937
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101761
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-13 17:32:17 +00:00
Ben Clayton 4b70776aed tint: Fix transform errors when calling arrayLength() as a statement
Bug: chromium:1360925
Change-Id: If60fa4bb1cf4981c10dd15f8814c0aed70c0066e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101780
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-09 20:42:29 +00:00
dan sinclair e214a130dd Run substitute_overrides for all tests.
This CL updates all of the integration tests to run the substitute_override
transform where needed. The test runner is updated to match comments in
the spvasm files as well as the wgsl files.

Bug: tint:1155
Change-Id: I8187d426970d056d744e530ed6447e4ec69db5f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101661
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-09 16:04:39 +00:00
Antonio Maiorano 29aa613dcf tint: const eval of comparison operations
Change-Id: Iec6e78dbe00baaed8c90e709447a20f6c8ac9fb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101304
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-07 19:34:44 +00:00
Ben Clayton eeda18d55e tint::transform::SingleEntryPoint: Preserve global 'const's
These can be used in all sorts of places which are not tracked by sem::Function::TransitivelyReferencedGlobals().
As they're not emitted as variables by any backend, just preserve them.

Fixed: tint:1598
Change-Id: I2696486cb2ffe8408bd5dd3090d7d600ca1d170f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101481
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-09-07 13:05:24 +00:00
Ben Clayton 8b4ed5093e tint: Fix / remove tests that access OOB
With constant indices.
Also fix the SPIR-V builder tests that did something completely different from the test name / comment.

Bug: tint:1665
Change-Id: I83537cf6e44ffcb14d54de52649d1f9da1ef7e1b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101182
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-06 17:43:23 +00:00
Antonio Maiorano 3740ac6092 tint: implement const eval of binary divide
Bug: tint:1581
Change-Id: I72f7f34046086ad00d3bf8f21d67db831903d60b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100861
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-03 22:42:51 +00:00
Antonio Maiorano 679cf4f351 tint: HLSL and GLSL backends now emit 0 for inf and nan
Bug: tint:1581
Change-Id: I62dcde177c3b82408cd8d737526d10d481b48a17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-03 21:43:01 +00:00
Stephen White 863d9edf59 GLSL: Change Add[Spirv]BlockAttribute to support GLSL
Modify the AddSpirvBlockAttribute transform to fix top-level structure
access of uniform, storage and push-constant buffers for use in the
GLSL backend. The small change to the transform makes the transform
wrap host-sharable buffers, if they're also used as a
non-host-sharable structure. Also rename the transform to
AddBlockAttrbibute in order to reflect its wider applicability.

Change-Id: Ib2bf4ebf6bce72790791dbae9387032be765e4b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101061
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-09-02 19:19:10 +00:00
Ben Clayton 8b30ca3efa tint/transform: Fix FoldTrivialSingleUseLet for abstracts
If the let initializer was an abstract numeric that was implicitly materialized to a concrete type, then we could inlining the initializer into the use without the implicit materialization cast.
This could lead to validation errors, and subtly different results in the program.

In this situation, add an explicit cast to keep the types the same before and after inlining.

Fixed: tint:1664
Change-Id: Icca980cf8af74673906ad6c681a6b07d0c1932fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101160
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-02 13:58:00 +00:00
Ben Clayton 657e61d43d tint: Add and use new Std140 transform
This transform breaks up matNx2<f32> matrices used in uniform buffers
into column vectors, which fixes std140 layout rules.

Used by the SPIR-V and GLSL backends.

Re-enable tests that were disabled for these cases.

Bug: tint:1632
Change-Id: I596d016582b4189a0b413d762b3e7eabd3504b22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100907
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-09-01 22:12:19 +00:00
Antonio Maiorano c20c5dfb4a tint: Implement const eval of binary multiply
Bug: tint:1581
Change-Id: I70ff40ed4d8faf0a665824fef936ffbafb3f0948
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99362
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-01 14:57:39 +00:00
Zhaoming Jiang 426b47e481 tint: add missing F16 conversion expression support
This CL add missing type conversions for f16, especially for SPIRV
backend which require special handling. A transform,
VectorizeMatrixConversions, are also added for SPIRV to replace a matrix
conversion to a matrix construction with converted column vectors.
Unittests for the transform and SPIRV writer, and end-to-end tests for
all conversion rules are added.

Bug: tint:1473, tint:1502, chromium:1356215
Change-Id: Iaff125e5dd295d35c4ab74757eb56b642802a51a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100483
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-01 03:08:20 +00:00
Antonio Maiorano cbe8b36256 tint: spir-v reader: add support for GLSLstd450Determinant
Bug: tint:1061
Change-Id: I18f6d0726c2fac192b8893f35dcbf45bf4a3d752
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100466
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-29 20:52:00 +00:00
dan sinclair 7517e213cf Update `workgroup_size` to use `expression`.
This CL updates the `workgroup_size` attribute to use `expression`
values instead of `primary_expression`.

Bug: tint:1633
Change-Id: I0afbabd8ee61943469f04a55d56f85920563e2da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99960
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-24 21:31:45 +00:00
Zhaoming Jiang ff1330240b tint/transform: Fix index 0 accessing in DecomposeMemoryAccess
This patch fix a bug in DecomposeMemoryAccess, allowing access index 0
of a member in uniform and storage buffer being recognized as constant
index.

Bug: tint:1652
Change-Id: Ia428de17c860bdafe87c3af9e46426c74fe8fd68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99480
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 18:15:00 +00:00
Antonio Maiorano b79238d7ec tint: Implement const eval of binary minus
Bug: tint:1581
Change-Id: I90ce59e89a5b4b9e94de1181ca9d85e9040be3e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99421
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-17 17:38:23 +00:00
Ben Clayton 0f0ba20208 tint/transform: Fix PromoteInitializersToLetTest for materialized constants
PromoteInitializersToLet was not handling sem::Materialize nodes.
This can happen for const arrays when they are dynamically indexed.

Fixed: tint:1653
Change-Id: I3d67d8139e481c89b31a3a30c7ef44384b7545ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99500
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 17:26:41 +00:00
dan sinclair 735e4b4fa1 Emit deprecation for fallthrough.
The `fallthrough` statement is being removed from WGSL. This CL adds
a deprecation warning into the current implementation to prepare folks
for the upcoming removal.

Bug: tint:1644
Change-Id: I599984b6a30b39312c4b794a9ecd70f0f626c759
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98841
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-15 11:41:07 +00:00
dan sinclair 3abad2c125 When emitting a MSL struct initializer emit the struct name.
This CL changes the MSL emission for struct initializers to emit the
struct name first.

`const a = {.f=float3(1)}` becomes `const a = Normals{.f=float3(1)}`.

This fixes an issues where the initialization happens inside an array
which the downstream compiler rejected without the explicit struct
naming.

Bug: tint:1641
Change-Id: I948b9ca94f4b89eac6d5bbbaa615b3d71d50c737
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98760
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-11 02:28:01 +00:00
Antonio Maiorano a58d8c9fac tint: fix builtin calls and binary ops with abstract args of different type
If a call to atan2 with args of type AFloat and AInt is made, Resolver
would correctly select the atan2(AFloat, AFloat) overload, but if the
input args were of type (AFloat, AInt), it would attempt to constant
evaluate without first converting the AInt arg to AFloat. The same would
occur for a binary operation, say AFloat + AInt. Before constant
evaluating, the Resolver now converts AInt to AFloat if necessary.

Bug: chromium:1350147
Change-Id: I85390c5d7af7e706115278ece34b2b18b8574f9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98543
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-10 20:01:17 +00:00
Antonio Maiorano 90d5eb6128 tint: Add RemovePhonies transform to spir-v backend
This will be needed by an upcoming CL that fixes call statements to
builtins that return a constant value. Without this transform, the
constant value reaches the backend, where we don't currently deal with
abstract numbers. Note that the other backends (HLSL, MSL, GLSL) already
use this transform.

Bug: chromium:1350147
Change-Id: Icc1f1416a07db228f8e3f39851a9ac079c48319f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98740
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-10 19:32:23 +00:00
Zhaoming Jiang 9443cebd53 tint: End-to-end tests for f16 built-in
This patch add Tint end-to-end tests for built-ins using f16 types.

Bug: tint:1473, tint:1502
Change-Id: I09db6e0b7e90541fb246e11d475e27be96a6d07e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97340
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-08-05 15:15:17 +00:00
Zhaoming Jiang 20cddbf04c tint: Implement modf and frexp built-ins for f16 types
This patch implement modf and frexp built-ins for f16 types, and also
simplify their implementation for f32 in MSL and HLSL, and clean up
deprecated code in GLSL writer. Corresponding unittests are also
implemented, but end-to-end tests for f16 are not implemented yet.

Bug: tint:1473, tint:1502
Change-Id: I12887ae5303c6dc032a51f619e1afeb19b4603b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98102
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-05 15:11:44 +00:00
Antonio Maiorano 7e9f571814 tint: const eval of binary add
Bug: tint:1581
Change-Id: Ie34ee52bdd4a4c5d45a5f6c0d8d923cc690c8b2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98021
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-04 19:48:27 +00:00
Ben Clayton 52f852fa28 test/tint: Regenerate SKIP expectations
`./test/tint/test-all.sh ./out/active/tint --generate-skip`

A bunch of these got missed by https://dawn-review.googlesource.com/c/dawn/+/98020, as I assumed only `glsl` and `spvasm` backends would be affected.

Some are just refreshes of existing skips

Bug: tint:1632
Change-Id: I1b003a56143b52e8e47bef8a10fec2878a48be06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98120
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-03 09:47:48 +00:00
Zhaoming Jiang 7d7976d590 tint: Add end-to-end tests for expressions using f16 types
This patch add DXC compile flag "-enable-16bit-types" and change profile
to SM6.2 when validating generated HLSL using DXC if f16 extension is
enabled in the WGSL program.
The patch add Tint end-to-end test cases for expressions using f16 type,
including constructor, binary operator, splat, zero-init, and others.
Testcases that use f16 types in uniform or storage buffer are SKIPped,
because such usage is not implemented yet.

Bug: tint:1473, tint:1502
Change-Id: I481ab3d12cbb822f11ef85ba807bca3f9770089b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96252
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-08-03 08:45:25 +00:00
dan sinclair 6f8d945dd6 Sync reserved token list to WGSL spec.
This CL updates the list of reserved words to match the WGSL spec. The
use of a reserved word is changed from an error to a deprecation at the
moment be cause the majority of the list would be new errors.

Bug: tint:1633 tint:1624
Change-Id: I498db41689cdd666dfb291b1a6761a1182c87ec8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98042
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-03 02:49:28 +00:00
Loko Kung 99fa7b9e7f test/tint: Suppresses vulkan-dep failures in crbug.com/tint/1632
Bug: tint:1632
Change-Id: Ie80a94821ddb0cdd467df2b9ee64adae32efde21
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98020
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-02 21:06:55 +00:00
dan sinclair 73778d3b0b Add support for >>= and <<=.
This CL adds `<<=` and `>>=` to the supported operators in WGSL. The
ExpandCompoundAssignment transform is used to convert to the expanded form.

Bug: tint:1594
Change-Id: I20519052c52d4b69bc90def1acc5c0a30c36fd8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97980
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-02 18:18:05 +00:00
Ben Clayton 27f0ea69ea test/tint: Add end-to-end tests for inferred arrays
Bug: tint:1628
Change-Id: Ic3019f5d1db4c7b28c80292075ec68d79f286697
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97664
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-08-02 16:08:45 +00:00
dan sinclair 4abf28e29b tint: Add basic support for chromium_experimental_push_constant.
This extension adds support for the push_constant storage class such
that it can be tested with WGSL test files. The real goal is to allow
future transforms that will add push constants that the SPIRV writer
will output.

The extension:

 - Adds the `chromium_experimental_push_constant` enable.
 - Allows the push_constant storage class for global variables.
 - Adds validation that the types are host-shareable for push_constant
   variables, and that they don't contain f16 (must be 32bit types
   only).
 - Validates that at most one push_constant variable is statically used
   per entry-point.
 - Skips validation that the extension has been enabled if
   kIgnoreStorageClass is used.

Tests are added:

 - For parsing of var<push_constant>
   - Caught a missing conversion.
 - For each of the validation rules.
 - For the wrapping of push constants in structs if needed by
   AddSpirvBlockAttribute.
 - For the layout and type rules of the storage class.
 - For a shader with multiple entry-points using various push constants.
    - Caught a missing reset of the previous push constant variable in
      the validation check that at most one is used.
    - Caught the missing wrapping in structs that had to be added to
      AddSpirvBlockAttribute.
    - Caught incorrect logic when adding diagnostics about the call
      graph leading to the reference to push constants.

Bug: tint:1620
Change-Id: I04a5d8e5188c0dcef077f2233ba1359d1575bf51
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96682
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-02 15:55:35 +00:00
Antonio Maiorano 239a92d2d0 tint: transform::RemovePhonies: skip builtins with no side effects
This transform was attempting to remove builtins with no side
effects, such as a call with abstract int/float args, which is unhandled
by this transform. For example, this would cause the transform to ICE:

_ = clamp(1, 2, 3);

Fixes ClusterFuzz issue crbug.com/1348739.

Bug: chromium:1348739
Change-Id: Ie355eb36c6c020417c2d93f2dc434c11dbb72d1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97880
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-01 17:21:54 +00:00
Zhaoming Jiang 6fe1f515d4 tint: Add f16 support for parts of float built-in, part 1
This patch add f16 support for a major part of numeric built-in, and
implement corresponding unittests for resolver and backends. This patch
also enable f16 constant evaluation for unary minus operator, `atan2`
and `clamp`.

The following numeric built-ins are not supported yet:
* frexp
* modf

The end-to-end tests for f16 built-in are not added yet.

Bug: tint:1473, tint:1502
Change-Id: If807185617b21c510a1a9c371179a60800c4f875
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96722
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-07-29 11:41:51 +00:00
Ben Clayton a253a5f7e7 tools: Expand / clean-up the template WGSL type helpers
Fix `IsAbstract()` so that it doesn't consider most-nested element types.
Add `ElementType()` and `DeepestElementType()` helpers.
Add `OverloadUsesF16` as a helper for https://dawn-review.googlesource.com/c/dawn/+/96722.

Simplifies template code.

Change-Id: Iff5a9a7258caea06e00ee37c29e5298d9c35b799
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97361
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-27 19:36:49 +00:00
Antonio Maiorano bf8ee35498 const eval of clamp
Bug: tint:1581
Change-Id: Icffaf023021e704b3beaacf35136a9d6263b31e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97221
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-27 15:02:25 +00:00