Commit Graph

1788 Commits

Author SHA1 Message Date
Ben Clayton e5b315084d CloneContext: Support inplace cloning
Add a new constructor that only takes a ProgramBuilder.
This allows cloning objects to and from the same ProgramBuilder.

Also clean up tests.

Change-Id: I7c7bbaced4956f9094d0a6231aa4d7f7b6f17d4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49744
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 18:06:31 +00:00
Ben Clayton 49a545c919 ast::Module: Move ConstructedTypes() to typ::Type
And add a few additional helper methods.
Stepping stone to having the module only reference AST nodes.

Bug: tint:724
Change-Id: Ib321dadce5f739afe4f71cbafde9dd2d1c6431bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49743
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 18:03:11 +00:00
Ben Clayton 0f88b31503 ProgramBuilder: Add more helpers
And use MaybeCreateTypename() in more places.

Bug: tint:724
Change-Id: I232229c76205e148a2235dc5706522adb0789bcc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49742
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 17:36:31 +00:00
Ben Clayton 89952d0412 Fix all doxygen warnings
Change-Id: Ic312bc3771a69765b43f1a7c025f1f57783823c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49741
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 17:20:31 +00:00
Antonio Maiorano ca992196d2 spirv reader: do not add duplicate constructed types
My last CL (https://dawn-review.googlesource.com/c/tint/+/49542) made it
so that AST nodes are re-created every type we resolve a spirv type id
to a tint type. This creates duplicate nodes, most of which are cleaned
up at the end of parsing. However, duplicates added as global
constructed types are not handled, so this CL makes sure we do not add
said duplicates.

Bug: tint:769
Bug: tint:724
Change-Id: Ifab46aa3b843a841c4371659dbec64891fdabc9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49760
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-04 14:51:11 +00:00
Antonio Maiorano 1b898d56b4 spirv parser: create ast types along with sem types
The spirv parser now creates ast types along with sem types via
typ::Type. All sem::Type* were replaced with typ::Type, and its `ast`
member is used over the `sem` member to make it easier to migrate to
ast-only.

The parser was written to take advantage of the fact that types were
resolved to semantic types during parsing. For instance, a mapping of
spirv typeid to sem::Type* was used throughout (`id_to_type_`) to
resolve types once, and to support type aliasing. Since the goal is to
only create AST types, and to resolve only in the Resolver, I made many
changes to remove this dependency on semantic types. For instance, we
now always call ConvertType(typeid) instead of looking up via
id_to_type. Similarly, the `signed_type_for_` and `unsigned_type_for_`
maps were replaced with `UnsignedTypeFor` and `SignedTypeFor` functions.

Bug: tint:724
Change-Id: I3aee3928834febd71b473d6a8d8cb77b1ac94e21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49542
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-03 20:49:40 +00:00
Ben Clayton b6831c3395 castable.h: Fix warning
> clang --version
Apple clang version 11.0.3 (clang-1103.0.32.29)

../src/castable.h:199:11: error: definition of implicit copy assignment operator for 'CastableBase' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated]

Seems to only be raised with this particular flavor of clang?

Change-Id: I9a549c753cd28a11855138a97823e7c1c92fab25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49532
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-30 21:27:02 +00:00
Ben Clayton 1a492a27db writer/hlsl: Begin migration to ast::Types
The HLSL writer doesn't really care much for ast::Types, so most of the work here is repointing the logic to fetch the resolved, semantic type.
Output for aliases has changed, as the semantic type resolves away aliases.

Bug: tint:724
Change-Id: I6eb9d5c2fbcd62eef0f9dd145360714db649e13f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49530
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:22:49 +00:00
Ben Clayton ccab6bd694 reader/spirv: Return early if MakeExpression() fails
Bug: tint:762
Change-Id: If17e666cf459117c52ece73cb20ea8f70ed1fcd5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49531
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-04-30 20:22:19 +00:00
Ben Clayton fbec46fba9 Resolver: Generate mapping for ast::Type -> sem::Type
Currently untestable as nothing currently calls Type(const ast::Type* ty).

Bug: tint:724
Change-Id: I92dd772acd758b0960a7e9a19f15c91414ab505c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49527
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:20:19 +00:00
Ben Clayton f34cb1fe70 writer/msl: Begin migration to ast::Types
The MSL writer doesn't really care much for ast::Types, so most of the work here is repointing the logic to fetch the resolved, semantic type.

Bug: tint:724
Change-Id: I017b83c9f661cc01cbde377991aab184c1733348
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49529
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:19:09 +00:00
Ben Clayton 44539d85b2 writer/spirv: Begin migration to ast::Types
The SPIR-V writer doesn't really care much for ast::Types, so most of the work here is repointing the logic to fetch the resolved, semantic type.

Bug: tint:724
Change-Id: I7647e17b015bac8394bc0fc76daceb7c0a391a47
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49528
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:13:19 +00:00
Ben Clayton 1737485a05 ast: Add ast::NamedType
Have ast::Struct and ast::Alias derive from it.
NamedType currently derives from ast::Type, but this might change in the future.

Bug: tint:724
Change-Id: I46ab7751c89176f4dec34d63247d2459d02ab6bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49525
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 19:58:49 +00:00
Ben Clayton 3068dcb3d7 sem::Function: Add ReturnType()
This is the resolved, semantic, return type of the function.

Bug: tint:724
Change-Id: I4ef9f7874414a3ea48131d0102da776f6d82a729
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49526
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 19:24:29 +00:00
Ben Clayton fa9af4b0ef writer/spirv: Return error message in Disassemble
Instead of printf-ing and returning an empty string.
When there's a lot of other test output, it can be really hard to actually spot the error message.
With the error being returned, this will likely appear in a EXPECT_EQ() style error message.

Change-Id: I733741a68de4843e986037c5e309c5a4c3d66124
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49522
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 19:23:49 +00:00
James Price e87ded8567 Rename builtin constant_id to override
There are no downstream usages, so we can skip deprecation. Allowing
the ID to be omitted will be done in a separate patch.

Fixed: tint:754
Change-Id: I3bd6de4d0f426fc3c66708bfd5b411a4051b375b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49581
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-30 17:14:19 +00:00
Ben Clayton 083b591783 writer/wgsl: Emit ast::Types
This takes precedence over semantic types.

WGSL should be printed as faithfully as possible to the parsed program.
The semantic nodes are more abstract than the AST - aliases are folded
away, decorations may be absorbed into the semantic types, etc.

Bug: tint:724
Change-Id: I500af3d20e4ea3f9bfcb7664f0ad2360aeeecd68
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49350
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 16:01:29 +00:00
Ben Clayton 275eb7e4e4 reader/spirv: Clean up disjoint AST nodes
Perform a program clone at the end of parsing to remove any unreachable AST nodes.
Actually fixing the parser to never create these looks like a huge amount of work.

Fixed: tint:749
Change-Id: Ib956634257e0933c9702d6be22f79942f7cf4c51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49520
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-30 10:43:19 +00:00
Ben Clayton 9481156eb9 Fix Undefined Behaviour
All caused by calling Castable::As<> on nullptr objects.

Bug: tint:760
Change-Id: I0a408b3cd58086cfeab5a1af34d643f50f304948
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49523
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-30 10:16:45 +00:00
Zhaoming Jiang 30c03a5d50 HLSL writer: Translate the built-in function "mix" into "lerp"
The built-in function "mix" in WGSL should be translated into the
intrinsic function "lerp" in HLSL according to the HLSL document.

With this patch the dawn sample CubeReflection will be able to run
correctly with tint generator on D3D12 backend.

Bug: tint:758
Change-Id: I7e84987c02fd2090d5e7af8f4aba995fc95a6fdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-30 08:47:06 +00:00
David Neto e08cc15dd9 spirv-reader: HLSL-IO: Convert input, output vars to private
Bug: tint:508
Change-Id: I5cd7c1b476112eb489f9e6acc94f7a1cf6e43b6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48863
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 22:04:55 +00:00
James Price 5f7f7c0f9e Revert "transform/EmitVertexPointSize: Handle entry point parameters"
This reverts commit e6307e5100.

Reason for revert: This change assumes that vertex shaders do not return void, but the validation for this is currently disabled since CTS still has vertex shaders that return void.

Original change's description:
> transform/EmitVertexPointSize: Handle entry point parameters
>
> Generate a new struct that contains members of the original return
> type with the point size appended to it, and replace return statements
> as necessary.
>
> The SPIR-V sanitizer then special-cases this builtin when handling
> entry point IO to always use a RHS which is a literal.
>
> Fixed: tint:732
> Change-Id: Id718632a5e671f3e7c82a304f5bc1fc223a6c8ee
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49440
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: James Price <jrprice@google.com>
> Auto-Submit: James Price <jrprice@google.com>

TBR=bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com

Change-Id: I6113b2d8994eb088cb890a6af52e392b2d5a45f6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49582
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-29 21:29:36 +00:00
Ben Clayton f0756e347a resolver: Improve the ICE msg about nodes
Include the pointer - helps debugging

Change-Id: I50058095710eb528446bbd8d8e3069dd657c75c8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49521
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-04-29 20:57:55 +00:00
David Neto 7896d85146 spirv-reader: Register a name for an entry point inner implementation
It's tricky when mulitple entry points share the same implementation
function.

Bug: tint:508
Change-Id: Ie3084d4af8d6eb3aa9f0d25babb8ebfaed7b2fae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48902
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 20:28:15 +00:00
David Neto ac16789eba spirv-reader: add option to use HLSL-style pipeline IO
This is currently unused.

Bug: tint:508
Change-Id: I9027d468496014123a41b9941cf9df35868b6e1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49000
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 19:47:05 +00:00
Antonio Maiorano 543d471889 TypePair: add more operators to fix ambiguous bool conversions and nullptr comparisons
Bug: tint:724
Change-Id: I6698d95aeebe067d7b370b35fca05372e120b8ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49321
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-04-29 17:47:34 +00:00
James Price 0a45d84fd4 Add missing include to fix g3 build
This is needed for std::nullptr_t.

Change-Id: I45780e783a81b29fb173cd3fa59542b5dbda0823
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49541
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-29 16:48:44 +00:00
James Price 3189bf02e6 reader/wgsl: Allow trailing commas in lists
Also allows empty constexpr type constructors.

Fixed: tint:739
Change-Id: Ic4729c13b6ac538491d5d1d3c7960e78fac80127
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49443
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 15:56:54 +00:00
James Price 4248a46bfb reader/wgsl: Set source locations for literals
Change-Id: I34c6fd6760fb948682d427648cae963b9c1d8a6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49442
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 15:54:44 +00:00
James Price e80887d14c reader/wgsl: Handle parentheses inside expect_argument_expression_list
This simplifies the callsites, which were previously each having to
handle the "empty list" case (and soon: trailing commas). This is also
a better match for the grammar rules in the WGSL spec.

Change-Id: I88ed54f94964f7b23a0fd9b584659037abb567ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49465
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 15:49:44 +00:00
James Price 961dc6fbf5 reader/wgsl: match spec rules for function calls
Function calls should be parsed in `primary_expression`. Renames the
old `postfix_expression` to `singular_expression`, with the recursive
part now becoming `postfix_expression`.

Fixed: tint:170
Change-Id: I1afad794880916db38a25d73447cdaf84abd6584
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49464
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-04-29 15:02:15 +00:00
James Price e6307e5100 transform/EmitVertexPointSize: Handle entry point parameters
Generate a new struct that contains members of the original return
type with the point size appended to it, and replace return statements
as necessary.

The SPIR-V sanitizer then special-cases this builtin when handling
entry point IO to always use a RHS which is a literal.

Fixed: tint:732
Change-Id: Id718632a5e671f3e7c82a304f5bc1fc223a6c8ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49440
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-04-29 13:05:34 +00:00
James Price 65ae64d009 transforms: Add a ProgramBuilder::Sym() helper
This creates a new, unnamed symbol.

Change-Id: I0ea11e812296c3215ba624a18777d3e7233e2ae4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49441
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-04-29 12:59:14 +00:00
David Neto 77f7f5d369 spirv-reader: register statically accessed inputs and outputs
Bug: tint:508
Change-Id: I585abb0791f5ea0bcb282f12f6940e718da4956d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48861
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-04-29 00:09:04 +00:00
James Price 0949bdf68f Add transform to strip entry points from a module
Remove the Generator::GenerateEntryPoint() APIs as they were mostly
unimplemented and not used by anything except the Tint sample app,
which now uses the new transform.

Change-Id: I1ccb303d6c3aa15e622c193d33b753e22bf39a95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-28 15:33:03 +00:00
Ben Clayton f5f311e264 Global tweaks to handle having no sem::Type
Soon, we'll start migrating the AST from using sem::Types to ast::Types.
This change fixes up a bunch of places that makes the assumption that the semantic type is always expected.

Bug: tint:724
Change-Id: I96096bdf7177751ca6c6240e1739244cbeb82761
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49348
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 14:31:23 +00:00
Ben Clayton 2ac55febf5 sem::StructMember: Add Type()
Once the AST switches to pure ast::Type nodes, we need a way to fetch the semantic type for a structure member.

Bug: tint:724
Change-Id: I4b55c1ec0220e29ca4ff3131cf2d41409821a538
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49347
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 14:13:13 +00:00
Ben Clayton 109b18f504 ast: Remove types from ast::Literals
A literal has an implicit type, so there should be no type on the AST node.

This highlighted that the resolver was nto canonicalizing TypeConstructorExpression types, which has been fixed.
This required preservation of the declared type name in order for error messages to contain aliased names.

Bug: tint:724
Change-Id: I21594a3e8a0fb1b73c6c5b46a14b8664b7f28512
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49345
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2021-04-28 13:50:43 +00:00
Ben Clayton 0bf0fb9b29 ast::TypeName: Clone the name.
Caught by the new seatbelts in the CloneContext.

Bug: tint:724
Change-Id: I1877248455e7654cb9c980cacd2f73562b006233
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49349
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 13:39:53 +00:00
Ben Clayton e41808b6b9 Add typ::Ptr<T>
A simple raw pointer wrapper that will allow us to migrate typ aliases to ast::Types without immediately having to fix up all the `auto` declarations to `auto*`.

Bug: tint:724
Change-Id: Icff7e009b768d9e54c8c73059c700af788962e77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49346
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 13:32:13 +00:00
Ben Clayton 95c2e95100 ProgramBuilder: Don't wrap nullptr types
Once we start migrating over to just creating `ast::Type`s instead of a
AST+SEM pair, we're going to start having the sem::Type of the TypePair
be nullptr. Only create composite AST / SEM types if the inner type has
a non-nullptr AST / SEM type.

Bug: tint:724
Change-Id: I9bec53d1be4e8dc43f5d6c86fc5f968bf61fb41e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49344
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 12:58:13 +00:00
Ben Clayton 12ed13d0d4 resolver: Be const-correct with sem::Types
Make all the sem::Type pointers const.
The later stages still have not been fixed up, so there's liberal usage of const_cast where we create semantic nodes.

Bug: tint:745
Change-Id: I160b791f2b7944f8966bc961e061d1e5996c1973
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49343
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 12:38:13 +00:00
Ben Clayton 761e6b139c ast: Migrate all nodes over to typ::*
(except for ast::Module)

CloneContext::Clone(typ::Type) now only clones the sem::Type. Attempting
to clone both the AST and SEM type will cause the cloned AST to be
disjoint. Another change will switch this over to cloning the AST.

Bug: tint:724
Change-Id: I2baf5491365d7dc25e6b25d02bfbb46bf90fd0d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49341
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-28 09:29:13 +00:00
Ben Clayton 4c0b7807f8 formatter: handle tabs
Transform these into whitespace so we can sensibly align the ^^ markers
with the text.

Change-Id: I151c0e55bc0a02c1cff6e381cb9839c9f9abdaf6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48694
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-27 18:01:28 +00:00
Antonio Maiorano 4b16a160d5 wgsl parser: use new TypesBuilder factory functions, and set Source for ast::Type nodes
* ProgramBuilder: added a bunch of overloads that take Source

* Added MultiTokenSource RAII helper to build source ranges for
multi-token types

* Added comparison operators to Source::Range and Source::Location to
make it easier to write tests to compare Source ranges

* Moved CombineSourceRange from resolver.cc to a static function in
Source named Source::Combine()

* Added Source tests for all ast type nodes returned by the wgsl parser

Bug: tint:724
Change-Id: I6fb6211a3c42c14693df8746af6a30f5aa56f2af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48963
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-27 17:32:37 +00:00
David Neto d30047fea0 spirv-reader: always reserve entry point names
We have to be careful when the same function is used for
two entry points.  The first entry point name will be registered
as the name for the function ID.  But subsequent entry points
should have their names reserved in the namer, even if they
aren't associated with an ID.

Bug: tint:508
Change-Id: I3b6e7770ce49aa1b73594e57bdda5800febd55ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48864
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-27 16:14:06 +00:00
David Neto f63a2948c6 Better document ast::Variable parameters
In particular, "is_const=true" is required for formal parameters.

Change-Id: I05105da901a02d9bb51c88cab7430dd211c7b0ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49302
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-04-27 15:16:06 +00:00
David Neto 2c953eca48 spirv-reader: SaveName -> Register, add RegisterWithoutId
Change-Id: Iab2eaa3b2d13a3cbb8f6bca01ed79be14dedbfd1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49141
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-27 14:39:47 +00:00
Ben Clayton 86a406b79e Revert "transforms: Use new ProgramBuilder::Sym() helper"
This reverts commit 19b4b6cc2b.

Reason for revert: https://dawn-review.googlesource.com/c/tint/+/48980 was reverted which added the Sym() helper.

Original change's description:
> transforms: Use new ProgramBuilder::Sym() helper
>
> Change-Id: I8600a1935556632c94778248f3711531a22f4701
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48981
> Commit-Queue: James Price <jrprice@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>

TBR=bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com

Change-Id: Ie176df6e1b7606615e2acfae99e7853e6227185a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49261
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-27 14:24:08 +00:00
Ben Clayton e008b1ffcf Revert "transform/EmitVertexPointSize: Handle entry point parameters"
This reverts commit 05e16ed1c5.

Reason for revert: Breaks Dawn autoroll.

 [ RUN      ] VertexBufferRobustnessTest.DetectInvalidValues/Metal_Intel_R_UHD_Graphics_630__e_metal_enable_vertex_pulling
 ../../src/tests/DawnTest.cpp:945: Failure
 Value of: self->mExpectError
   Actual: false
 Expected: true
 Got unexpected device error: Tint SPIRV reader failure:
 Parser: error: cannot store a value other than constant 1.0 to PointSize builtin: OpStore %8 %18


Original change's description:
> transform/EmitVertexPointSize: Handle entry point parameters
>
> Generate a new struct that contains members of the original return
> type with the point size appended to it, and replace return statements
> as necessary.
>
> Fixed: tint:732
> Change-Id: I2b5816144d5e95c65baca95dc0c50b4dfdd25ed3
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48980
> Auto-Submit: James Price <jrprice@google.com>
> Commit-Queue: James Price <jrprice@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>

TBR=bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com

Change-Id: Id795d5320471d09d66a964c8e469b60da8f0a672
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49260
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-27 12:58:31 +00:00
Ben Clayton 5d5ec24571 src/transform: Remove deprecated APIs
These have now been removed from Dawn.

Change-Id: I50e784141e6eb07f4f0d3f508bb8c6199429dd63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48044
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-04-26 20:38:36 +00:00
James Price 19b4b6cc2b transforms: Use new ProgramBuilder::Sym() helper
Change-Id: I8600a1935556632c94778248f3711531a22f4701
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48981
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-26 19:49:06 +00:00
James Price 05e16ed1c5 transform/EmitVertexPointSize: Handle entry point parameters
Generate a new struct that contains members of the original return
type with the point size appended to it, and replace return statements
as necessary.

Fixed: tint:732
Change-Id: I2b5816144d5e95c65baca95dc0c50b4dfdd25ed3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48980
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-26 19:37:46 +00:00
David Neto 9ef328f530 spirv-reader: add namer::IsRegistered
Change-Id: I014132f9a655c7f52ebce4b141f6ea5235e828f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49140
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-26 19:25:06 +00:00
James Price 439ef278b7 transform/VertexPulling: Handle entry point parameters
Adds support for the new shader IO syntax by processing entry
parameters and pushing them to function-scope variables as necessary.

Module-scope variables are still supported for now.

Fixed: tint:731
Change-Id: I36d7ce4e3a990b6323292cb7c685af37187d6fda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48960
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-26 17:39:46 +00:00
Antonio Maiorano 31204afeb0 Add ast::ExternalTexture
Also create it in wgsl parser. With this, we now create all the AST type
nodes in the wgsl parser.

Bug: tint:724
Change-Id: I575c9eb0ffbd60c3e7aca0b00227d9833ef65d58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48962
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-26 14:55:25 +00:00
Antonio Maiorano 73fdc16c33 wgsl parser: replace almost all sem::Type* with typ::Type where possible
All that remains in the wgsl parser that references sem::Type* are
the register_constructed funcs/types, and adding an ast::ExternalTexture
type.

Also:

* Added specialization of OperatorArrow for type::TypePairs that returns
the value by reference so that operator-> can chain properly.

* In a few places where we expect the type to implicitly cast to a
pointer for a bool expression, e.g. `if (type)` or `TINT_ASSERT(type)`,
I added access to the `.sem` member of the TypePair. I tried adding an
implicit cast to bool, but this results in ambiguity in gtest for
equality comparisons.

* Constified more type pointers in type nodes

* Replaced header includes with forward declares in wgsl/parser_impl.h

Bug: tint:724
Change-Id: Ie0875aa4d4a5e830e3466ac40c63cd185f357200
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48881
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-26 14:19:55 +00:00
David Neto 8f9de8a509 spirv-reader: Add method to be used in tests later
Bug: tint:508
Change-Id: Ifd83bcfe168a2be0a11e8a81e392ba20101fc586
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48865
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-26 09:56:05 +00:00
James Price 12353bc5fd Remove duplicate using directive
This alias is already defined in src/ast/decoration.h and is probably
just a copy-paste error.

Change-Id: I9efc16881b551ccac287eef1f86ca7560e87131b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48982
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-23 22:11:14 +00:00
Ben Clayton 6052d41d51 sem::Alias::type_name(): Optimize complexity
Precalculate the type_name to reduce complexity from O(N²) to O(N).

Fixed: chromium:1199700
Fixed: chromium:1200936
Change-Id: Ifd16508ace42d4a686f06d58121cc106842df7d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48691
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-23 18:21:34 +00:00
Ben Clayton b205b872ae reader/spirv: Don't create disjoint AST nodes
This is a waste of memory, and now fires a TINT_ASSERT() in the resolver.

Add some more information to the resolver assertion message so that its easier to identify the node. This is especially useful when there's no source information available.

Fixed: tint:740
Bug: tint:469
Change-Id: I0cd4529db7b3906e64da6ed7290163509eb0c3f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48689
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-23 18:19:54 +00:00
Antonio Maiorano ab215981fe Fix linux dawn roll
As in other places, we need to #undef Bool for X11

Bug: tint:741
Change-Id: I0185ed3c252f540212504b88859c600618fbfe23
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48961
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-23 18:09:34 +00:00
Ben Clayton 3b3cf5f2d3 ProgramBuilder: Fixup last few uses of sem::Type*
With typ::Type.

Involves decoupling the use of named types as sub-types of other types,
otherwise ty.array("x", Structure(...)) produces an AST tree with
duplicated AST nodes.

Bug: tint:724
Change-Id: I2b4e904dc23bb554a75d4612f6543f1911f469bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48693
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-23 15:41:34 +00:00
Ryan Harrison 099ceb2050 Remove use of UnwrapAll()
Change-Id: I26518ecd17cd3a69357698d1e1a2201fcbc460e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48880
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-23 08:36:33 +00:00
Antonio Maiorano 0b9ea91fcf Make ast::StructMember accept typ::Type
A minimal change to get a feel for what updating AST types to accept
typ::Type (for now) looks like.

Bug: tint:724
Change-Id: I33b33eb6af90e3629f76716a421f952f5a4bc11d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48841
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-23 08:35:13 +00:00
Antonio Maiorano 05abdf5096 wgsl parser: make type_decl() return typ::Type
Many more changes to come, but this just gets things started.

Bug: tint:724
Change-Id: I6c1dab0d9b7998e273543f2a72b6f8eafeb19fda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-23 08:19:33 +00:00
Brandon Jones 145f865fb1 Add texture_external parsing and intrinsic overloads
Adds texture_external to ParserImpl. Adds texture_external overloads to
TextureSample, TextureLoad, and TextureDimensions to the intrisic table.
Adds corresponding tests.

Bug: dawn:728
Change-Id: I5e5557a10327f8c3d3044319decd748f812ecf3e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48722
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-22 22:47:03 +00:00
Ryan Harrison add325bb61 Add check for access controls on Storage Textures
BUG=tint:736

Change-Id: I6baae6507597383dd58b0d86605cbd44d5488c8f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48842
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-22 19:57:33 +00:00
Antonio Maiorano 26fa9927e8 Constify Type* constructor args for ast/sem classes
To avoid breaking things, functions that return the type cast away
the constness for now. This, however, makes it easier to use typ::Type
with these classes, as typ::Type stores pointers to const types. This
also brings us one step closer to constifying types everywhere.

Bug: tint:724
Change-Id: Ia3f4b76f375184dd09b8041c1f60bf1afaefe629
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48740
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-22 15:34:13 +00:00
Ben Clayton e204f27f86 ProgramBuilder: Migrate any remaining types to typ::*
Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: Ib2d6c150fe8aa7c1e2c502676922b14b1518a4be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48686
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-22 14:40:23 +00:00
Ben Clayton 7241a504f0 ProgramBuilder: Migrate arrays to typ::TypePair
Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: Idadb7d8b5d6fce1d898127675442221de07a633d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48685
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-22 14:32:53 +00:00
Ben Clayton fdb91fd85e ProgramBuilder: Migrate matrices to typ::TypePair
Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: Ic81f0a00456e91ac089df32193c4323c2e779c29
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48684
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-22 14:30:53 +00:00
Ben Clayton e30ffeb02a ProgramBuilder: Migrate vectors to typ::TypePair
Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: I19d7df9ab684db598783235c1720586966a232e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48683
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-22 14:24:43 +00:00
Ben Clayton 43073d8aa3 tests: Use ProgramBuilder helpers where we can
A general code cleanup

Change-Id: Ib251ca2d4b71f75736bdba8b4255965593a76c31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48680
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-22 13:50:53 +00:00
David Neto 261642e4e3 Update spirv-reader readme
Change-Id: I933cab554b3bbd278a23b892535cba4992649002
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48760
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
2021-04-22 12:54:43 +00:00
David Neto 943ded79d2 spirv-reader: support OpTranspose
Change-Id: If338b22b703257e863e511579cfd3abcaa0bdfe7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48761
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-04-22 12:29:45 +00:00
Ben Clayton d5ceafee16 resolver: Temporarily disable vertex position validation
CTS needs updating to fix this validation error, and this is blocking autorolls for tint and dawn.

Change-Id: Ie3aaa37f0914fdb39099e7c15e65be0bcca0677a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48682
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-21 22:55:42 +00:00
Ben Clayton 42708348b7 resolver: Validate uniform buffer types
Fixed: tint:210
Change-Id: I7763ca23a5dce09755a1ca71d35f24897a875ac0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48604
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-21 17:55:12 +00:00
Ben Clayton 8db818840e Resolver: Validate array el is not [[block]] struct
Fixed: tint:90
Change-Id: I9500a8c7fad9acf5f797dd2903217821c953acb6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48421
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-21 16:45:02 +00:00
James Price 2dd393729c Require vertex shaders to return builtin(position)
Fixup many tests that were just returning void.

Change-Id: Ic93db5b187c679dc1c24a356b48a64e41ba9a823
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48560
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-21 16:13:42 +00:00
Ben Clayton fec63b7aa6 Resolver: Add ast -> sem type resolving
Not currently called (nothing currently attaches ast::Type nodes to the AST), but implements some of the boilerplate that'll be shortly required.

This change also removes a bunch of duplicated enumerators from the sem namespace for their counterpart in the ast namespace.

Bug: tint:724
Change-Id: I0372a9f4eca2f9357ff161e7ec1b67eae1c4c8f6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48603
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-21 13:47:12 +00:00
Ben Clayton a922e65d72 ProgramBuilder: Generate type pairs for primitives
Emit the new typ::I32, typ::U32, typ::F32, typ::Void, typ::Bool types instead of the just the sem::Types.

Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: Ic492e33bc909e0821b581af05242d956631db2e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48602
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-21 13:37:22 +00:00
Ben Clayton 440636c15c Add typepair.h
Introduces typ::Type which wraps a templated pair of AST and SEM type pointers.
This is a temporary helper to ease migration of the thousands of tests that use the ProgramBuilder over from sem::Type to the new ast::Types.

Bug: tint:724
Change-Id: I4e2643a819cde97947d789fce7a74c251f837a58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-21 13:32:22 +00:00
Corentin Wallez c0810e7e6e Fix gn check in Chromium
- Move headers from libtint_sem_src into libtint_core_all_src so that
there is no circular header dependency between headers of these two
targets. libtint_sem_src is now just a hack to have a different name for
a few .cc files.
 - Made libtint_core_src publicly depend on its deps so that headers of
libtint_core_all_src are made visible through it.
 - Added spvtools dependencies in a couple places that were mistakenly
removed in a previous commit.
 - Moved helpers common to multiple unittest targets out of
tint_unittests_core_src and into a tint_test_helpers target that
all tint_unittests_source_set depend on.
 - Ran GN format that reordered some lists a bit.

Bug: None
Change-Id: I544a73d73366be9dd2ac8e56c7593fd9f2b86cf8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48600
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-21 09:18:52 +00:00
Ryan Harrison de8f1332f6 Validate Storage Textures and update existing tests
Adds rejecting unsupported image formats and texture dimensions.

BUG=tint:718

Change-Id: Ic6375d1e75524336462ea59b159cb4c8601f55fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48500
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-04-20 20:47:51 +00:00
Ben Clayton 5b3d88b748 resolver: Fix for ICE: node not reached by the resolver
More of a workaround. Will be properly fixed by tint:724 .

Fixed: tint:728
Change-Id: If4887a781106010d12209365f36f27b493a9f173
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48422
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-20 18:11:51 +00:00
Ryan Harrison 83116d298c Add validation rules for multisampled textures
Fixes:tint:717
Change-Id: I7f23086ec516c1196a9cdc741bbaa150754a533a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47940
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-20 16:09:21 +00:00
Ryan Harrison a32e4f66e5 Remove 2d Array Multisampled Textures
These do not exist in the WGSL spec, so removing them.

BUG=tint:717

Change-Id: I5eb2280fa2f0c923b67070a9ce4a7d2fc10d365d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48460
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-20 16:00:21 +00:00
Ben Clayton 913a2f4b2a sem::StructType remove symbol()
The name now lives on the ast::Struct. Use that instead.

Bug: tint:724
Change-Id: I4ee5e9b29973e468edd8df8c5448816b36f0fca6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48384
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-20 15:21:21 +00:00
Ben Clayton 8a8d26bbd9 ast: Add type nodes
Copy all of the type classes from src/type into ast.

Required the merging of:
* type::Struct into the existing ast::Struct - ast::Struct now has a name.
* type::AccessControl into the existing ast::AccessControl enumerator - The old ast::AccessControl enumerator is now ast::AccessControl::Access

Bug: tint:724
Change-Id: Ibb950036ed551ec769c6d3d2c8fb411809cf6931
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48383
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-20 15:04:21 +00:00
David Neto ba6f260629 spirv-reader: Remove stale TODO
Change-Id: Icd9bf067160c7b79b3c5d8c3123ac94a8f29376c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48400
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
2021-04-19 23:16:23 +00:00
Antonio Maiorano aea9c68de9 Move type/* files to sem/ directory
Bug: tint:724
Change-Id: I45d83d32dbce1fbee265810615c18219ef879b20
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48363
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-19 22:54:43 +00:00
Antonio Maiorano 3751fd2290 Move all classes from namespace `type` to namespace `sem`
Bug: tint:724
Change-Id: I4eeabab9b00b6b28f61645bd95d326fb48609bf0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48362
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-19 22:51:23 +00:00
Antonio Maiorano 3aa226138e Rename type::Struct to type::StructType
This is to avoid name conflicts once we move all classes from namespace
`type` to `sem`.

Bug: tint:724
Change-Id: I23cdec636cb5bcf0bbba03ee7bb7c44252ddade7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48361
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-19 21:31:43 +00:00
Antonio Maiorano cf4057be01 Rename type::Array to type::ArrayType
This is to avoid name conflicts once we move all classes from namespace
`type` to `sem`.

Bug: tint:724
Change-Id: Icc3d81ae62eb3b329ce28e78a23ea27f29c9263b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48360
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-19 21:13:12 +00:00
Brandon Jones e94237dcdd Add ExternalTexture Type
Adds ExternalTexture type and basic unit tests in accordance with the
currently proposed WGSL specification.

Bug: dawn:728
Change-Id: I7a16a351ff098ba6df5b1e6305c390e3ca1c9d46
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47180
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-19 20:35:13 +00:00
Ben Clayton cf28b5aafe resolver: Call ValidateVariable() for globals
This was only called for function-scope variable declarations.
In calling this, there were inevitable tests failing, which have now been fixed.
Added a test for the single runtime-array-length validation rule that this function was checking.

Fixed: tint:345
Change-Id: Ic453c38158c1290a5e1ef6de56af0c621d97982a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48381
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-04-19 20:23:12 +00:00
Ben Clayton 85bfea6edd resolver: Validate storage buffers have the [[block]] decoration
Fixed: tint:94
Change-Id: I1d3e512c030ec16031b8c8fcfbde0cd1db5d1ea4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48380
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-19 20:20:33 +00:00
David Neto 8b50537767 spriv-reader: handle loop-header with internal divergence
Handle the case where the OpBranchConditional in a loop header
branches to two distinct blocks inside the loop construct.
This is an if-selection in disguise.

Create an kIfSelection with the same set of blocks as the kLoop,
and with the continue target as the merge.

Fixed: tint:524
Change-Id: I5150d19a2b4388da409e2da6e68ffafdc5d21a9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47560
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-04-19 19:54:32 +00:00
Antonio Maiorano ff7c293141 Fix clang-cl build
Fixes "error : use of identifier 'Node' found via unqualified lookup
into dependent bases of class templates is a Microsoft extension
[-Werror,-Wmicrosoft-template]"

Change-Id: Id54cdff24189b73c625f951ae369ec292be4c81b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48340
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-19 19:41:02 +00:00