Commit Graph

3189 Commits

Author SHA1 Message Date
dan sinclair a5bba6037a [spirv-builder] Handle single element swizzle.
This CL adds the code to handle a swizzle of a single element (eg vec.x)

Bug: tint:5
Change-Id: If23979c8b715e6770e75fb72c92a91aec83c5b0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20502
Reviewed-by: David Neto <dneto@google.com>
2020-04-28 17:31:07 +00:00
dan sinclair 40aa8d64aa [spirv-writer] Generate loads for call parameters.
This CL updates the call code to emit an OpLoad if the parameter being
passed is a pointer.

Bug: tint:5
Change-Id: I19c2ffa1b55697173ded6d5509fecd37442e7966
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20501
Reviewed-by: David Neto <dneto@google.com>
2020-04-28 17:31:00 +00:00
dan sinclair 228392558f [spirv-writer] Add start of break and continue.
This CL adds the beginning of break and continue support. The
conditional versions are not supported, just the non-conditional.

Bug: tint:5
Change-Id: I84418cffd3e29dc011c4313bf9aa3da4833c009f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20500
Reviewed-by: David Neto <dneto@google.com>
2020-04-27 20:32:56 +00:00
David Neto a92c114c1a [spirv-reader] Label control flow constructs
Label basic blocks with:
- their nearest enclosing structured control flow constructs.
- their nearest enclosing continue construct, if any
- their nearest enclosing loop construct, if any

A construct consists of a span of blocks in the computed block order.
It knows its parent construct, if any, and its nesting depth.

Bug: tint:3
Change-Id: Ia945706e8ea2435d6c40fb4e36dc2daeeb9780d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20421
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-27 20:14:08 +00:00
David Neto 195e4fe575 [spirv-reader] Verify order among header, continue, merge
This is gives us the fundamental ordering of blocks in relation
to a structured construct.

Bug: tint:3
Change-Id: I76eb39403131305398808c33ce4cee256a1c23c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20266
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-27 18:12:50 +00:00
dan sinclair 26ec00a4c2 [spirv-writer] Handle alias struct members.
This CL adds support for alias types in the members of structures.

Bug: tint:5
Change-Id: I22f19b9a57d0f1be0ec4d6299948c1a93766ff9d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20347
Reviewed-by: David Neto <dneto@google.com>
2020-04-27 15:58:55 +00:00
Ryan Harrison d34b210e73 Add fuzzing target to BUILD.gn
TEST=Built fuzzer in local checkout of Chromium with tint integrated.
BUG=dawn:14

Change-Id: I84aacd41f893070c3af40f5e640361e177689f9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20343
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-27 15:31:27 +00:00
David Neto 597f52add2 [spirv-reader] Fix labels in CFG tests
Bug: tint:3
Change-Id: I13c67649d7e630828eeae34a2b4cd5612d5f2217
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20420
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 19:11:43 +00:00
dan sinclair 75dbd8739e Add missing storage classes to compute boids.
This CL adds the missing storage classes to the module scoped variables
in compute boids.

Change-Id: I59cbe0f9bcc4b235f2f9157801dcbc445a6bd5eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20346
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:41:23 +00:00
dan sinclair 361e457438 Fixup non-const identifiers in type constructor.
As long as a type constructor is not global the values can be non-const
which means they don't have to be constructors. This CL fixes an issue
where we incorrectly assumed the value was a constructor.

Change-Id: Ib1661830cbb14298ea9254145edd60b74e0dee1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20344
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:41:12 +00:00
dan sinclair b445a9bf80 Unwrap member accessor aliases
The member accessors end up being aliases in a lot of cases because you
can't have a struct that isn't an alias. This Cl unwraps the aliases at
the start of the determination for member accessors.

Change-Id: Ib090ebd6aedd502c2812d95373c19d8eb831a361
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20342
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:40:45 +00:00
dan sinclair e6759029fb Unwrap pointer arguments to imported methods.
Make sure we unwrap pointers in import determination so things like
passing a member of a struct will determine the import correctly.

Change-Id: Id4565351c45e7798664c3368e2dec19b1440492d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20341
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:40:12 +00:00
dan sinclair 9eab206e3f [spirv-writer] Test loading and storing to an accessor.
This CL adds load and store tests for a member accessor result.

Bug: tint:5
Change-Id: I5b8da3bb8d3df2c150967c812ffe3eeae3189fa7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20340
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 22:27:15 +00:00
dan sinclair 8eddb78433 Update type determiner to create pointers.
This CL updates the type determiner such that variable result types
end up wrapped inside pointers, constants do not. The result of Member
and Array accessors are also pointers if the source was a pointer.

Change-Id: I6694367daf6ba1db929e54a975dfea8404fca40c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20265
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 22:26:52 +00:00
dan sinclair 1a4d90667b [spirv-writer] Add start of single swizzle test case
This CL adds a DISABLED test for the single swizzle case.

Bug: tint:5
Change-Id: I75df147adba4e2e2b7eb6bfd0e0ede951502a73d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20300
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 20:35:32 +00:00
David Neto 742790c8ff Fix nits from review
From review https://dawn-review.googlesource.com/c/tint/+/20080
- single_block_loop -> is_single_block_loop
- better message for internal error for missing block when registering
  merges

Bug: tint:3
Change-Id: Ief8ac5ce8ad7ffe93c28e0e7e2a793d50ce2de6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20345
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 20:28:34 +00:00
David Neto a82384ee97 [spirv-reader] Add ordered float inequalities
Bug: tint:3
Change-Id: I302001a7d368cb09068df1220e81885a813fa247
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20246
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto ce84ac5023 [spirv-reader] Add signed integer inequalities
Bug: tint:3
Change-Id: Ic73491c2a00e5b9fd1aa70c385341ae79666cd1c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20245
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto 1c6164363e [spirv-reader] Add unsigned integer inequalities
Bug: tint:3
Change-Id: If50d3816962679a8c199a515e8e0b4cdaf91a88c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20244
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto daf4b3a60d [spirv-reader] Add LogicalEqual LogicalNotEqual
Bug: tint:3
Change-Id: I4925ccf555ea7d0dadcafeb539317a00b1a4b92f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20242
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto 592a71c647 [spirv-reader] Test OpLogicalNot, vector case
Also, list remaining logical instructions to be tested

Bug: tint:3
Change-Id: I48dda1d3637bc7c4d75358e26fb9de8f0c6f0bb6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20261
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto c7e8c9c1a9 [spirv-reader] Test position field of BlockInfo
Bug: tint:3
Change-Id: I746b04b545da9dcd7c0b8805f264b67cb59c8a1c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20240
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto 0131580407 [spirv-reader] Register merges
Record header/merge cross-links, and single_block_loop attribute of BlockInfo.

Also checks that they are sane: only target blocks in the same function.

Bug: tint:3
Change-Id: I715f7ed354a556e92d58a4c9ba6f306c746c3641
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20080
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
Sarah Mashayekhi dd218b050d Assing const As.* functions to type class
Change-Id: I99c588b53f28da119611ef0a5b27820cdaa57fc2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20262
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:52:51 +00:00
Sarah Mashayekhi cb883a2817 Adding const As.* functions to expresssion class
Change-Id: I57fbe9d5c5054b65d64f1992e5e33dd31dd64a36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20263
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:52:32 +00:00
Sarah Mashayekhi 194b6a2fce Adding const As.* functions to statement class
Change-Id: Ie9c0cecfce1ebb7decf377cee7053fb7ae0dee9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20260
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:52:10 +00:00
Ryan Harrison 13a652963c Rename tint_fuzz to tint_wgsl_reader_fuzzer
This is in anticipation of future fuzzer implementations.

BUG=tint:56

Change-Id: I73492c135bed7d5bee9c114ec336a837b4f447ac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20243
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:51:39 +00:00
dan sinclair 88725a0f30 [spirv-writer] Member accessor.
This CL fixes up the member accessor code and adds tests.

Bug: tint:5
Change-Id: I139cb2e853da92e762255e4836daf2b9a437179d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20181
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:04:22 +00:00
David Neto 795bebf1f2 [spirv-reader] Check terminators are sane
Each basic block must have a terminator, and if the terminator branches
to another block, that block must name a label in the same function.

Bug: tint:3
Change-Id: If22bece6a8041fef362c02b05e4dfee999a3e5bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20046
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-22 17:53:00 +00:00
Ryan Harrison fd1526bd33 Fix type conversions to make Clang 10 happy
Change-Id: I07f30e9bb19e3f7b0486c982bb3c4406a03dd615
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20161
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 17:46:36 +00:00
dan sinclair 20077b7b87 [spirv-writer] Start accessor chain additions.
This Cl adds the code for the ArrayAccessor generation. Some of the
MemberAccessor code is included, but tests are coming in a later Cl.

Bug: tint:5
Change-Id: Id7d006ab4a82c1d31d8036d141c83d0d61f9bea5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20180
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 14:07:05 +00:00
dan sinclair 43f975e71f [spirv-writer] Call the Call expression generator.
This CL adds the missing call for the call expression.

Bug: tint:5
Change-Id: Ia046e2b57ebc56eaf0c3dc330d9f8e81763df8bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20144
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 13:55:25 +00:00
David Neto aa257c068f [spirv-reader] Rename "rspo" to block_order
Bug: tint:3
Change-Id: I2d7e817fd30da98dc20da1be083be7e3cc5dcd89
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20147
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-22 00:27:31 +00:00
Ryan Harrison 1933185510 Add documentation about potential fuzzing pitfall
Change-Id: I2ea01b3ad3359510bff3ffd298d4ed17d3677ffc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20146
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-22 00:26:49 +00:00
Ryan Harrison 3170bebba1 Fix building fuzzer
BUG=tint:53

Change-Id: I0462baf302d5183b089dbdfd595045f8376f7a53
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20145
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:25:10 +00:00
dan sinclair c9308dcb75 [spirv-writer] Generate Unary Op expression.
This CL adds the code to generate the negation and not operators.

Bug: tint:5
Change-Id: Ibb4d374586e1415a2a678e375c64ba69bbc20367
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20143
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:24:11 +00:00
dan sinclair 9a7cc7c73c Add more context to unknown expression error
Change-Id: I16bc118f5d3ec6536890404748fd06eb89a4433e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20142
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:24:03 +00:00
dan sinclair 2287d01233 Generate 3 param GLSL methods.
This CL adds the needed code to handle three parameter methods in the
type determinater.

Bug: tint:5
Change-Id: Id8584fbb1d308de585b59a4034e184b41f5bd74c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20141
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:23:57 +00:00
dan sinclair 21244880f8 Expression results should not be aliases.
This CL updates the expression class to set the alias value instead of
an alias as the result type.

Change-Id: If19ae394a09ba0dc76380514e53a488bbb5a7292
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20140
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:23:49 +00:00
David Neto 50e738eca4 [spirv-reader] Test loop block order + nesting
Bug: tint:3
Change-Id: I97915d8e30c1676e1c1340217c5eb732c44f8ef0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20067
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 8e8c291db1 [spirv-reader] Test loop block order
Change-Id: If33d37d2813b1b1e584972d4da7aadbcb345d12f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20066
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto b5d518b68b [spirv-reader] Test block order dup cases
- branch-conditional where both targets are the same
- switch where the default target is the same as a case target

Bug: tint:3
Change-Id: If5a3e1fead43ae3d528341f3e54dcae959d9eb8c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20061
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto f6def6d572 [spirv-reader] Test nested if, switch
Bug: tint:3
Change-Id: I7b84523b765bd51ea7a65dc2de396a14b80fcc62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20044
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 9cba3e1850 [spirv-reader] Split arithmetic, bit tests
Separate them into different test files, to match SPIR-V spec sections

Bug: tint:3
Change-Id: I89fe76230740da060d57ac23870069a5483b2d7d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20043
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 6235caaae4 [spirv-reader] Test block order with Kill, Unreachable
Bug: tint:3
Change-Id: Ic8627ca3449ddc7f6abf248b0a461cfbafe77819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20041
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 571eea5a1a [spirv-reader] Compute basic block order
Test non-nested sequences and selections.

Bug: tint:3
Change-Id: Ibbbcd428d701d9e7d4da1682f94c2bdbef00121b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19920
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
dan sinclair d3d1230062 Add name to GLSL error message
Change-Id: I03b71d81d4975512d57f7383123689e57eba7735
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20065
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:37:23 +00:00
dan sinclair 7025918287 Cleanup some error messages.
This CL makes it clearer where errors are coming from and fixes the
source information on a few type determiner error messages.

Change-Id: I356518ac3004effe005bb7dea147c7fe442ab1a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20063
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:05:42 +00:00
dan sinclair aac5865121 Fixup single element swizzle type determination.
For a swizzle with one element (eg vec.x) the result type is just the
type of the vector, instead of a new vector.

Change-Id: I04ddb22da61db1c3553d465e4e5f9d6b32beae83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20062
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:05:34 +00:00
dan sinclair 54444382a6 Add GLSL distance support.
This CL adds support for the GLSL distance command.

Bug: tint:5
Change-Id: I0934d461ca6d4fca379849d8f41a33fb202c67ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20060
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:04:15 +00:00