Commit Graph

1514 Commits

Author SHA1 Message Date
Ryan Harrison b16a5d6e9b Exclude builtins from reflected stage variables
BUG=tint:456

Change-Id: I941b25dd5bf5e758d5fdecf379137d92d5db8556
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38460
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
2021-01-25 21:15:08 +00:00
Ben Clayton d59cedb5a5 Add tint::Program as a wrapper of tint::ast::Module.
`tint::Program` will become the new public API object for a parsed shader program.
For now, have Program be a simple wrapper around ast::Module so we can migrate Dawn's use of the public tint API.

Add new Program variants of public APIs for places that returned or took a Module.

Remove Reset() methods from Generators, they aren't used, and make the migration harder.

Change-Id: Ic5bee46ceb109ea591ba7fec33685220b244a1ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-25 18:14:08 +00:00
David Neto aee7acaaea spirv-reader: refactor getting image, sampler
Change-Id: I6620781f620067e4df8f7e39f2bb2a80b32f9ecf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38180
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-01-25 15:16:58 +00:00
Ben Clayton 5c243f824c Rename CloneContext::mod to CloneContext::dst
In the future, CloneContext will be operating on `Program`s so a field called `mod` is poorly named.
CloneContext has a `src` member, so rename to `dst` to keep symmetry.

Bug: tint:390
Change-Id: Ic724f8a18b46ef719790394cdc810f7eb3681234
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38364
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-22 13:41:06 +00:00
Ben Clayton 6761160dc1 ast: Move Module function methods to FunctionList
Module will be split into Module (immutable) and ModuleBuilder (mutable).
By moving these methods to the FunctionList, we can deduplicate a bunch of common logic.

Bug: tint:390
Change-Id: I3fd85200aae4e8dc3d5afce8c9aaa6512809a3a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38363
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 18:45:50 +00:00
Ben Clayton 281b602f59 type::Manager: Simplify interface and use BlockAllocator
Internally use BlockAllocator to allocate the types.
When we optimize the allocation patterns of BlockAllocator, this will now benefit both AST nodes and types.

Remove Reset(). It was not used.

Remove type::Manager::Get(std::unique_ptr<type::Type>) - this was used (via Module::unique_type) in one place, which has easily been migrated to using the standard Module::create<>.

Replace all remaining uses of std::unique_ptr<> of types in tests with the standard create<> so we can guarantee uniqueness of the types.

Change-Id: Ib0e1fe94e492b31816450df5de0c839a0aefcb9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38362
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 16:35:10 +00:00
Ben Clayton 1e29f4beb0 Move CloneContext and Traits from src/ast to src/
CloneContext clones the AST, types, symbols and in the future semantic info.
3/4 of these are non-ast, so promote these up to the root.

Bug: tint:390
Change-Id: I49619796e6f81f9ab64f79413a12c87312cb1901
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38361
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 16:20:40 +00:00
Ben Clayton f12054ea2a test: Add Build() method for tests using ast::Builder
This separates out the usage of the built module from the construction of the module.

Previously, we'd happily interleave generator testing with module construction statements. Once the AST / Program is made immutable, this will no longer be possible.

Bug: tint:390
Change-Id: Ib4538228e93ca816f5bb796d024f021116609213
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38360
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-21 16:15:00 +00:00
Ben Clayton 207b5e2de1 Move tint::ast::type to tint::type
Despite `tint::ast::type::Type` being in the AST namespace, these classes are clearly not AST nodes:
* They don't derive from ast::Node
* They're deduplicated by the type manager
* None of the types have an Source - they have no lexical declaration point
* The fact we have `ast::Struct` and `ast::type::Struct` clearly demonstrates what is an AST node, and what is a type.
* We have code scattered in the codebase (TypeDeterminer, writers, etc) that create new types after parsing - so clearly not part of the original syntax tree.

Types in tint are closer to being semantic info, but due to the parse-time generation of types, and tight dependency of ast::Nodes to types, I'd be reluctant to class these as semantic info. Instead, put these into a separate root level `tint::type` namespace and `src/tint` directory.

The fact that types exist in the ast::Module has already caused bugs (https://dawn-review.googlesource.com/c/tint/+/37261). This is a first step in separating out types from the ast::Module.

Bug: tint:390
Change-Id: I8349bbbd1b19597b8e6d51d5cda0890de46ecaec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38002
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 15:42:10 +00:00
Ben Clayton 587f387fd9 Add tint::BlockAllocator<T>
A container and allocator of objects of (or deriving from) the template type `T`.

Objects are allocated by calling Create(), and are owned by the BlockAllocator.
When the BlockAllocator is destructed, all constructed objects are automatically destructed and freed.

Objects held by the BlockAllocator can be iterated over using a View or ConstView.

Use this to hold the ast::Nodes in the ast::Module

This is called BlockAllocator as it can be optimized to hold objects in contiguous memory blocks, which will improve cache coherencey. Currently BlockAllocator is a straight port of the vector-of-unique-ptr, taken from ast::Module.

Change-Id: I4bf4d298aec3c70d2ddf833e2f168416cbb024c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38001
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-21 15:30:10 +00:00
Vasyl Teliman e1abcb4564 wgsl-reader: support multiple case selectors
Bug: tint:454
Change-Id: I5a046e19f66b5807723e96593ea6ba107ef69e6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38261
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-20 21:53:13 +00:00
Ryan Harrison afb8cfb254 Add location data to input/output variable reflection
Adds this data to the Inspector API, as well as needed internal
utility methods.
Updates and expands tests to cover changes.

BUG=tint:452

Change-Id: I598f8149cb6abd13abf606416ae61e615b99e1e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38200
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-01-20 18:58:17 +00:00
David Neto ed14524b1e Refactor getting number of coordinate dimensions
Change-Id: Ibafffb29bc33c722b8a4da25ed7a9c1986d13a24
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38162
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2021-01-19 03:29:35 +00:00
David Neto 71012dcc2f validator: Support assignment through pointer
Also enable a test to check assigning to scalar literal.

Fixed: tint:419
Change-Id: Ic565af22c4ef6b60c41faaf9fabe3bd55fe48d2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37961
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-01-18 22:17:25 +00:00
dan sinclair 336bb0b4dd Update storage_buffer storage class.
This Cl updates the `storage_buffer` storage class to just be `storage`.

Change-Id: Ibfaecbb0862bd60d39665eb937c0b6300899e177
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38161
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-18 21:06:34 +00:00
David Neto 20f4d1daca validator: add IsStorable helper function
Bug: tint:419
Change-Id: Ib15aa819a032d8412fb3bc162b29a02c331f56b8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37960
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-01-18 19:45:24 +00:00
dan sinclair d7335fa974 Update builtin idx names.
This CL upldates the vertex_idx, instance_idx and global_invocation_idx
builtins to use the full _index names. The original values still exist
until we can update downstream users.

Change-Id: Icd02601eeb15704d5463158541c07816d98e5383
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37940
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-18 15:51:13 +00:00
dan sinclair c068cfc139 Support the group decoration.
This CL changes the set decoration to a group decoration. We still parse
`set` until downstream users can be updated.

Bug: tint:338
Change-Id: I610d1ed769b3a26c117ad6d875f8a99a3d5b7754
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37920
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-15 12:22:16 +00:00
David Neto 0e17caa361 spirv-reader: expand OuterProduct to primitive ops
Bug: tint:3
Change-Id: Id6de3554d945bc743a484e80b494690c26552079
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37660
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-01-14 19:01:27 +00:00
Ben Clayton 0a68b365eb Implement textureNumSamples()
SPIR-V reader TODO

Bug: tint:140
Bug: tint:437
Change-Id: Id95855660680b12e3ff49b6340ef966dfa49f8e4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37848
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-14 18:11:17 +00:00
Ben Clayton 6e5b5ecc52 Remove underscores from ValidTextureOverload enum names
For consistency's sake.

Change-Id: I08d0b7a5377fed0075feb7c3a0332cda43fb73bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37847
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-14 18:09:07 +00:00
Ben Clayton d97132028a Implement textureNumLevels()
SPIR-V reader TODO

Bug: tint:140
Bug: tint:437
Change-Id: Icd41b2ef84e62b304e446589eb2e37c38279af35
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37846
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-14 18:06:57 +00:00
Ben Clayton c21f1f92a2 Implement textureNumLayers()
SPIR-V reader TODO

Bug: tint:140
Bug: tint:437
Change-Id: Id397f5f07a2f18f365dc9c2d588e619cea8f89dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37844
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-14 16:50:07 +00:00
Ben Clayton 8121fe3367 Add missing doxygen comments
Change-Id: Ia4b1a5bc1d046633a7f1f91e23659d237d35e640
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37842
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-14 15:52:52 +00:00
Ben Clayton 1f14595723 reader/wgsl: Remove duplicate lexer logic
See:
https://dawn-review.googlesource.com/c/tint/+/37780/1/src/reader/wgsl/lexer.cc#750

Bug: tint:286
Change-Id: I6d39fdfefad619beb65ad1d496b27925da3db8ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37840
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-14 14:15:02 +00:00
dan sinclair 904c5b9621 Add texture_storage_yy parsing.
This CL adds support for the decorated texture storage tokens. The old
_ro_ and _wo_ tokens still exist until downstream users are updated.

Bug: tint:286
Change-Id: I4ddc50be3b22bd3feeab41b3b4fe4ded63e6e59a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37780
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-14 08:34:46 +00:00
Ben Clayton 395ec2c4ae writer/spirv: Add TextureStorageWithDifferentAccess test
Checks that multiple texture_storage types with different access modifiers only produces a single OpTypeImage.

This was broken before Ia944ed8

Bug: tint:286
Change-Id: Idbcd0189d46b78b31d5ec38f355d2369cb86327a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37707
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-13 19:28:12 +00:00
dan sinclair d50a3041fa Remove access control from StorageTexture.
This CL removes the access control value from the storage textures and,
instead, wraps in an type::AccessControl. This matches the current spec
where the access is an annotation on the type as opposed to part of the
type.

Bug: tint:286
Change-Id: Ia944ed8557fbf490d78db2a1b49c31d0aba08728
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37740
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-13 18:48:11 +00:00
Ben Clayton 57166264e0 Fix ValidTextureOverload enum names for kSampleCompare
For some stupid reason, these were all incorrectly prefixed with kSampleGrad, despite the test data all being correct.

Bug: tint:140
Change-Id: If556194d06c7596419a9e7b83165361bb19c7f44
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37705
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-13 16:36:51 +00:00
Ben Clayton 7c5980991a writer/[hlsl,msl]: Emit a implicit return for entrypoints
WGSL no longer requires a return statement at the end of each function, and the generated entrypoint functions are not valid without a return.

Fixed: tint:446
Change-Id: I702e4217f4ac41013e30927d532895c6835f6ca9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37704
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-13 16:34:51 +00:00
dan sinclair 1c200cffd0 Remove outerProduct.
The community decided to remove outerProduct from WGSL. This Cl removes
the pieces from Tint.

Change-Id: Ib1735867e4a7ca852a72549fc8c9bd86e8de22b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37600
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>
2021-01-12 22:00:58 +00:00
Ben Clayton 8f4784006e writer/spirv: Validate SPIRV for all texture intrinsic functions
Finds brokenness.

Change-Id: I1280d456dfe0e4296100e40eef4fb0a17d3d047a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37450
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 21:52:50 +00:00
Ben Clayton 72114bd61b writer/spriv: Cast level parameter to f32 for depth texture sampling
SPIR-V expects a f32, while WGSL has an i32 type for these.

Bug: tint:143
Change-Id: I8e724f24f12154f57cddfd01dfd727e440ca8450
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37449
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 21:42:28 +00:00
Ben Clayton 9a9aa58ddd writer/spriv: Extract first element from depth texture reads
These operations return a vec4, when WGSL expects a single float scalar.

Fixed: tint:438
Change-Id: I4e16190155f80481897ad7db8b96ed3e58a7bfe3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37448
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 21:39:19 +00:00
Ben Clayton ecad052dac writer/spirv: Use ConstOffset instead of Offsets
Offset requires the ImageGatherExtended capability, where as ConstOffset does not. WGSL enforces the offset range required by SPIRV.

Bug: tint:143
Change-Id: Ia098010ecdb8a4a01999b4e9a6faabf3f4d1251f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37447
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 21:37:28 +00:00
Ben Clayton 2dbd556a18 writers: Duplicate cube height for textureDimensions()
All shader backend languages describe cubes as width / height, but give no way to query depth. WGSL however returns a vec3<i32> for cube textures when calling textureDimensions().
As cube textures must be square (width == height == depth), just replicate the height for the depth.

See https://github.com/gpuweb/gpuweb/issues/1345

Bug: tint:140
Bug: tint:437
Change-Id: I76ef18ee4bd8b53d5f9d9d3f1c10c3f7cb23e137
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37446
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 21:20:48 +00:00
Ben Clayton ecc2cdfb61 writer/spirv: Use OpImageQuerySizeLod for non-MS images
Fixes validation error:
`Image must have either 'MS'=1 or 'Sampled'=0 or 'Sampled'=2`

Bug: tint:140
Bug: tint:437
Change-Id: If6d7e86aeb7767b212debf94bcae9ee2ce8ad209
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37445
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-12 21:18:58 +00:00
Ben Clayton d1aef67011 writer/spirv: Fix storage class and add decorations for texture test cases
These are required for correct SPIR-V emission.

Bug: tint:444
Change-Id: I6d25dcc6e06af7f9ca9f250758b7901171923773
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37444
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 20:14:18 +00:00
Ben Clayton 50c5fa1100 writer/spirv: Refactor IntrinsicTextureTest.OutsideFunction_IsError
Use the same builder helpers as IntrinsicTextureTest.Call, significantly reducing boilerplate

Change-Id: Idb37a1704b9ed76c3872d14003ff279b2955d18b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37443
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-12 20:09:42 +00:00
David Neto 559f4e66d5 Remove stdout output from test
Change-Id: If1c4b72f636f7aa9d8fac81b5172dd050b06dc32
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37500
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>
2021-01-12 18:25:58 +00:00
David Neto 4651a6ee8b spirv-reader: explicitly reject combined-image-sampler
This was already rejected, but with a not-very-useful message.
Error out more consciously and issue a higher level, more informative
error message.

Fixed: tint:442
Change-Id: I3643b98d17f55b44b9dcf86aa828010bb39fcd8e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37242
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>
2021-01-12 15:24:18 +00:00
dan sinclair 987376cd21 Revert the namer changes.
This CL reverts the changes to use the top level namer in the various
backends. This is causing issues when rolling into Dawn in the case
where the tint generator is used to create SPIR-V which is sent to
SPIRV-Cross but then generator and inspector aren't used. The entry
points end up being incorrect as SPIRV-Cross gets the renamed entry
points.

Change-Id: I4749e1d773f2bd9edcce83e63555f07a443d5ca5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37342
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-12 04:34:53 +00:00
dan sinclair b91e8a9fbe Add a Unsafe SPIR-V generate call.
Currently Dawn may use the tint generator or the SPIRV-Cross generator.
In the case of SPIRV-Cross, we need to generate the SPIR-V with the
original names otherwise SPIRV-Cross won't be able to match up the entry
point name with the names in the shader.

Change-Id: Ica473030009b282fee352f2d1c1acc93f1db592c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37222
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-12 02:59:12 +00:00
dan sinclair 03f38e0cd9 Update new entry points to use correct namer.
This CL fixes up a merge conflict which accidentally used the Unsafe
namer instead of the Mangle namer for the temporary API to allow rolling
into Chrome.

Change-Id: Id3b932d29fe15ab64347350f5b36b3d9efeffbdf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37300
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-11 22:07:02 +00:00
Ben Clayton f6866a2ffc Add std::hash<tint::Symbol> specialization
Allows symbols to be used as keys for std::unordered_map and std::unordered_set.
Replace all map / set use of uint32_t for Symbol, where applicable.

Change-Id: If142b4ad1f0ee65bc62209ae2f277e7746be19bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-11 22:02:42 +00:00
Ben Clayton 4527a512eb TypeDeterminer: Fix type map iterations
`DetermineStorageTextureSubtype()` may add types to the module while these types are being iterated over, leading to UB.

To work around, collect all the storage texture types into a vector first, and iterate over these.

Change-Id: Ib94b1df52d6ccbbf635a6d89eeeabef46ba03416
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37261
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-11 21:14:22 +00:00
Ben Clayton d221738e20 Add diag::Formatter::Style::print_newline_at_end
Automatically prints a newline at the end of the last diagnostic in a list. Defaults to true.

Disabled for many tests that assume no newline at end of string.

Change-Id: Id1c2f7771f03f22d926fafc2bebebcef056ac5e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-11 21:09:22 +00:00
Ben Clayton 4a0b9f77ef Implement textureDimensions()
SPIR-V reader TODO.

Bug: tint:140
Bug: tint:437
Change-Id: Ia3a6cb0b36142142d3dc8662281e1860c609c82b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36980
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-11 21:07:32 +00:00
dan sinclair c3c70f848a Fix const-ness of inspector constructor.
This was changed originally, but we no longer need the module to be
non-const for the Inspector. Set it back to const to fix the Chrome
roll.

Change-Id: I68166a7a687249cab5c344167386144554b7d175
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37221
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>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 20:01:12 +00:00
David Neto e86fd505e4 Fix doxygen comment
Change-Id: I5977c7fe09f80e9da9438e7842fdfdf44346c839
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37220
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>
2021-01-11 19:17:59 +00:00
David Neto 3f245ed362 spirv-reader: convert arity of textureLoad on depth texture
Fixed: tint:439
Change-Id: I151e388a1ea11bdcb5cebf0441a73ddcaf8a6f54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37063
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 19:04:49 +00:00
dan sinclair 2dc1ef47e0 Switch default to the MangleNamer.
This Cl updates all of the generators and the inspector to use the
mangle namer by default.

Change-Id: Id6811d76bf2475a2c2a2864fb8fc0f43e95a6e65
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36944
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 16:24:32 +00:00
dan sinclair a8d9755053 Allow setting the namer into the inspector.
This CL adds an extra constructor to the inspector to change the namer
user. The inspector tests are then updated to use the test namer.

Change-Id: Ibc91de89b52161dc125b38d65e445b5833ad6c18
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36943
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 16:24:32 +00:00
dan sinclair b920e604b2 Change generators to take a pointer instead of move.
This CL changes the generators so we don't have to move the module into
the generator. This will then allow calling the demangler at a later
point and still having access to the module.

Change-Id: Icad16ddb2b89921cbb174cf7fec520c410139285
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36942
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 7d152e0936 Use TestNamer in the SPIR-V backend.
This CL updates the SPIR-V generation tests to use the TestNamer.

Change-Id: I6a1d9a4c41f080ba3518509864bb06f1629ab0a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36941
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair f4bc0e7337 Use TestNamer in HLSL tests.
This CL updates the HLSL tests to use the test namer and fixes up places
where the incorrect name was output.

Change-Id: I8510d1ff5a57f3a0996dc9c7c8478775ef141105
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36940
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair f74b90b3dd Use a test namer in the MSL generator.
This CL updates the MSL generator to use a test namer, the various
places where the incorrect name was emitted have been fixed.

Change-Id: I20c990bdddc4f0580b09269920abe8376fa3ca07
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36900
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair c8c31560de Remove name fields
This CL removes the name fields from the various AST nodes now that the
symbols are used everywhere.

Change-Id: I73e8fa8958aa6e6f0159b12b63176b12c418f525
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36762
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 16:24:32 +00:00
dan sinclair e65e4bd2c5 Remove IdentifierExpression::name().
This CL removes the name method from IdentifierExpression. The usages
have been converted over to the symbol.

Change-Id: Id751c2fc4a43bd5414fbaf8a8a66ecffb3838e48
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36801
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 4ac6568821 Remove Function::name().
This CL removes the function name accessor and changes all usages to use
the symbol.

Change-Id: I19b92bf1bc557ba14e68ef8cb381487a4ad1f7ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36821
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair eb737c25db Remove StructMember::name().
This CL removes the name accessor from the struct member. Usages have
been replaced with symbol usages.

Change-Id: Idd9c5b34f0b5503ffee84e0c82d69aa65b1df7ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36820
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 16:24:32 +00:00
dan sinclair e76a86a22c Remove StructType::name()
This CL removes the name accessor from the StructType. All usages are
updated to use the symbol.

Change-Id: I65d793e9609a1663facce955bdb89e60f11f382a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36800
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 1d967e3228 Remove the AliasType::name() getter.
This CL removes the name() method from AliasType and replaces with
usages through the Symbol.

Change-Id: I50a85e4262e488adf935b9a484214fc85a966301
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36781
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 396b02342f Remove Variable::name().
This CL removes the name getter from the Variable class. All usages are
updated to use the symbol.

Change-Id: I3e4d86d2124d39023cad6113c62230c1757ece71
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36780
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 197a1b943d Use the top level namer in the SPIR-V backend.
This CL updates the SPIR-V backend to use the top level namer.

Change-Id: I67566d7674d5366c82c99d6fbb985805a2a9a5b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36720
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair f3e3586835 Use namer in the Inspector.
This CL adds the namer to the Inspector when getting the remapped name.

Change-Id: Ic5ed8c50a24b7a1cc303767d049a358181d27603
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36661
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 8d6e625ef4 Convert HLSL to higher level namer.
This CL switches the HLSL generator to use the top level UnsafeNamer
instead of a custom namer.

Change-Id: I7643ee6586955ed2bc493104004fb9f9c524e951
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36660
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 05b64849b2 Convert MSL generator to unsafe namer.
This Cl updates the MSL generator to use the unsafe namer internally.

Change-Id: Ibeea747da1d7675c05a0dcb2416fbd491bb5d64b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36581
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 795b6b5a28 Convert ScopeStack over to symbols.
This CL converts the ScopeStack to use a Symbol instead of a string as
the accessor.

Change-Id: I2893003bc119c86c4822732ef36c7393e4be1e79
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36580
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2021-01-11 15:10:19 +00:00
David Neto f51d965bef spirv-reader: Reject dref sampling with Bias or Grad
Bias and Grad image operands are not supported for
depth-referencde sampling.

Fixed: tint:440
Change-Id: Ic2bf995f7c7b791b8e3a7ceb3514b10220dda8a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37062
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 14:53:29 +00:00
David Neto 1e01c2c116 spirv-reader: rename variable
Rename the state variable describing whether the "Level"
suffix should be used to indicate the level-of-detail variant
of a texture builtin.

Bug: tint:3
Change-Id: I21fdfcace06575e7f9586d7bfc22200f9c1176fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37004
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>
2021-01-08 15:44:44 +00:00
David Neto 8144af91b4 spirv-reader: ignore PointSize builtin declared at module-scope
Fixed: tint:434
Change-Id: Ia29d0f7227e838fc5f9dd4ca521b5fd6b9a88637
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36761
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-07 01:38:41 +00:00
Ben Clayton 9bbf8252a9 wgsl: Treat // as comment
Also support # as comments for now while we migrate.

See:
https: //github.com/gpuweb/gpuweb/issues/1262
https: //github.com/gpuweb/gpuweb/pull/1326
Change-Id: I3547f575c35f4fd46b95f0f2d8b79f4015364c83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36680
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-01-06 19:54:01 +00:00
Ben Clayton 40b4928a73 Implement clamping of runtime array accesses
Bug: tint:252
Change-Id: I2b32ab9d69ca39b6178fc4e94ccd090516a37c98
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36620
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-06 14:33:31 +00:00
Ben Clayton e9d7f7e640 src/transform: Reimplement tests in WGSL
Easier to read and write, and ensures that the tests exercise valid AST instead of synthetic structures that can never exist.

Change-Id: I5d361ef96383c71943a424f5765952f21d740042
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36422
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-01-06 12:57:41 +00:00
David Neto 6cad63c2ad spirv-reader: support OpArrayLength
Fixed: tint:431
Change-Id: I727ca8200118e0b93b42c5f7d9e97bc4afd97830
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36460
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>
2021-01-05 21:21:50 +00:00
Ben Clayton 9894867678 reader/wgsl: Fix parsing of matrices.
https://gpuweb.github.io/gpuweb/wgsl.html#matrix-types :
"matNxM<T>	Matrix of N columns and M rows"

Fixed: tint:432
Change-Id: Ib8fdb836b02c5e6be87acea850f095355545adbd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36421
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 20:53:10 +00:00
David Neto a35b57f91f spirv-reader: rename to isNan, isInf
Fixed: tint:418
Change-Id: I09185880c838d437f84c4ef85528b4d807c0b340
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36440
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 19:22:30 +00:00
Ben Clayton ca2c1ed370 Validate that runtime arrays aren't used as parameters
Remove the logic around `arrayLength()` being passed anything but a member accessor. Runtime arrays types cannot be used for variables nor parameters.

Add validator logic and test for runtime array parameters.

Adjust the validator error message so it doesn't include the field / variable name. This read weird, and the same information is already provided by the source.

Bug: tint:266
Bug: tint:252
Change-Id: Iecedb0524e10a67b4f8ad15635d67fe61e9d69d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36420
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 18:20:40 +00:00
David Neto 938ff5f482 spirv-reader: ImageQuerySize can be on readonly image
Fix how handle usage is collected.  OpImageQuerySize
is usable for *any* image that is either MS=1 or Sampled=0 or 2.
(Sampled=0 is not allowed by Vulkan).
So it's usable by storage images or multisampled image.

OpImageQuerySizeLod is usable by Sampled=1 MS=0 images, ie. sampled
images.

Fixed: tint:422
Change-Id: Ibfbcab2daa8b38f17758a0428a08cb9660496bac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36061
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-05 16:10:40 +00:00
Ben Clayton 1637cbb868 cleanup: Refactor tests to use ast::Builder helpers
Change-Id: I5bf1dac217c9c6192c0637d98c4a38196d41cbe8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36382
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 15:44:39 +00:00
Ben Clayton dbfe2de982 reader/spirv: Move common test name to fixture name
Helps with test grouping, and more importantly fixes a lint error about
the line length exceeding 80 characters, which cannot otherwise be
sensibly fixed as the formatter wants the fixture name to be unsplit.

Change-Id: I54b32e3516250b4064cd66a618f2239982aaf2d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36381
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 15:41:25 +00:00
Ben Clayton e6e704145b Remove all Source{} smell from tests
Switch all remaining AST stack allocations in tests to using create<T>() which will automatically inject the current Source as the first parameter.

Most remaining uses of Source{} in the codebase are places where we need to fix.

Bug: tint:396
Change-Id: I24655800b50d6ad52e682a7339022972e9b354d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36380
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-05 15:29:29 +00:00
David Neto 9a644c7903 spirv-reader: Restrict use of ConstOffset
Only permitted for image sampling (and later gather).

Only permitted for 2D, 2D Array, and 3D textures

Fixed: tint:408
Change-Id: Ib97bd17e45046ec8a2147b46899bf52ad9a8f883
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35980
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-17 20:32:12 +00:00
David Neto 3ec1d5eae7 [inspector] test interference between sampled and multisampled resources
Change-Id: Icea3b4acfa407110d9ae078e9b3ea13fb13ca31e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32561
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-12-17 17:04:01 +00:00
David Neto d1469c60c1 spirv-reader: fix arity for depth texture builtins
Texture buitins on depth textures always result in scalar f32.
Corresponding operations in SPIR-V always result in vec4<f32>.

When translating to Tint AST, wrap the generated texture builtin
in a type constructor to vec4, with the builtin result as the
x component.

Fixed: tint:411
Change-Id: Idf26a1cbc7e875bc8a97bf3c0b342c0220c6d4b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35900
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-17 16:29:31 +00:00
dan sinclair a57f842be9 Add Symbol to Variable.
This CL adds a Symbol to the Variable AST node along side the name. The
name will be removed in a future CL.

Change-Id: I1c05e5595392b1c4a0afa82387d97b2b4472bade
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35881
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-16 21:42:30 +00:00
dan sinclair b5839939e1 Cleanup code using RegisterSymbol
This CL goes through and converts things which call RegisterSymbol to
use the helper builders. Several variables are also updated to use the
helper as it will need RegisterSymbol in the near future.

Change-Id: Ib5a8e8be54c1eaad123384fab09f6625421d9fcd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35880
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-16 21:38:40 +00:00
David Neto e5d288be5e spirv-reader: ignore storing 1.0 to PointSize builtin
If you try to load it, return 1.0f instead.
Some cases of copy-object of intermediates are unhandled,
and will error out.

This is being done as an aid to porting GLSL Vulkan shaders
that do store 1 to gl_PointSize.

Fixed: tint:412
Change-Id: Ia33dc70bca630dccfbf11644f71d6be4b3f43f1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35861
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-16 20:50:10 +00:00
David Neto e9b90f755b spirv-reader: generalize skip reasons
Bug: tint:412
Change-Id: Ie9dd230361019ec929f4d36215e7058a893bbe0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35860
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-16 20:42:10 +00:00
David Neto 99688918e1 spirv-writer: sampled type must be f32,i32,or u32
Fix emission of the sampled type for write-only storage images.

Fixed: tint:415
Change-Id: I83b74272630f16258295a354f952ce19c2eae57a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35863
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-16 20:40:53 +00:00
dan sinclair 181d8baf8f Add helper for function creation.
This CL adds a Func helper to the ast builder class. The helper is then
used through the various files to simplify function creation.

Change-Id: Ie93777586e9311d82cff5932dfba2c4ca763ae08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35823
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-16 15:15:40 +00:00
dan sinclair 5e5e36e7d2 Add helper to create StructMember nodes.
This CL updates the ast::Builder to provide help creating struct members
and decorations. The helpers are then used throughout the various files
to simplify the code.

Change-Id: I53af4578190499d9ae2623073f8a44182954e5d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35821
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-16 14:41:00 +00:00
dan sinclair 8b40a67cf7 Rename Index and Member builder helpers.
This CL renames Index to IndexAccessor and Member to MemberAccessor.
This keeps the naming consistent and makes room to use Member for
StructMember.

Change-Id: Icbba3a39ed5e079cd83d8f512fff69494dfac10d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35824
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-16 11:49:10 +00:00
Sarah Mashayekhi 523b2193e3 fix gcc error: changes meaning of Transform
Change-Id: Ie40e175c414928414a8b791b9a78a2e634bbd339
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35822
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-12-15 22:26:08 +00:00
Ben Clayton d94cbf6023 reader/spirv: Fix permissive GCC warning
... about getters having the same name as the type they return. Prefix getters with `Get`, remove unused ones.

Also remove the cases field, the compiler helpfully now tells us it is unused.

Change-Id: I7e3fcdae3818cee5aae8b70b48e9b0507a8d3b45
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35743
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-12-15 21:06:28 +00:00
David Neto 035c524486 spirv-writer: Exit gracefully when bad inst outside function
Change-Id: Icb7c50d498808cc2c5a6703163a07d224aca669d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33940
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-15 20:29:08 +00:00
dan sinclair 36e22f0f3b Add symbol to member name.
This CL adds the symbol to the struct member. The name will eventually
be removed when the symbol is used everywhere.

Change-Id: Ie97f61509804992b44b22396773a635efbc4458e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35780
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-15 16:43:18 +00:00
Ben Clayton be96376d8e ast: Make all non-semantic fields const
Annotate those that are set by the TypeDeterminer as "Semantic Info"

Bug: tint:396
Bug: tint:390
Change-Id: I0705c64e8e23d97a6430230728f82e64dd92efb7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35165
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 14:52:38 +00:00
Ben Clayton 9df857de9a Start cleaning up tests (5/N)
Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: Ife7da25a4171cce404d496cb63acc34522316d81
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35742
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 14:11:48 +00:00
Ben Clayton 7e805ba44a Start cleaning up tests (4/N)
Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: I07fdefdbbcc4a9289069e2e494f475c7baea7531
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35741
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 14:10:28 +00:00
Ben Clayton 983e8dd938 ast::Builder: Remove zero-init Source constructors
Builder now has a SetSource() method that can be used to specify the source for the future built nodes

Bug: tint:396
Bug: tint:390
Change-Id: I9b49bc31c4bf92b3baf5946c413dfe770de0e23d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35740
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 14:07:58 +00:00
Ben Clayton e075102931 Fix HLSL emission of RWTextures
These must have a element type in a declaration statement for the object. See: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-rwtexture2d

Change-Id: Ia13fb37351a7cf3f043e152d5f7a216e3c2bf88e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35380
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 13:11:38 +00:00
Ben Clayton 8df62847f4 spirv-writer: Emit the DepthReplacing execution mode
... if the kFragDepth builtin is referenced.

Bug: dawn:399
Change-Id: I17a4a50d7aa03fd341dec4787a93566c61b59320
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35500
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-12-15 12:36:08 +00:00
Ben Clayton 11276ef97d spirv-reader: Fix texture[Load|Store] with lod
Don't suffix texture intrinsics with `Load` unless it's a `textureSample`.

Discussion:
d46b4fa3ca (diff-709b5c343d59ae10cbabe69f9df1eee9e2dbb6e9d848632fa94357083d6e0a34)

Bug: tint:109
Bug: dawn:399
Change-Id: Ic42ef9f8681dd04bd8f4c901c6d4cdc5f4166d26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35423
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-12-15 12:34:38 +00:00
Ben Clayton 0b930237ec ast: Clone symbols instead of ever-growing
The interface for cloning a module was made significantly more complex in https://dawn-review.googlesource.com/c/tint/+/35502/ as some of the transforms required constructing symbols before the clone. This was temporary solution in 35502 was to copy the symbol table, then construct the new types, then perform the clone. This lead to a really messy callback interface, that was extremely error prone (e.g. lamda-capturing stack variables from the initializer callback that had been unwound).

Instead, clone the symbols as they're encountered. This may produce an entirely different set of identifiers, but no longer ever-grows the symbol list, and keeps the interface clean.

Bug: tint:396
Bug: tint:390
Change-Id: I54affd68ac3b730b649af9b47eba685c8a1d784a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35663
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 12:32:18 +00:00
Ben Clayton f42b90dbe1 traits: Replace FirstParamType with ParamType
Allows you to infer the N'th parameter type of a function.

Change-Id: Iab7065cb37dbf1332cef601bca91894b8c6b4edf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35662
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-15 12:06:51 +00:00
Ben Clayton 1523f5c276 Start cleaning up tests (3/N)
Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: I7b3188fa8239bf11e88ff6b396a57c23d76a3152
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35660
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-14 22:30:57 +00:00
Ben Clayton 5180e16386 Start cleaning up tests (2/N)
Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: Ia29fe615ac8975252a34f1252c363109ee382d72
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35508
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 22:27:37 +00:00
Ben Clayton 7eaf4b57ae Start cleaning up tests (1/N)
Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: Ie404f3a963ed8c40e056590ebb4ae36f67a92753
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35505
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 22:08:27 +00:00
Ben Clayton f4daa505ec ast: Inject Source parameter into create calls if not provided
This will be used to clean up some of the gross Source{} littering everywhere.

Bug: tint:396
Bug: tint:390
Change-Id: I63311378ac3ef6d246ac972b3335a50974d583bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35504
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 21:46:37 +00:00
Ben Clayton 5aad70a069 Move all Source constructor params to be the first
This consistency can be utilized by the ast::Builder to inject the source parameter if it isn't provided.

Bug: tint:396
Bug: tint:390
Change-Id: I2f19002131e79daae799b8cbe918eb192d6bfc75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35503
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 21:10:07 +00:00
David Neto 7b2f8d010f spirv-reader: reject sampling operations on non-float textures
Fixed: tint:350
Bug: tint:109
Change-Id: I754ff4ade03dabb70a1eb5706a65c48a0a7d35a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35581
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-14 20:34:37 +00:00
Ben Clayton d408f2465a Remove BlockStatement::insert()
Bug: tint:396
Bug: tint:390
Change-Id: I719b84804164fa801ded505ed56717948f06c7a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35502
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:31:17 +00:00
Ben Clayton db5ce658b5 Remove BlockStatement::append()
Bug: tint:396
Bug: tint:390
Change-Id: I3b558a8961f9890f24d1aa3d6647ec095e5fe1cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35421
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:25:27 +00:00
Ben Clayton ed70caf6a5 Improve error messages raised by SpvParserTest
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);

is a less-idiomatic way of writing:

    EXPECT_EQ(xxx, yyy);

The latter also provides a diff when two strings do not match.

Refactor these to:

    auto got = xxx;
    auto expect = yyy;
    EXPECT_EQ(got, expect);

So that the error message clearly shows which one is the generated, and which one is the reference.

Change-Id: I781437ee63abdff3a67798b09e958be603c21313
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35507
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:16:29 +00:00
David Neto f9e8da1d06 spirv-reader: convert unsigned ConstOffset
Bug: tint:109
Fixed: tint:348
Change-Id: Ie3d1a6b6276ccb5184c5138d38931f7674324d59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35580
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-14 19:50:49 +00:00
Ben Clayton b833f1572b reader/spirv: Remove use of BlockStatement::append()
Introduce `StatementBuilder`s , which may hold mutable state, before being converted into the immutable AST node on completion of the `BlockStatement`.

Bug: tint:396
Bug: tint:390
Change-Id: I0381c4ae7948be0de02bc13e54e0037a72baaf0c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35506
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-14 19:48:47 +00:00
David Neto 2353bd0d3d spirv-reader: convert coordinate type when unsigned
In SPIR-V, coordinates for ImageRead, ImageFetch, ImageWrite are
integral.  When they are unsigned, they must be converted to signed.

Fix tests for image sampling and dref sampling that used integer
coordinates. SPIR-V requires them to be floating point.

Bug: tint:109
Fixed: tint:346
Change-Id: If33c8970b9d8f7d934d3e582194fe6ed83eff7e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35560
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-14 17:31:37 +00:00
dan sinclair 24bbbbb25f Add Symbol to struct type.
This CL adds a Symbol to the struct type along side the name. The name
will be removed in a future CL when the symbol is used everywhere.

Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620
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-12-14 16:01:37 +00:00
Ben Clayton ce33d42b41 ast: Remove no-arg constructor from Node
Bug: tint:396
Bug: tint:390
Change-Id: I730738dd6bafa946dc66ee8a15c48b3a3f73e5fc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35164
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-12-12 13:00:34 +00:00
Ben Clayton bcf37549c8 ast: Remove Struct constructors that don't take a Source
And swap the `decorations` and `members` parameters, as decorations come last for other constructors.

Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9b814c1de24b6c987f0fbb9e6f92da7c352caa2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35163
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 12:52:44 +00:00
Ben Clayton 4543d1a232 ast: Remove StructMember constructor that doesn't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9f8f7428d2308c3b1a9a8d2137e2e3c6d1d13e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35162
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 12:18:04 +00:00
Ben Clayton bbefff63a3 ast: Remove statement constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 11:58:44 +00:00
Ben Clayton 1ff59cd0e2 ast: Remove expression constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I7f823e2489101b43c1b21a6b89c248695a3f35b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35160
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:38:13 +00:00
Ben Clayton 5ed161b2d9 ast: Add Source argument to literals
Bug: tint:396
Bug: tint:390
Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:35:43 +00:00
Ben Clayton 604bc72dd9 ast: Remove Node::set_source()
All nodes that don't have a Source constructor will need to have one added.
We can then find all missing Source mappings with a search for `Source{}`

Bug: tint:396
Bug: tint:390
Change-Id: I06f9689d4da0f3fd1bd757c7358dcc65f15dc752
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35018
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:24:53 +00:00
dan sinclair 4226b6a1d8 Add Symbol to alias.
This CL adds a Symbol alongside the name in the Alias type. The name
will be removed in a future CL.

Change-Id: I23fa77566cc7a2aead783b64c34c0cc3195df24b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35461
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-12-11 19:35:03 +00:00
dan sinclair 6b59bf45aa Add a symbol to the Identifier AST node
This CL adds a Symbol to the identifier to represent the name. The name
still exists but will be removed in a future CL when the namers are in
place.

Change-Id: Ic3cc8ad0d99e3bea6eb1ff1ce212e7de67991aec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35460
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 19:16:13 +00:00
David Neto 5b3c9f1c62 spirv-reader: refactor, add ToI32 helper
- The create function is available locally without needing
  to go through ast_module_.
  But go through ast_module_ during member initialization.
- Add ToI32 helper.
  - Use it during possible conversion of the sample index

Bug: tint:3
Change-Id: I8224119f780486d769697910dfa3dd9fb5413259
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35541
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 18:35:43 +00:00
dan sinclair 2d0282b308 Add a demangler
This CL adds a simple demangler to convert the `tint_symbol_YYY` back to
the original symbol name.

Change-Id: I532ed13dc4c52e0f0e3568b8b7d8d0a5c67d8472
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35440
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 18:29:03 +00:00
dan sinclair a41132fcd8 Add a symbol to the Function AST node.
This Cl adds a Symbol representing the function name to the function
AST. The symbol is added alongside the name for now. When all usages of
the function name are removed then the string version will be removed
from the constructor.

Change-Id: Ib2450e5fe531e988b25bb7d2937acc6af2187871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35220
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-11 18:24:53 +00:00
David Neto cd9e5f6e91 spirv-reader: Support multisampled textures
Only ImageFetch is supported.

Converts the signedness of the sample operand as needed.

Bug: tint:109
Bug: dawn:399
Change-Id: I1d00ff4452af123457bb1841d872afcf2c591c48
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35540
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-12-11 18:19:33 +00:00
Ben Clayton a80511e021 ast: Merge DecoratedVariable into Variable
Remove all Variable setters (with exception to set_storage_class() which is called by the TypeDeterminer)

Bug: tint:390
Change-Id: I172667e21e2b02e85dcea6703aa1e608ec718250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35015
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-11 13:07:02 +00:00
David Neto ccc67252ff spirv-reader: support OpBitCount, OpBitReverse
Bug: tint:3
Change-Id: I81580136621ab51a9852e1d692ddad2457b9aab9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35340
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 18:51:51 +00:00
dan sinclair d8591088fb Cleanup some includes
Change-Id: I4f6a871cb38a2af53583c582831990c2d76e38b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35102
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-10 18:42:41 +00:00
dan sinclair 1e0472cdba Update namer to use symbol table.
This Cl updates the various namer objects to work off the symbol table
instead of names.

Change-Id: I94b00a10225d0587f037cfaa6d9b42e2a8885734
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35101
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-10 18:40:01 +00:00
Ben Clayton 591268db48 Implement textureWrite()
Bug: tint:368
Bug: tint:140
Bug: tint:143
Bug: tint:144
Bug: tint:145
Bug: tint:146
Bug: tint:147
Change-Id: I1b6943d8663fbac8fbaa77a4804afb5a20fdb5e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35320
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 18:39:41 +00:00
Ben Clayton 3a7bba8c98 Rework the FirstIndexOffset transform
So that it transforms more on clone than in-place.

Bug: dawn:548
Bug: tint:390
Change-Id: I0127bc02c4e0e88c924042c491d274363422cc52
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35420
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 17:47:41 +00:00
dan sinclair 89caee197c Add a symbol table.
This CL adds a table which maps symbols to strings. This will allow us
to remove the use of std::string in the various AST nodes and refer to
the symbols instead.

Change-Id: I902641b3e546a2a44b3b2a39ce4f019cdcbeacc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35100
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-10 16:56:02 +00:00
David Neto 287f6f12ef spirv-reader: support more integer builtins
Support:
 - SAbs
 - UMax, SMax
 - UMin, SMin

Add tests for operand and result conversion for UClamp.
SClamp was already tested.

Bug: tint:3
Change-Id: I9b9278843ca5243991b330b27764756137da4ee4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35302
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-10 15:22:51 +00:00
David Neto 3ca59444cd spirv-reader: remove redundant disabled test
Testing result signedness conversion was already covered
in https://dawn-review.googlesource.com/c/tint/+/35180

Change-Id: I2f7b1caf512ceb81fbe2ea6a2037de61dea25c96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35360
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 15:22:11 +00:00
Ben Clayton 7fbd67a132 Fix CMake build when TINT_BUILD_FUZZERS=1
The `libtint-fuzz` target needs to be defined before reference.

Change-Id: I030f4b3b93a095bd353aa6cff402e351d5b77dca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35381
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 14:33:31 +00:00
Ben Clayton e1bea58ca4 Fix HLSL emission of cbuffers
Despite the documentation claiming otherwise, the DXC doesn't allow
these to be anonymous.

Change-Id: I853d11970890106b8fd4d6b8bb321940f0658bd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35281
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 13:09:21 +00:00
David Neto c82eeeef07 re-enable Tint testing
Fix a typo in CMake variable naming

Change-Id: I46049669f5fdcf07cbfb2ec11ad99de212a8edc4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35301
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-12-09 18:15:30 +00:00
David Neto 5213c400eb spirv-reader: convert signedness of texturing result when needed
Fixed: tint:382
Change-Id: I786e1f5d5d122a82ef29c733e514bf3b45651c5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35180
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 17:09:50 +00:00
Ben Clayton 7f04e5c1e2 Implement textureLoad()
Bug: tint:140
Bug: tint:143
Bug: tint:144
Bug: tint:145
Bug: tint:146
Bug: tint:147
Change-Id: I8f41abac2e355c121e8868aa708ae51d0db87665
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34960
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 15:57:00 +00:00
Ben Clayton 7a0daa233d transform: Fix Manager::Run() with no transforms
If there are transforms added to the manager, then Run() would output an empty module. Fix this.

Bug: tint:390
Bug: tint:389
Change-Id: I439fe7a28816761f3702e304ef130b7a6992ecce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-09 15:15:20 +00:00
Corentin Wallez f3717fa249 CMake: Add a flag to control whether to built tint_unittests
Bug: dawn:605
Change-Id: I03860c263746939112e03544fbc3579631423c37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35282
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-12-09 14:47:30 +00:00
David Neto 350330bb46 spirv-reader: Fix signedness for extended instructions
SClamp is the only implemented instruction that is affected, so far

Bug: tint:405
Change-Id: I21c1cdd3e70fc3a64046f0473569ba906048cd37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35240
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:18:36 +00:00
David Neto 6ff8cdb991 spirv-reader: support ldexp
Bug: tint:3
Change-Id: I6a9204b19c5b4d631634b9a585a0081eaead9c1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35046
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:13:46 +00:00
David Neto cb5dd552c2 Fix doxygen for src/transform/first_index_offset.h
Change-Id: I29cee48b3b757373f90768af545a7449f60a5f26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35142
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-12-08 22:15:34 +00:00
Enrico Galli 3d449d2be5 [transform] Add first index offset transform
Adding new transform to workaround D3D's vertex/instance_index always
starting from 0

Bug: dawn:548
Change-Id: I048f39e76e236570f3ce337a77d804384ee659a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34600
Commit-Queue: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 21:07:24 +00:00
Ben Clayton 6c85272d62 Fix spelling mistake in comment
Change-Id: I559e2348b1d61aa2db8c0cdfd284bd4aa98a86c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34462
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 19:56:44 +00:00
Ben Clayton 3982bb8c28 Update texture intrinsic writer tests for signed params
All unsigned texture intrinsic parameters were recently changed to signed: https://github.com/gpuweb/gpuweb/pull/1271

Update the writer tests to match. The spirv reader side of things will also need to be updated.

Bug: tint:391
Change-Id: I280f223f2556355f4b6538ae1ef446e33b017c9f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34820
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-08 19:39:34 +00:00
David Neto 195917c0be spirv-reader: Support many more float builtins
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Fixed: tint:214
Change-Id: I10f7df66875ccda968fc5654b4f1c1d3a6ac23ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35062
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 14:29:03 +00:00
David Neto eb7865cd0d spirv-reader: Support NClamp, NMin, NMax
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Change-Id: I48503be68128d2a0659bef7057e890cb9c0617ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35080
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 23:45:47 +00:00
Ben Clayton 8b0ffe9185 ast::type: Remove Array::set_decorations
Move to constructor

Bug: tint:390
Change-Id: If6c65b7305db7f9977c0cc9884a8f551e07de050
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35014
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-07 22:19:27 +00:00
Ben Clayton dec971328d ast: Remove unused Struct::set_decorations()
Bug: tint:390
Change-Id: If0aeb618ef15c64e7379501ec88a448bc4d7e015
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35013
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 22:15:57 +00:00
Ben Clayton 602c025aa0 ast: Remove Function::set_body()
Bug: tint:390
Change-Id: I525086868c6470ba39fe8c4ede7390e74c9489ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35012
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:17:47 +00:00
Ben Clayton 2190a8f480 ast: Remove ReturnStatement set_value()
Unused.

Bug: tint:390
Change-Id: If2832da7181e168f8a3bb8c986d8ee2d469b25b2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35011
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:11:47 +00:00
Ben Clayton d0dda258cc ast: Remove ReturnStatement constructors that don't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I2b81929e362ccf75145ebc45028dd973a77ae068
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35010
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:09:57 +00:00
Ben Clayton 321e5a9d7e ast: Remove Variable constructor that doesn't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:08:07 +00:00
David Neto b4b29639a1 spirv-reader: simplify GLSL.std.450 tests
Use variables with names rather than constants
which elaborate to a lot of text in the AST.

Change-Id: Ic284bbd4019e50308c5836768df01c6a9525c004
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35061
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 21:02:27 +00:00
David Neto 201fa87a6d spirv-reader: list missing GLSL.std.450 instructions
Add a TODO for them

Change-Id: I038e4384ae44d87544ae040b2e5ba193415e01b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35060
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 20:55:07 +00:00
Ben Clayton 234b7de460 ast/function: Remove [set|add]_decorations()
Move them to the constructor

Bug: tint:390
Change-Id: I30bb6a1de060b790bf5202194d020d4e3889a307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35008
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:45:14 +00:00
Ben Clayton 9838768599 ast: Remove IfStatement::set_else_statements()
Move it to the constructor.

Bug: tint:390
Change-Id: Ib4ac1a1c83aa59963472ac7c14c9e0cbcf2734e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35007
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:11:24 +00:00
David Neto 4d6635858e spirv-reader: support UClamp, SClamp
Fixed: tint:383
Change-Id: I101370a82379363a4fb1f725e010eedc2da059ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35042
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-07 19:53:54 +00:00
David Neto 4f8b96e13c spirv-reader: texture level and array index are signed
Fixed: tint:394
Change-Id: Ic81c7167d65e7a8d09363a62848b74928fdc2798
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35043
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-07 18:17:14 +00:00
dan sinclair c35176eadf Remove the context object.
This CL strips the context object out of Tint.

Change-Id: Id0dcb9c557b217c03a8d9ac08fc9fe1c799f3fdc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34742
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 16:03:54 +00:00
Ben Clayton bd018d254d Improve error messages raised by SpvParserTest
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);

is a less-idiomatic way of writing:

  EXPECT_EQ(xxx, yyy);

The latter also provides a diff when two strings do not match.

Refactor these to:

  auto got = xxx;
  auto expect = yyy;
  EXPECT_EQ(got, expect);

So that the error message clearly shows which one is the generated, and which one is the reference.

Change-Id: I299204a615aa3e68cd82d19ce892ab33aabe2f08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35006
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 15:57:04 +00:00
Ben Clayton d1398203f9 Remove more unused AST setters
Bug: tint:390
Change-Id: Ia15414e73ba921c0880556f4d43af783f1d497ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35005
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-07 14:53:14 +00:00
Ben Clayton b8a3078bbe Remove DAWN_USE_NEW_TINT_TRANSFORM_API
The legacy code path has now been removed from dawn:
https://dawn-review.googlesource.com/c/dawn/+/34900

Bug: tint:390
Bug: tint:389
Change-Id: Id897bae3d29c7ff5bb0e2e32db1a4b493d4fe715
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35004
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-07 14:23:44 +00:00
Ben Clayton 00b77a80ab Rework all transforms to transform-on-copy
instead of transform-in-place.

This is a public API breaking change, so I've added the `DAWN_USE_NEW_TINT_TRANSFORM_API` define which is used by Dawn to know which API to use.

As we're going to have to go through the effort of an API breaking change, use this as an opportunity to rename Transformer to Transform, and remove 'Transform' from each of the transforms themselves (they're already in the transform namespace).

Bug: tint:390
Bug: tint:389
Change-Id: I1017507524b76bb4ffd26b95e550ef53ddc891c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34800
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-04 09:06:09 +00:00
Ben Clayton 0f37afb74e Refactor transformer tests
Transformers will be moving to a transform-on-copy model, instead of transform-in-place.
Rework the tests to handle this.

Bug: tint:390
Change-Id: Id53a0ba0bd365472940d116bd686e450a29e5028
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34571
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 20:25:29 +00:00
Ben Clayton ad0b2cb841 ast/builder: Add more builder helpers
Will be used by the transforms

Change-Id: Id4cece30f1ef4cbeb7cf4d7ca8d0e775b4ab4c7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34570
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 20:22:59 +00:00
Ben Clayton 8e6cd2e680 Fix doxygen warnings about missing docs
Change-Id: I6bfade1db4b3e1a8c63a0bba16303925554ca6cc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34569
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 18:21:49 +00:00
Ben Clayton 2bc6840d3c Add ast::CloneContext::ReplaceAll()
ReplaceAll() registers `replacer` to be called whenever the Clone() method is called with a type that matches (or derives from) the type of the first parameter of `replacer`.

`replacer` must be function-like with the signature: `T* (T*)`, where `T` is a type deriving from CastableBase.

If `replacer` returns a nullptr then Clone() will attempt the next registered replacer function that matches the object type. If no replacers match the object type, or all returned nullptr then Clone() will call `T::Clone()` to clone the object.

Example:

```
  // Replace all ast::UintLiterals with the number 42
  CloneCtx ctx(mod);
  ctx.ReplaceAll([&] (ast::UintLiteral* in) {
    return ctx.mod->create<ast::UintLiteral>(ctx.Clone(in->type()), 42);
  });
  auto* out = ctx.Clone(tree);
```

This is to be used by Transforms that want to replace parts of the AST on clone.

Bug: tint:390
Change-Id: I80a0e58aa3711f309f58a504f6b6a06f6c546ea1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34568
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-03 18:10:39 +00:00
Ben Clayton 5f8061bd39 Castable: Minor tweaks
Prefix the fully-qualified Unique name in TINT_INSTANTIATE_CLASS_ID with :: as there might (however unlikely) be a nested 'tint' namespace.

Move the test structures in castable_test back into the anonymous namespace. This means `TINT_INSTANTIATE_CLASS_ID` needs to sit outside the anonymous namespace, but prevents global namespace pollution.

Change-Id: I035e9568c081fee120726106dc2150c4990c3881
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34567
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-03 17:44:19 +00:00
Ben Clayton f1f10e6571 Add src/traits.h
Contains some intimidating template magic for inferring the first parameter type of a function or function-like.

Will be used by the CloneContext for transforming the AST while cloning.

Bug: tint:390
Change-Id: I432059d13e65fa0f0f3e52588eb43abe9a4efadd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34566
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 17:14:29 +00:00
Ben Clayton 76d12f0f5a Add EmitVertexPointSizeTransform
EmitVertexPointSizeTransform is a Transformer that adds a PointSize builtin global output variable to the module which is assigned 1.0 as the new first statement for all vertex stage entry points.

If the module does not contain a vertex pipeline stage entry point then then this transformer is a no-op.

Bug: tint:321
Change-Id: I0e01236339d9fa1ceab3622af0931a1199c33b99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34561
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-03 14:54:09 +00:00
dan sinclair 685cb02ea8 Remove internal usage of Context.
This CL removes all internal usage of the Context object. It is still
accepted as a parameter until we update Dawn, but all usage is removed.

The namer has been removed from the SPIR-V backend with this change and
the emitted names reverted to their non-modified version.

Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-02 21:17:58 +00:00
dan sinclair 573d8939f4 [ast] Remove more set methods.
This CL updates the SPIRV-Reader to not require set methods for various
AST expressions.

Change-Id: Ieb9a8fcc1746d3051e5b663559127ca63b45a388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34642
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-02 19:13:48 +00:00
Ben Clayton c15d0a73ee Unrevert "[ast] Remove unused constructors and setters".
Hopefully the trybot issue is now resolved.

This reverts commit 5792783e72,
unreverting commit 4d28b27935.

Change-Id: I2855bf17c5025a3d349e7fce16fdca342517aad3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34564
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 18:48:58 +00:00
Ben Clayton 89ea705766 Add ClassID::Unique template and TINT_INSTANTIATE_CLASS_ID
We're seeing some chrome bots fail unittests in ways that suspiciously
look like dynamic casts are doing Wrong Things.

The ClassID::Of() logic depends on the linker folding away duplicate
compilation unit definitions based on ODR rules. If we were to somehow
end up with different definitions, then we'd have two or more different
ClassIDs for the same T type - leading to issues similar to what we're
seeing.

I'm not entirely sure why/how this could happen - and we've so far been
entirely unable to locally reproduce - but it _might_ have something to
do with the goma cache.

In an attempt to work around this, move the static symbol definition out
of a header-local-static and into the .cc file for each of the types.

Change-Id: If914d3045b9dac6fbe8824dac71153a768cfceb9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34563
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-02 18:19:28 +00:00
Austin Eng 41083cbca4 spirv-reader: Fix bug with passing stack-allocated variable
When handling OpCompositeExtract, the SPIRV reader uses a
stack-allocated U32 type instead of one heap allocated by the
type manager. This causes type determination later to dereference
a garbage address.

Change-Id: I7d60b6dbf8310e53565d7db47eac4dd92b1bbfa0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34684
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-12-02 16:30:38 +00:00
dan sinclair 555696ddd0 Remove unused variables.
This fixes the build when using gcc.

Change-Id: I98b9afcf0b40b692e46f92dc4b71583e41877281
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34681
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-02 15:51:38 +00:00
Ben Clayton f8971ae74d Fixup all doxygen tags
We've been using |blah| in various places to markup code, however this is not doxygen markup. So instead:

* If the code links to a parameter, use `blah`.
* If the code links to a member field, use #blah.
* If the code links to a method use blah().
* If the code is somewhere unlinkable use `blah`.

Change-Id: Idac748a4c2531b5bae77e1a335e3d3ef6fab48b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33787
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-02 15:31:08 +00:00
dan sinclair 5792783e72 Revert "[ast] Remove unused constructors and setters."
This reverts commit 4d28b27935.

Reason for revert: Seeing weird build breakage ...

Original change's description:
> [ast] Remove unused constructors and setters.
>
> This CL removes unused default constructors and various set methods
> from the AST classes where they are not longer required.
>
> Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com

Change-Id: I9d5bf6fd6d47131650c964cad4e17a1cbe86b040
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34682
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 15:18:59 +00:00
dan sinclair 4d28b27935 [ast] Remove unused constructors and setters.
This CL removes unused default constructors and various set methods
from the AST classes where they are not longer required.

Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 14:31:38 +00:00
Ben Clayton fb54145b6f ClassID: Add some comments in ClassID::Of()
Change-Id: I64df4af9cb0de05891fdcca705ecb02562262986
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34461
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-02 13:31:58 +00:00
Austin Eng bf5e6b98cc Add move assignment operators to tint::ast::Module and tint::Context
This enables usage with DAWN_TRY_ASSIGN in Dawn in simplify error
handling.

Bug: tint:306
Change-Id: I91a96b6670341943c26d9972058ecc3ad8162db0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34640
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-02 04:27:08 +00:00
dan sinclair 31f55c6517 Add move constructor to CastableBase.
This CL adds the Move constructor to castable base as the default one is
deleted due to the defined destructor and the Node subclass defines a
Move constructor.

Change-Id: I0eaac140719e74adfab1aeccf6ea663faff031e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34580
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-01 21:59:57 +00:00
Ben Clayton 1b6a8ce165 Post migration to castable cleanup
Change-Id: I5c47b1736bd850548cb1c9c7a6f69242d8626173
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34460
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-01 21:07:27 +00:00
David Neto 782f6a5e3e spirv-reader: support textureLoad
Both OpImageRead and OpImageFetch map to WGSL textureLoad.

Bug: tint:109
Change-Id: I3c99840c2e62c52dcaaf7177773a3c972de90cc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34425
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-01 20:37:37 +00:00
David Neto 91ad3961df spirv-reader: support textureStore
Fixes: tint:381
Change-Id: I401cebcd94b92365037228e0bd50b67bc8d12ab8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34424
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-01 20:33:07 +00:00
dan sinclair 2478ae78bb [wgsl-reader] Remove keywords which aren't in spec.
This CL updates the WGSL-Reader to remove the decoration keywords as
they are no longer reserved in the spec. The old `::` token is removed
as well as namespaces don't exist anymore.

Change-Id: I1dfa16c1d7e4866f6c2f9ea7b4f93a48ff5a23d7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34481
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-01 20:10:47 +00:00
Ryan Harrison 15f80a706c [parser] Remove assert about input validity
This assert is only enforcing that the input is valid, not that it is
safe. This should be deferred until validation.

Bug: dawn:578
Change-Id: I083a62292ff7ca0fc35080d8c66dabf3188c7bca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34480
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-01 19:27:29 +00:00
Ben Clayton ed2b97811e ast: Add Module.Clone()
Deep-clones all `Node`s and `Type`s into a new module.

Instead of writing a million standalone tests that'll only ever test the
existing fields of each type, I've opted to write the tests using
wgsl<->ast<->wgsl conversion. This means the tests require the enabling
of TINT_BUILD_WGSL_READER and TINT_BUILD_WGSL_WRITER, but I believe this
is much easier to maintain.

I'm aware there are probably gaps in the tests, and that even full
coverage is likely to rapidly rot, so I've also added
fuzzers/tint_ast_clone_fuzzer.cc - a fuzzer based test that ensures that
all AST modules can be cloned with identical reproduction.

I've run this across 100 cores of a 3990x for 4 hours, fixing the
single issue it detected.

Note: Expressions do not currently clone their `TypeManager` determined
types. This is for two reasons:
(a) This initial CL is mahoosive enough.
(b) I'm uncertain whether we actually want to clone this info, or to
    re-run the `TypeDeterminer` after each AST transform. Maybe it should
    be optional. Time will tell.

Fixed: tint:307
Change-Id: Id90fab06aaa740c805d12b66f3f11d1f452c6805
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33300
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-01 18:04:17 +00:00
Ben Clayton f1b0e1ee57 ast/type: Remove Type suffix from all types
They already exist in a `ast::type` namespace, so `ast::type::BlahType` is just stuttering.
This is more important now that Is<> and As<> use the full type name.

Change-Id: I7c661fe58cdc33ba7e9a95c82c996a799786661f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34321
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
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