Commit Graph

1514 Commits

Author SHA1 Message Date
Ben Clayton 03ae9a397f Cleanup: Remove unnecessary namespace prefixes
No need to prefix with `ast::` when you're in the ast namespace already.

Change-Id: Iac6cd3a215c05a80ee2035d582500f1d6c882a06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34320
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton acf7643518 Replace Literal::(Is|As)* with Castable
Change-Id: I842483890b369d63c23dba475b6738bffe5cfdbd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34319
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton aedca4288c Replace Variable::(Is|As)* with Castable
Change-Id: I7a49287af079d53cee095fa2243dd21757546b56
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34318
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 19fe07236e Replace ConstructorExpression::(Is|As)* with Castable
Change-Id: I18e9768fef36b79cb0e65c6eb79fd147013c54f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34317
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d6ae990811 Replace Expression::(Is|As)* with Castable
Change-Id: I6ab98ed8b198f1b3b42ce1f09a6c4f992d65fe95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34316
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 1d8098ae94 Replace Statement::(Is|As)* with Castable
Change-Id: I5520752a4b5844be0ecac7921616893d123b246a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34315
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 4d3ca7f132 Replace StructMemberDecoration::(Is|As) with Castable
Change-Id: I158194c60a9fe0ea2126ca31a92ad536c92a6388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34314
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 8a82dcd977 Replace StructDecoration::IsBlock with Castable
Change-Id: I4b053aab610b18f99b72156f92317bc8eaf430b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34313
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 731372f0b4 Replace FunctionDecoration::(Is|As)Workgroup with Castable
Change-Id: Ia365504fd745579b3bd7bef0b6eda73d3164f539
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34312
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 75828dbaee Replace FunctionDecoration::(Is|As)Stage with Castable
Change-Id: Iecb683c4bee29952d5f08d92533918f65e342158
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34311
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton c24ac2720d Replace VariableDecoration::(Is|As)Set with Castable
Change-Id: I9808e31f3842b70b3df9ed0398583e09e4f2ca42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34310
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 2c1d7d5be7 Replace VariableDecoration::(Is|As)Location with Castable
Change-Id: I3096045fc093f3782401ce8623a18e0bca49b22c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34309
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 0482b54782 Replace VariableDecoration::(Is|As)ConstantId with Castable
Change-Id: I3f402fe8925ef7d5c9b3d5b21f2556d7af59a0cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34308
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton c0eb9aeafb Replace VariableDecoration::(Is|As)Builtin with Castable
Change-Id: I49d970301c46cfe29d7b22e18abb443daa0c8073
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34307
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 62d81485dd Replace VariableDecoration::(Is|As)Binding with Castable
Change-Id: Ia13ce42054e5f514eb34f6549da10b22129f9026
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34306
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 864579db3d Replace ArrayDecoration::(Is|As)Stride with Castable
Change-Id: I0a346226996c86a6f976b51f69ae4df32806a797
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34305
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 3958f81fd7 Replace TypeDecoration::(Is|As)Access with Castable
Change-Id: I06a2f663cf56f8bb9a9b05557aef428b2d69e84c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34304
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 26e944bc4e ast: Remove non-group DecorationKind enums
The following DecorationKinds were sub-types of core decoration types:

  kStride, kStage, kWorkgroup, kStructMemberOffset, kAccess, kBinding, kBuiltin, kConstantId, kLocation

These only existed for casting (not for error messages), and are no longer needed, so remove them.

Change-Id: I1e4bb9bf51952c6e86bac984d0d667a071ca80bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34303
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 370d20a4c6 ast: Remove the now unused Decoration::IsKind() method
And replace the use of`ast::As(Decoration* deco)` with `Castable::As<T>()`.

These were used for dynamic casting, but is now replaced with Castable.

Change-Id: Ie5fe19ad4db4bc4d19f5386d2cfddaaf84b215d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34302
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton e319d7f0e9 Derive all ast::Node from Castable
The hand-rolled `AsBlah()`, `IsBlah()` methods will be migrated in future changes.

Change-Id: I078c100b561b50018771cc38c1cac4379c393424
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34301
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 11c9de63aa ast: Add virtual GetKind() instead of kind member
Reduces the per-instance size for an extra vtable entry.

Change-Id: Ie087e0b8d8524adf85663ab1224fb0ae1a5e0000
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34300
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton b062bbdce8 Replace TextureType::(Is|As)Sampled with Castable
Change-Id: Id997f118a8ce9f4f7c42bed306368d3f204b6607
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34279
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 1a23756294 Replace TextureType::(Is|As)Storage with Castable
Change-Id: I627304c0b397605f565ae688f2a2b61132c26b9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34278
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 0441bd1756 Replace TextureType::(Is|As)Multisampled with Castable
Change-Id: I9a0e2ba4c6b0950134cef4b291cd1ba5cae1198c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34277
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 09b8829d8e Replace TextureType::(Is|As)Depth with Castable
Change-Id: I2f1785cec1880f728fbbf0c75762bc957e34ca0a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34276
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 16ec1bb626 Replace Type::(Is|As)Void with Castable
Change-Id: If8a27c69c91a968a40a982c02b9fcaf9481e60b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34275
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 8a083ce9c8 Replace Type::(Is|As)Vector with Castable
Change-Id: Ic838aa783a279d0939a972773206fee2e33c4bff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34274
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d11ced4765 Replace Type::(Is|As)U32 with Castable
Change-Id: I4999d45950fdffe4345cf0abae1b026244abba1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34273
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 38409c79dc Replace Type::(Is|As)Texture with Castable
Change-Id: I53bbccc3e1e7b88ad8c201997cf7e2e485ad9c81
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34272
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d734dd0c10 Replace Type::(Is|As)Struct with Castable
Change-Id: I0bc5645d65d7b53058bda7b343a991a9614741be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34271
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 351128a41e Replace Type::(Is|As)Sampler with Castable
Change-Id: Iaa43e607199e25308ecb121c61bb7a37abff197c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34270
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton c52f4214ad Replace Type::(Is|As)Pointer with Castable
Change-Id: Ic1b82f1ddc61355021a80d8e72f645f830363c62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34269
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d8457c15f1 Replace Type::(Is|As)Matrix with Castable
Change-Id: I861aed231604a8bfba1f4cf3659b4863556fc3c4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34268
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 9857f81e94 Replace Type::(Is|As)I32 with Castable
Change-Id: Id130581f72e762bd398a4c1c509cdbe21739e750
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34267
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 75f39be976 Replace Type::(Is|As)F32 with Castable
Change-Id: I75e5a34034360c1d4c96ae0ce293bc6cbfc1c33d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34266
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton f3639b787f Replace Type::(Is|As)Bool with Castable
Change-Id: I60ed33bd9a54b14bb9b35f3cd999a2604c2c4450
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34265
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton af37c4ae83 Replace Type::(Is|As)Array with Castable
Change-Id: I8d9b916f5977121380325d373c4e2f805b691fae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34264
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 67864267c2 Replace Type::(Is|As)Alias with Castable
Change-Id: I10f1d3d0757661a41b44517d55d6f159aced04ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34263
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton a8d87788da Replace Type::(Is|As)AccessControl with Castable
Change-Id: I833c92be270236fefd1e77a7a145dede757e93e9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 69aabb51a9 Derive all ast::types from Castable
The hand-rolled `AsBlah()`, `IsBlah()` methods will be migrated in future changes.

Change-Id: I46a350a560f9eda8ca15f8ba8c95b17b9b6010b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34261
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-30 23:30:58 +00:00
David Neto 21e9204e14 tests: Change name SampledImageCase -> ImageAccessCase
Bug: tint:109
Change-Id: I6f5b1d3cf73fa58ae9f4c37d155199649eb37518
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34423
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-30 23:17:05 +00:00
David Neto 2082beed0f spirv-reader: Add entry point declaration to handle test
Bug: tint:109
Change-Id: I25645944061b8b247eda442b61f4591a9359ec4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34422
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-30 22:53:25 +00:00
Ben Clayton 95feb99a9d Add Castable template class
Implements `As<Blah>()` and `Is<Blah>()` automatically.

There are several benefits to using this over the pattern of hand-rolled `IsBlah()`, `AsBlah()` methods:
(1) We don't have to maintain a whole lot of hand written code.
(2) These allow us to cast from the base type to _any_ derived type in a single cast. The existing hand-rolled methods usually require a couple of intermediary casts to go from the base type to the leaf type.
(3) The use of a template parameter means these casts can be called from other template logic.

Note: Unlike the hand-rolled `AsBlah()` methods, it is safe to call `As<T>()` even if the type does not derive from `T`. If the object does not derive from `T` then  `As` will simply return `nullptr`. This allows the calling logic to replace the common pattern of:

```
if (obj.IsBlah()) {
   auto* b = obj.AsBlah();
   ...
}
```

with:

```
if (auto* b = obj.As<Blah>()) {
   ...
}
```

This halves the number of virtual method calls, and is one line shorter.

Change-Id: I4312e9831d7de6703a97184640864b8050a34177
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-30 22:50:25 +00:00
David Neto 386755b1ac spirv-reader: fix SPIR-V types in handle tests
Bug: tint:109
Change-Id: Icb4cbe12334c92a86d1c52a0b3569fb22a1cfc7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34421
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-30 22:48:55 +00:00
David Neto aa212ee81f spirv-reader: sampling depth texture requires unsigned Lod
Fixed: tint:378
Change-Id: I835ee7e9fb63dc68db571091f28fd34287c209b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34201
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-27 19:28:53 +00:00
David Neto 29e7e3b78e spirv-reader: Use better names in handle tests
Change-Id: I461cc6fd3b497e7b56b8004266580b4280c7dc42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34200
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 18:14:53 +00:00
David Neto a8b6f87cca spirv-reader: test texture builtins over arrayed textures
Tested:
 - textureSample
 - textureSampleBias
 - textureSampleLevel
 - textureSampleGrad
 - textureSampleCompare

Fixed: tint:349
Change-Id: Ibb45883b88c8eeec6ba40170f47d78613e150db7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34102
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 17:00:03 +00:00
David Neto e5aa390e15 spirv-reader: refactor image access tests
Bug: tint:349
Change-Id: I0cd3dc6d6704f5b636a14542993c39d3f6ea5f59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34101
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 16:46:33 +00:00
David Neto 76e5f17313 spirv-reader: simplify tests
Change-Id: I69b4893d8693310f445bbf9667358d7b09f35728
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34100
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 16:43:13 +00:00
David Neto 3f305ac294 spirv-reader: split off last coordinate for arrayed texture access
Also ensure that the number of texture coordinates is exactly
the right number required for the given texture dimension.
I think SPIR-V is looser in this respect.

Assumes coordinates are floating point.

Bug: tint:349
Change-Id: I4512c333fada3647c66f13ef31897b2d73b46cf0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33982
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 16:17:03 +00:00
Corentin Wallez 456aad3bce Remove use of recent SPIRV-Tools functionality
reader/spirv/parser_impl.cc was using an overload of a function that's
recently added in SPIRV-Tools so rolling Tint would require rolling
SPIRV-Tools at the same time, which is not currently possible because of
a breaking change in spirv-headers.

Bug: chromium:1153258
Change-Id: I4e8cf87a3f11adbd8b6ef289260c6159faf9580c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34142
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-27 15:36:23 +00:00
Ben Clayton f32a3c1f35 Diagnostics: Add error code to the Diagnostic
Allows this to be formatted similarly to the severity.

Change-Id: I74cd863d8f1d94089ce753ab76a2c70784eb5553
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33938
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-26 17:49:22 +00:00
David Neto 61ec48b99e spirv-reader: refactor swizzle creation
Change-Id: I6a09756026b7cbc436d5f232be9331255615e8c3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34040
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-11-26 17:45:52 +00:00
David Neto 3ec71a63aa spirv-reader: test textureSample with depth texture
Bug: tint:109
Change-Id: Ia13940b521229012a7c73fe0896e6ea75c4b1307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34020
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-26 16:58:02 +00:00
Ben Clayton ba06db6e00 validator: Migrate to using diagnostics
Unlike error strings, diagnostics can:
* Describe more than one error
* Be printed with colors
* Highlight (`^^^`) the particular error on the line
* Can have separate severities

Change-Id: I4ead391ffbe190e55f79c5f23536a4524768478d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33820
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-26 16:50:02 +00:00
Ben Clayton b7b6a3f3f4 Fix linter errors about newlines in lists
Change-Id: I5c2eb4d9beed1e6cf9f0f410da116ae3958589b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33939
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-26 16:47:32 +00:00
David Neto 77e3318b39 spirv-reader: Support depth-reference sampling
Bug: tint:109
Change-Id: I1e1dcd7c0724124a3a29e94e65856a07c54dd998
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34005
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-26 16:39:32 +00:00
David Neto ddaf59016b spirv-reader: Infer a handle type when needed
Fixed: tint:374
Change-Id: I4785a48d456a6b5ba1fa8c9950b4c72d00853fc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33981
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-26 15:35:12 +00:00
Ben Clayton 83b32455c2 writer/msl: Emit texture builtin functions
Bug: tint:145
Change-Id: I8a2d10c2e7239c81a11933c009d9175d4f4d8577
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33782
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-26 15:07:52 +00:00
Ben Clayton f48d244252 writer/spirv: Use PackCoordAndArrayIndex()
As `PackCoordAndArrayIndex()` extracts the elements of vectors-in-vectors, the resulting SPIR-V is now more compact.

Change-Id: I3e35546efc89531b9f70d4c44c23c179e76b15d8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33781
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-26 14:18:12 +00:00
Ben Clayton 41c8cd3e68 writer/hlsl: Move the coord/arrayidx packing to utility function
So we can also use this for the `spirv` backend

Bug: tint:146
Change-Id: I26f70125a5015946d2428a6e669da32bdea23bcd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33780
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2020-11-26 13:57:32 +00:00
David Neto 8ad2c91c60 spirv-writer: Add SampledCubeArray cap when needed
Fixed: tint:371
Change-Id: I13f568725370f446f154af26c326edfd4abec3c8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34003
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-26 13:37:32 +00:00
David Neto b496611165 spirv-writer: avoid dup OpCapability instructions
Change-Id: Iaf53d2addadd8efbb912e4f97ff426fd4182c9f3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34002
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-26 13:32:12 +00:00
David Neto 66794eada3 Roll dependencies; spirv-reader: avoid spurious OpLine
Roll third_party/gpuweb-cts/ 2a53a9bd3..abe6e1dd2 (51 commits)

2a53a9bd3d..abe6e1dd26

$ git log 2a53a9bd3..abe6e1dd2 --date=short --no-merges --format='%ad %ae %s'
2020-11-25 corentin Port the robust vertex access tests from GLSL to WGSL (#379)
2020-11-25 corentin Port createRenderPipeline validation tests from GLSL to WGSL (#372)
2020-11-23 kainino iterateCollapsedQueries: don't yield files with no tests (#383)
2020-11-20 kainino Clean trailing whitespace inside shader strings (#382)
2020-11-20 yunchao.he Memory sync test for buffer (#302)
2020-11-20 corentin Port verteState validation tests from GLSL to WGSL (#376)
2020-11-20 corentin Port the setVertexBuffer validation tests from GLSL to WGSL (#375)
2020-11-20 corentin Port the render pass validation tests from GLSL to WGSL (#374)
2020-11-20 corentin Port the validation index access tests from GLSL to WGSL (#373)
2020-11-20 corentin Group and update the dynamic state validation tests. (#307)
2020-11-20 corentin Port the primitive topology tests from GLSL to WGSL (#371)
2020-11-20 corentin Port culling tests from GLSL to WGSL (#370)
2020-11-20 corentin Cleanups in webgpu/api/operation/command_buffer (#369)
2020-11-20 kainino From HackMD plan, part 2: some more validation tests (#368)
2020-11-19 kainino Fix cross-device fence signal tests (cherry-pick) (#366)
2020-11-19 kainino From HackMD plan: manual, stress, web_platform, documentation, and some validation (#364)
2020-11-18 corentin Port basic command_buffer tests from the GLSL branch (#350)
2020-11-17 kainino add src/webgpu as a separate folder in the workspace
2020-11-17 kainino Replace grunt tasks with shell tasks
2020-11-17 kainino Check directory names match validQueryPart
2020-11-17 kainino rename web-platform to web_platform
2020-11-17 2154796+austinEng Remove TexelDataRepresentationImpl.isGPULittleEndian (#357)
2020-11-17 2154796+austinEng Implement texelData for rgb9e5ufloat and add texelData unit tests (#352)
2020-11-17 2154796+austinEng Refactor texture zero init tests and use WGSL (#353)
2020-11-17 corentin Port the renderPass resolve tests from GLSL to WGSL (#351)
2020-11-13 mehmetoguzderin Make comments optional (#348)
2020-11-12 corentin Add gen_wpt_cts_html as an NPM script (#347)
2020-11-11 9856269+sarahM0 [wgsl] Update tests to match spec update: Relaxing void return requirement (#330)
2020-11-11 mehmetoguzderin Check PRs to glsl-dependent (#341)
2020-11-10 kainino Remove travis config from main branch (#336)
2020-11-10 kainino Remove AsyncMutex
2020-11-09 kainino Simplify WPT runtime
2020-11-10 mehmetoguzderin Fix Actions on CI (#334)
2020-11-10 corentin Roll webgpu-types. (#329)
2020-11-10 mehmetoguzderin Add CI on Actions (#331)
2020-11-05 natashalee add create sampler validation test (#327)
2020-11-04 kainino wpt: Don't return promise from async_test
2020-11-04 kainino Allow marking tests as explicitly unimplemented (#319)
2020-11-04 kainino standalone: Don't generate DOM when test finishes (#323)
2020-11-04 kainino standalone: Show only the full query string for a test, and aligned (#324)
2020-11-03 kainino standalone: Replace results JSON textarea with copy button (#322)
2020-11-02 kainino standalone: Lazily-generate DOM subtrees (#321)
2020-10-27 enrico.galli Add API validation tests for compute pass (#308)
2020-10-26 kainino Optimize device pool lookup (#295)
2020-10-23 kainino Remove unneeded @babel/plugin-proposal-class-properties (#313)
2020-10-23 kainino Remove non-test dependence on WebGPU ambient constants (#318)
2020-10-20 kainino Loop to exhaust eventualExpectations (#309)
2020-10-20 dsinclair Update WGSL to new struct syntax. (#316)
2020-10-19 kainino Add support for logical assignment operators (&&= ||=) (#311)
2020-10-19 kainino Update npm dependencies (#310)
2020-10-20 corentin Add validation tests for mapAsync. (#301)

Created with:
  roll-dep third_party/gpuweb-cts

Change-Id: Ibed486c6e02d8df9db7a66c00c4546c46df0c1fc

Roll third_party/spirv-tools/ 7e1825a59..2c458414c (62 commits)

7e1825a596..2c458414c0

$ git log 7e1825a59..2c458414c --date=short --no-merges --format='%ad %ae %s'
2020-11-25 dneto BuildModule: optionally avoid adding new OpLine instructions (#4033)
2020-11-25 dneto Remove prototype for unimplemented method (#4031)
2020-11-25 afdx spirv-fuzz: Fix facts arising from CompositeConstruct (#4034)
2020-11-24 afdx spirv-fuzz: Do not flatten conditionals that create synonyms (#4030)
2020-11-23 dneto Update MeshShadingNV dependencies (and land Ray tracing updates) (#4028)
2020-11-18 greg Fix buffer oob instrumentation for matrix refs (#4025)
2020-11-13 afdx spirv-opt: Set parent when adding basic block (#4021)
2020-11-13 jaebaek spirv-opt: properly preserve DebugValue indexes operand (#4022)
2020-11-11 dneto Use less stack space when validating Vulkan builtins (#4019)
2020-11-05 46493288+sfricke-samsung spirv-val: Fix SPV_KHR_fragment_shading_rate VUID label (#4014)
2020-11-05 46493288+sfricke-samsung spirv-val: Label Layer and ViewportIndex VUIDs (#4013)
2020-11-05 alanbaker Add dead function elimination to -O (#4015)
2020-11-04 jaebaek Add DebugValue for invisible store in single_store_elim (#4002)
2020-11-04 dnovillo Fix SSA re-writing in the presence of variable pointers. (#4010)
2020-11-04 afdx spirv-fuzz: Fixes to pass management (#4011)
2020-11-03 afdx spirv-fuzz: Add support for reining in rogue fuzzer passes (#3987)
2020-11-03 vasniktel spirv-fuzz: Fix assertion failure in FuzzerPassAddCompositeExtract (#3995)
2020-11-03 vasniktel spirv-fuzz: Fix invalid equation facts (#4009)
2020-11-03 vasniktel spirv-fuzz: Fix bugs in TransformationFlattenConditionalBranch (#4006)
2020-11-03 andreperezmaselco.developer spirv-fuzz: Fix bug related to transformation applicability (#3990)
2020-10-30 jaebaek Temporarily add EmptyPass to prevent glslang from failing (#4004)
2020-10-30 Junda.Liu spirv-opt: Add support to prevent functions from being inlined if they have DontInline flag (#3858)
2020-10-29 jaebaek Propagate OpLine to all applied instructions in spirv-opt (#3951)
2020-10-29 bclayton CMake: Add SPIRV_TOOLS_BUILD_STATIC flag (#3910)
2020-10-29 dneto Avoid copying a ref in a loop (#4000)
2020-10-28 justsid spirv-val: Allow the ViewportIndex and Layer built-ins on SPIR-V 1.5 (#3986)
2020-10-28 dnovillo Simplify logic to decide whether CCP modified the IR (#3997)
2020-10-27 jaebaek Add DebugValue for DebugDecl invisible to value assignment (#3973)
2020-10-26 greg Fix bounds check instrumentation to handle 16-bit values (#3983)
2020-10-23 andreperezmaselco.developer spirv-fuzz: Add expand vector reduction transformation (#3869)
2020-10-23 vasniktel spirv-fuzz: Don't replace irrelevant indices in OpAccessChain (#3988)
2020-10-23 vasniktel spirv-fuzz: Add FuzzerPassAddCompositeExtract (#3904)
2020-10-22 afdx spirv-fuzz: Fix mismatch with shrinker step limit (#3985)
2020-10-22 afdx spirv-fuzz: Fix off-by-one error in replayer (#3982)
2020-10-22 afdx spirv-fuzz: Get order right for OpSelect arguments (#3974)
2020-10-22 afdx spirv-fuzz: Do not add synonym-creating loops in dead blocks (#3975)
2020-10-22 afdx spirv-fuzz: Skip OpTypeSampledImage when propagating up (#3976)
2020-10-22 afdx spirv-fuzz: Pass OpUndef in function call if needed (#3978)
2020-10-22 afdx spirv-fuzz: Fix off-by-one in TransformationCompositeConstruct (#3979)
2020-10-22 afdx spirv-fuzz: Tolerate absent ids in data synonym fact management (#3966)
2020-10-21 afdx spirv-fuzz: Fix to id availability (#3971)
2020-10-21 afdx spirv-fuzz: Fix operand types (#3962)
2020-10-21 8729214+jonahryandavis Update SPIRV-Headers revision in DEPS file (#3961)
2020-10-21 afdx spirv-fuzz: Don't flatten conditional if condition is irrelevant (#3944)
2020-10-21 afdx spirv-fuzz: Do not produce OpPhis of type OpTypeSampledImage (#3964)
2020-10-21 afdx spirv-fuzz: Restrict fuzzer pass to reachable blocks (#3970)
2020-10-21 afdx spirv-fuzz: Handle more types when extending OpPhi instructions (#3969)
2020-10-21 afdx spirv-fuzz: Skip early terminator wrappers when merging returns (#3968)
2020-10-21 afdx spirv-fuzz: Avoid irrelevant constants in synonym-creating loops (#3967)
2020-10-21 afdx spirv-fuzz: Skip dead blocks in FuzzerPassAddOpPhiSynonyms (#3965)
2020-10-21 afdx spirv-fuzz: Avoid the type manager when looking for struct types (#3963)
2020-10-20 afdx spirv-fuzz: Fix to TransformationDuplicateRegionWithSelection (#3941)
2020-10-20 afdx spirv-fuzz: Skip OpFunction when replacing irrelevant ids (#3932)
2020-10-20 afdx spirv-fuzz: Use component-wise selectors when flattening conditional branches (#3921)
2020-10-20 TobyHector Add SPV_EXT_shader_image_int64 (#3852)
2020-10-20 TobyHector Support SPV_KHR_fragment_shading_rate (#3943)
2020-10-19 afdx spirv-val: Fix validation of OpPhi instructions (#3919)
2020-10-19 afdx spirv-fuzz: Avoid void struct member when outlining functions (#3936)
2020-10-19 afdx spirv-fuzz: Do not allow Block-decorated structs when adding parameters (#3931)
2020-10-19 afdx spirv-fuzz: Fix to operand id type (#3937)
2020-10-19 afdx spirv-fuzz: Handle dead blocks in TransformationEquationInstruction (#3933)
2020-10-19 afdx spirv-fuzz: Do not allow sampled image load when flattening conditionals (#3930)

Created with:
  roll-dep third_party/spirv-tools

Change-Id: Ic75967a4b775dfae8b53a679f48bcc8b3f162217

Roll third_party/spirv-headers/ c43a43c7c..104ecc356 (9 commits)

c43a43c7cc..104ecc356c

$ git log c43a43c7c..104ecc356 --date=short --no-merges --format='%ad %ae %s'
2020-11-12 dneto MeshShadingNV enables builtins PrimitiveId, Layer, and ViewportIndex
2020-10-16 dkoch de-alias/reassign OpIgnoreIntersectionKHR/OpTerminateRayKHR
2020-06-29 alele Raytracing and Rayquery updates for final
2020-06-15 alele Updated headers for new trace/executeCallable and acceleration structure cast.
2020-11-04 michael.kinsner Reserve additional loop control bit for Intel extension (NoFusionINTEL) (#175)
2020-11-02 4464295+XAMPPRocky Add EmbarkStudios/rust-gpu to vendor list. (#174)
2020-10-23 john Bump revision to 4, for SPIR-V 1.5.
2020-10-19 TobyHector Add SPV_EXT_shader_image_int64 (#170)
2020-10-19 TobyHector Added SPV_KHR_fragment_shading_rate (#172)

Created with:
  roll-dep third_party/spirv-headers

Change-Id: Ib43e5574d9fc1d2cffdd3a6cf66cbc3a88db2051

Roll third_party/googletest/ 3c95bf552..b1fbd33c0 (30 commits)

3c95bf5524..b1fbd33c06

$ git log 3c95bf552..b1fbd33c0 --date=short --no-merges --format='%ad %ae %s'
2020-11-23 absl-team Googletest export
2020-11-19 absl-team Googletest export
2020-11-13 vlee Initialize TestInfo member is_in_another_shard_ in constructor.
2020-11-12 absl-team Googletest export
2020-11-12 absl-team Googletest export
2020-11-12 absl-team Googletest export
2020-11-11 dmauro Googletest export
2020-11-11 dmauro Googletest export
2020-11-11 dmauro Googletest export
2020-11-11 absl-team Googletest export
2020-11-11 marius.brehler Refactor finding python
2020-11-06 absl-team Googletest export
2020-11-06 absl-team Googletest export
2020-10-29 knut Only save original working directory if death tests are enabled
2020-11-08 hyuk.myeong fix typos
2020-11-06 absl-team Googletest export
2020-11-05 ofats Googletest export
2020-10-27 absl-team Googletest export
2020-10-27 elliott.brossard Add instructions for sanitizer integration
2020-10-26 absl-team Googletest export
2020-10-20 sonzogniarthur Fix typo "definedin in" => "defined in"
2020-10-15 absl-team Googletest export
2020-10-15 absl-team Googletest export
2020-10-07 manavrion Improve FilePath::Normalize method
2020-09-16 hyuk.myeong Remove spaces between Google Test and Google Mock
2020-09-15 hyuk.myeong Add follow-up patch for more natural reading
2020-09-15 hyuk.myeong Apply the reviewed comment
2020-09-15 hyuk.myeong Remove a space
2020-09-15 hyuk.myeong Improve the tutorial that may be confusing
2020-02-17 krystian.kuzniarek remove a duplicated include

Created with:
  roll-dep third_party/googletest

Change-Id: I62335cb23a96218f62c1842e786777d7e8dfe4f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34007
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-25 21:13:17 +00:00
David Neto eb913d3829 spirv-reader: Start emitting sampled image builtins
- Emit (non-depth) sampler variables
- Emit sampled texture variables

- Test emission of textureSample, textureBias, textureLevel

TODO: convert unsigned offset parameter to signed. crbug.com/tint/348
TODO: support arrayed access, where we have to split out the array index
into a separate operand. crbug.com/tint/349
TODO: for explicit-lod sampling, we may have to convert coordinates to
floating point. crbug.com/tint/346

Bug: tint:109
Change-Id: I12558f99473ca234ce0d09a87fc0c2f4730497bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33342
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-11-25 19:23:17 +00:00
Corentin Wallez 4e91325bf0 writer/spirv: Emit Image1D and Sampled1D capabilities when needed
Fixes: tint:363
Change-Id: Ia0f09e3173f54abaf15aa8f772b097835d451bcb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33920
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-11-25 17:02:37 +00:00
Corentin Wallez d49841ca9f writer/spirv: Emit NonRead/Writable decoration of storage texture vars
Fixes: tint:366
Change-Id: I03e1312841d5b86d1192382bf4cdf0ad1bcfc43d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33921
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-25 13:59:27 +00:00
Corentin Wallez bed7a32b3b type_determiner: use f32 as the subtype for u/norm storage texture.
Fixes: tint:367
Change-Id: I311f5b9524d6251c88ae774dc8dc80f6d52e457d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33922
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-25 13:58:47 +00:00
Ben Clayton 12ed862c7e Add fuzzer instrumentation when building fuzzers
Without this the fuzzing is unguided and takes exponentially more time to find interesting corpus cases.

Change-Id: I1b66de153bc41a829a5276a02a729f4e6bb50ef0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33722
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2020-11-24 15:28:06 +00:00
David Neto 1b543c6778 spirv-reader: Add a disassembler helper
This helped me debug a problem.

Change-Id: I665aaa482c6f20d24966f0990bfe4e15cdd82915
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33800
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-24 15:17:46 +00:00
Ben Clayton 1e87fe5517 reader/wgsl: Abort after raising too many errors
Change-Id: I641ee8c2e34e059a02742d06c24f96acecb39cd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33720
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2020-11-24 15:15:36 +00:00
Ben Clayton c489875ff0 ast/module: Additional documentation for type methods
Bug: tint:337
Change-Id: I60dae81baba3c5c85efa277e772f4a1f12589e11
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33786
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-24 15:11:06 +00:00
Ben Clayton 8282262304 writer/spriv: Add an assert that functions_ is not empty
... before attempting to push instructions to `functions_.back()`

If this fires, we're in an invalid state anyway. At least make the explosion less head scratching.

Change-Id: I7b4a002043de4b55a12d9aba80a0393c630140c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33664
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 22:32:55 +00:00
Ben Clayton fecf10664a Improve error message when suffixing float with f
Fixes: tint:277
Change-Id: I7ec3bb758c7d80c95c6ecd51eebf4144b696bec5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33668
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 20:07:15 +00:00
Ben Clayton 7e4ffa0064 Add create<T>() method to Module for types
Migrate all uses to use this and the new `unique_type<T>()` and `types()` methods.

Remove the `type_mgr()` accessor. `TypeManager` is now an implementation detail of the module, allowing us to unify the allocation of types and nodes (if we so wish).

Fixes: tint:337
Bug: tint:307
Change-Id: I233fa9dc73d60515dd721f02ea7ba089ef7d374f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33667
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:58:55 +00:00
Ben Clayton 0fb5168fc7 Move TypeManager from tint::Context to ast::Module
Bug: tint:307
Bug: tint:337
Change-Id: I726cdf89182813ba6f468f8ac35e5d44b22e1e1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33666
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:50:55 +00:00
Ben Clayton 3e67c5dba6 Move type_manager to the ast dir/namespace
First step to moving this to the `ast::Module`.

Also remove a bunch of redundant includes to `type_manager.h` as this is already included in `context.h`

Bug: tint:307
Bug: tint:337
Change-Id: Ic4baffa7b76ddefa29f56f758c25b1003ef40888
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33665
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:30:55 +00:00
David Neto 4c32dd9735 spirv-writer: Fix phi for short-circuiting operators
The Phi in the merge block was taking the value of the RHS
from the wrong basic block ID. Instead of taking it from
the first block of the expression for the RHS, take it from
the last block of the expression for the RHS.

Bug: tint:355
Change-Id: I1b79a1b107459fd420e39963ad7ab2e89bc4494f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33640
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-23 17:17:35 +00:00
David Neto 6cd6f7462c spirv-writer: support identity cast for vectors
Pending WGSL spec update https://github.com/gpuweb/gpuweb/issues/1103

Bug: tint:352
Change-Id: Ice44066ffcbb64de2544f82489e07b19a2423f72
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33601
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-23 16:34:35 +00:00
Kai Ninomiya 4c13659a2a Fix includes and BUILD.gn deps for gn check
Bug: tint:331
Change-Id: If1c1fa7495cf50f2456eb0b150c8b9a692dee12f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33620
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-11-20 20:17:24 +00:00
David Neto 189ceb6703 Avoid floating point equality checks in tests
Make newer Apple clangs happy even with -Wfloat-equal

Change-Id: I186c03811b3ed582f740afd3f01ea09090e6b7e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33600
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-20 19:34:34 +00:00
Sarah Mashayekhi ca03041ad7 [validation] add implementation and unit test for v-0031
v-0031: A struct containing a runtime array must be in the 'storage' storage class

Change-Id: I3f7f8bd70cb24514815d7fc19858f64fd40860ac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33361
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-20 16:57:54 +00:00
Ben Clayton 7f075c2a88 reader/wsgl: Improve error message for missing 'var'
Fixes: tint:295
Change-Id: Id01ad61fa24f14a1d86ca945d941fd27ee1e8f82
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33400
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-20 11:03:04 +00:00
Ben Clayton 0f4632d0ae writer/hlsl: Emit texture builtin functions
Fixes: tint:146
Change-Id: I2a59fd369c767163ac1b72976883a577fd51a632
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33422
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-20 10:28:24 +00:00
Ben Clayton eaa85796c7 ast: Fix vector constructors in ValidCases()
A couple of the vector constructors were the wrong width.
Noticed when looking at the far-more-readable HLSL writer output.

Change-Id: Ibb383eafb55c5f743851aa4500adeda5909f0922
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33423
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-20 10:25:54 +00:00
Ben Clayton 2da833d815 writer: Simplify floats when printed
Add `tint::writer::FloatToString()`:

Converts the float `f` to a string using fixed-point notation (not scientific).
The float will be printed with the full precision required to describe the float.
All trailing `0`s will be omitted after the last non-zero fractional number,
unless the fractional is zero, in which case the number will end with `.0`.

Use this for the wgsl, msl and hlsl backends.

Change-Id: If5701136579e4398c31c673942f30e8877e9f813
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33421
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-20 10:04:44 +00:00
Ben Clayton 5b5c98cdf4 writer/hlsl: Clean up matrix type emission
For HLSL emission instead of:
    `matrix<type, N, M>` emit `typeNxM`

These are significantly shorter, more idiomatic, and is far easier to read.

Change-Id: I78d3256aa36f4a23f5aece817ac48c255462991c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33460
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-20 09:37:14 +00:00
dan sinclair ea9c3a604b [wgsl-writer] Emit access control type.
This CL updates the WGSL-Writer to emit the access control type.

Bug: tint:287
Change-Id: Ifb42a5ab199f18014c33be62960d078e57df8dba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33360
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-11-19 19:40:41 +00:00
dan sinclair 7214f407dc [wgsl-reader] Add support for read only storage buffers.
This Cl adds the necessary infrastructure to parse the access decoration
for storage buffers.

This CL incorporates changes from bclayton@ from
https://dawn-review.googlesource.com/c/tint/+/33202 and
https://dawn-review.googlesource.com/c/tint/+/33201

Bug: tint:287
Change-Id: I7479f2cf7ab794b24c682b9927c4c68f6d325839
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33161
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-11-19 18:55:01 +00:00
dan sinclair d2f73226bc [hlsl-writer] Use `mul` method where required.
This CL updates the binary operator emission to use the `mul()` method
in the following cases:
 - vector * matrix
 - matrix * vector
 - matrix * matrix

This is because the `*` operator works per-component in HLSL which does
not do the expected multiply.

Bug: tint:301
Change-Id: I0810522ac26fbbea323cf8a05a3ff6f2fb62117e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33362
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-11-19 18:38:11 +00:00
Ben Clayton 31df1137d4 writer/hlsl: Clean up vector type emission
For HLSL emission instead of:
  `vector<float, N>` emit `floatN`
  `vector<int, N>` emit `intN`
  `vector<uint, N>` emit `uintN`

These are significantly shorter, more idiomatic, and is far easier to read.

Change-Id: Idef8cc550e0b49cc919087e281b72a7a0a0f11bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33424
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-19 16:49:12 +00:00
David Neto 36d9a061c8 spirv-reader: Rename a test class
Bug: tint:109
Change-Id: I31ce88cc28e38a22cc7f83ad5653109b133d401a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33440
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-19 15:36:11 +00:00
David Neto 3bc06e3099 spirv-reader: Convert handle types
Synthesize Tint types for handle variables and function parameters.

Bug: tint:109
Change-Id: I3c155e03b154c5ebf46e79c96a6e2b054dbca9b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33341
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-19 15:06:31 +00:00
Ben Clayton aa5f23e1ca reader/wgsl: Improve errors for statements outside functions
Fixes: tint:328
Change-Id: I29c35605c2cf546080e28eaa9d983595b4a8d977
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33401
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-19 14:19:31 +00:00
Ben Clayton f2bfeda1c4 writer/spriv: Move IntrinsicTextureTest to its own file
It's mahoosive, and will only get bigger.

Change-Id: I4593bd5ded9d67a8457676245189638874a8d5b3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33420
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-19 14:08:51 +00:00
Sarah Mashayekhi 8bea9671d5 [validation] v-0015: runtime arrays cannot be declared in a function body.
Bug: tint:345
Change-Id: I547e8981c2b541979add0a40d7f685b7c7f948aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33320
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-19 14:05:01 +00:00
Sarah Mashayekhi d8ea65bb2c [validation] impl v-0015: runtime array may only appear last
This CL adds checks to verify that runtime arrays only appear as the last element of a struct

Bug: tint:345
Change-Id: Ic2930aaf1e24e5c1d116add3a4a6dbdb9eaa02a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33261
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-11-18 22:34:30 +00:00
Ben Clayton 3ea3c997b5 Implement textureSample builtins
Handle wsgl parsing and spirv writing of:
  textureSample(), textureSampleBias(), textureSampleLevel(),
  textureSampleGrad(), textureSampleCompare()

Handle the different signature for array texture types.
Includes offset overloads.

Change-Id: I6802d97cd9a7083f12439b32725b9a4b666b8c63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32985
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 21:19:22 +00:00
Ben Clayton 2f4096b0d7 Move the ast node ownership from Context to Module
Fixes: tint:335
Change-Id: I128e229daa56d43e7227ecab72269be33b3ee012
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33240
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 20:58:20 +00:00
Ben Clayton 627732c408 src/reader tests: Have parse() return a unique_ptr
The reason being that some tests called parse() twice, which will silently destruct the first parser.
Once the `Module` owns the AST nodes, the second call will end up deleting all the AST nodes. Tests would then perform use-after-free for the AST nodes belonging to the first parser / module.
There's no reason why the unique_ptr can't be returned, which is cleaner overall.

Bug: tint:335
Change-Id: I7ff2e9777a7ebeb76702f806294fe4c2c49bd7c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33241
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-18 19:40:00 +00:00
Ryan Harrison 40e3ccda33 [transformer] Remove deprecated Manager constructor
Also moves the type determiner call out of the transformers into the
manager.
Cleans up the code to not have anything directly calling
Run() on the transformers other then the manager.

Bug: tint:308
Change-Id: I3343f2ba16dae6fb33f35e390ae4c797f2a05522
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33262
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 19:40:00 +00:00
dan sinclair c7f51b7d3c ast: Support decoration kind hierarchies
Instead of just having a single `DecorationKind` for the first
derivation from `Decoration`, have a `DecorationKind` for every
decoration type.

Add `Decoration::IsKind()` to test whether the decoration is of, or
derives from the given kind.

Note, this change is originally by bclayton@ from
https://dawn-review.googlesource.com/c/tint/+/33201

R=bclayton@google.com

Bug: tint:287
Change-Id: I69b51dfaa3f82ef4d61cda383b2f98f401013429
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33280
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-18 19:33:30 +00:00
Sarah Mashayekhi 038f6d2f37 [validation] unittest v-0015: runtime array may only appear last in a structs
this CL adds disabled tests to validate v-0015.

Bug: tint:345
Change-Id: I39ec9bc3b44f8f9c9fe241d3492de66509722e4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33260
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 18:40:10 +00:00
dan sinclair a7c9391dc6 [spirv-writer] Support optional trailing return.
This CL updates the SPIRV-Writer to inject an OpReturn as the trailing
statement in a function if the function does not end with a `discard` or
a `return` statement.

R=bclayton@google.com, dneto@google.com

Fixes: tint:302
Change-Id: I2e7c7beff15ad30c779c591bb75cf97fc0960bf7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33160
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-11-18 18:25:30 +00:00
Ben Clayton 46d9c7745e Fix linter warnings, stdout test spew
Change-Id: I2fed4cf2a052686e2121066588686f05907a169f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33200
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 14:31:00 +00:00
David Neto 5eae9bfaf5 Fix doxygen comment
Change-Id: Ic7778f390324431cc8e517d514e03c74de02ec46
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33142
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-18 03:17:39 +00:00
David Neto 064882de2c spirv-reader: Register usage for handle vars and func parameters
Bug: tint:109
Change-Id: I03b684dc75bf20b95e0bd38a9c5e7b78836ec7db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33141
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 02:57:49 +00:00
David Neto 62c8f07015 spirv-reader: GetMemoryObjectDeclarationForHandl can return null
It's valid to look for but not find an underlying memory object
declaration.

Bug: tint:109
Change-Id: I7296d79550a50050d2438996dc3e0c8d09a6babd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33140
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-18 02:14:09 +00:00
Ryan Harrison 88091d3d17 [transform] Add calling type determiner in manager
This is the first step into migrating away from callers of transforms
knowing that they have to re-run the type determiner.
This CL adds a new constructor that allows the caller to pass in the
context and module and conditionally calling the determiner.
Once downstream users have converted, the old constructor can be
removed, along with hacks to call the determiner in transforms.

Bug: tint:330
Change-Id: Iec49e6d27f92a651cb1e46681a3b3f8fae105164
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33124
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-17 21:40:59 +00:00
David Neto bd7ab2cd5f spirv-reader: Add (handle) Usage abstraction
Bug: tint:109
Change-Id: I5cb8f35636c61cf2f837271a51c4753117b288be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32387
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-11-17 18:32:18 +00:00
David Neto cebde298f9 spirv-reader: add GetMemoryObjectDeclarationForHandle
Bug: tint:109
Change-Id: Ifb437ce9a39db7f92ca081e7ea551a576b0ecb2b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32740
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-17 17:59:38 +00:00
Ben Clayton 0ae939bc0c writer/spirv: Refactor builder constructor tests
... using the new ast::Builder.

Also rename the test fixture name to include the common part of the test
names, and prefix with Spv. This makes it possible to run just these
tests with `--gtest_filter=SpvBuilderConstructorTest*`

Change-Id: I82067a551f4bc86847e61cb284a21b0d14536e87
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32984
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-17 17:53:38 +00:00
dan sinclair 8f26453c7d Fixup SPIR-V include of builder
R=kainino@chromium.org, rharrison@chromium.org

Change-Id: I8ff30362a8a26705280510ff5d2867d634b4f483
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33122
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-17 17:49:09 +00:00
dan sinclair c2af0a3fba Add missing override
R=bclayton@google.com, rharrison@chromium.org

Change-Id: I3daffbb7bf9b9e74e4bbadca7a62af5ceb6f2475
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33121
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-17 16:50:59 +00:00
Ben Clayton 655638c4a8 writer/spirv: Inherit TestHelperBase from ast::Builder
Exposes all the AST builder helpers to the spirv writer tests

Change-Id: Ie6709cc9f941a52899285ad476e8b4fc7ee9e4d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32983
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-17 16:12:08 +00:00
Ben Clayton 2d86bf4c32 ast::Builder: Add more builder methods
Add matrix types and missing expression overloads.
Tweak the signatures of the vec constructors so they can take mixed parameter types.

Change-Id: I303401e7ba80cbfddd14d9415e586e23eefcdd90
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32982
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-17 15:28:48 +00:00
Ben Clayton 165ff1c978 ast::Builder: Make the interface more fluent
Add C++ aliases for the wgsl types `i32`, `u32` and `f32`.

Separate types out from the builder and into a `Builder::Types` class. An instance of this is now held by the `Builder::ty` field. Makes it clear when you are referencing a `ast::type` instead of a constructor method.

Rework a number of builder methods so they take the type as a template argument instead of a parameter. This more closely resembles wgsl (example: `vec2<i32>(1,2)`)

Use PascalCase for the constructor methods, but keep the wgsl-like constructors lowercase to imitate the language style.

Add `BuilderWithContext` so that `Builder` can be truely immutable, and so we can remove `set_context()`.

Change-Id: Idf2d7d5abe7d11e27671b8e80d3d56d6bc4b3ca2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32980
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-17 15:23:48 +00:00
David Neto 90f3253645 spirv-reader: pretend handles are void
We convert types of samplers, images, and sampled images entirely
differently, but still find it useful to generalize ParserImpl::ConvertType
to cover them.

Fake it: Make ConvertType return void for them.

Bug: tint:109
Change-Id: I0982eb987d0914db8227bc0fce552989831129b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33020
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 23:55:19 +00:00
dan sinclair 33956dc4c4 Fixup include
This Cl fixes the msl/test_helper include to reference the MSL generator
impl.

Change-Id: Ic9858b47db460ccfadad3961ecc518ad3a040972
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32960
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-11-16 20:13:27 +00:00
David Neto a0b6796687 spirv-reader: better message for unknown SPIR-V type
Change-Id: I56a314d0c4eb1f1dfdb8804024a5824e5456356c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32940
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 17:35:57 +00:00
David Neto df2d92d5bb spirv-reader: add conversions for image Dim and Format
Change-Id: I9ad499aaa4683ce9a3ed702f21babaf24a15a8e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32741
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:44:17 +00:00
Ben Clayton 4bfe461646 Big cleanup now that AST nodes are raw pointers
Remove all redundant std::move()s. I've also removed calls to
std::move() in tests, even if they act as an optimization. This is for
two reasons:
(a) Performance is not important for testing, and this helps with
    readability.
(b) A whole bunch tests were relying on std::move() clearing vectors so
    they can be repopulated and used again. This is undefined behavior:

> Objects of types defined in the C++ standard library may be moved from
> (12.8). Move operations may be explicitly specified or implicitly
> generated. Unless otherwise specified, such moved-from objects shall
> be placed in a valid but unspecified state.

All of these UB cases have been fixed.

Removed all duplicate variables left over from:
  `auto* foo_ptr = foo.get()`
which became:
  `auto* foo_ptr = foo`

Bug: tint:322
Change-Id: Ibd08a2379671382320fd4d8da296ccc6a378b8af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32900
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:41:47 +00:00
Ben Clayton b053acf796 Replace use of std::unique_ptr<T> with T* for AST nodes
This is a minimal effort to fix up the code. There's substantial code
cleanup which can now be done, which is done in the next change.

Bug: tint:322
Change-Id: Iafcf5e814837d9534889e8c21333de4931a19cfa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32864
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:31:07 +00:00
Ben Clayton 0613890eed Replace remaining std::make_unique<T> -> create<T> for ast::Nodes
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I9d85e925538789d9b58f32c2bba32a05e22aea1c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32863
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:24:37 +00:00
Ben Clayton 0575449b82 src/transform: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I4d0c3a6b471c559617538bda90a5a991c71045a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32862
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:13:49 +00:00
Ben Clayton f65799e7da reader/wgsl: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I281fe91864a98365db5ccd40e264d042e6476172
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32861
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-16 16:11:19 +00:00
dan sinclair 75b740c4ae [spirv-writer] Fixup generation of temporary variable.
When extracting values out of constant arrays we sometimes generate a
temporary variable. That generation was over eager in the creation of
the variable and was also creating it for constant vector extractions
where it was providing the wrong souce type.

Bug: tint:318
Change-Id: I8d16182fd1fcf7d7aba0b0e1b7d947137efc136b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32801
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 15:34:07 +00:00
Ben Clayton 307919dba9 reader/spirv: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I72558482c4b6aff7a655087ee010b3e16b006192
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32860
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 15:21:07 +00:00
Ben Clayton eeac0c5f63 ast: Remove no-arg constructor for ast::IfStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I36a1cf55c31a1dabccde272b2be415f98c16b18f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32677
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 15:15:37 +00:00
dan sinclair aa57015db4 [spirv-writer] Generate loads for const constructors.
When building a const variable from a pointer we need to make sure to
load the value and use the loaded ID as the constant Id.

Bug: tint:310
Change-Id: Ia544fd69f3d2ae13e9ff9a983935ddc332d8d6ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32800
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-11-16 15:06:37 +00:00
dan sinclair 80598edf78 [ast] Add the result_type into the AST dump
This CL adds the result_type type_name into the AST dump if available.

Bug: tint:310, tint:308
Change-Id: Iea678fd4f7a2dadbfca86f29043c75459c421cb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32780
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 14:46:27 +00:00
Sarah Mashayekhi 112314b73d [validation] add error number to invalid member accessor error: v-0007
Bug: tint:6
Change-Id: Ia92ed8a328ff3c7986d8e5298b13f5d1db33935b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32384
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 14:35:17 +00:00
Ben Clayton 4ad0019df0 ast: Remove no-arg constructor for ast::CastStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I2a571d0a4727d6dc3d6c38e8b6602e131292f49c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32676
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 14:25:27 +00:00
Ben Clayton e5e9617220 ast: Remove no-arg constructor for ast::ElseStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I6173a63a243fdcbdd8a53c91010e2f628248298f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32678
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 09:53:12 +00:00
Ben Clayton 6a788df30e ast: Remove no-arg constructor for ast::LoopStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I3db9b3c037896f07b84b14b7b8d4da0f066b69b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32679
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 09:52:25 +00:00
Ben Clayton b29b09fba6 ast: Add body parameter to ast::Function constructors
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: Iddb5605b9bc0de80ad2710ced0e429f89410af2f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32675
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 01:13:04 +00:00
Ben Clayton 9a31c641e2 writer/wgsl tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I69cb8eb0a4943831fc9233e4dcce2ee65b682738
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32674
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 01:11:04 +00:00
Ben Clayton 16b1b9438d writer/spirv tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I5321553847b6a7d47ac211ba093d219c7f3bb9bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32673
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 01:09:04 +00:00
Ben Clayton 4c88cd93ec writer/msl tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I1756981b206c125d1dbf78ac178e0a7b60ec2941
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32672
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:23:05 +00:00
Ben Clayton bbc9b967a3 writer/hlsl tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I06511413e4d1afd84504f9ec8ab36f2c02764b9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32671
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:21:05 +00:00
Ben Clayton 16b12fa9a4 validator tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I69487200d9595f3176615ee1edf81da9fe1f5abc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32670
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:18:35 +00:00
Ben Clayton a1f4d4fda9 transform tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I630ce57017fe84b5d00e9bd74902f47547a13f3a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32669
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:16:25 +00:00
Ben Clayton 68f6afe2a4 inspector_test: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: Ibb9f437b9cb8b9883e05d1a266fa69141dc200d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32668
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:13:08 +00:00
Ben Clayton 6262592297 type_determiner_test: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I41860f91128920a1462edc603cce7caab7372c8a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32667
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:09:38 +00:00
Ben Clayton b673de0ec3 ast/types tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I39e7d1c9a1c64608d41dfd032c419e06d147e064
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32666
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:06:58 +00:00
Ben Clayton 327b1c7cd3 ast tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I0e68992963f52e432d4d485feae1123f35732552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32664
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:03:58 +00:00
Ben Clayton 4f7c2955ab ast/type: Have all tests derive from new TestHelper
It doesn't actually do anything (yet), but will hold the context and
a helper for constructing AST nodes.

Bug: tint:322
Change-Id: I265093f2ef38040c77a34fb0c23d7fc33757466f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32665
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-13 22:01:58 +00:00
dan sinclair c7c8f58f17 [spirv-writer] Generate load of conditionals.
This CL adds the missing load of conditional values.

Bug: tint:327
Change-Id: I836ecfacb3a237a54886ebc7625c9449ba33fdc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32700
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-13 22:01:29 +00:00
Ben Clayton 10d5c6a6b6 ast: Have all tests derive from new TestHelper
It doesn't actually do anything (yet), but will hold the context and
a helper for constructing AST nodes.

Bug: tint:322
Change-Id: Ic7ba92bf39abf64ff2ac51d81c8a6338f5eff608
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32663
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-13 21:58:28 +00:00
Ben Clayton 6f58546193 ast: Have all AST types derive from ast::Node
A common base class is required to move from std::unique_ptr<> to raw pointers for AST types.

Also unifies a bunch of similar APIs.

Bug: tint:322
Change-Id: If829f8c3f22069adf62751365f1f1eeb646aba08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32660
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 21:43:58 +00:00
dan sinclair 196e097730 Place the namer into the context object.
This CL moves the namer into the context object and makes it a parameter
to the various generators. The old constructor is maintained until we've
updated downstream repos.

Bug: tint:273
Change-Id: I49b2519c4250be21fb73374b16e7c702b727078f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32580
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-13 18:13:24 +00:00
Ryan Harrison 8ca4561b25 [inspector] Add Multisampled Texture data extraction
BUG=tint:257

Change-Id: I3feff89822762014e12e098f00474484139f83c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32382
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-12 21:50:50 +00:00
dan sinclair 20a8d31849 Create an AST builder class.
This Cl adds an ast::Builder class which provides a series of helper
methods to make creating AST nodes simpler.

Change-Id: Ife57f27e598d575681f7192d65fab968191699b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32560
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-12 19:49:10 +00:00
Ryan Harrison 1980095da7 [inspector] Convert GetRemapped to be a pass through
This is a temporary fix to get Tint rolling into Dawn again and will
be removed in a future patch.

BUG=tint:273

Change-Id: I632e71711146eb4055f46c1bebfbd6d3ff5772fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32520
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-11-12 15:43:00 +00:00
dan sinclair 1995ddf876 [spirv-writer] Revert change to entry point name.
This CL rolls the entry point name change back for the spirv-backend to
allow Dawn to continue to work.

We'll need to roll this together with the inspector change, MSL and HLSL
changes.

Bug: tint:273
Change-Id: I54e7e05a4c277d6c55bd6808f50fb0c7903bc418
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32500
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-12 15:42:20 +00:00
Ryan Harrison 2b706110f6 [inspector] Add better support for remapped entry point names
Add remapped_name to entry point structure, also supply method to find
the remapped name for individual entry points.

BUG=tint:312

Change-Id: I5f2cc02bc37c17e99c453b16108bc8e10c602fba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32383
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-11-11 21:35:36 +00:00
Ben Clayton f8cf585582 writer/spirv: Further reduce test boilerplate
Add helper methods for constructing `CallExpressions`, which is tediously verbose.

Change-Id: Idb6fbf25e79f07f4108df224fedb88f3fe3fb392
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32401
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 21:05:26 +00:00
Ben Clayton 394b4b92b6 writer/spirv: Reduce test boilerplate
Move common Context, Module, TypeDeterminer, Builder and common types into a test base class.

Add helpers for making common types.

Rename `BuilderTest` to  `IntrinsicBuilderTest`, otherwise it will collide with tests in another .cc.

Change-Id: I2badbbb381336ddd52aef72811da8adaebdeaf31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32400
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-11 19:17:06 +00:00
Ben Clayton af8091e353 wsgl parser: support multiple error messages
Use synchronization tokens to ensure the parser can resynchronize on error.

Bug: tint:282
Change-Id: I8bb033f8a723eb8f2bc029e1ffc8350174c964e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32284
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 18:44:36 +00:00
Sarah Mashayekhi ef486bf0e4 remove redundant std::move to fix clang errors
Change-Id: I86be320a3f3ac7855460341d4570bc7df715243a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32381
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-11-11 16:40:05 +00:00
dan sinclair cc73c8df5c Remove unused function
Change-Id: Idf831d3b6b4c6e97191ebead9fd503d4a15db9e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32380
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-11 16:06:45 +00:00
David Neto f16dfeb015 ast: intrinsic spelling matches the spec
Update the comments around the stream output method for ast::Intrinsic.

Change-Id: I06a3082927c83eb9172357c34a0587aac5f80465
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32360
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:30:25 +00:00
Sarah Mashayekhi 3b04058d19 [validation] Update entry points validation v-0020
Remove irrelevant unit tests
Add/Update ValdiateEntryPoints function
Update known failure file

Bug: tint:296
Change-Id: I7d5c9c96fcca29f3e0a4c0315eb8ce869160a3ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32220
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-11-11 14:21:05 +00:00
Ben Clayton 1bbafa3445 wsgl parser: Tweak top-level unexpected token error message
I feel this reads better.

Bug: tint:282
Change-Id: I04fe42a0347ea050e93e5cf5ccae7259bc79bb58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32283
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:16:45 +00:00
Ben Clayton b707258c8f wsgl parser: Fix tests that have multiple errors
A number of tests check the first encountered error is correct.
As the parser currently aborts after the first error, later errors are ignored.

Once the parser supports resynchronization, we'll emit multiple error messages, and these tests will start to fail. Fix them now.

Bug: tint:282
Change-Id: If8d0c41f030c652500b2e3b7284297b7a448d23e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32282
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:15:05 +00:00
Ben Clayton 54af8746ae wsgl parser: refactor statements()
Split out statments that are non-block (non-loops, etc) into a separate function.

These all end with a semi-colon, which is important for resynchronization on errors (coming up in another change).

Bug: tint:282
Change-Id: I0e58c4938f2bbe859dc6ffb8dcd45c8cf26101da
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32281
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:11:55 +00:00
Ben Clayton 00bc8ba88c wsgl parser: add expect_lt_gt_block(), use it
Reduces code, paves the way for multiple errors with resynchronization points.

Bug: tint:282
Change-Id: I68018ea8cabe4ec347afa21d1220126d6348d3d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32280
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:10:25 +00:00
David Neto a4f49d91dc spirv-reader: support OpDot, OpOuterProduct
Change-Id: I39f2369572a340be1c4c7c6e4a2c8e0e9347d792
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32200
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-11-11 13:59:24 +00:00
dan sinclair f7e152a3ab [msl-writer] Emit texture types
This CL adds texture and sampler type emission to the MSL backend.

Bug: tint:145
Change-Id: Iaab4d32b7fc6fedc1ffba16658f7800d6a502853
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32320
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-11 00:58:19 +00:00
Ryan Harrison dbcc1e0e80 [inspector] Extract Sampled Texture data
BUG=tint:257

Change-Id: I146591d052edfc959df33ccf235ea466cb59e59d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-11-10 22:30:56 +00:00
dan sinclair 2e6dc6037a [hlsl-writer] Emit texture types
This CL adds emission of the texture types from the HLSL backend.

Bug: tint:146
Change-Id: I378bd6d63719acfbedff887bdf280709dc981e8f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32221
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-10 22:10:56 +00:00
dan sinclair 84f827506a [spirv-writer] Hash names
This Cl hashes the OpName, OpEntryPoint and OpMemberName strings so we
are no longer passing user provided strings through into the resulting
SPIR-V binary.

Bug: tint:273
Change-Id: I0ca2c65d0cd2800c54d867ab698c7751c341778c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32061
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-10 21:49:56 +00:00
Ben Clayton 0573714bfd wsgl parser: Have Expect & Maybe operator-> deref
For values of type T* and std::unique_ptr<T>.

This allows us to replace all occurances of `res.value->member` with: `res->member`, which also asserts that `res` is not in an error state.

Brings the verbosity back down to pre-expect and pre-maybe levels.

Bug: tint:282
Change-Id: Ib00018affca53ac5e71ee2140e7e0cd607b83715
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 20:44:34 +00:00
Ben Clayton ab5dfee240 wsgl parser: Add ParserImpl::Maybe<T>
And use it for the non-ParserImpl::expect_xxx() methods.

Another step towards supporting multiple error messages, as the caller can now test to see if the specific call errored, or didn't match, instead of using a global error state.

Makes reading the control flow conditionals a bit easier too.

Change-Id: Ie8627b8499ec9079167965da2a566401cd6bd903
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32102
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 19:52:24 +00:00
Ben Clayton 653c4042e2 wsgl parser: Add ParserImpl::Expect<T>
And use it for the ParserImpl::expect_xxx() methods.

This is the first step towards supporting multiple error messages, as
the caller can now test to see if the specific call errored, instead of
using a global error state.

Also cleans up a bunch of code.

Bug: tint:282

Change-Id: I5e39fc33bd1e16620cee80d27fa728bc2af3387e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32101
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 19:39:34 +00:00
Ben Clayton f2e91857e1 wsgl parser: Migrate more code to use expect & match
Reduces code. Keeps things more consistent.

Bug: tint:282
Change-Id: Iff280880eb033fbcee4c6095c2da2d4af06835b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32103
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 19:19:44 +00:00
Ben Clayton d60f0feee4 wsgl parser: expect for storage_class
All the call sites of `storage_class()` add their own error handling, so transform this into `expect_storage_class()`.

Also makes error messages more consistent.

Bug: tint:282
Change-Id: I5131acd84f91fc7494ed6b90965853b7d0fc37f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32104
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 18:45:53 +00:00
Ben Clayton b8df12042a wsgl parser: expect for variable_ident_decl
All the call sites of `variable_ident_decl()` add their own error handling, so transform this into `expect_variable_ident_decl()`.

Also makes error messages more consistent.

Bug: tint:282
Change-Id: I0b5ac984018ba78896ddec0320636f5b5c4ad0b2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32100
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-09 18:41:23 +00:00
Sarah Mashayekhi 6512327f01 [validation] relax rule v-0002: return is mandatory for non-void functions
Bug: tint:302
Change-Id: Ia8a5cf1d36d5da6e2defdfff6c87f0d8a1a39b4a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32040
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-09 16:11:43 +00:00
Ben Clayton cd477e6b7b wsgl parser: Remove pointless nullptr checks
The `expect_` prefixes now clearly indicate when a method will internally error, or produce a valid AST object.

Verified by code coverage.

Bug: tint:282
Change-Id: Icbdae9db02bd48c69aec010a4f8fdc5a496125f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32002
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-09 15:58:42 +00:00
Ben Clayton 7b750dc733 wsgl parser: Prefix methods with `expect_`
... for those that will internally error if the grammar does not match,
otherwise will always return a valid AST object.

This helps identify whether the caller is expected to error or not.

Bug: tint:282
Change-Id: Ied94f717526a63033f2e6c9e94fca43dbf0b8f05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32001
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 15:49:33 +00:00
dan sinclair 8655b62207 Switch to GLSL450 memory model.
This CL updates Tint to use the GLSL450 memory model.

Bug: tint:63
Change-Id: Ia32851fbf8ee71233977a00386af5a91cb4b4b58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31601
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-07 02:03:45 +00:00
dan sinclair 2c0cd311b8 Remove unused param documentation
Change-Id: I5e7a6deddfe49cf992a8066771a19ea77bed2618
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32041
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-07 01:30:25 +00:00
Ryan Harrison 110af53089 [inspector] Extract ComparisonSampler resource binding information
Adds in method to get resource binding information for comparison
samplers along with tests.

BUG=tint:257

Change-Id: I60f675347d2b9596308b1599d0a9b846615d547e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31980
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-06 17:53:45 +00:00
Sarah Mashayekhi 34f90a0097 [validation] make validator directory
Change-Id: Ia5caea84b48b37f0bee9582ee4c8514da4ee3978
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31981
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-06 17:31:15 +00:00
Ryan Harrison cc2305dd95 [inspector] Extract Sampler resource binding information
Adds in method to get resource binding information for non-comparison
samplers along with tests. Additionally some of the infrastructure for
implementing an equivalent comparison sampler code path is included.

BUG=tint:257

Change-Id: I5775bbd6233e1014bea54c5281d460544ab8383d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31920
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-05 20:09:50 +00:00
dan sinclair 795bf4c716 Fixup emitting duplicate globals in HLSL.
This CL fixes the issue with duplicate globals being emitted in HLSL if
used in multiple entry points. Tests are added for the other backends to
verify the issue does not exist there.

Bug: tint:297
Change-Id: I16d7504e8458fd375c6e1896758fe180ad963871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31880
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-05 14:52:32 +00:00
dan sinclair eff1fb88fc [wgsl-reader][wgsl-writer] Update storage texture type name.
This Cl updates the storage textures to have `storage` in the name. So,
`texture_ro_1d` -> `texture_storage_ro_1d`

Bug: tint:286
Change-Id: I0a9ea02f15de2681d64e272cb42be51a940b6a13
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31840
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-04 22:19:33 +00:00
Ben Clayton 88dc2a4895 wsgl parser: Unify logic for all decorations
Parse all decorations with the same function, and create a
`ast::DecorationList`. Once the parser has progressed to the consumer of
the decorations, we attempt to downcast these to the required type,
erroring if they're the wrong kind.

While the error message could be improved further, this greatly reduces
the headscratching around crbug.com/tint/291.

Also knocks another 223 lines off parser_impl.cc.

Bug: tint:291
Bug: tint:282
Change-Id: I7506faeb56d876e5446d900c7c134669a9db6409
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31660
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:55:31 +00:00
Ben Clayton 786bc92002 wsgl parser: Add expect_block(), use it
`expect_block()` takes a start and end token, along with a function to parse a lexical block body.

This reduces code, keeps error messages consistent, and also gives us a future place to try resynchronising the parser so we can have more than one error emitted.

`expect_paren_block()` and `expect_brace_block()` are convenience helpers for providing the start and end tokens for common block types.

Bug: tint:282
Change-Id: I432a0301727b131a6fce875687b952dfc6889a4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31736
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:08:51 +00:00
Ben Clayton b8791a5129 wsgl parser: Add expect_builtin()
Mirrors expect_pipeline_stage()

Bug: tint:282
Change-Id: I413c87b3684c1f5cfec0c4acd7d3a5160d4b24a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31735
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:06:21 +00:00
Ben Clayton 32ba9b6722 wsgl parser: pipeline_stage() -> expect_pipeline_stage()
The only place that calls `pipeline_stage()` expects a stage to exist, so follow the `expect_` pattern.

Bug: tint:282
Change-Id: Ie18d24ed25a5f882e66a8e553e53b4fb52dcf6fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31734
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:00:31 +00:00
Ben Clayton 53e619f7e9 wsgl parser: Use match() for more trivial patterns
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: I75ac50ef4a2435cfd42e95e851fa1f3524d1dd63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31733
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-04 19:11:41 +00:00
dan sinclair a7e1492a6a [wgsl-reader][wgsl-writer] Support new sampled texture syntax.
This CL updates Tint to support the `texture_1d` format for sampled
textures. This is alongside the old `texture_sampled_1d` to allow
migration time.

The WGSL writer will always output the new form when converting to WGSL.

Bug: tint:286
Change-Id: I96f0308ad3c28ade96bcab7e24aa0b405e3c4f05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31380
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-04 19:03:21 +00:00
Ben Clayton 4ce7a93202 wsgl parser: Add optional Source* out params
... to match() and expect_ident().

The uses of these two functions frequently want to know the souce of the matched token.

Bug: tint:282
Change-Id: I5279fc2e0834f48d419c6d8c9888189f6212c44a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31732
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 18:39:41 +00:00
Ben Clayton 0371cc4a8d wsgl parser: Use expect_ident()
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Id6e219222a5967bb4b6d67e54816f669c38d0c19
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31731
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-04 16:34:10 +00:00
Ryan Harrison 77f7bb5b00 [inspector] Refactor to handle access control wrapped uniform-buffers
Updates the extraction code to assume that the StructType will be
wrapped by an AccessControlType. Tests are changed to match this
behaviour, and some minor naming clean up occured.

BUG=tint:257

Change-Id: I888ac2fae228531e956437afb937082a142d5736
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31780
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 16:08:00 +00:00
Ben Clayton 443039a58f wsgl parser: Use expect() for call r-parenthesis
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ibbbb98bb6f080dd338af7de415c6e86298d910e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31730
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 15:48:20 +00:00
Ben Clayton 67c37197d6 wsgl parser: Use expect_[nonzero_]uint()
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: If89265dfe4356468d610dab931c906aa3260ce5a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31728
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:27:51 +00:00
Ben Clayton 0358d1bc1b wsgl parser: Use expect() for parenthesis checks
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ie5059599ed538bc589d594d7f16aa3db6774110b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31727
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:25:21 +00:00
Ben Clayton 5c58a06515 wsgl parser: Use match() for trivial patterns
Replace uses of peek, test, return-or-next with match().
Reduces code.

Bug: tint:282
Change-Id: I5e53601746e78efd007773cfea7109483c5e1630
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31726
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:21:51 +00:00
Ben Clayton f7fc63b8e3 wsgl parser: Use expect() for semicolon checks
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ifddb63b65d44427e0680bb25837fcb24ca854eb0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31725
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:17:51 +00:00
Ben Clayton d70f251188 wsgl parser: Add match() and expect() helpers
These will be used to simplify common parser patterns.

Bug: tint:282
Change-Id: Ia281b9aa66b98f4afc726e876fe8aeae5ff4f12c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31724
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:14:40 +00:00
Ben Clayton a47b277b26 Fix build
https://dawn-review.googlesource.com/c/tint/+/31760 landed just after https://dawn-review.googlesource.com/c/tint/+/31722, which added a new parameter to all decorator constructors.

Add the missing parameters to fix the build.

Change-Id: Id8360dd23dd59096ffdff0cf523c3323ac01b431
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31729
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:12:51 +00:00
Ben Clayton 88cd156fd9 wgsl parser: Replace set_error() with add_error()
Have slightly different overloads.

Long term we will want to be able to emit more than one error in a single parse.

Bug: tint:282
Bug: tint:291
Change-Id: Ide61c6ca75d45065e917b8fa16a097048397e31b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31723
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-04 02:23:10 +00:00
Ryan Harrison e862fde45c [inspector] Extract Read Only Storage Buffer data
BUG=tint:257

Change-Id: Ie9486726b2a164971d720f4496a87a0bd118ebde
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31760
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-11-03 22:19:50 +00:00
Ben Clayton 34a2eb1999 Add Source parameter to decoration constructors
Once a `Decoration` has been parsed, it'll be placed into a `DecorationList` and validated later in the parse. In order to create error diagnostics that refer back to the decoration, we need to know its source.

Bug: tint:282
Bug: tint:291
Change-Id: I38de708adbd041601b61d7e0a4d0402e9a2fe526
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31722
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 21:48:20 +00:00
Ben Clayton 35298800a6 ast: Have all decorations derive from base class
This is the first step in unifying the way decorations are parsed - i.e. instead of parsing decorations in different ways based on the predicted grammar that follows, we can parse decorations blocks in a unified way, then later verify what we have is as expected.

`StructDecoration` has been transformed from an `enum class` to a proper class so it can derive from `Decoration`.

Bug: tint:282
Bug: tint:291
Change-Id: Iaf12d266068d03edf695acdf2cd21e6cc3ea8eb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31663
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-03 21:40:20 +00:00
Ben Clayton 1a61e8613e formatter: Remove colon line prefix with no source
If a diagnostic has no Source information, don't start the diagnostic line with a colon.

Bug: tint:282
Change-Id: I80c4103e31556b2769d4b4c2a98dce21a2e1c233
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31662
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-03 18:27:29 +00:00
Ben Clayton 06c892a6ec diagnostic/printer: Print newline at end of tests
Otherwise other test messages will continue from the same line as the pretty colors.

Bug: tint:282
Change-Id: I14727b4faa7bbca490523cdd6941fa09dc6b514a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31661
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-03 17:56:29 +00:00
Ben Clayton f8bd106041 Fix all warnings when building with CMake + clang
Change-Id: I987b4580f5f99584649b2b189369a0b962b0c3d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31721
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 17:46:49 +00:00
Ryan Harrison a28d19b18d Add tests for MinBufferBindingSize
BUG=tint:283

Change-Id: Id198175d232680ca89e04561b8b7510f41d982f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31106
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 16:53:59 +00:00
dan sinclair d5fd7e02ba Fixup lint errors.
This CL fixes up the various lint errors.

Change-Id: If4d3077b55aadec33980452c43917194d803fac6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31680
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-03 16:26:09 +00:00
Ben Clayton de6938789c Add test for bad function attribute
This test reproduces the unhelpful error message described in tint:291.

Bug: tint:291
Change-Id: Ie93cc59d981691981ba978b690d11c93dfe46ae0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31571
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 15:33:19 +00:00
Ben Clayton d59a5da9e5 Have tint executable use the diagnostic printer
Will now print with better formatting and colors on terminals that support it.

Bug: tint:282
Change-Id: Ibff341cb1dc2dcbda6fa0d72e24fdcb172990138
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31570
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 13:15:19 +00:00
Ben Clayton ecea5c8aec Make Formatter a non-interface
I had originally created `Formatter` as an interface as I was intending to implement this differently for linux and windows (for terminal coloring).

Color printing is instead implemented by the `Printer` interface / PIMPL classes.

Replace the multi-boolean constructor with a `Style` struct, as this will make life easier when we want to add / remove flags.

Bug: tint:282
Change-Id: I630073ed7a76c023348b66e8a8517b00b2b6a0d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31569
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 21:16:38 +00:00
dan sinclair 28f7764704 [spirv-writer] Generate load in Unary Op generation.
When generating a unary operation we need to make sure we correctly
generate the load otherwise the resulting SPIR-V will be invalid. This
CL adds the required GenerateLoadIfNeeded call into the unary
generation.

Bug: tint292
Change-Id: Ia04314726afdda8f63a78e8e52f996681373db6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-02 19:43:08 +00:00
Ben Clayton 2e6cc992c8 Implement diagnostic color printing
For linux and windows consoles.

Still needs hooking up to `samples/main.cc`

Bug: tint:282
Change-Id: If8430572708ea7d8788ef05d5379886be89fcb17
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31564
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 19:26:28 +00:00
Ben Clayton 2d89d98fe1 Fix all doxygen warnings
Bug: tint:282
Change-Id: I6c243c30f4477bb972dc737c8b3ff9cc2e0a91f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31568
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 18:02:18 +00:00
Ben Clayton cd5e4a8083 Remove Parser constructors that take a string
... for the content. Everything should be using a `Source::File*` now.

Bug: tint:282
Change-Id: I9bebb94995a946a5919ba6503f2b0ee2058f0fb1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31482
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 17:55:18 +00:00
dan sinclair 3d0e273ec3 Make doxygen happy.
This CL adds some code comments to fixup doxygen warnings.

Change-Id: I0d0f4b20a1023691141b2f49f82f4538ffe18614
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31600
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-02 16:03:38 +00:00
Ben Clayton 3d54f13613 Use the new diagnostics for wgsl the parser
Keep the `ParserImpl::error()` format identical to the old error style for now.
Use the explicit `ParserImpl::diagnostics()` method for the error message tests, updating the tests to match the new, improved output.

Bug: tint:282
Change-Id: Ia7e1237170f0f5203a8cfa256322df29e90e2791
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31481
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:56:28 +00:00
David Neto 0a06243a70 spirv-reader: support scalar spec constants
Translate OpSpecConstantTrue, OpSpecConstantFalse, and OpSpecConstant.
The latter only can be used with integer or float scalars.

If the constant has a SpecId decoration, then generate a module-scope
decorated constant.  Otherwise generate a module-scope constant without
decorations.

Register the ID so we know to use the declared const identifier in
expressions later in the module.

Bug: tint:156
Change-Id: Icd6e9b60225ced7ee99963c4f85cec1eb0e3ae6b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31541
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:44:27 +00:00
Ben Clayton f0740ae0f2 Add tint::diag namespace for diagnostics
Diagnostics will be used for printing parser / validator error mesasges.
Diagnostics are collected into a `diag::List`, and can then be formatted into a human readable message with `diag::Formatter`.

Bug: tint:282
Change-Id: I8bbef3db22b72d62cb9467c878d9a346890589ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31480
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:41:08 +00:00
Ben Clayton 580d6c7f3e Produce end ranges for tokens and AST nodes
This includes a couple of position fixes in `lexer.cc`.

The source for identifiers (vars, params, etc) now refer to the identifier, not the first token of the construct.

Bug: tint:282
Change-Id: I58cb8422a4af1c7dc5f84431fd7f06b823b514c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31444
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:25:18 +00:00
Ben Clayton a3bcde2c10 Rm line() & column() from wsgl::Token & ast::Node
Use `source().range.begin.line` and `source().range.begin.column` instead.

Bug: tint:282
Change-Id: I6c9bf8766d6db2c9d8e7e1b8bafb2eea93e065d8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31441
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:17:50 +00:00
Ben Clayton fc5a9cfaf7 Remove tint::Source(size_t, size_t) constructor
This was a temporary overload to break up the changes into smaller chunks.
Change all call sites to use one of the other constructors.

Bug: tint:282
Change-Id: I500fe9700d22f72312827808caa22f7feef7b294
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31440
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:07:47 +00:00
David Neto 74023424da Remove stale TODO
Change-Id: I1b7dbbc0290c48309c9cbf00a432e3beccd27bcf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-02 14:56:47 +00:00
Ben Clayton 5bee67fced Add File & Range information to tint::Source
This is the first step in improving the error messages produced while parsing.

The `line` and `column` information of `Source` has been moved to `Source::Location`.

`Source::Range` has been added that contains a `Location` interval - allowing error messages to highlight the full region of the error.

The `File` information provides an optional file path, and pre-splits the content into lines. These lines can be used to print the full line containing an error.

This CL contains a few temporary changes that help split up this work, and to ease integration with Tint.

Bug: tint:282
Change-Id: I7aa501b0a9631f286e8e93fd7396bdbe38175727
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31420
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-10-30 20:44:53 +00:00
Ben Clayton 5d40a5621b Add ParserImplTestWithParam to reduce boilerplate
There were a number of places where we were declaring classes derived from `testing::TestWithParam<T>` and then adding the same `parser()` helper logic.

Move this common logic down to a new `ParserImplTestWithParam<T>` class, and derive from that instead.

Removes a whole bunch of copy-pasta.

Change-Id: I8f308b77817fd6327c045d2fdee4462b7f32897a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31401
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-29 19:19:34 +00:00
dan sinclair bfc2fceb84 Use min for bounded array accessing.
This CL updates the BoundArrayAccess transform to use `min(u32(val),
size)` instead of `clamp(val, 0, size)` so as to reduce the number of
instructions needed to clamp within range.

Bug: tint:285
Change-Id: Ic12bd67f3d755c8e52590f0585bac114ba9eaa94
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31360
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-29 17:56:06 +00:00
dan sinclair c8b2d23e9d [spirv-writer] Emit access control information.
This CL adds emission of the decorations for the access control flags.

Bug: tint:208 tint:108
Change-Id: I3286132dad8edd2586228dc6e87749ad49451739
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31082
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-29 14:45:02 +00:00
David Neto 6857ed0b0b spirv-reader: apply access control to storage buffers
- Apply the AccessControlType wrappar around the struct type for any
  variable in the StorageBuffer storage class.
- Drop the NonWritable member decorations for the struct type.

Bug: tint:108
Change-Id: I6496c8c3e8b5d92b2ed0071385915d2b8065a80d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31020
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-29 14:36:22 +00:00
dan sinclair c55fc39acb [ast] Unify the access control types.
This CL merges the StorageAccess enum with the AccessControl enum. The
enum is moved up to src/ast and placed in its own file for clarity.

Change-Id: I95a905a399b5d2e046ea1ea429b35f2064510c2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31242
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-29 13:36:32 +00:00
Ben Clayton 4dd5665502 Add tests for all reachable parser errors
These are _mostly_ covered in the over various test files, but unlike those, these new tests always parse from the root translation unit.

These new tests also use a new testing class which may be extended to verify error output for different error styles (verbosity, colors, etc).

Change-Id: I105488f9b16d90279af4cc418a1c845b6e239e9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31263
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-29 13:05:52 +00:00
dan sinclair 5ede1190cf [hlsl-writer] Add read-only storage buffers.
This CL updates the HLSL backend to emit based on the AccessControlType.

Bug: tint:208 tint:108
Change-Id: I25baccaaa9af99a214467fe67d55a2f4256dab8c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31105
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-28 21:08:12 +00:00
dan sinclair e8dc46a8c8 [msl-writer] Add read-only storage buffers.
This CL updates the MSL backend to emit based on the AccessControlType.

Bug: tint:208 tint:108
Change-Id: I02c0afe360c286888580135b496fb78a1e747d3b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31241
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-28 20:45:02 +00:00
dan sinclair 512ecc2762 Rename unwrap helpers.
With the addition of the AccessControlType we want to look through the
access control as well as the aliases as we work through the type tree.
This CL renames UnwrapAliasesIfNeeded to be UnwrapIfNeeded and
UnwrapAliasPtrAlias to UnwrapAll.

Change-Id: I5b027919c3143a89be24c4d87b8106f70358c03b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31104
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-28 20:32:22 +00:00
Ben Clayton c23a5652bd Fix a couple of typos found in parser_impl.cc
Change-Id: Ice4047838ad5c5e48803d8a529f3ca24d2ce77c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-10-28 20:18:22 +00:00
dan sinclair bfd81096a5 [ast] Add AccessControlType.
This CL adds the AST for an AccessControlType. This type contains an
access control (ReadOnly, WriteOnly, or ReadWrite) along with another
type pointer.

Bug: tint:208 tint:108
Change-Id: I2eed03f8760239f7e71dc2edd4a19a7c1661746e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31060
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-10-27 18:50:59 +00:00
Ben Clayton ebe97f3ce1 Fix build for tests on gcc-9
```
../src/inspector/inspector_test.cc
[build] ../src/inspector/inspector_test.cc:203:13: error: explicit specialization in non-namespace scope ‘class tint::inspector::{anonymous}::InspectorHelper’
[build]   203 |   template <>
[build]       |             ^
[build] ../src/inspector/inspector_test.cc:205:60: error: template-id ‘MakeLiteral<bool>’ in declaration of primary template
[build]   205 |                                                   bool* val)
```

These `MakeLiteral()` methods can just be standard non-templated overloads - so do that.

Change-Id: I7e0b4ec10636eaf772d1ed4d3e9341c5da4087af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31120
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-27 18:47:39 +00:00
Ryan Harrison 70a3f152f2 Ran 'git cl format' over repo, found some nits
Change-Id: I5774e4cfc8a570522ac6533d69b5b87f7e5e0b6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31081
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-27 18:14:29 +00:00
Ryan Harrison fcbc6efa8f [inspector] Extract storage-buffer information
BUG=tint:257

Change-Id: Ib85d76a3b972226b401e57ba2a632d6252e95f8f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31080
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-27 18:03:09 +00:00
Ryan Harrison 57694c8dab Change test terminology to reflect WebGPU spec
The spec explicitly refers to these as uniform buffers, not uniform
buffer objects (UBOs).

Change-Id: Ia825f8ddd64fe9a3c20fb10914c6446346fc0217
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31001
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-10-26 20:11:48 +00:00
David Neto 1bafdc3c45 spirv-writer: Generate load for return value, when needed
spirv-writer: treat function parameter as const

Bug: tint:274
Change-Id: Iba4d90ea10a70ce1f551b7b8da6efcc01fe97412
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30924
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-26 14:27:08 +00:00
David Neto f81c1081ea wgsl-reader: treat function formal params as const
They should only be singly-assigned.

This is required because consts can hold pointers, but
var's cannot.  And we need to support pointer arguments.

Bug: tint:275
Change-Id: I00a58734725bd08d40df71c736854a93c364a33c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30923
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-23 23:39:25 +00:00
David Neto 9ab6e8b9eb spirv-reader: treat function parameters as const declarations
Change-Id: I5e5f35be15737c6dc46bb2e9dc1319f7c403eab8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30921
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-10-23 18:19:10 +00:00
David Neto e6fda61ef0 ast::Variable dumping now indicates is_const
If is_const is true, then dump VariableConst{...

For ast::DecoratedVariable, dump "DecoratedVariableConst{..."
when it's const.

Change-Id: I8383e5bc989e4ee20e3a5812f346d5f9a7990dbb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30920
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-23 17:45:50 +00:00
David Neto 79d271580e Don't leak the array-type memo table.
This also keeps tests isolated from each other.

Change-Id: I56937bb160138d7d82b2cf8f2560ddb5c0647048
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30881
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-23 17:04:40 +00:00
David Neto 1b1d2a5907 Fix doxygen comment
Change-Id: I7ae8d3eda8d9cbe042dc5d571f4e66a54f6c75da
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30880
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-23 16:47:30 +00:00
Ryan Harrison 88d705dc85 [inspector] Extract UBO information
Also includes adding in sizing information for various types.

BUG=tint:257

Change-Id: Iaaa8a7c28851d14790285b5bd14636bf3ae2b9b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30704
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-22 19:31:31 +00:00
dan sinclair 0ce0704741 Remove type alias struct variant.
This CL removes the `type IDENT = struct` format in favour of the
`struct IDENT` variant.

Bug: tint:175
Change-Id: I4fde8012fd07f811cd0bd80445198f6bbc92b720
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30661
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-21 19:15:20 +00:00
dan sinclair 4f79c84050 [spirv-writer] Deduplicate sampler and comparision_sampler.
Both sampler types generate an `OpTypeSampler` in SPIR-V so we need to
make sure they're considered duplicates in the SPIR-V backend. This CL
registers the generated ID with for both sampler type_names when either
one is emitted.

Bug: tint:272
Change-Id: If459bbb34fe8670a7e29d101686b70bf83b184c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30662
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-20 21:43:29 +00:00
dan sinclair 7156d3e314 [wgsl-reader] Add parsing of named structs.
This CL adds the parsing of structs with names. The parsing of type
aliased structs remains to allow for migration to the new system. The
named struct format is always emitted.

Bug: tint:175
Change-Id: Ic0579dedbd2dd0edc7dfd30bc2ec02972091e718
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30341
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-19 15:31:47 +00:00
Ryan Harrison 8904253837 Add getting constant ID information from Inspector
This also involves a reorganization of the code into its own
subdirectory.

BUG=tint:253

Change-Id: If05018da2662e923e659b485576704f3a6bcd062
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30340
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-16 02:26:54 +00:00
dan sinclair 95dc655bf8 [ast] Change module dump order.
This CL changes the AST dumping order to emit alias types before global
variables. This makes the output easier to read as the types come before
the usages.

Bug: tint:175
Change-Id: Ib7325384b910472e89d6d01853503be989ce4210
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30281
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-15 18:04:44 +00:00
dan sinclair 481ecff293 [ast] Require StructType to have a name
This CL moves the StructType name into the constructor of the struct
type instead of receiving through an accessor. The |set_name| accessor
is removed as it should not be needed anymore. All call sites have been
updated.

The vertex pulling transform was fixed to correctly register an alias
for the structure being created so it will be emitted.

Bug: tint:175
Change-Id: I8802931d9bdbc6c2f12982eea9032931939d195c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30280
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-15 17:54:13 +00:00
dan sinclair ff267ca60e [type-determiner] Fixup handling of unknown identifiers.
This Cl updates the identifier type determination check to fail if the
identifier is not found and is not an intrinsic method.

Bug: tint:139
Change-Id: I332dd7fb42dae62bdee459c4a8819bdb5685c903
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30081
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-10-14 18:26:31 +00:00
dan sinclair 5afb002aa4 Add comments
Change-Id: I85f13d7f115a900ffdbc9411d56bf829619288ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30160
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-14 17:37:01 +00:00
dan sinclair 435916e544 [spirv-writer] Fixes to constant constructor determination.
The change from `cast` to type constructor casts causes our current
determination if a constructor is constant to no longer be correct.

This Cl updates the determination to match the current spec and adds a
bunch of unit tests to verify the behaviour..

Bug: tint:270
Change-Id: I8ce74eb7c3f849ce62815868313449d8ca2de6be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30020
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-14 15:14:11 +00:00
dan sinclair 4311dd05c8 [spirv-writer] Fix accessing array of non-scalars.
Currently, if we access an array of non-scalar items we'll incorrectly
emit an OpVectorExtractDynamic which will fail as the result is not
scalar.

This CL updates the array accessor code such that if the base array is
an array of non-scalars we'll do load of the array and then access chain
into the loaded variable.

Bug: tint:267
Change-Id: Ia4d7052b57d8b31b835714b7b922c7859e3dce1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29844
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 21:34:25 +00:00
dan sinclair c169506c9e [wgsl-reader] Allow global variable decorations to have multiple blocks.
This CL updates the WGSL parser to allow global variable  decorations
to accept multiple blocks.

Bug: tint:240
Change-Id: Iaf8f794d285d87af6e2ff8c93e34d88331eedccb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29840
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-10-08 19:40:15 +00:00
dan sinclair 25f883520e [spirv-writer] Remove push_preamble
The push_preamble method was dealing with multiple sections of the
SPIR-V binary layout. As we changed the way things write (like
extensions getting written later) the preamble section was ending up in
incorrect order.

This CL replaces push_preamble with push methods for each of the
sections at the start of the SPIR-V module which should fixup the
ordering issue.

Bug: tint:267
Change-Id: Ib73a66d0fdb2c67dd6e80582289dd18475fad9f9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29841
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-08 19:37:45 +00:00
dan sinclair eb5d3e147d [wgsl-reader] Allow array decorations to have multiple blocks.
This CL updates the WGSL parser to allow array decorations to accept
multiple blocks. The stride decoration on arrays was turned into a
proper decoration object instead of just storing the stride directly.

Bug: tint:240
Change-Id: I6cdc7400d8847e3e043b846ea5c9f86cb795cf86
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29780
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 19:34:25 +00:00
dan sinclair 71d69e5ed3 Update struct member decorations to allow multiple blocks.
This CL updates the struct member decoration parsing to allow multiple
blocks of decorations.

Bug: tint:240
Change-Id: I97293ef30333f63c33bbc6e728dba11abc020c7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29280
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 19:17:45 +00:00
Ryan Harrison 5118c07261 Add In/Out variables to returned EntryPoint
BUG=tint:257

Change-Id: Iec0dca854dfa6380991c04544848c24f21496a93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29524
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-08 18:38:45 +00:00
dan sinclair 1a63c49b4e Update structs to allow multiple decorations
This CL updates to match the spec change allowing multiple struct
decorations.

Bug: tint:240
Change-Id: Id859c6a331c67c46597fc3c70de06d6cc0f486ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29260
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 18:33:25 +00:00
dan sinclair 007dc42cbb [type-determiner][spirv-writer] Add arrayLength support
This CL adds support for retrieving the array length of a Runtime Array
in the SPIR-V backend.

Bug: tint:252
Change-Id: Ic13c4a99da5760738d57702c45f52c6a194a172d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29220
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 17:01:55 +00:00
dan sinclair fc5c5ab60b [hlsl-writer] Emit specialization variables
This CL adds specialization to the HLSL backend. The specialization is
emulated using defined preprocessor macros.

Bug: tint:154
Change-Id: I73ab42360558967eee9a0da6bbe74d513fe4cc57
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29720
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 16:22:45 +00:00
dan sinclair a388d56d99 [spirv-writer] Fixup constructor with bitcast parameters.
Currently if a constructor contains constructors we consider it const.
This falls down with the new type constructor syntax if the types don't
match. In the case they don't match we no longer consider the
constructor const as we'll generate OpBitcast and OpCopyObject
instructions which we need to build the composite from.

Bug: tint: 263
Change-Id: Ic85f58c8410e862a2ec30c7d93c9b87a61822f6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29523
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-07 14:06:28 +00:00
Ben Clayton c9110b93cb Add missing #include - fixes build on vs2019
Change-Id: I68bdf5ad1028ac344bca91c055045e5bf81318a3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29580
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-07 13:13:58 +00:00
dan sinclair 488d7a9346 [spirv-writer] Fix emission of OpExecutionMode
All of the OpEntryPoint declarations must come before OpExecutionMode.
Currently if you have multiple fragment shaders we'll interleave the
OpEntryPoint and OpExeutionMode which will fail to validate.

Bug: tint:263
Change-Id: I7c925cf6b5345c03bfaf1aa15115caa1bdb9af4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29522
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-06 21:20:28 +00:00
dan sinclair 56acec91b1 [msl-writer] Emit function constant information
This CL adds the code to emit function_constant attributes to the
generated MSL.

Bug: tint:153
Change-Id: I0e4f50257fde7e8db8f53e15bc9f460ebfc809ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29520
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-06 21:05:18 +00:00
dan sinclair 90ee6c4360 Doxy comments
Add some missing doxygen comments

Change-Id: Ic5d6684d90f5b2fe9ed3914bbb7c4058effc040c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29500
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-06 17:47:57 +00:00
Ryan Harrison 8a9007221c Add Workgroup size information to EntryPoint struct
BUG=tint:257

Change-Id: Iaf03bfaeb622b7315d65e46eccfe90244bced339
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29420
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-06 16:28:57 +00:00
dan sinclair dd516e6b64 Doxygen cleanup
This CL suppresses some Doxygen warnings for code doxygen doesn't
process correctly and adds the missing return for GenerateEntryPoint
method.

Change-Id: If97443a7177caa51c1054de83fb0711692a7ab22
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29461
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-06 15:35:37 +00:00
dan sinclair b8d90ead93 Move visibility=hidden directive.
This CL moves the visibility=hidden directive from the top level applied
flags to libtint specifically. This fixes up an issue between
SPIRV-Tools and the sample app when using std::rfind which ends up with
different visibility.

Change-Id: Ib06949b3755db66027d3656d3d6ce2504bfda81e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29460
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-06 15:11:17 +00:00
dan sinclair b5e5b804c3 Reduce duplication of type format strings.
This CL makes the AST type format name match the WGSL name so the
overloaded operator<< can be used in the WGSL writer. This removes a
bunch of duplication of WGSL type format name strings.

Bug: tint:230
Change-Id: I14aaefd21ced267ceed31f21faba3bd291275f0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29402
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-05 19:55:56 +00:00
dan sinclair 94b7c66858 [msl-writer][hlsl-writer] Add countOneBits and reverseBits
This Cl adds countOneBits and reverseBits intrinsic support to the MSL
and HLSL backends.

Bug: tint:250
Change-Id: Idb572da32e9c10767a27326cacf58aafef44a77a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29401
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-05 19:46:16 +00:00
dan sinclair 44b043d46a Remove unused function.
This Cl removes the unused ctx method from the inspector helper.

Change-Id: I3c35aeb18c29078d5bdb46e3d1a2c5d4d6dcce54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29400
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-05 19:29:26 +00:00
Ryan Harrison 1a9a2dd07d Add Inspector class
This class is used to examine a module and get information about its
contents. This is the getting side of shader of reflection. Future
work will add transforms that perform the setting side of reflection.

In addition to the basic class and infrastructure, this CL adds a
GetEntryPoints() function demonstrate it works. More functionality
will be added in later CLs.

BUG=tint:257

Change-Id: If41dbb6c93302e0332754c086c75729d6ffe04d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29320
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-05 14:52:36 +00:00
Sarah Mashayekhi 60a272a86e [validation] Update switch error numbers
fix clang error

Bug: tint: 6
Change-Id: Ib387258387e1f5069585a7fe3af3990df6fc8ddd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29043
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-30 20:12:50 +00:00
dan sinclair 00000b57e8 [spirv-writer] Emit spec constants for non-constructor scalars.
In WGSL you can provide a constant_id variable without a constructor. In
SPIR-V we must synthesize a constant to attach the SpecId too. This CL
adds that variable creation.

Bug: tint:254
Change-Id: I2f25fdc3cb7e2c9c0f9e2129885865bd24298416
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29200
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-30 18:44:40 +00:00
dan sinclair af780816ca [wgsl-writer] Emit constant_id decorations.
This CL adds constant_id decorations to the WGSL writer.

Bug: tint:152
Change-Id: I637d158c0ef4d0ace2ce70a6fb3cbe6f0b8b3b4e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29102
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-29 23:57:03 +00:00
dan sinclair 5bb9b75684 [transform] Add a simple transform manager.
This CL holds a simpler manager to hold and execute multiple transforms.

Bug: tint:206
Change-Id: I45f6b55134f871167704f3549c4e4c72ef806c3a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29121
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-29 23:54:03 +00:00
dan sinclair 58f2e9cf6a [spirv-writer] Emit specialization constants.
This CL adds OpSpec constants to the SPIRV-Writer.

Bug: tint:151
Change-Id: I309013ca0b4cb514edd92fab3dab2e4faa15969a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29101
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-29 21:11:43 +00:00
dan sinclair 97b729de10 [transform] Add Transformer base class
This CL adds a Transformer base class from which the transformers will
inherit.

Bug: tint:206
Change-Id: I542eacb05d9a92af46d172a5803c245472c0e22c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29120
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-29 20:28:21 +00:00
dan sinclair 9caffa4491 [ast] Add constant id helper.
This CL adds constant id helper methods to the decorated variable class.

Bug: tint:150
Change-Id: Icfdc516f37d4f2680d2b990879bff722085cf732
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29082
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-29 20:00:00 +00:00
dan sinclair b403cb50ab [transform] Add BufferArrayAccessors transform
This CL adds a buffer array accessor clamping transform to
the available transforms in Tint.

Bug: tint:101
Change-Id: If9d5b0fb2c3adba723ce2185870b0e10981103a6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28980
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-29 18:40:40 +00:00
dan sinclair 9e7f9dc96c [ast] Add constant_id decoration
This CL adds AST support for the constant_id decoration.

Bug: tint:150
Change-Id: Ifde5a5325f770567ea24129e786953d89f3f514b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29100
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-29 18:07:50 +00:00
Sarah Mashayekhi 095f5f71b5 fix clang error
Change-Id: I7e68da53821b143d7ec55ef323822982b8f0b336
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29042
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-26 02:00:53 +00:00
dan sinclair 816764dbd4 [ast] Remove IsCast
This was missed in the general removal, cleanup.

Change-Id: I7912bb86e73cd9e38d497fab5995f7740a9dfbc6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29000
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-25 18:41:02 +00:00
dan sinclair 571bce6b8d [spirv-writer] Add struct constructor test.
This CL adds a test for struct constructors in the SPIR-V backend.

Change-Id: I9ae82ce86cde159b87cce2ee95d0b16910aadc7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28901
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 18:18:05 +00:00
dan sinclair 8a220a6f40 [spirv-writer] Add array constructors.
This CL emits array type constructors in the SPIR-V backend.

Change-Id: I796e81964df1af39ad1aacdd4ab8181852f661fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28900
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 16:48:35 +00:00
dan sinclair d6e063d13e [spirv-writer] Add matrix constructors.
This CL adds the matrix constructors to the SPIR-V output.

Change-Id: I7471700c262b499f843ffa4e3c49bcac0b0c7565
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28881
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 16:38:35 +00:00
dan sinclair b2a0c8aee7 [msl-writer][hlsl-writer] Remove space between builtin and (.
The builting CL accidentally inserted indenting between the name of the
builtin and the opening paren. This CL removes the extraneous spacing.

Change-Id: If684ec6f2fb4bf13b559c16b246f57f7975d019d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28944
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 15:12:55 +00:00
dan sinclair 3c02592718 Remove cast operator.
This CL removes the cast operator and converts the tests over to using
type constructors.

Bug: tint:241
Change-Id: I2526acb61f5624b2e1c068612a2ddcc748c92aed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28860
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:38:44 +00:00
dan sinclair f367eadeef [msl-writer] Emit zero values for private, function and output vars.
This CL updates the MSL writer to emit the needed zero initializers for
Private, Function and Output variables.

Bug: tint:172
Change-Id: I73b1c3bb4c87a8ec7b1fb9d17a35e907c9a42095
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28943
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:33:24 +00:00
dan sinclair 93801bebd1 [transform] Rename generated variables.
This Cl prefixes the generated variable names from the vertex pulling
transform to prefix a '_' as you can not have an identifier in WGSL with
a leading '_'

Change-Id: Ic9ad873ac5f3ac25f96013f96e6d9a4c17964f22
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28942
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:32:48 +00:00
dan sinclair 5c948e4f8f [transform] Move the transform folder
This CL moves the transform folder from src/ast to src/. The transforms
operate on the AST, but they aren't part of the AST so I think the top
level folder makes more sense.

This will possibly cause issues when rolling if the transform is being
used.

Change-Id: Ibd7c94474168a7a4bdf38321f4e12ad111c80323
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28941
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:30:34 +00:00
dan sinclair 45292213bd [spirv-writer] Emit ShiftRightArithmetic.
This CL updates the SPIR-V writer to emit the arithmetic right shift if
the LHS of the expression is a signed scalar or vector.

Bug: tint:84
Change-Id: I4ca33a31783e1954515db5f12b2cf1d364aedee4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28940
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:29:29 +00:00
dan sinclair 596fcdcec6 [spirv-writer] Fix ! to emit logical not.
The ! operator should emit an OpLogicalNot instead of an OpNot.

Bug: tint:248
Change-Id: I6e404c3286db7819e0692603e3cf9a87a1b37ed9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28841
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-23 14:45:24 +00:00
dan sinclair a7d498e060 Rename 'as' to 'bitcast'
This CL updates Tint to use 'bitcast' instead of 'as' for the OpBitcast
conversions.

Bug: tint:241
Change-Id: I53a80de10421b2d9cc009527eebe5ff07e1285c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28801
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-22 22:07:13 +00:00
dan sinclair b4fee2f824 Update builtin methods.
This CL removes the import mechanism, the identifier paths and updates
all of the standard library methods to be builtins.

Bug: tint:242
Change-Id: If09b98a155ae49ced3986ba2c9b517a060693006
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28720
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-22 19:42:13 +00:00
dan sinclair 5f8126271d Remove EntryPoint.
This CL removes the EntryPoint node and transitions everything to the
stage decoration.

Change-Id: Ib2840155905c8fa60ff35870f0c4b6705efb73ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28705
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-22 14:53:03 +00:00
dan sinclair de2a019a7f [spirv-reader] Emit StageDecoration when building the functions
This CL adds the emission of StageDecoration to entry point functions.
EntryPoint nodes are still emitted. We duplicate the function emission
if there are multiple entry points pointing to the same function.

Change-Id: Icb48a063f5c6a30948bbe2c37c7fce7431af5864
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28665
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-22 14:22:12 +00:00
dan sinclair f91b9664e7 [hlsl-writer] Emit function decoration stage
This CL updates the hlsl writer to emit stage decorations.

Change-Id: Ic9ae9fbd47537f141949e27c876d37e6d4dcd97d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28704
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-22 13:47:32 +00:00
dan sinclair b5bb2d91af [msl-writer] Update to emit based on pipeline stage.
This CL updates the MSL writer to emit data base on the pipeline stage.

Change-Id: I9fb2e146f0c898d9703d69a6a92f535757106bba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28703
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-21 18:58:01 +00:00
dan sinclair a8274b2fef [spirv-writer] Emit entrypoint from function decoration.
This CL updates the SPIRV-Writer to emit entry point information based
on the function stage as well as EntryPoint nodes.

Change-Id: I1fa937cbb2159b31516b0189216d679e03f0384d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28702
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 18:49:01 +00:00
dan sinclair 48d08d2147 [wgsl-writer] Emit stage decorations.
This CL updates the wgsl writer to emit the stage decorations.

Change-Id: I0501088e074aa5d027f83fd0a2ac45ba3f36332f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28701
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-21 17:59:51 +00:00
dan sinclair 51ac24ab10 [validate] Update to validate pipeline stages.
This CL converts the validator to work against the pipeline stages
attached to functions instead of entry point nodes.

Change-Id: Ia6274423e49426766c527d1123880ef6e0140959
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28700
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-21 17:56:41 +00:00
dan sinclair 0592643782 [type-determiner] Update to work with entry point and function stages.
This Cl updates the type determiner to work with both styles of entry
point definition.

Change-Id: Ic48f1a5f0a5820821f9a74380896426a97483049
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28666
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-21 17:51:31 +00:00
dan sinclair 767ea855ab [wgsl-reader] Parse stage decoration
This CL adds parsing of the stage decoration to the WGSL parser. The
decoration is not hooked up yet so it's effectively ignored.

Change-Id: I8d86c55cee189f993c10b6da31a9c388ba452021
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28664
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-21 17:42:10 +00:00
dan sinclair cb907b5bc2 [wgsl-reader] Fix issue with missing open brace for functions.
This Cl fixes the function parsing so the opening brace is required.
This will return an error now. The statement::body_stmt is changed to
make the open paren optional.

Bug: tint:236
Change-Id: I3faee1fd5add19aebcdb86943d6f4190c03d0f7a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28520
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-21 15:55:32 +00:00
dan sinclair 43d17780ca [spirv-writer] Add multisampled textureLoad test.
This CL adds a test for multisampled textureLoad and fixes up a few type
determiner issues for multisampled textures.

Bug: tint:237
Change-Id: I5c33797b197b6f092842b22aa93d2076b0779766
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28582
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 15:52:10 +00:00
dan sinclair 64f9cdec68 [spirv-writer] Simplify the texture intrinsic tests
This CL removes the complete coverage of the possible input formats
infavor of simpler testing of a few of the inputs. This should be
sufficient coverage and makes the tests easier to read.

The incorrect OpConstantNull for the samplers and textures has also been
removed.

Change-Id: I9cd7d6299f0454bb8e2019968e0422221e4ec183
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28581
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 15:46:00 +00:00
dan sinclair 4dc0d7d311 Simplify SPIR-V builder texture type tests.
This CL removes the instantiated test suites, instead it tests each of
the required formats with one texture type and then uses the rest of the
tests to verify the texture type generated is correct.

This makes the tests a lot easier to read as the string generation for
results is removed.

Change-Id: I2c54471a2afc8bf2602ec8e4b50b27ad078dc4ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28580
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 15:38:10 +00:00
dan sinclair 2dbe9aa784 [hlsl-writer][msl-writer] Enable generate tests.
This CL fixes and enables the generic generate tests for both the MSL
and HLSL writers.

Bug: tint:7 tint:8
Change-Id: I7a3e76196a7c50bd30dcd55940686dc8269786f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28441
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-21 15:16:20 +00:00
dan sinclair d05f93fd8e [wgsl-reader] Add workgroup_size parsing
This CL adds parsing of the `workgroup_size` function decoration.

Change-Id: Ia90efc2c014ac0e1614429280cc903d30cf8171d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28663
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-21 00:37:08 +00:00
dan sinclair 643827967e [ast][spirv-writer][hlsl-writer][wgsl-writer] Add workgroup_size decoration
This CL adds the workgroup_size decoration to functions and emits as
needed from the various backends.

Change-Id: Ifffde239e68047f6419c6980eca70c4efa9822c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28662
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 00:28:58 +00:00
dan sinclair 35552f2a48 [wgsl-reader][wgsl-writer] Update variable decorations to new syntax.
This CL updates the variable decorations to require ()'s around
parameters.

Bug: tint:238
Change-Id: I835879f41349756ace553a52fc2d460173e70dce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28583
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-20 23:02:48 +00:00
dan sinclair 077d16d5e1 [wgsl-reader][wgsl-writer] Update array decorations to new syntax.
This CL updates the array decorations to the new syntax requiring ()'s
around parameters.

Bug: tint:238
Change-Id: I5a8b19e302fbd3f78392553d8d1c5e882b900180
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28601
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-20 21:28:18 +00:00
dan sinclair 636d588f6e [ast] Add decorations to functions.
This CL extends the function AST object to allow function decorations to
be attached.

Change-Id: I5b16aa2e6927792368b7f88047c0229e258b5bd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28661
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-20 19:18:58 +00:00
dan sinclair 8b685866cd [wgsl-reader][wgsl-writer] Update struct decorations to new syntax.
This CL updates the parsing of struct decorations to require ()'s around
parameters.

Bug: tint:238
Change-Id: Ia35ca5c260c3c57b5fc95788bd1aef07f75edc39
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28600
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-20 19:14:28 +00:00
dan sinclair d3f75ca0e8 Add support for multisampled textures.
This Cl adds the AST, WGSL-Reader and SPIRV-Writer support for the
`texture_multisampled_2d` type.

Bug: tint:237
Change-Id: Ib3eb831227b49f32162801f1e1b4e474774c78b3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28480
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-17 03:53:04 +00:00
dan sinclair 83ed2cc2b9 [wgsl-writer] Emit texture types.
This CL adds texture type emission to the WGSL writer.

Bug: tint:144
Change-Id: I18e40a587b77b953f17a6d0ad1a75a1bc4158ef0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28460
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-17 02:51:03 +00:00
dan sinclair 5e989306e5 [type-determiner] Handle pointer arguments.
Currently if the type determiner is determining an identifier it will
wrap it into a pointer if it isn't a constant. This CL updates to make
sure we don't already have a pointer as otherwise we endup with a double
pointer.

Bug: tint:216
Change-Id: I2f8c83bd8680df6c3aef31e1cbb754fdff709b4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28442
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-16 21:20:36 +00:00
Tomek Ponitka 43759bff1c [wgsl-reader] Adding texture_sampler_types to type_decl
Bug: tint:147
Change-Id: Ib806d5c434e98632a83ad8802a3a0aeea609c8c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28125
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-15 18:35:43 +00:00
dan sinclair 3af512046e [hlsl-writer] Implement some disabled tests.
This CL fills in some of the disabled tests around function entry points
and global variables.

Bug: tint:7
Change-Id: Iff40944fbac9985eeafcc7c8a105652b217ff924
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28440
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-14 19:45:53 +00:00
David Neto 0e70e71a87 [spirv-reader]: entry point names are WGSL identifiers
Bug: tint:233, tint:3
Change-Id: Ib753c47c4a77b852e5065c540da79d8cebe6a100
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28282
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-10 17:01:47 +00:00
David Neto 66dd683148 Fix doxygen: don't describe return of void method
Change-Id: Ib5795e44cbf23155dc2d2a7dcd6466e68dac4e2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28281
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-10 16:20:17 +00:00
Sarah Mashayekhi 2e9f1f54c8 [validation] validate switch statement
This CL adds validation for the following rules:
v-switch01: switch statement selector expression must be of a scalar integer type
v-0008: switch statement must have exactly one default clause
v-switch03: the case selector values must have the same type as the selector expression the case selectors for a switch statement
v-switch04: a literal value must not appear more than once in the case selectors for a switch statement
v-switch05: a fallthrough statement must not appear as the last statement in last clause of a switch

Bug: tint: 6
Change-Id: I264d5079cc6cb31075965c8721651dc76f3e2a24
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28062
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-10 14:37:17 +00:00
Tomek Ponitka ed0527a016 Adding a TODO for updating textureLoad on storage images
Change-Id: I1d724a1743caa94ba040aca804dfac6abbb2d6e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28360
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-09-10 14:15:37 +00:00
David Neto b6adc5bd42 Simplify getting entry point function
The get-by-name method on the function stack already
tells us if the name exists.  We don't have to check,
and then get it later.

Change-Id: I26a1d395a9986df48f598055c3bc2864d94c87a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28260
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-08 19:16:05 +00:00
David Neto 0ecac8f6ab Fix GCC warnings
Change-Id: I9c719298a25d28f964c0a987c35fc94426807d51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28180
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-08 17:56:55 +00:00
Tomek Ponitka bcb6eb0830 [wgsl-reader] Parsing storage texture type
Bug: tint:147
Change-Id: I446786b529e777d709213e100e57cbae78ded75f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28122
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-08 16:48:09 +00:00
Tomek Ponitka 03f5e2fc9d [wgsl-reader] Parsing image storage type
Bug: tint:147
Change-Id: I79713b5dfa0a4b219cff7a6bb3c514557cf4f261
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28121
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-08 16:38:39 +00:00
Tomek Ponitka 4e2d2484f8 [ast] Change intrinsic function names to camel case
Change-Id: I227eade96ccf84a4ed006cc5e98ac9e47f44129a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28163
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-08 16:30:29 +00:00
Tomek Ponitka cd862fdc7c [spirv-writer] Removing GenerateConstantFloatZeroIfNeeded
Bug: tint:143
Change-Id: I81b4ec280264ec175736bae32bf1826d565ed5c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28162
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-08 16:28:59 +00:00
Tomek Ponitka e4f60fa0be [spirv-writer] Fixing memory leaks in texture intrinsics tests
The variables are no longer released.

Bug: tint:143
Change-Id: I56a3edd0e7acb3c729aa82851879d69e510298db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28164
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-09-07 12:05:28 +00:00
David Neto f51a48dc49 [spirv-reader] Set entry point name
Until now, we were only setting the function name.

Bug: tint:3
Change-Id: I6d82f6e9744201a04cc8969013694e2e8304a928
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28080
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-09-03 18:52:47 +00:00
Tomek Ponitka e46282a956 [spirv-writer] Generating texture intrinsic operations
Bug: tint:143
Change-Id: Ibc5b232b952b8ecd8d5d87a7486cdfbc1af29fa4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27641
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-03 17:26:57 +00:00
Sarah Mashayekhi b693b4c10d [validation] add const variables shouldn't have a storage class
This CL adds a rule to separate global variables and global consts in regards to storage class:
v-0022: Global variables must have a storage class
v-global01: const variables shouldn't have a storage class

Bug: tint: 225
Change-Id: I53d84afd771c78d91eaf47568e954986abf38e58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28141
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-03 17:20:07 +00:00
Sarah Mashayekhi 75c492a0cc [writer] add a return to convert_image_format_to_spv
This CL adds a return to convert_image_format_to_spv function to stop
clang from failing with this error: "control reaches end of non-void
function." because we haven't covered all the enums in the switch.

Change-Id: Ibcb02ff52ca4c6e597a36f5c3d57e41df9e7b02a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28061
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-03 17:17:37 +00:00
dan sinclair e7ec7f1689 [wgsl-writer] Add GenerateEntryPoint
This Cl adds the preliminary GenerateEntryPoint method to the WGSL
writer.

Bug: tint:211
Change-Id: Ib414ff66d482179f10eeeb890f6127bc585cd664
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28045
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-03 01:46:36 +00:00
dan sinclair 2dc982f7ea Stub out the method to generate individual entry points.
This CL adds the stub methods for the various backends to generate
individual <pipeline stage, entry point> pairs.

Bug: tint:211
Change-Id: I7c5c6af4b44cb78976e4388a2b2174ee1a116531
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28044
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-03 01:07:46 +00:00
dan sinclair 0f49753f35 Add reset method to the generators.
This CL allows the backend generators to be reset so they can be re-run
again.

Bug: tint:211
Change-Id: I67b0c650d0ab4615130777becc513099247339c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28043
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-03 01:02:06 +00:00
dan sinclair 836027e327 Move generators to unique pointers.
This Cl will setup the code to allow a Reset method to be added to the
generators.

Bug: tint:211
Change-Id: I41c3aaf0daf832729aea9c76500e297ae32d7f5e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28042
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-03 00:58:46 +00:00
Sarah Mashayekhi bab2a4dd96 [validation] Add disabled tests for validating switch statements
This CL adds 6 unit tests for validating switch statements.
v-switch01: switch statement selector expression must be of a scalar integer type
v-switch02: switch statement must have exactly one default clause
v-switch03: the case selector values must have the same type as the selector expression
v-switch04: a literal value must not appear more than once in the case selectors for a switch statement
v-switch05: a fallthrough statement must not appear as the last statement in last clause of a switch

Bug: tint: 6
Change-Id: I0283afec22e56097b6f63c8455da23b87dfe26dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27740
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 19:58:06 +00:00
Tomek Ponitka fd3ca9ee47 [wgsl-reader] Parsing sampled texture type
Bug: tint:147
Change-Id: I21c864dd63c2003797c78758358ab4134cd8ff31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28002
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 15:52:15 +00:00
dan sinclair 17b2b246c1 [hlsl-writer] Simplify generated logical and/or expressions.
This Cl simplifes the generated code for logical and/or expressions to
assign the LHS and RHS directly instead of using if statements.

Bug: tint:192
Change-Id: I358e07007510cf8df151a100fda678c1c299cf4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28040
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-02 15:13:25 +00:00
dan sinclair 2b5c9b23af [hlsl-writer] Simplify logical and/or code.
This CL unifies the logical and/or HLSL code as it was mostly duplicate
code.

Bug: tint:192
Change-Id: Ied050afb0b054a9ccda1c8896edabf78deaa3709
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27921
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-02 15:09:55 +00:00
dan sinclair 593824c9d3 [hlsl-writer] More logical and/or tests.
This Cl adds more tests for the logical and/or expansion based on the
various statements and expressions where the expansion can happen.

Bug: tint:192
Change-Id: I143cf80402dc70e2fb89b6a41914cbbe167b5a96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27920
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-02 15:06:35 +00:00
dan sinclair b39c77e370 [hlsl-writer] Emit LogicalAnd and LogicalOr operations
This Cl emits the required code to handle LogicalAnd and LogicalOr short
circuting in HLSL.

Bug: tint:192
Change-Id: I30a88c207f7864e0a3c856d2dae1420c7ff35eb4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27782
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-02 15:02:45 +00:00
dan sinclair a0842b50b9 [hlsl-writer] Support pre stream in if/else statements.
This CL updates the if and else statement support to output the pre
streams in the proper places.

Bug: tint:192
Change-Id: If217de7f838fc033823987e20ba7efc5cd6108ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27781
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-02 14:29:05 +00:00
dan sinclair b95fc538ed [hlsl-writer] Emit pre strings
This Cl updates the various statements to emit any pre strings which are
generated when emitting the statements.

Bug: tint:192
Change-Id: Ieb2e621a500c5d91a0b6a2938eabe8e2ffdd11d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27800
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-02 14:21:05 +00:00
dan sinclair ddb05a3679 [hlsl-writer] Update all expressions to take a pre stream.
This Cl updates all of the expression methods to accept a pre stream.
The prestream is used to output code _before_ the statement which is
executing the expression. This will allow for unwrapping logical and and
or expressions and emitting them prior to their expression.

Bug: tint:192
Change-Id: Ifb24e7b8964948a3893185710f17177aaec2a2c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27780
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-02 14:19:45 +00:00
Tomek Ponitka 4beff41b7d [wgsl-reader] Parsing texture sampler types
Change-Id: I6a29d81deca40e89cf5b8ca95cf0373af3dd16b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28005
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 14:16:35 +00:00
dan sinclair f6e5c936b9 Fixup doxygen comment
Change-Id: I5ee292a4c408dc7ce368b2f078422ebce61dbf1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27860
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-02 14:16:25 +00:00
Tomek Ponitka cbd1ef8523 [wgsl-reader] Parsing depth texture type
Change-Id: Ie886c85db52b934331abe2d5675d9d0e6cdd7210
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28001
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 14:06:45 +00:00
Tomek Ponitka c354200889 [wgsl-reader] Parsing sampler type
Change-Id: I58a3218a5d0b7ccbe6422340c94cdf3dc1bdf17a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28000
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 13:26:15 +00:00
Tomek Ponitka 18a54647b7 [spirv-writer] Generate sampler type
Change-Id: I587cf7430711d8009becf76f7630091f32ed3490
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27840
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-01 14:20:24 +00:00
David Neto 7653485162 [spirv-reader] Set some source locations
Set source location on function variable declarations, const
declarations, and most normal instructions.

Bug: tint:3
Change-Id: I469afcdf1b7d8f6d1e64617189a6fa329056737f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27700
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 18:52:54 +00:00
Tomek Ponitka 3588406b78 [spirv-writer] Generate texture type
Change-Id: I9a3c75af1c5243f400cd98780736860e68b709ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27580
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 16:11:44 +00:00
Tomek Ponitka 6803529d58 [spirv-writer] Convert ast image format types to spv
Change-Id: I987e729a607e69294c472b7667eae82c7339a0df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27640
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 15:49:43 +00:00
Tomek Ponitka 1a61fc4dc7 [type-determination] Adding builtin texture operations
That includes texture_load, texture_sample, texture_sample_level,
texture_sample_bias, texture_sample_compare. Also determining the
result type.

Change-Id: I9e6fb19964fa171ee9b0594633b2dfe95e3e38b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27360
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 15:24:54 +00:00
Tomek Ponitka a454ef9024 [ast] Determining subtype of StorageTextureType
It's determined at the beginning of TypeDeterminer::Determine().

Bug: tint:141
Change-Id: I761199db0c9813dbd42c6cb4ecb3532d1a39f49f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27460
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 15:11:23 +00:00
dan sinclair 764110d675 [msl-writer][hlsl-writer] Pull loop variables out with continuing.
If there is a continuing block we pull the variables declared in the
loop up into the scope outside the loop. This allows those variables to
be used in the continuing block.

We pull out all variables instead of detecting ones which are only used
in continuing as that's easier and still correct.

Bug: tint:187, tint:186
Change-Id: I1de0e36111a236ff04a323cf9777bc79e67afa77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27620
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-31 14:15:51 +00:00
David Neto 5a75a174d6 [spirv-reader] Uses in phis count as uses
This is required so we actually emit values that are only used
in phis.

Bug: tint:3, tint:215
Change-Id: I9d957a697839b8d09246905c3f28064f0bc01731
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27701
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 14:05:51 +00:00
David Neto c5d65cc917 [spirv-reader] Don't hoist pointers that are already in scope.
Bug: tint:3, tint:213
Change-Id: I79410c670b8690c1f1ea86b7b9427f272a4ebbbb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-29 16:11:02 +00:00
David Neto 6c2a7b712c [spirv-reader] Track line numbers
If OpLine debug instructions are present, use their line and column
numbers.  Otherwise, use the instruction number as the line number, starting
counting from 1.

Bug: tint:3
Change-Id: Ia46c10732922b80b5737b13af1ef71f4259a3555
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27680
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-28 20:38:02 +00:00
David Neto 25b856aa64 [spirv-reader] Avoid certain hoisting cases
If a definition occurs in the first block of an IfSelection or
SwitchSelection, then it should count as belonging to the scope of the
parent of that if or switch selection.  This prevents some bad hoisting
decisions.

Bug: tint:3, tint:213
Change-Id: I89df5e8cbc163577e19e78c2bf393eb1eec4a0aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27660
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-08-28 19:58:12 +00:00
David Neto fed63103f5 [spirv-reader] Follow non-canonicalized SPIR-V type for composite extract
Follow the actual SPIR-V type when computing a composite extract
instad of the canonicalized view in the optimizer's type manager.
Do this so we can generate the correct member name for a struct,
rather than using the member name for the other representative
struct type. The optimizer's type canonicalizer is insensitive to
struct member names.

Prompted by tint:213, for which the original case was an
access chain.

Bug: tint:3, tint:213
Change-Id: I8705c7ee655fe47c8b7a3658db524fe18833efdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27603
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-28 16:28:42 +00:00
David Neto 53b1c39036 [spirv-reader] Follow non-canonicalized SPIR-V type for access chains
Follow the actual SPIR-V type when computing an access chain expression,
instead of the canonicalized view in the optimizer's type manager.
Do this so we can generate the correct member name for a struct,
rather than using the member name for the other representative
struct type. The optimizer's type canonicalizer is insensitive to
struct member names.

Fixes tint:213

Bug: tint:3, tint:213
Change-Id: I88ec42a4cb049b011a59d5522e4cb39bc181a4fb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27602
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-28 15:49:31 +00:00
dan sinclair 46252ec3ba [wgsl-parser] Consume empty struct closing brace.
This CL updates the WGSL parser to consume the closing } of an empty
struct.

Bug: tint:218
Change-Id: I0b17d2178b1b4b7f44fcf007da867db07dc2a6ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27600
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-27 18:17:10 +00:00
Sarah Mashayekhi 5f915f1f92 [validation] check if at least one of vertex, fragment or compute shader is peresent
Bug: tint: 6
Change-Id: I826d951c374409699082f38fb65225f5b4a83f2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27483
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-27 18:05:00 +00:00
Sarah Mashayekhi 4bc38c3f63 [validation] Add a helper function to create a fake entry point
Change-Id: I234c04315bec006597caed38f1872baf348a3651
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27482
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-27 17:59:20 +00:00
dan sinclair 8d72a2bc4e Add missing doc comments.
This cl adds some missing doc comments.

Change-Id: Ic5452c2f9a40ddcc4642062a338f602632f3e057
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27520
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-08-26 20:38:46 +00:00
dan sinclair 63b007d34f [hlsl-writer] Move test helper to a template.
This CL updates TestHelper to be a templated class and converts the test
suites into using statements based off that template.

Bug: tint:7
Change-Id: I747434e7c6a8ecae353df448f06153e982dcec44
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27500
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 20:02:26 +00:00
dan sinclair 663be30b55 [hlsl-writer] Support matrices in storage buffers.
This CL adds the needed code to load matrix data from a storage buffer.

Bug: tint:7
Change-Id: I850b03adc7fa957b7babbad40d07ec3544b0617f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27442
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-08-26 19:55:46 +00:00
dan sinclair fea2636945 [hlsl-writer] Emit numthreads for compute shaders.
This CL adds the numthreads annotation when emitting compute shaders.

Bug: tint:7
Change-Id: Ie0f47adfca0a0684f701f280958163b3da0019b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27480
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:24:26 +00:00
dan sinclair 42b0e2d5af [hlsl-writer] Emit zero matrix values.
This CL extends the zero emission to support matrices.

Bug: tint:7
Change-Id: I7e39a68c83edb096fc4b365c66539e8a8b7cb1db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27443
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:24:16 +00:00
dan sinclair 04746d930d [hlsl-writer] Extract storage buffer index generation.
This CL extracts the index string for a storage buffer access.

Bug: tint:7
Change-Id: Ibc0d7dd5b532bbd6141cce4a82495732452d1414
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27441
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:22:56 +00:00
dan sinclair 43915bd0a1 Emit structs when emitting the aliases.
This Cl updates the AST dump command to emit struct members after
emitting the type alias.

Change-Id: I5e0c3d8f2cc56525586646c613839c2e014d471f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27320
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:09:26 +00:00
dan sinclair df503f0e85 [hlsl-writer] Refactor output emission.
This CL updates the HLSL backend to take the output stream as a
parameter. This is needed because there are cases where we have to
generate the resulting stream out of order. This will allow that to
happen.

Bug: tint:7
Change-Id: Id1877a07e536a84da0555f207d1030588d44c034
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27440
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:05:46 +00:00
dan sinclair bdb86723e8 [hlsl-writer] StorageBuffer support.
This Cl adds support for storage buffers to the HLSL backend.

Bug: tint:7
Change-Id: I7adb655de8ccfcb6771fa661ff205c543b4efe66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27001
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-25 21:22:37 +00:00
Sarah Mashayekhi fc1327f1d9 [validation] implement the pair of entry point stage and name must be unique
This CL implements the following rule:
v-0020: The pair of <entry point name, pipeline stage> must be unique in the module

Bug: tint: 6
Change-Id: Id0c50438861b251d48a9f8dcb8a23556327c965c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27380
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-08-25 21:22:07 +00:00
Sarah Mashayekhi 6a0e28b624 [valdiation] Add disable test for v-0020, the <entry point name, pipeline stage> must be unique
Bug: tint: 6
Change-Id: I3fa9c1427ee99c9a442369516ddef0c11f33304f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-25 16:06:24 +00:00
Sarah Mashayekhi 4fb431c90e [validation] validates if global variables have a storage class
This CL moves the global variables checks to a function
Adds tests and checks for validation rule v-0022:
Global variables must have a storage class.

Bug: tint: 6
Change-Id: I2f2cd7df6e849bfd1ddfbca35568c6fc3345efa6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27283
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-25 15:04:53 +00:00
dan sinclair deea295fc1 [wgsl-parser] Set max recursion depth on const_expr
The `const_expr` can recurse into itself if there are type declarations
inside the const_expr (e.g. vec2<f32>(f32(1.0), f32(2.0))). Currently
there is no limit on the amount of recursion which can be triggered.

This CL sets a limit of 128 nested type declarations at which point an
error will be emitted.

Bug: chromium:1112144
Change-Id: Ifae45034dc9de35aed78ba8eddf584a46c7a55ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27340
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-25 14:58:33 +00:00
Ryan Harrison a291fc1e7f Ran 'git cl format' over an empty CL
Change-Id: Ied8585a4d266900925a81836db45f7525cd5f628
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27181
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-25 14:55:53 +00:00
Sarah Mashayekhi 3765a24060 [validation] clean up: using ValidatorImpl member instead of creating one
Change-Id: I9a35319a33b5c9c0508d1fdc38c8678ca204b4ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27285
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-25 14:09:03 +00:00
Sarah Mashayekhi 3fad211a8f [validation] Add a validator test helper class
Change-Id: I12d225dbbda3ceffda6f0f0dbf264a6a6b249fb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27284
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-25 14:06:05 +00:00
Tomek Ponitka 63a5aa7d58 [wgsl-reader] Adding for loops
Implementing ParserImpl::for_stmt(). Also adding
for_stmt and body_stmt to ParserImpl::statement().

Bug: tint:138
Change-Id: Idc3f901648ca115f4d94b3614a940263ef841282
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27261
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-24 18:22:22 +00:00
Sarah Mashayekhi f70065f622 [validation] Validate if entry point functions accept parameters
Bug: tint: 6
Change-Id: I7e9f50759e65ed6ef3dc25a6c004bec3dfbd4648
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27122
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-24 16:03:36 +00:00
Sarah Mashayekhi c3038ddfa6 [validation] Adds disable test for v-0023, entry point functions accept no params
Bug: tint: 6
Change-Id: I7ea874e90f4dbd213ff35275823342027340e348
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27121
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-24 15:00:46 +00:00
Tomek Ponitka 43c2a6c7d4 [wgsl-reader] Adding body_statement to statement grammar
Block statements will now be parsed in ParserImpl::statement()

Change-Id: I28f63d4a53c85c0306c57df545f78b4562c6ea7b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-24 13:43:16 +00:00
David Neto c189b1d479 Re-enable float emission tests
Test a value that should stably convert to decimal exponent
representation.  This might be working around a bug in the MSVC runtime
library.

Bug: tint:201
Change-Id: I37200cef815cafc35284c8c873dfbb8a5312360e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27160
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-21 21:19:33 +00:00
Sarah Mashayekhi e871e48df0 [validation] validate if entry point functions return void
This CL validates following validation rule:
v-0024: Entry point functions return void

Bug: tint: 6
Change-Id: I420781008016af110cb0d3d65fc018a1301efeae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27120
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-21 15:40:43 +00:00
Sarah Mashayekhi 1026fe3d27 [validation] Add disabled test for v-0024-entry point functions return void
Bug: tint: 6
Change-Id: Iae865125b30952a9422261fbfe14e9b6fb74e16f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27101
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-20 21:51:39 +00:00
Sarah Mashayekhi 3c9fee13b9 [validation] checks if function used in entry point exists
This CL check validation rule v-0019: Functions used in entry points must exist.

Bug: tint: 6
Change-Id: Ic4d4702cac53dcdaa1207425a6214d53cacb2442
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27100
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-20 21:25:39 +00:00
Sarah Mashayekhi 255cfe829f [validation] Add disabled test for v-0019-entry point functions must exist
Bug: tint: 6
Change-Id: I303fab6e0cd4a807173bef8f69e14220480fbb9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27080
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-20 20:52:29 +00:00
Sarah Mashayekhi 8db00dffa2 [validation] Checks if recursions exist
This CL validates the following rule. ie. As functions must be defined before use (v-0005), self-recursion is only case that has to be invalidated.
v-0004: Recursions are not allowed.

Bug: tint: 6
Change-Id: Icfb040907c5ea0abb6359dade74dcfc30a0db7d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26980
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-20 17:00:09 +00:00
dan sinclair d38df397e3 [hlsl-writer] Add support for import statements.
This Cl adds support for imported methods to the HLSL backend.

Bug: tint:7
Change-Id: Ib906542915670dcc916d48d9e5d64d7032ba829a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26928
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:19:04 +00:00
dan sinclair a1087ee513 [hlsl-writer] Generate intrinsics.
This CL adds the beginning of intrinsic emission for the HLSL backend.
The `outer_product`, `is_normal` and `select` intrinsics are currently
missing.

Bug: tint:7
Change-Id: Ice7a2b285eeb52041e3accd9751e127d6c5a0177
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26927
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:17:54 +00:00
dan sinclair 3739a23f24 [hlsl-writer] Emit cast expressions.
This CL adds support for cast expressions to the HLSL backend.

Bug: tint:7
Change-Id: Ie7e180dc89abf137ab7d9b8790cc4206b3d5a672
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26926
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:14:44 +00:00
dan sinclair 10585f0ac3 [hlsl-writer] Add tests for entry point data.
This CL adds the missing tests for emission of Entry Point Data
structures.

Bug: tint:7
Change-Id: If21071b07584780243ccd0629a92efa653640251
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26925
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:04:54 +00:00
dan sinclair 6fdc77a966 [hlsl-writer] Emit module constants.
This CL adds emission of module constants to the HLSL backend.

Bug: tint:7
Change-Id: Iff07b0c0de7351f400dc35ca2ac07b44b22f8499
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26924
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:03:24 +00:00
dan sinclair 1811639709 [hlsl-writer] Fix emission of struct aliases.
You can only typedef builtin types in HLSL. This Cl updates the struct
emission to emit named structs instead of typedef'd structs.

Bug: tint:7
Change-Id: I835b7f4d23bc225c730ef3f39c4572c043a58156
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26921
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:00:21 +00:00
dan sinclair bfaa6f8e57 [hlsl-writer] Emit uniform variables.
This CL adds emission of uniform storage class variables to the HLSL
backend. If the variable is a base type (float, int, etc) it is emitted
as a `cbuffer`. If the variable is a struct it will emit as a
`ConstantBuffer`.

Bug: tint:7
Change-Id: I9932d30df24c023c58d3a2ba4167bcb7ccb85dae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26920
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 18:57:09 +00:00
dan sinclair 7df4a845d9 [hlsl-writer] Add CallExpression.
This Cl adds support for call expressions into the HLSL backend.

Bug: tint:7
Change-Id: Id07e3d95e745aa016a658c3ec5d099f74f21a80e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26781
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 17:44:45 +00:00
dan sinclair 34fd95ced0 [hlsl-writer] Add support for input locations and builtins.
This CL adds the beginning of support for input/output locations and
builtins in the HLSL backend.

Bug: tint:7
Change-Id: I8fb01707b50635a800b0d7317cf4a8f62f12cfca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26780
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-08-19 17:37:25 +00:00
dan sinclair be89a06b03 [hlsl-writer] Add function handling.
This CL adds the beginning of function handling to the HLSL generator.

Bug: tint:7
Change-Id: Id40109c342e7a128b1fe79a0c50967e1dbd125eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26662
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-08-19 17:32:25 +00:00
Sarah Mashayekhi 844f632785 [type-determiner] return false when type determining an undeclared function
Change-Id: Ia7e43be64675528037f92026a6c239d1e5220fc0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26941
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-18 02:10:03 +00:00
Sarah Mashayekhi 8fcf269d4b [validation] Add Disabled test for detecting recursion
This CL adds a disabled test for validating following rule:
v-0004: Recursion is not allowed

Bug: tint: 6
Change-Id: I35d51b08174ac23a4b1def9f762e80c5950a726d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26942
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-17 21:01:28 +00:00
dan sinclair dd99471420 [spirv-writer] Output name for constant global variables.
When emitting a global constant we'd early exit the emission code before
emitting the debug statement for the constants name. This Cl adds the
needed code to emit names for global constants.

Change-Id: I1a7a3660b4ff31879393a6a776a9f00e895de216
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26923
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-17 20:00:48 +00:00
Sarah Mashayekhi b08e253886 [validation] Validates if return statement type matches function return type
This CL checks if the return statement type matches the function return type

Bug: tint 6
Change-Id: I621d67086291c392b68261673a25c0e6caca71ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26860
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-17 15:46:07 +00:00
Sarah Mashayekhi eec1a6e628 [validation] Validates function name uniqueness
This CL implements and add a test for the following validation rule:
v-0016: Function names must be unique

Bug: tint: 6
Change-Id: I9f135dd577863e41f03a2d02adebe4347a9922eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26782
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-17 15:32:38 +00:00
Sarah Mashayekhi 23c3fee354 [validation]: Add disabled test for validating return statement type matches function types
Bug: tint: 6
Change-Id: I573cd4fb5759f1d72dd2e0f04a1dd183879745d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26723
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 19:17:49 +00:00
Sarah Mashayekhi d73f812c84 [validation] Validates return statement
This CL checks if functions end with a return statement (v-0002)
reworks previously added tests to pass
enables related tests

Bug: tint: 6
Change-Id: Iafe46581ccc50e146b33d33f9577d995a7f80d77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26722
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 18:09:59 +00:00
Ryan Harrison a532ac55d9 Fix handling of .spvasm inputs
BUG=tint:207

Change-Id: Ic429a909d092423908409678b7256bd88de10a99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26760
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 17:33:59 +00:00
Sarah Mashayekhi 5e7ef27ca7 [ast] Adds get last statement to ast::Function
This CL adds a function which returns the last statement of a ast::Function

Change-Id: I1dc68b7f4669c17a24a62c03a87dcc95866a428d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 20:06:29 +00:00
Sarah Mashayekhi f16250b8ac [validation] Validates functions return statement
This CL adds a disabled test for validation rule v-0002: functions must
end with a return statement

Bug: Tint: 6
Change-Id: I127aa1bd7d236ff353fd89024b274c9f9b463f15
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26680
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 19:31:42 +00:00
dan sinclair 633b1a7463 Minor updates to fix compilation.
This CL adds the needed `memory` include for clang on windows and fixes
up some issues to make doxygen happy again.

Change-Id: I2c3f21aa086b079d3b861786834bcf4370123a7d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26703
Reviewed-by: Idan Raiter <idanr@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 19:28:59 +00:00
Idan Raiter eca0eaa006 Find un-named entry points, change set number
Finds entry points, and uses set 4 intentionally as it is bigger than
the maximum set for users.

Bug: dawn:480
Change-Id: I24f01d770ba43796233aeb40b3b6b2ae9b3c3663
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26520
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 17:44:01 +00:00
Idan Raiter ef6a4af7b5 Add instance step mode to vertex pulling transform
Bug: dawn:480
Change-Id: Icf650b7f340528e6a49d68d155fd9becc212e623
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26440
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 17:30:08 +00:00
Idan Raiter 63551e3b2f Add vertex pulling transform
Adds a first-pass version of vertex pulling. This is missing several important things such as buffer offsets, support for more types, and clamping.

Bug: dawn:480, tint:206
Change-Id: Ia8a3abc446bca4c5a40e064f85fb59de1c3f5af9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 17:23:58 +00:00
Sarah Mashayekhi d3107bdbaa [validation] Validates declaration name uniqueness
This CL adds implementations and tests for these validation rules:
v-0011: Global variable names must be unique
v-0013: Variables declared in a function must be unique between that function and any global variables.
v-0014: Variables declared in a function must have unique names

Bug: tint 6
Change-Id: I793485c981f67abc6a3dc81d35be743ccc18db5b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26480
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-11 20:44:06 +00:00
dan sinclair a5e7ead0c6 Disable failing tests
A few of the tests depend on floating point string output which is
slightly different on MSVC. Disable for now.

Bug: tint:201
Change-Id: I51510a1192488f4e391dfb3560b5b6a2915ebcd1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26220
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-11 20:23:40 +00:00
David Neto bc80805c4b [spirv-writer] Infer and emit matrix layout
WGSL matrices are always column major, with tightly packed columns.
We need to infer that layout and decorate the containing structure
members, if those members require a layout.

Bug: tint:200
Change-Id: Ieceb460ed6c7eeb1244beecbf4e0eee0b8b8e373
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26180
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-08-09 15:45:37 +00:00
Sarah Mashayekhi e88f1c388c [validation] v-0021: cannot re-assign constants
Bug: tint: 6
Change-Id: Ib5cd57478b35c8dbf04136eb4167a3c3bce1c954
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26420
Reviewed-by: David Neto <dneto@google.com>
2020-08-07 14:34:34 +00:00
Sarah Mashayekhi 65f88d6f1d [Validation] v-0006: variables must be defined before use
Bug:tint 6
Change-Id: I22f3117a8d59eaba97166de1f188156a9e3cd7a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26381
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-08-06 21:24:14 +00:00
David Neto 6eb2a85adf [spirv-reader] Remove support for NumWorkgroups builtin variable
It was removed from WGSL MVP
https://github.com/gpuweb/gpuweb/issues/920

Bug: tint:3
Change-Id: I94a584feec88dda7e310ee5d7fa01e93e26cd31d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25526
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-05 21:16:59 +00:00
Sarah Mashayekhi b77399cbad [validator] implement variable_stack_
Change-Id: I388847770de8dc703e92030f0fab8f9001643f95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26006
Reviewed-by: David Neto <dneto@google.com>
2020-08-05 15:23:47 +00:00
dan sinclair 3125a8d73f [ast] Add texture types to the AST.
This CL adds the texture types into the AST.

Bug: tint:141
Change-Id: I8e95aa23849af737e63d9cacc8c57f23aedec73d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26123
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 23:26:28 +00:00
dan sinclair fe8c59ace9 Add SamplerType to AST.
This CL adds the sampler type into the AST.

Bug: tint:141
Change-Id: Id2f7678a2df677cb7dae47f05543c1e0a1999eed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26080
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:27:25 +00:00
dan sinclair 8278f2c6f0 [hlsl-writer] Add loop support.
This CL adds support for the LoopStatement emission in HLSL.

Bug: tint:7
Change-Id: Ie42b24abff3a69c9cbfe3d3c8ab6fb9b1823e61d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25849
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:27:09 +00:00
dan sinclair 97bc4ad8d6 [hlsl-writer] Add if/else statements.
This CL adds if/else statement emission to the HLSL writer.

Bug: tint:7
Change-Id: Idd6e6d8c329ed270676fa0276474a68c715dd9eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25847
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:26:55 +00:00
dan sinclair cbe0668f9b [hlsl-writer] Emit variable declarations.
This CL adds variable declarations to the HLSL backend.

Bug: tint:7
Change-Id: I5c1e42ca26029f1595bf4f23b3b867a492ddacc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25846
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:26:46 +00:00
dan sinclair 753f40b869 Fixup build warnings
Change-Id: I7a61bd4363b01bf186e235bf76e97bd513d2fd12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26081
Reviewed-by: Ryan Harrison <rharrison@google.com>
2020-07-30 18:18:46 +00:00
dan sinclair c8a85aa5a9 [wgsl-reader] Add stride support.
This CL adds stride support to the WGSL reader.

Bug: tint:178
Change-Id: Id6b5163438e562a371255ad3fb992d0a716543e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26040
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 16:50:25 +00:00
dan sinclair ac4a2894fe [wgsl-writer] Emit array stride decoration.
This CL adds array stride decorations to the WGSL writer.

Bug: tint:179
Change-Id: I39d7625e1bdc876bbf9a83da7af76eb98bd09c28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26002
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 16:48:36 +00:00
Idan Raiter a8e4e2ad5d Add BlockStatement insert and non-const global_variables
Insert will be used for adding code at the beginning of a function, and
non-const global_variables to edit decorations.

Bug: dawn:480
Change-Id: I9fbb0210a95b8488c9ce6d9a536a68f169b0cc33
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25850
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-30 13:59:00 +00:00
Sarah Mashayekhi a3f9778ee6 [Validator] Using pointers instead of refs
Change-Id: I19a1cd27b6cbbc5d5d88a46bc5dd43c66a318b7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26004
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-30 02:27:03 +00:00
dan sinclair f961850988 [hlsl-writer] Add member accessor emission.
This CL adds emitting MemberAccessorExpressions to the HLSL backend.

Bug: tint:7
Change-Id: Ic6c99232e98322c8145700d5f1a3a8314cf60feb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25844
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 19:12:19 +00:00
dan sinclair 7cf1979667 [hlsl-writer] Add AsExpression to the HLSL backend.
This CL adds as casts to the HLSL backend.

Bug: tint:7
Change-Id: I599527d665a3ec1ab6cf80b4f550f7aee8fdf294
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25843
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 19:11:15 +00:00
dan sinclair d450a920d5 [hlsl-writer] Add BlockStatement support.
This CL adds support for BlockStatement to the HLSL backend.

Bug: tint:7
Change-Id: I953a1b85a05cd84e8e296d677204ae9b5a3ae669
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25860
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 19:06:46 +00:00
dan sinclair cda5af0fa2 [hlsl-writer] Emit discard.
This CL adds the discard statement to the HLSL writer.

Bug: tint:7, tint:166
Change-Id: I292e9b97a1246c9b79a9660ec229ff7855aeb2a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25842
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 18:56:50 +00:00
dan sinclair ec007b98c7 [hlsl-writer] Emit array accessors.
This CL adds array accessor expressions to the HLSL backend.

Bug: tint:7
Change-Id: I46d60f5d8ef74fee2a2f4da48c2d792969bfa365
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25820
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 18:56:35 +00:00
dan sinclair 0e48082549 [hlsl-writer] Add alias type support.
This CL adds support for emitting type aliases to the HLSL backend.

Bug: tint:7
Change-Id: Ibd2c2d3bbe6c9a86033e379b4e1cb494259b4df2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25800
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-07-29 18:56:25 +00:00
dan sinclair 4a11b5600d [hlsl-writer] Add constructor emission.
This CL adds scalar and type constructor emission to the HLSL backend.

Bug: tint:7
Change-Id: I2b402b7eb66f266c3a111c9b07502ef17cc1a679
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25726
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 18:50:18 +00:00
dan sinclair 8cce7cece8 [hlsl-writer] Add type emission.
This Cl adds the start of type emission to the HLSL backend.

Bug: tint:7
Change-Id: I403635080841c63382afe162ac80ae2be30b4faa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25780
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 18:30:44 +00:00
dan sinclair bf4614e252 Update some language usage.
This CL updates a few bits of language to be inline with the Android
respectful code rules [1].

1- https://source.android.com/setup/contribute/respectful-code

Change-Id: Ia35b58d9003df64eeb1e9196c9c194f8955c11c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25941
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 17:49:01 +00:00
David Neto d35e4e1bbe [spirv-reader] Only support column-major matrices
- drop ColMajor, MatrixStride member decoration
- RowMajor matrix decoration is an error

Bug: tint:3, tint:99, tint:31
Change-Id: I7eb1ec53813a4b1ada971e8725dc91ffdf97bd43
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25920
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-29 16:04:23 +00:00
Idan Raiter e018cefdce Fix Tint ninja build
Rebasing I saw chromium style issue with auto pointers and a missing BUILD.gn file.

Change-Id: I7666595664b5eb95f681b3d2edd1d84df7d6fe63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25848
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-28 15:04:07 +00:00
dan sinclair e8c12f32f9 Remove StatementList.
This CL removes the StatementList define now that BlockStatement is used
everywhere.

Bug: tint:130
Change-Id: Id51de13cd1ca0cd69023523c762fe719bc2da999
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25725
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair cfdc5995ec [spirv-reader] Update to create BlockStatements
This CL updates the SPIR-V Reader to create BlockStatements instead of
StatementLists.

Bug: tint:136
Change-Id: I957019446ca00306187de701f86ae3e0dd5c5eb8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25740
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair f751501c35 [wgsl-reader] Update to create BlockStatements
This CL updates the WGSL Reader to create BlockStatements instead of
StatementLists.

Bug: tint:135
Change-Id: Ifda394023553a625dad67be7d4e0dc815292282a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25724
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 37c0970d51 Convert LoopStatement to use BlockStatement.
This CL converts the LoopStatement class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: Ied4b82f0ef49c7b92caa040bcf73050093022df7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25723
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 77040b85d9 Convert IfStatement and ElseStatement to use BlockStatement.
This CL converts the IfStatement and ElseStatement classes to using a
BlockStatement internally. All usages have been updated execept for the
two readers.

Bug: tint:130
Change-Id: I59a5b92f22f35f27f17e005aa9b266f4a2b0ef25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25722
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 7c2fa1e7bc Convert CaseStatement to use BlockStatement.
This CL converts the CaseStatement class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: Idb9114230f7d9eb0f2208af635316edb0a0e8f99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25721
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 4069f3357d Convert Function to use BlockStatement.
This CL converts the Function class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: I7159cf2d3ed5cb8a34d51fbe848b88f0e5479605
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25720
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 0975dd5663 [spirv-writer] Add BlockStatement emission.
This CL adds BlockStatement support to the spirv-writer. The type
determiner is also updated as needed.

Bug: tint:134
Change-Id: I91e08c3acafd67401a010fff21abde7feec46e8e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25609
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair cd182b137e [msl-writer] Emit BlockStatement.
This CL adds BlockStatement emission to the MSL backend.

Bug: tint:132
Change-Id: Ie64c02b81760787f6d8aa8833b9756ede3deddf9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25608
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 21f8e253a0 [wgsl-writer] Add emission of BlockStatement.
This CL adds BlockStatement writting to the WGSL writer.

Bug: tint:131
Change-Id: I6d1d286134311cea13e19c7381ed344da8205199
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25607
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 775cb51794 [ast] Add BlockStatement
This CL adds a BlockStatement to wrap the statements in a given block.

Bug: tint:130
Change-Id: Idc2389e001d9d87ef7f45dcd8aa90bbd27ff7dce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25606
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 99ad0e8c94 [msl-writer] Emit intrinsics.
This CL adds intrinsics to the MSL backend.

Bug: tint:8, tint:159
Change-Id: I03e3c4bdf234ec4ca437ab1b1a0d4835e3342b0c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25500
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:39:23 +00:00
dan sinclair 8f3c6356d4 Remove KillStatement
This CL removes the KillStatement from the AST and replaces all test
usage with DiscardStatement.

Bug: tint:169
Change-Id: Ie68dd3cdd54056f144d10506f05cc1f6903d1cda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25605
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:50 +00:00
dan sinclair 23508f4339 [spirv-reader] Convert from KillStatement to DiscardStatement
This CL changes the SPIRV-Reader to generate DiscardStatements instead
of KillStatements for an OpKill.

Bug: tint:168
Change-Id: Ic4223b614c822c6ad449f61aedaddc9605c42535
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25642
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:35 +00:00
dan sinclair f75f2cd22e [wgsl-reader] Add `discard` parsing.
This CL adds parsing of the `discard` keyword to the WGSL reader.

Bug: tint:167
Change-Id: Iff91076a65715131f5f0f9bd1c8b6bf3a37cd3c7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25604
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:13 +00:00
dan sinclair d81bebcfcc [wgsl-writer] Add DiscardStatement support
This CL adds the DiscardStatement to the WGSL writer.

Bug: tint:165
Change-Id: I012bc030482e097fd9a957ed96f15d8360f621a5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25603
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:04 +00:00
dan sinclair a9696b511f [msl-writer] Emit DiscardStatement.
This CL adds the DiscardStatement to the MSL backend.

Bug: tint:164
Change-Id: I1e201d3b6a167690af7bb799e1c93e48232f4a0a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25602
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:32:54 +00:00
dan sinclair 6a61d4127e [spirv-writer] Add DiscardStatement support.
This CL updates the spirv-writer to emit the DiscardStatement as an
OpKill.

Bug: tint:163
Change-Id: Ic2514ee8a4ef7ef0220fc2e1145f8df0c3d32069
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25641
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:32:44 +00:00
dan sinclair b4374c271e [ast] Add DiscardStatement AST node.
This CL adds DiscardStatement to the AST.

Bug: tint:162
Change-Id: I1905023eb8297d9a983884e77c6a2267fd43a076
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25601
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 03:34:33 +00:00
Sarah Mashayekhi ce973e355c [validation] Add a disabled test for re-assigning a constant.
Bug:6
Change-Id: Ic2cd1d0eed82354e605e15aec2ba350c15773e51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25522
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-24 14:50:51 +00:00
dan sinclair 095523020a Fixup some doc and compile issues.
Change-Id: I75547e3fb4e1e4be08bde08f0bcfcf7e979791e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25640
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-24 00:11:53 +00:00
Sarah Mashayekhi 591fe919c2 [validation] implement invalidate assignment to a different type.
Bug:6
Change-Id: I5bd98731a5827e5a6aa1761dd18e7e116dd68544
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25524
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-23 23:49:52 +00:00
Ryan Harrison 7a0b734864 Fix BUILD.gn builds
Change-Id: I4e54b30497e064061baff2dcc205b68db87bee2c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-22 20:41:12 +00:00
dan sinclair b522fb343a [msl-writer] Only emit in/out structs if function call requires.
This CL updates the EmitCall method to only ouptut the input and output
struct name if there are in/out variables used in the function.

Bug: tint:107
Change-Id: Ic0c7722c8796c2f9baa3515cb46be0568f9e1ac3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25400
Reviewed-by: David Neto <dneto@google.com>
2020-07-22 20:02:08 +00:00
Sarah Mashayekhi fbf4506356 [validation] Add a disabled test for assignment statement.
Bug: tint:6
Change-Id: I37fe9f69917a007b9e3325de324e719637b192e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25420
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-07-22 12:59:19 +00:00
David Neto b6f0299964 [spirv-reader] Support OpAny, OpAll, OpIsInf, OpIsNan
Bug: tint:3, tint:121
Change-Id: I1a6a2d45684c28a0e03ad4b208dc6b2f737da694
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25422
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-22 12:58:31 +00:00
dan sinclair e3de74fd2b [spirv-writer] Emit select intrinsic.
This CL adds the select intrinsic to the SPIR-V backend.

Bug: tint:106
Change-Id: Ib5b4c1f25ff8620055f75f0291a949a950a50b7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25381
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 17:44:44 +00:00
dan sinclair 16a2ea11d3 Add type determination for the select intrinsic.
This CL adds type determination for a `select` intrinsic.

Bug: tint:106
Change-Id: Ie5c051cb42c72ae732579e3064561a4544a90473
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25380
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 17:44:44 +00:00
David Neto d71e80b710 [spirv-reader] Add README.md
Bug: tint:3
Change-Id: Ie711f7bdbb870c9f370ce777653884c5942a0622
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-07-21 17:11:50 +00:00
David Neto 28d0f4b905 [spirv-reader] Support function call returning void
Bug: tint:3, tint:99
Change-Id: I6fe6d06d79115e6b3b0adb800f21c4704795dc15
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25360
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-21 16:08:56 +00:00
dan sinclair a0b73e8aca [hlsl-writer] Add assignment statement.
This CL adds the assign statement emission to the HLSL backend.

Bug: tint:7
Change-Id: I3e46ac09170ea1af7444ae89267a82e1d1c42c52
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25224
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:56 +00:00
dan sinclair 41aa1a1ed8 [hlsl-writer] Add switch statement support
This CL adds emission of switch statements to the HLSL backend.

Bug: tint:7
Change-Id: Ie6f41031878a1f5a945f9310429d28fb0e4a98c8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25223
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:50 +00:00
dan sinclair 557a0f8e63 [hlsl-writer] Emit case statements.
This CL adds emission of case statements to the HLSL backend.

Bug: tint:7
Change-Id: I5d0dd7ecfe4ef032a03777c29f3d0d00e584a93a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25222
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:43 +00:00
dan sinclair 6dab73b5c6 [hlsl-writer] Emit unary operators.
This CL emits unary operators from the HLSL backend.

Bug: tint:7
Change-Id: I997d89d62d279fc7440ba6045c56e290ec7601c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25221
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:36 +00:00
dan sinclair abfdd22acc [hlsl-writer] Emit break, return and continue.
This CL updates the HLSL writer to emit break, return and continue
statements.

Bug: tint:7
Change-Id: I03eafc343e57e9e8d1efaf930023099d6f85fc57
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25220
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:29 +00:00
dan sinclair dee9136c20 [hlsl-writer] Add binary operator emission.
Emits the binary operators.

Bug: tint:7
Change-Id: I6f4fce3b6fb646b8340e39538b041715a676ac28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25164
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:20 +00:00
dan sinclair fbbc617888 Parse void function call.
This CL updates the WGSL parser to handle a void function call.

Fixes: tint:45
Change-Id: If5b2a4b9e62f0b10e0f2e2e10c0ca2586c5268e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25322
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-07-21 15:13:36 +00:00
dan sinclair e5228407f4 [hlsl-writer] Add emission of identifiers
This CL adds identifier emission and an HLSL namer to guard against
names using reserved words.

Bug: tint:7
Change-Id: Id3d73ff683048c26ac99451d21c3dd7ef3c620a3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25001
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 14:51:33 +00:00
dan sinclair b44fe3c034 Emit call statements from the various backends.
This CL adds emission of CallStatement to the various backends.

Bug: tint:45
Change-Id: Ia2bdf0433f136c516ecccdcbc64a5365094220af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25281
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 13:44:27 +00:00
dan sinclair 50080b74e1 Type determine the call statement.
This CL adds type determination for the call statement.

Bug: tint:45
Change-Id: I2460fe6c6103bdf7e5d0367cded1d78ca5d671d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25321
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 13:42:13 +00:00
dan sinclair 2e40491467 Add a call ast statement.
This CL adds CallStatement to the AST to allow wrapping a CallExpression
into a statement.

Bug: tint:45
Change-Id: I5a9525514344fcc2cf9900eb2cd78c1fb94ca2ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25320
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 13:42:05 +00:00
David Neto 0a56a103be [spirv-reader] Support select over scalars and vectors
Still TODO: OpSelect over arrays and structures, as permitted in SPIR-V 1.4

Bug: tint:3, tint:99
Change-Id: I70f6c8a43ea3339cd715813c6eb0128d66ff0df8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25301
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-21 13:36:25 +00:00
David Neto d6b024b66d Add missing Doxygen comments on two methods.
Bug: tint:3
Change-Id: I5cb5c3ce078951363279ccc999074c0c46dfad6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25300
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 23:31:56 +00:00
David Neto c29bad28ad [spirv-reader] Support function calls, except returning void
Functions returning void are blocked on https://crbug.com/tint/45

Change-Id: I15ec9cf0e267571bbfab921c678a59e25d0e3619
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 22:19:01 +00:00
dan sinclair feffa9d887 [hlsl-writer] Scaffold the HLSL backend.
This CL adds the scaffolding for the HLSL backend.

Bug: tint:7
Change-Id: Iaf9f5159bc409f3ac71fcec281229258bdfa021b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25000
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 22:13:37 +00:00
dan sinclair 5dee499c57 [msl-writer] Emit storage buffers.
This Cl adds the emission of storage buffers to the MSL backend.

Bug: tint:8
Change-Id: I6923926b36e73f2e351443cf1d2bf6d70873bc9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25264
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 22:13:20 +00:00
dan sinclair 26c8a216e8 [msl-writer] Add import emission.
This CL adds emission of import function calls to the MSL backend.

Bug: tint:8
Change-Id: Ib8b8638b11caee2ff3557d551447b215ef2a4c69
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25262
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 22:13:00 +00:00
David Neto 747e80a9b3 [spirv-reader] Drop NonWritable NonReadable for now
Pending WGSL issue https://github.com/gpuweb/gpuweb/issues/935

Bug: tint:3, tint:99
Change-Id: I90771e6e0c6a2f109fd6e361d79adea273ca7bc6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25261
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 20:00:10 +00:00
Ryan Harrison c8af502c01 Fix issues with BUILD.gn
Couple of little style issues, and a path to a file that was incorrect.

Change-Id: I21d1a4ca41bc36163602378086989ac712f54469
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25265
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 19:54:23 +00:00
dan sinclair 18c85f52e4 [msl-writer] Cleanups and refactors.
This CL cleans up some interfaces and methods in the MSL generator and
generator impl classes.

Bug: tint:8
Change-Id: I9aabeb1ecb69baeaa9cb6bbc15e313806923dddc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25163
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 17:27:58 +00:00
dan sinclair f1c3fb7670 [msl-writer] Handle uniform buffers.
This CL adds support for handling uniform data. Currently the uniform is
added to a buffer where the number is the binding value. This will need
to be updated to accept the correct mapping from the embedder.

Bug: tint:8
Change-Id: Icccccbe599a9555defa6136e384745f4093df020
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25104
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 13:46:32 +00:00
David Neto e6c575538a [spirv-reader] Support DescriptorSet and Binding
Bug: tint:3
Change-Id: I92d44cc59883d3834aedd2529ab5e20b49d6eb31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25200
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 13:24:58 +00:00
David Neto 6982c22eee [spirv-reader] Handle old-style storage buffers
Old way:
  - struct decorated with BufferBlock
  - Uniform storage class

New way
  - struct decorated with Block
  - StorageBuffer storage class

Also fixes the result type for an access chain.

Bug: tint:99
Change-Id: I2324ba94bb19b369d206313de798bdfec6099fe0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24605
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 13:24:26 +00:00
David Neto 3c3d2275fe [spirv-reader] Support Location on module vars
Bug: tint:3
Change-Id: If7fc85251cbffab477b0b4f86c204de6c6a853f6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25103
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-16 21:13:58 +00:00
David Neto d8a4d4b06f [spirv-reader] Ignore empty string user names
Bug: tint:3
Change-Id: Ibef645b123706cf9fa7d5b98413a709d4624244d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25102
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-16 20:58:09 +00:00
David Neto 5f43fedcdd [spirv-reader] Handle gl_Position
Emits it as a module-level variable.  Deconstruct and throw away
the gl_PerVertex struct.

Not handled: unusual patterns that are technically valid but
which don't occur in practice:
- loading, storing, or producing intermediate values of the whole structure.
- multiple definitions of the per-vertex structure (e.g. if someone had
  put both a vertex shader and a tessellation shader in the same
  module.)

Bug: tint:3, tint:99
Change-Id: I3ad9ff6ab780a002367f01f385bfa7d6ddba6db9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24880
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-16 20:15:22 +00:00
dan sinclair 4264af9d3d [msl-writer] Emitting of program constants.
This CL adds code to emit program constants in the MSL backend.

Bug: tint:8
Change-Id: I63e40983253349d2e293904fbe9b6f543b885b34
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24940
Reviewed-by: David Neto <dneto@google.com>
2020-07-16 17:54:26 +00:00
dan sinclair 3f10421cee [msl-writer] Fixup matrix and array constructors.
This CL fixes up the array constructors to emit `{}` instead of
`<type>[<size>]()`. The matrix example is also updated to have the
correct data format for WGSL matrices which fixes the MSL output.

Bug: tint:8
Change-Id: I3a08a8814d4b8b38a57b6324e2182a271c958ef3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25060
Reviewed-by: David Neto <dneto@google.com>
2020-07-16 14:35:44 +00:00
dan sinclair 4556cbe24f Differentiate size and stride in array type name.
This CL adds a `_stride_` into the array type name to differentiate an
array of 8 elements and a runtime array of stride 8.

Bug: tint:102
Change-Id: Iaf10fe5957acde16a9ccdf2a0fd8a83e47bb57bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24962
Reviewed-by: David Neto <dneto@google.com>
2020-07-16 14:02:40 +00:00
David Neto aa601387a2 [spirv-reader] Support duplicate type definitions
Affects structs, runtime arrays

Bug: tint:3, tint:99
Change-Id: I9ca73f8f3f6395c829d134460ad4b1a9e50c3ec9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-16 13:00:37 +00:00
dan sinclair b0391c6fa4 [msl-writer] Add struct offset support.
This CL adds support for injecting padding into structs in the MSL
backend.

Bug: tint:8
Change-Id: I83631a71ce4a2f00b61974ee2c0c7ca1b97f3028
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24601
Reviewed-by: David Neto <dneto@google.com>
2020-07-15 20:54:48 +00:00
dan sinclair 7caf6e5959 [msl-writer] Add builtin support
This CL extends module scoped variables to include support for builtins.

Bug: tint:8
Change-Id: I9e4363be32401bfdd45ad5d1727d9432aca206fe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24786
Reviewed-by: David Neto <dneto@google.com>
2020-07-15 20:51:16 +00:00
dan sinclair 5423d91d87 Add helpers for referenced variables.
This CL adds a helper to get referenced builtins and referenced
locations from the ast::Function.

Change-Id: I95cf7efd6b0fe9569c5e514d3245112e78147ffe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24783
Reviewed-by: David Neto <dneto@google.com>
2020-07-15 18:26:25 +00:00
dan sinclair d1684ed287 [msl-writer] Refactor some entry point variable code.
This CL cleans up some of the entry point variable code.

Bug: tint:8
Change-Id: Ic89ff3608d34af26eeb9fe9408cdbd5c7de22dda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24782
Reviewed-by: David Neto <dneto@google.com>
2020-07-15 18:26:17 +00:00
dan sinclair df415a8919 [msl-writer] Generate entry point functions.
This CL generates entry point functions and duplicate functions as
needed to call from the entry points.

Bug: tint:8
Change-Id: I8092ce463248e7a887c26ae05b0774e8fa21ab94
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24764
Reviewed-by: David Neto <dneto@google.com>
2020-07-15 18:04:11 +00:00
dan sinclair c5a5f9666f [msl-writer] Handle emitting user function calls.
This CL adds support for calling user defined functions from the MSL
backend. Intrinsics and imports are not handled yet.

Bug: tint:8
Change-Id: I45c3078d014ab89cc0eec76dd626759077e1a890
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24763
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:38 +00:00
dan sinclair de2dd68f2b Inherit refererenced globals up the call stack.
A given caller should inherit the globals referenced from a callee. This
way, a given entry point will have a list of all the variables used up
the stack which it needs to reference.

Change-Id: Ib6efcdd5c3347749ad2d54aecfa425bd966a62fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24762
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:28 +00:00
dan sinclair a2eb8c52b2 [msl-writer] Generate input/output structs
This CL adds generation of the input/output structures for entry points.

Bug: tint:8
Change-Id: I93942496bcea0a2eea944e5e1cd0baf383530f5e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24721
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:20 +00:00
dan sinclair 16890b9ce8 Add determination of entrypoint callees.
This Cl updates the type determiner to annotate each function with the
name of any entry points which call into the given function. This will
allow determining in the backends if we need to duplicate the function
due to differing entry point parameter requirements.

Bug: tint:8
Change-Id: Icd7c4ccab72dd6eabcf0abaf1159319949c4ecf5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24760
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 19:45:47 +00:00
David Neto 919011af0a [spirv-reader] Refactor how we emit const definitions
Take the type of a const-definition (or a write to a hoisted variable)
from the generated expression rather than the directly-converted type
from the SPIR-V ID.

This prepares the way for remapping storage buffers from
Uniform/BufferBlock to StorageBuffer/Block representation.

Bug: tint:99
Change-Id: I6104d8ad96312053562468a3cdb247932c1cb6cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24604
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-13 14:16:12 +00:00
David Neto 018428dcd0 [spirv-reader] avoid using WGSL reserved words
Bug: tint:3
Change-Id: I8ab9ee4604f725cefcfab854e953caba7051b1ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24524
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-13 14:15:52 +00:00
dan sinclair 25058a9213 [msl-writer] Fix output of array-of-array.
This CL fixes the output of multi-dimentional arrays in the MSL backend.

Bug: tint:7, tint:100
Change-Id: I8fe925145973555f77673e9db97f150077e2471f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24560
Reviewed-by: David Neto <dneto@google.com>
2020-07-10 00:03:19 +00:00
dan sinclair 45101598a1 [msl-writer] Add variable declarations.
This CL adds variable declarations to the MSL backend.

Bug: tint:7
Change-Id: Icf63ad44a217213e5036eb76429e25a3031822eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24540
Reviewed-by: David Neto <dneto@google.com>
2020-07-08 20:52:46 +00:00
dan sinclair d0f7381090 [msl-writer] Better error message for missing statement and expression.
If the statement or expression being emitted is not implemented this
will now output the failed statement.

Bug: tint:7
Change-Id: I8a359abd369067540d503a1facbee018e91e8666
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24523
Reviewed-by: David Neto <dneto@google.com>
2020-07-08 18:29:21 +00:00
dan sinclair 723c5b4889 [msl-writer] Add missing include.
Need the algorithm include to build on Windows.

Bug: tint:7
Change-Id: I5691c9e30c762271c767934921fe925120a67e01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24522
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-07-08 17:17:46 +00:00
dan sinclair 928f59ca46 [msl-writer] Handle remapping remap collisions.
If the remapper give an ident a new name which collides with a future
ident name we need to rename the future name to not collide.

Bug: tint:7
Change-Id: I162a3071f75ed714cee730b78aebefa8c75c77de
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24521
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-07-08 17:17:35 +00:00
Ryan Harrison 7b819aa162 Multiple fixes to get BUILD.gn builds working again
Change-Id: I00c8050d85e25c4e926c06b4df1381434de92f34
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24460
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-07-07 19:11:07 +00:00
David Neto 6453bee795 [spirv-reader] Even better hoisted variables
Use the fact that in WGSL the scope corresponding to the loop construct
encloses the scope for its associated continue construct.
In our construct data structure, the two are adjacent but not
overlapping.

This improvement means that when a definition is in a loop construct,
but used only in the loop or associated continue construct, then no
hoisting is required.

Bug: tint:3
Change-Id: I8d33b8f76303ab2868306847e846b4c26899e746
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24420
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-07-07 17:25:48 +00:00
dan sinclair 6249e38189 Use Tint Generator Number.
This Cl updates the code to use the new Tint generator ID.

Bug: tint:5

11d7637e7a..308bd07424

$ git log 11d7637e7..308bd0742 --date=short --no-merges --format='%ad %ae %s'
2020-06-26 dj2 Register the Tint compiler

Created with:
  roll-dep build buildtools testing third_party/binutils third_party/googletest third_party/spirv-headers third_party/spirv-tools tools/clang

Change-Id: I703d7bf7ad81bc6190e45a5271a30bc7110f4cb7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24401
Reviewed-by: David Neto <dneto@google.com>
2020-07-06 19:50:42 +00:00
David Neto 91cb60f2ec [spirv-reader] Improve placement of hoisted vars
When we hoist a variable out of a continue construct, put it
in associated loop construct, if it exists.  This reduces its
lifetime in WGSL, and easier to understand as a code reader.

Change-Id: I8f0cc37640bfe67874cbc27b55029e79e9a8992c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24321
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-07-06 18:10:52 +00:00
David Neto 4c48622aa1 [spirv-reader] Allow multi-block continue construct being the entire loop
The special case is not "single-block-loop" but rather the
case where a continue target is also its own loop header.
This can occur for single-block loops and multi-block loops.

Bug: tint:3
Change-Id: I4af1410793caf8b26a1f781e221fc0b395f07aa3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24320
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-07-06 16:13:54 +00:00
David Neto 9b9a0b07da [spirv-reader] Support OpPhi
For each OpPhi, make a variable to carry values from predecessor blocks
to the OpPhi.  Declare the variable at the smallest scope enclosing all
the predecessor blocks (where we write to it), and the OpPhi (where we
read from it).

Bug: tint:3
Change-Id: I7898b4b903d9ee1a25a7466e3c5aaf6840550e2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24181
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-07-06 16:08:17 +00:00
dan sinclair f2aaa0e985 [msl-writer] Always add the metal_stdlib include.
This CL adds the metal_stdlib include to the MSL generator.

Bug: tint:8
Change-Id: Ie80a7aa3921e2c4594cb7dc5a69d1b04a253c752
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24185
Reviewed-by: David Neto <dneto@google.com>
2020-07-02 20:53:54 +00:00
dan sinclair 6002a3345f [msl-writer] Add namer class.
This CL adds a namer class to prevent collisions with builtin names in
MSL. The MSL generator has been updated to use the namer anywhere that
names are emitted.

Bug: tint:8
Change-Id: I820f226a7286be1d5b0d613bd0fa41b68cb9f8ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24184
Reviewed-by: David Neto <dneto@google.com>
2020-07-02 20:53:45 +00:00
dan sinclair 53b3283c6a [msl-writer] Emit switch statements.
This CL adds support for switch and case statements into the MSL writer.

Bug: tint:8
Change-Id: Ib51f943e8476c0ecfd45e9131404f96934c6e21f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24180
Reviewed-by: David Neto <dneto@google.com>
2020-06-30 21:33:20 +00:00
David Neto 2c11bd6b68 [spirv-reader] Refactor bookkeeping for localy defined values
Bug: tint:3
Change-Id: Ibe26b802ae61c6271f8a75e641ac31db36df6000
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24124
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-30 19:03:17 +00:00
dan sinclair e88c0f6f8a [msl-writer] Emit loop statements.
This CL adds the code to convert a loop/continuing statement into MSL.

Bug: tint:8
Change-Id: I9fa595908c6d834d9543b583c8baf8c19f8cae6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24122
Reviewed-by: David Neto <dneto@google.com>
2020-06-30 17:40:28 +00:00
David Neto e91325956d [spirv-reader] Hoist definitions as needed
Compensate for the fact that dominance does not correspond
exactly to scoping. A definition can dominate a use, but when mapped
in a naive way to constant definitiion and its use, the definition
name goes out of scope by the time you reach the use.

This is correct for storable types.

Bug: tint:3
Change-Id: I03e6c5ba68393151485ed4cdbe6b2b3d7773d1ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24141
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-30 15:16:18 +00:00
David Neto de7b15ebb9 [spirv-reader] Don't move combinatorial values across control flow
Avoid sinking expensive operations into control flow such as loops.
The heuristic way to achieve that is to avoid moving combinatorial
values across *any* structured construct boundaries.

Bug: tint:3
Change-Id: I91502b01166a0db64c0e652331591850df75f9d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24140
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-30 13:59:43 +00:00
dan sinclair 57b3b1d117 [msl-writer] Add break and continue emission.
This CL adds writting of break and continue statements to the MSL
backend.

Bug: tint:8
Change-Id: If2443c036fa82f54708d209d924192ee7a159e76
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24121
Reviewed-by: David Neto <dneto@google.com>
2020-06-29 21:17:54 +00:00
dan sinclair fa1659a3ef [msl-writer] Emit member accessors.
This CL adds emission of member accessor expressions to the MSL writer.

Bug: tint:8
Change-Id: I21d8564880c44d719c89dca2a10cd97ccb1e2cd7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24120
Reviewed-by: David Neto <dneto@google.com>
2020-06-29 21:17:44 +00:00
dan sinclair 48bb366991 [spirv-writer] Allow casting of vectors along with scalars.
The current `cast` conversion code only handles scalar types and fails
if provided with vectors. This CL updates the logic to accept scalars
along with the provided scalar cases.

Bug: tint:96
Change-Id: I60772e75286fc3ee7a9dfba6634db069062b22d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23820
Reviewed-by: David Neto <dneto@google.com>
2020-06-29 17:58:09 +00:00
dan sinclair d4eafb631d [msl-writer] Emit alias types.
This CL adds emission of alias types to the MSL writer. They are output
as `typedef`s.

Bug: tint:8
Change-Id: I18b839ed0238c4636e3975f35f5d88badd412fe4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24001
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair dc841f1bf2 [msl-writer] Add array accessors.
This CL adds the code to emit array accessors from the MSL backend..

Bug: tint:8
Change-Id: Ia6b49c11602d39aa559feac31fcfd592ab54928c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24000
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair d1bf87b9d8 [msl-writer] Add unary op emission.
This CL adds emission of the unary `-` and `!` operators.

Bug: tint:8
Change-Id: I9dda066111cc8f115b593127cf070c6ca37bdc66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23842
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00