Commit Graph

2908 Commits

Author SHA1 Message Date
David Neto c1cfa84ff9 spirv-reader: reduce fragment output location
MSL compiler requires colour output location at most 7.

Bug: tint:1043
Change-Id: I2b0c09fecae124cc4af05712d7f3c872c2f93f99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60081
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-07-28 15:49:27 +00:00
egj cc6d5b464d Add regex fuzzer
A fuzzer that mutates a WGSL code by finding two regions enclosed by
semicolons and swapping them randomly.

Change-Id: I5b14eb21fd2924227d05ac516f806c6e2efa6198
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58395
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alastair Donaldson <afdx@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <afdx@google.com>
2021-07-28 11:11:26 +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
Alastair Donaldson 3647df3fb7 SPIR-V Tools fuzzer: validate before mutation
ClusterFuzz will provide inputs to a fuzzer that did not necessarily
come from the current fuzzing run, thus the SPIR-V Tools mutator can be
presented with arbitrary inputs. This change causes it to validate
inputs before mutation, and reject invalid inputs.

Change-Id: Ic90e62e4f80f38826765b0d815e4f41de915b5df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59661
Auto-Submit: Alastair Donaldson <afdx@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-27 16:32:59 +00:00
Ryan Harrison dee93c6b9a Handle complex cases in Inspector::GenerateSamplerTargets
This code was implicitly assuming that all resources it was looking
for would be directly referenced at the intrinsic callsite, and not
passed via function parameters.

This was causing a crash in more complex cases.

The inspector code has been updated to handle cases where the
resources are not being directly referenced.

Unneeded calls to GenerateSamplerTargets() are removed.

Utility function GetOriginatingResources() is added to handle walking up
call sites to resolve resources.

Text shader based test runner is added to the Inspector tests to make
expressing complex tests easier.

BUG=tint:967

Change-Id: I2ecb6d57c518003da59f38b261bae4d62ce7e6ac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59340
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-27 15:42:51 +00:00
David Neto dffa60ca98 spir-writer: handle break continuing block
The continuing block can exit the loop in very constrained ways:

When a break statement is placed such that it would exit from a loop’s
§ 7.3.8 Continuing Statement, then:

   - The break statement must appear as either:
     - The only statement in the if clause of an if statement that has:
       - no else clause or an empty else clause
       - no elseif clauses
     - The only statement in the else clause of an if statement that has an
       empty if clause and no elseif clauses.
   - That if statement must appear last in the continuing clause.

By design, this allows a lossless round-trip from SPIR-V to WGSL and
back to SPIR-V.  But that requires this special case construct in WGSL
to be translated to an OpBranchConditional with one target being
the loop's megre block (which is where 'break' branches to), and the
other targets the loop header (which is the loop backedge).  That
OpBranchConditional takes the place of the normal case of an
unconditional backedge.

Avoids errors like this:
 continue construct with the continue target X is not
 post dominated by the back-edge block Y

Fixed: 1034
Change-Id: If472a179380b8d77af746a3cd8e279c8a5e56b37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59800
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-27 15:12:27 +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
Corentin Wallez c6cbe3fda6 Remove InputStepMode (it was deprecated in favor of VertexStepMode)
Bug: dawn:1023
Change-Id: Ie5bb84f34f62143f92b59a816c7976f358b5c102
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59665
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-27 07:33:19 +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
James Price 9a7ca38a86 test: Update E2E expected results
Several more tests are passing now that we have hex float parsing and
vector bitcasts in the HLSL backend.

Change-Id: I2809c83aa78afa7cfec187a2cb1671f79e06a876
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59822
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
James Price 3d73768aec writer/wgsl: Emit access mode on pointer types
Change-Id: If694489a079698df7d767967898d6c5238fe9f54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59821
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
James Price 00320c2580 writer/wgsl: Fix texture_external type emission
Change-Id: I5a622637a03483776b3b4bb2d2b46ad77d3e9eb4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59820
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-07-26 22:02:28 +00:00
David Neto 60d1eb6688 spirv-reader: fix emission of arrayLength
Pass a pointer argument instead of a reference argument.
Also handle the case where the argument is the result of
an OpCopyObject, which will generate a let-declaration of pointer
type.

Fixed: tint:1042
Change-Id: I25b1b7b95ade1b79130e51691194f32b3240e013
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59451
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-26 19:29:38 +00:00
David Neto 1fd3d95dd5 spirv-reader: disable dumping for known bug
Bug: tint:1043
Change-Id: I43759420c1d4f7104de02645505c23049bd867eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59450
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 19:22:59 +00:00
David Neto 85ca807a00 spirv-reader: fix unit test validity
Use Private or Function storage instead of Workgroup storage.

Bug: tint:1043
Change-Id: I07055c30c8b89c9661c2a4913b0c03c3dff5a75b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59562
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 18:54:28 +00:00
David Neto ad8eccea6f spirv-reader: fix storage class for pointer-to pipeline builtins
The DefInfo structure is used for remapping storage buffer types
as well as tracking special values like builtin variables.
In the latter case, don't take the defaulted storage class value
from the DefInfo initialization.

Fixed: tint:1040, tint:1043
Change-Id: I41ee364d76e632736d51f4474c97036bcc136c93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59484
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 18:23:58 +00:00
David Neto 4e4cef90fe spirv-reader: disable dumping for known incorrectness
Bug: tint:1043, tint:1039
Change-Id: I6de89097d166df30bcf573ec77b9af6f09eb3d75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59483
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 18:09:59 +00:00
David Neto 1444a2e117 spirv-reader: fix mapping of OpLogicalOr, OpLogicalAnd
These work on scalar and vector of bool, and map to ast::BinaryOp::kOr
and kAnd.

Bug: tint:1043
Change-Id: I009edf8e43c21cb75ccfdcde1106ec177d2fe50e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59561
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 17:34:58 +00:00
Ben Clayton 5f3063359c diagnostic: Disable the printer 'tests'
These just print colors to stdout, and actually do not check anything.
They're pretty, but I'm fairly confident this works now, and doesn't actually give us anything other than spam output.
Disable.

Change-Id: I6144f154345ae115f0899ca7e274fdee8947c785
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59621
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-26 17:23:18 +00:00
David Neto 31579c92b2 spir-reader: fix validity of unit tests
- skip dumping due to SPIR-V Tools validation error for Location
  conflicts for IO variables duplicated on an OpEntryPoint interface
  list (SPIRV-Tools issue #4403)
- Skip dumping for unit test for conversion of RelaxedPrecision
  decoration.

Bug: tint:1043
Change-Id: I8ce3a7660d74b771e3fa62dc39e4e030e4ba6aa1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59560
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 17:18:26 +00:00
David Neto d77c00f419 Update spirv-reader tests to be valid for WebGPU
- each vertex shader must have builtin-position output.
- when testing non-vertex shader features, change to fragment shaders,
  to avoid the need to have a builtin position output.
- Fix ordering of entry point declaration vs. OpName

Bug: tint:1043
Change-Id: Ic66383d42419a1ef893835ae71729ae27fc6e539
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-07-26 16:59:51 +00:00
Ben Clayton dd2e2ba4e2 transform: Add more HLSL keywords
List taken from https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-keywords

Change-Id: I2ef8cae85159d9a5d941c4a2e6e77cdbebaa9f1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59620
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-07-26 15:17:38 +00:00
Ben Clayton 64dfcd2c32 writer/hlsl: Support bitcast of vectors
Add end to end tests

Fixed: tint:1026
Change-Id: I10813cbe6dc4f1bccddf9a8a29e3a249a364c051
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59663
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-26 15:08:28 +00:00
Antonio Maiorano dcd3dcec70 Add support for parsing hex floats to WGSL frontend
As per https://gpuweb.github.io/gpuweb/wgsl/#literals, HEX_FLOAT_LITERAL
token.

Bug: tint:77
Change-Id: I09105df15a1888c2f0c84d7cccd2cc53e596f5cc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58781
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-07-26 14:02:18 +00:00
Ben Clayton 558969dd19 intrinsics: Deprecate textureLoad() for storage textures
Bug: tint:1013
Change-Id: I38fb8988e48ff5bbfc55f57e5e3fd3f9c3b361cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59662
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-26 11:46:47 +00:00
Vasyl Teliman badec55068 Fix null char in AST fuzzer
There is no need to take the null char into account when copying
mutated data with memcpy in AST fuzzer.

Change-Id: I78530c3679a31f252d2eaebd6de2a1261d346a57
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59449
Auto-Submit: Vasyl Teliman <vasniktel@gmail.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-26 11:25:17 +00:00
Corentin Wallez b32c22cead spirv-reader: Polyfill GLSLStd450 Degrees and Radians
Fixed: tint:1044
Change-Id: I5b2f3820b35c47bdc589ef41fb7a8735a7c6dff1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59660
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-26 09:12:57 +00:00
Corentin Wallez 13081d4e46 Deprecate InputStepMode in favor of VertexStepMode
Bug: dawn:1023
Change-Id: Ib2b5f51538e25455779a303564b98b7ee4a7ab40
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59443
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-25 17:21:15 +00:00
James Price 1c6ff0ec3b hlsl: Add 'line' to reserved keywords
Fixed: tint:1037
Change-Id: I46163ac6ec3e8ba7ba1fd31826d04c011fe04973
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59481
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-07-25 06:44:03 +00:00
David Neto f7d0c1cbfe spirv-reader: polyfill scalar reflect
Fixed: tint:1018
Change-Id: I60916d6c4ac4ae8c1a88763c12acf83d19bb2e68
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58821
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-07-24 06:31:02 +00:00
David Neto 70eb1d3573 spirv-reader: polyfill scalar faceForward
Bug: tint:1018
Change-Id: I912c6deaed4e3c3f4c5dfb76e7ed7e917b4c6498
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58820
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-07-24 06:11:52 +00:00
Ben Clayton 48411444b4 writer/[hlsl,msl]: Default `name_printed` to false
Addresses the review comment:
https://dawn-review.googlesource.com/c/tint/+/59302/4/src/writer/msl/generator_impl.cc#1932

Change-Id: I4cd6e0e626748328ca2bacc74aa9127cb224cf4a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59448
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-23 18:40:32 +00:00
Ben Clayton 294cb95f0e Re-generate expected outputs.
Change-Id: I97fc90d33fe7620b3fccfab343a9c0bbfdf6924c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59447
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-23 17:52:26 +00:00
Ben Clayton 5ac96af72c test: Add FXC test cases for indexing arrays in structs
Also move:
  test/fxc_bugs/vector_assignment_in_loop
to
  test/bug/fxc/vector_assignment_in_loop

Change-Id: I7bbfc476fdb7a3296025609625e322fed8d16285
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59444
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-23 16:44:52 +00:00
Ben Clayton 7204756d4d intrinsics: Add `mix(vec, vec, f32)` overload
Fixed: tint:1029
Change-Id: Ie367947bd9bf65ad6bb2c278bbe4bd0740512faa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59446
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-23 16:43:01 +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
Sarah f76c227cee parser: fix wgsl expect_const_expr()
Bug: tint:1025
Change-Id: I35aab866ffce57681662f59e4b8e701bb03cf718
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2021-07-23 13:15:10 +00:00
Alastair Donaldson f7e73d4ee3 Add tests derived from VK-GL-CTS
This adds SPIR-V assembly and WGSL tests derived from VK-GL-CTS commit
571256871c2e2f03995373e1e4a02958d8cd8cf5. The following procedure was
followed:

- Those .amber files in VK-GL-CTS wholly owned by Google were
  identified

- All GLSL and SPIR-V shaders were extracted from the Amber files and
  converted into SPIR-V binaries

- The compact-ids pass of spirv-opt was applied to each binary

- Duplicate binaries were removed

- spirv-opt -O was used to obtain an optimized version of each remaining
  binary, with duplicates discarded

- Binaries that failed validation using spirv-val with target
  environment SPIR-V 1.3 were discarded

- Those binaries that tint could not successfully convert into WGSL were
  put aside for further investigation

- SPIR-V assembly versions of the remaining binaries are included in
  this CL

- test-runner with -generate-expected and -generate-skip was used to
  generate expected .spvasm, .msl, .hlsl and .wgsl outputs for these
  SPIR-V assembly tests

- Each successfully-generated .expected.wgsl is included in this CL
  again, as a WGLSL test

- test-runner with -generate-expected and -generate-skip was used again,
  to generate expected outputs for these WGSL tests

Change-Id: Ibe9baf2729cf97e0b633db9a426f53362a5de540
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58842
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-23 13:10:12 +00:00
Alastair Donaldson bd3edb564f Disable size assertions in SPIR-V Tools fuzzer
The SPIR-V Tools fuzzer asserts that the binaries it receives have sizes
that are multiples of 4 bytes, as it should only ever run on valid
binaries. This is failing in ClusterFuzz, likely due to the fuzzer being
misconfigured, so for now these assertions have been replaced with early
exits. They should be reinstated once the fuzzer is correctly
configured.

Fixes: chromium:1232308
Change-Id: I1fa980d09ce9e5c349a2cfcebe0246ebad6613fb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59440
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Alastair Donaldson <afdx@google.com>
2021-07-23 11:21:41 +00:00
Ben Clayton ba93d14c9a fuzzers: Fix use-after-free
Diagnostics hold a pointer to the source, used for printing the source in the error message.
Because of this, the source must live at least as long as the diag::list.

Fixed: chromium:1232097
Change-Id: Iad8b30a2bd69f505dd8bb0eadc5a35115400d047
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59360
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-22 22:53:24 +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
James Price 4261466a84 writer/hlsl: Ignore struct member offset attribute
These are generated by the SPIR-V reader. Structures used by the
storage and uniform storage classes are handled separately, so we can
safely ignore this attribute for the other storage classes which are
not shared with the host.

Fixed: tint:1027
Change-Id: I8df4b41c687922a97f3b0ed97804cecc17d8997a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-22 14:41:37 +00:00
James Price eb39420ae6 reader/wgsl: Add support for block comments
Handles nested block comments.

Allow unterminated block comments at EOF, as it is not clear whether
WGSL will allow this or not.

Bug: tint:881
Change-Id: Ieae4e0073dab69f773adb32018a9bdaf4f352116
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59180
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-22 14:41:37 +00:00
Ryan Harrison 18d7e785d3 Fuzz WGSL and MSL generator options
BUG=tint:973

Change-Id: I94dc136444e9650dcf3d1c81a52e6d4491b21a16
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59221
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-22 13:25:54 +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