Commit Graph

253 Commits

Author SHA1 Message Date
James Price 7166f6ba93 validation: Fix continue-bypasses-decl check
An expression that is inside an if-statement condition does not have a
"current block", which is what we were using to see if the usage was
inside a continuing block. Use the current statement to find the
containing block instead.

Fixed: chromium:1251664
Change-Id: Icc808ca1cf6a1b51757da8303901fa5ecb693e83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/65520
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-09-30 17:29:50 +00:00
James Price 1ca6fbad8f msl: Use a struct for threadgroup memory arguments
MSL has a limit on the number of threadgroup memory arguments, so use
a struct to support an arbitrary number of workgroup variables.

This commit introduces a `State` object to this transform, which is
used to track which structs have been cloned eagerly, in order to
avoid duplicating them.

Bug: tint:938
Change-Id: Ia467db186e176a08f160455eab5fd3b3662f56b8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/65360
Auto-Submit: James Price <jrprice@google.com>
Kokoro: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-09-29 18:56:17 +00:00
Corentin Wallez 40ef4a8269 Revert "msl: Use a struct for threadgroup memory arguments"
This reverts commit af8cd3b7f5.

Reason for revert: breaking roll into Dawn.

Original change's description:
> msl: Use a struct for threadgroup memory arguments
>
> MSL has a limit on the number of threadgroup memory arguments, so use
> a struct to support an arbitrary number of workgroup variables.
>
> Bug: tint:938
> Change-Id: I40e4a8d99bc4ae074010479a56e13e2e0acdded3
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/64380
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Auto-Submit: James Price <jrprice@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: James Price <jrprice@google.com>

TBR=bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com,tint-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I58a07c4ab7e92bda205e2bbbab41e0b347aeb1e8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: tint:938
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/65162
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Corentin Wallez <cwallez@chromium.org>
2021-09-27 19:00:15 +00:00
James Price af8cd3b7f5 msl: Use a struct for threadgroup memory arguments
MSL has a limit on the number of threadgroup memory arguments, so use
a struct to support an arbitrary number of workgroup variables.

Bug: tint:938
Change-Id: I40e4a8d99bc4ae074010479a56e13e2e0acdded3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/64380
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-09-27 15:06:13 +00:00
Ben Clayton d1d99bc7de Resolver: Validate that type sizes fit in uint32_t
Bug: chromium:1249708
Bug: tint:1177
Change-Id: I31c52f160e4952475e977453206ab4224fd20df7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/64320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-09-15 17:37:00 +00:00
Sarah de767b1842 validation: fix arrayAcceor/memberAccessor error msg and add unit-tests
Bug: tint:1172
Change-Id: Icbc920dbc6adc9a5c78b8ae7d700b527a4fa48f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/64100
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2021-09-13 19:30:19 +00:00
James Price 1bb637195b resolver: Enable the num_workgroups builtin
The subsequent commits will implement this for all remaining backends.

Bug: tint:752
Change-Id: Id26f920fea93b5678466705612dcbfc229dc878a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63921
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: James Price <jrprice@google.com>
2021-09-13 17:11:58 +00:00
Ben Clayton 25517e9ce8 resolver: Validate unreachable stmts when terminator is in block(s)
Will requires updating the WGSL spec, which currently has rules looser than SPIR-V.

Fixed: tint:1167
Bug: chromium:1246163
Change-Id: Ie8fcfabc0bb89c7fb69c345475ff99c07fa04172
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63560
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-09-09 12:38:19 +00:00
Ben Clayton b7bcbf0d20 Resolver: Traverse expressions without recursion
This CL changes the way that the resolver traverses expressions to avoid stack overflows for deeply nested expressions.

Instead of having the expression resolver methods call back into
Expression(), add a TraverseExpressions() method that collects all the
expression nodes with a simple DFS.

This currently only changes the way that Expressions are traversed. We
may need to do the same for statements.

Bug: chromium:1246375
Change-Id: Ie81905da1b790b6dd1df9f1ac42e06593d397c21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63700
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-09-08 15:18:36 +00:00
James Price 4cc4315d6c Allow array size to be a module-scope constant
Change ast::Array to use an ast::Expression for its `size` field. The
WGSL frontend now parses the array size as an `primary_expression`,
and the Resolver is responsible for validating the expression is a
signed or unsigned integer, and either a literal or a non-overridable
module-scope constant.

The Resolver evaluates the constant value of the size expression, and
so the resolved sem::Array type still has a constant size as before.

Fixed: tint:1068
Fixed: tint:1117

Change-Id: Icfa141482ea1e47ea8c21a25e9eb48221f176e9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63061
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-09-02 13:49:59 +00:00
James Price 69ce5f74ed validation: Reject constructors in workgroup_size
WGSL only allows literals and identifiers as arguments to
workgroup_size.

Also, change "parameter" to "argument" in the workgroup_size error
messages.

Change-Id: Ibd252a7c2f08464d9cdea62707e64a8e4f12893a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63320
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-09-02 10:05:19 +00:00
Ben Clayton b09723e58b resolver: Validate that entry points are not called
Fixed: chromium:1245112
Change-Id: Ibe7e686e7688761fd681bb6b1d331adad84f8d61
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63161
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-08-31 16:14:46 +00:00
Ben Clayton 231648c6a9 resolver: Validate storage class for var initializers
Bug: chromium:1243418
Change-Id: Ia0cec7d77767783b2a3b85400a03c805b51699d8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62942
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-08-27 14:54:47 +00:00
Ben Clayton 9021eb5594 resolver: Allow parameters to shadow globals
In https://dawn-review.googlesource.com/c/tint/+/62444 the Resolver validated that there are no parameters of the same function with the same name, but this also introduced validation that errors if parameters shadow a module-scope variable.

The WGSL spec allows for shadowing, but Tint so far has not implemented this support.

There are transforms that generate functions that presume parameter <-> module-scope variable shadowing is okay. DecomposeMemoryAccess is one of these.

This fixes those transforms which could generate programs that fail validation.

Bug: chromium:1242330
Fixed: tint:1136
Change-Id: Id6ec59bbdb398b3b2a23312115a7c1dadf433e98
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62900
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-26 15:40:06 +00:00
Ben Clayton 6d60c046e8 resolver: Validate that parameter names are unique
Fixed: chromium:1242330
Change-Id: I7a5c32f55b5a4d5898c1fe4efeee084dfeb15346
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62444
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-08-23 19:01:19 +00:00
Ben Clayton 1fa6f5ce9b resolver: Validate calls to void callables
Calls to functions and intrinsics that do not return a value must only be used by a call statement.

Fixed: chromium:1241460
Change-Id: I0f940c942b55a5212367dbf9e261083beb4560ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62440
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-21 08:50:40 +00:00
James Price d47a7ef0cf validation: Reject decorations on local variables
These are never valid. The WGSL parser cannot produce them, but the
SPIR-V reader can since these are not always caught by spirv-val.

Fixed: chromium:1239557
Change-Id: Ie19e4534ffb73b61beaa42046b18b2b8a3f7f65b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62020
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-08-17 16:09:00 +00:00
James Price 06c86a551e validation: disallow non-constructible assignments
The storage type of an assignment has to be constructible, which
prevents stores to atomic or runtime-sized array types.

Change-Id: Ie7bb703bb4c6953a4ddf0286f39d0d3e17b5b1d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61801
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-08-13 15:20:42 +00:00
James Price cbbb420952 validation: disallow atomic type constructors
The type of a type constructor must be constructible, which forbids
atomics. Add checks for non-constructible types when validating arrays
and structures, and then error on any type that isn't explicitly
matched in the outer function. Replaces the separate check for
pointers, which is no longer necessary.

This also removes the validation for "an expression must not evaluate
to an atomic type". The only test that we had for this is no longer
valid (since the type constructor it used is now rejected). There are
no other ways of hitting this particular error, since other validation
rules will always kick in first.

Change-Id: I2172b57ee4e8ee3066aaf0cedc4a26aaca642376
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61800
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-08-13 15:20:42 +00:00
Ryan Harrison 3bcbfc7862 Use foo->source() instead of foo->type()->source() in errors
In these circumstances foo->type() may be null.

BUG=chromium:1238462

Change-Id: I77ed142e3f61f6af52a07e59e290f65613af3514
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61660
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-08-11 19:59:44 +00:00
Sarah 4038fa7f43 validation: atomics access mode and storage class
Bug: tint:901 tint:909
Change-Id: Ibbcdd80ddbe2aa9940bbd73bb404349afc633836
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60080
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-05 15:18:29 +00:00
Ben Clayton ada4864ffe resolver: Fix for-loop conditional validation
It wasn't unwrapping the reference before type checking

Change-Id: I4bfc038c468c32c2a164bbcbef0a97a3e385d5ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60210
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-29 16:55:27 +00:00
Sarah 7249404827 validation: function scope variable store type must be constructible
- function scope variable store type must be constructible
- add IsConstructible() to sem::atomic

Bug: tint:1069
Change-Id: Ib0616b486ecf278dbdd99640dc4ede7f3007feb8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
2021-07-28 22:43:36 +00:00
Ben Clayton 9ba6500c3f resolver: Clean up workgroup_size validation
Actually call Expression() on the workgroup sizes.
This generates the semantic information for the expressions that would otherwise be missing.

Bug: tint:910
Change-Id: I9d7f9d6b029165dfb3bd1e0bf7ce86c0a71dd4d5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60205
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-28 21:24:06 +00:00
Sarah c0f1ed4fe7 validation: validate 'location' attribute when applied to struct members
- 'location' attribute must only be applied to declarations of numeric scalar or numeric vector type
- 'location' attribute is not valid for compute shader
-  locations must not overlap

Bug: tint:1035
Change-Id: I0ba301996f390c8206192d2f81e787e0eac0aa6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59760
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-28 18:51:37 +00:00
Sarah 085dcbbe20 validation: redundant access mode, fix error msg and add unittest
Bug: tint:1070
Change-Id: Ibc6fb02abf891f57874494ddb8dcac0b4480f990
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60140
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-28 09:59:35 +00:00
Sarah edecbb161f validation: pointer to handle is not allowed
Bug: tint:986
Change-Id: Icce391c4741a2b9a090676fc5994a704941e4a30
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58941
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-28 03:57:22 +00:00
Ben Clayton 97668c8c37 reader/spirv: Handle the MatrixStride decoration
Add `transform::DecomposeStridedMatrix`, which replaces matrix members of storage or uniform buffer structures, that have a [[stride]] decoration, into an array
of N column vectors.

This is required to correctly handle `mat2x2` matrices in UBOs, as std140 rules will expect a default stride of 16 bytes, when in WGSL the default structure layout expects a stride of 8 bytes.

Bug: tint:1047
Change-Id: If5ca3c6ec087bbc1ac31a8d9a657b99bf34042a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59840
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-27 08:17:29 +00:00
Ben Clayton fd35aa8e47 Implement texture_depth_multisampled_2d
Implemented for all readers and writers.

Cleaned up some verbose code in sem::Function and the Inspector in the
process.

Fixed: tint:1032
Change-Id: Ia6f2f59e6d2e511c89160b97be990e8b7c9828d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59664
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-07-26 22:19:48 +00:00
James Price d12379a405 validation: type of a let must be constructible
This forbids let declarations from having handle types.

Change-Id: I6f7467b0fa3963711ec705e1a81bfdd2c550feee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59801
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-26 22:11:58 +00:00
Ben Clayton 053559d051 intrinsics: Add new struct form of modf(), frexp()
Implement these for all the writers.
SPIR-V reader not implemented (the old overloads weren't implemented either).

Deprecate the old overloads.

Fixed: tint:54
Change-Id: If66d26dbac3389ff604734f31b426abe47868b91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59302
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-23 16:43:01 +00:00
Sarah 465c5aa51d validation: clean up function attributes validation and unit-tests
- clean up function decorations unit tests
- clean up interpolate and invariant validation and unittest
- add separate unit-tests for each shader stage input and output
- add [[builtin(position)]] tests
- add validation and test for:
structures with 'location' decorated members cannot be used as compute shaders input

Bug: tint:1007
Change-Id: I12e97e163b3a77bc76ce21faba241683eec5d917
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58942
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-23 13:23:20 +00:00
Ben Clayton fced350b3d sem::Type: Replace GetDefaultAlignAndSize() with Size() and Align()
This is a cleaner API, and the implementation doesn't have to know a bunch of information about all the derived types.

Change-Id: I96bebcb9f3ceda86fa34bd8e70961dee63fd7e13
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59301
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-07-22 18:56:54 +00:00
Ben Clayton f5ed2ba906 sem: Rename `Vector::size()` to `Vector::Width()`
`Size()` will be added which is the size of the type in bytes.

Change-Id: If997820d7859cd9d1bb0631d1b72150378e6a24b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59300
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-22 18:31:34 +00:00
Ben Clayton 4ffcf067a3 sem: Add Owner() to sem::Parameter
Change-Id: I3de1e2437b9604378b8368494363e19070443670
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59201
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-07-22 13:24:59 +00:00
Ben Clayton 0f2d95dea3 sem: Split sem::Variable into global, local and parameter
Each of these may contain information specific to their kind.

Change-Id: Ic8ac808088132b7bc2e43da6ce46a06571e0fed5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59200
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-07-22 13:24:59 +00:00
Sarah a4696681eb validation: invariant attribute on struct members
Bug: tint:1008
Change-Id: If3c398b01952f6b482c60cf86ab8ddf724d385a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59060
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-21 12:16:35 +00:00
Sarah 36b49e8834 validation: fix error msg: textureSample*() offset must be a const_expr
Bug: tint:1016
Change-Id: I631ac820f3174ec7ad12e51396b7584df55b27f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59001
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-21 03:34:34 +00:00
Antonio Maiorano 68a6dd0073 Resolver: make IsConstructible non-recursive for arrays and struct members
Also fix cases of implicit conversions of bool to int when creating
sem::Array.

Bug: tint:917
Change-Id: I5392fb737efc410f039b4dbd96cffc5daa4fd3a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58783
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-20 18:28:31 +00:00
Sarah 3d441d48bb validation: validate function call pointer parameter
Each argument of a function call of pointer type must be one of:
- An address-of expression of a variable identifier expression
- A function parameter
Also added source location to duplicate struct member name unittest

Bug: tint:983
Change-Id: Ic5ab010b2ed76207a1d8d3ef9f66140ea95f7e72
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58480
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2021-07-20 18:14:02 +00:00
James Price c41d940650 Parse num_workgroups builtin and reject it
We have chosen not to implement this for origin trial, so just parse
it and produce an error in the validator.

Bug: tint:752
Change-Id: I40ebf0b4051fb0b8bab9d4c733e555b836320cd4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58780
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-19 21:32:27 +00:00
Ken Rockot ac9db206eb inspector: reflect workgroup storage size
This reflects the total size of all workgroup storage-class variables
referenced transitively by an entry point.

Bug: tint:919
Change-Id: If3a217fea5a875ac18db6de1579f004e368fbb7b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57740
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ken Rockot <rockot@google.com>
2021-07-19 20:30:09 +00:00
Ben Clayton b291cfced9 Resolver: Validate that var/let has a type or initialzier
Fixed: chromium:1230324
Change-Id: I05f6e82696d38014fa1bd16f663c4d39e138d7d5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58682
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-07-19 19:50:52 +00:00
Sarah 0bbe24d4ce validation: struct member name must be unique
Bug: tint:964
Change-Id: I45e324f65fb6e7c20488a154510daca6ae347e47
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58260
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
2021-07-19 17:38:20 +00:00
James Price 1fa28acc7a Add support for converting bool to other types
The only non-trivial case is SPIR-V, which generates OpSelect to
choose between 1 or 0.

Fixed: tint:997
Change-Id: Ifda7b3ec1e0a713843a2da7ed59c3449d4eec8bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58521
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-19 17:35:39 +00:00
Ben Clayton cd7eb4f968 Resolver: Validation for continuing blocks
Check they do not contain returns, discards
Check they do not directly contain continues, however a nested loop can have its own continue.

Bug: chromium:1229976
Change-Id: Ia3c4ac118ffdaa6cca6025366c19f9897718c930
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58384
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-07-17 18:09:26 +00:00
Ben Clayton 725159c17c resolver: Limit the number of parameters to 255
See: https://github.com/gpuweb/gpuweb/issues/1959

Fixed: chromium:1228642
Change-Id: Iadedd0a1396ebb6a006caa99e0931a92eb2c008e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58390
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-07-17 17:45:25 +00:00
Sarah c33503069c validation: location decoration is not valid for compute shaders
Bug: tint:981
Change-Id: I15024e0cf836af4f3ad7a14b8cd51c24fc3cd536
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58067
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
2021-07-16 19:11:54 +00:00
Sarah 71198438ac validation: textureSample*() offset argument must be literal or const_expr
Bug: tint:939
Change-Id: I4ba44902948e38aa9ce3e9ecae9b3b4b593bd93d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2021-07-16 13:38:05 +00:00
Antonio Maiorano 60dae2490d Reland "Validate storage class constraints"
This is a reland of fd5829e5ea

Original change's description:
> Validate storage class constraints
>
> As defined by https://gpuweb.github.io/gpuweb/wgsl/#storage-class-layout-constraints
>
> Bug: tint:643
> Change-Id: I9c78ba69a792a80c263a17b0a6e9b4810fdb7f30
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56780
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>

Bug: tint:643
Change-Id: I62036d615a062597339a9d130b7ccf49b5be26c7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-07-15 19:09:25 +00:00