Commit Graph

1659 Commits

Author SHA1 Message Date
dan sinclair 5ad2d0087b Revert "Remove support for the old _idx builtins."
This reverts commit c2972cfa60.

Reason for revert: Looks like CTS in Chrome doesn't have this change yet.

Original change's description:
> Remove support for the old _idx builtins.
>
> This CL removes the old _idx variants of builtins in favour of the
> _index versions.
>
> Change-Id: I1678b5fae63c9d4f7f63feabf7410a58505d397a
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38825
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

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

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I29b6016f2e9e0b6245e22e2e18ff2f8c9a17dc74
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-28 16:49:11 +00:00
dan sinclair 30c1f25a7a Reland "Remove support for # comments."
This reverts commit 21b52b60b6.

Reason for revert: Dawn fixes landed, trying again.

Original change's description:
> Revert "Remove support for # comments."
>
> This reverts commit 6e570a9360.
>
> Reason for revert: Missed Dawn tests
>
> Original change's description:
> > Remove support for # comments.
> >
> > This CL removes support for parsing # style comments. Only the //
> > comments are accepted now.
> >
> > Change-Id: I062c2a86149ecf828723c74f7168243678ee5870
> > Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38823
> > 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>
>
> TBR=dneto@google.com,dsinclair@chromium.org,bclayton@google.com
>
> Change-Id: Iaf19ab9def92ad10c27d70480d259e25f3da719d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39061
> Reviewed-by: dan sinclair <dsinclair@chromium.org>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

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

# Not skipping CQ checks because this is a reland.

Change-Id: I91a478237bc9853108e1ce97b9fdc2ce01841998
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39221
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-27 22:30:55 +00:00
James Price 186af2f6ad [wgsl-reader] Fix struct constructor expressions
The parser was matching struct constructors as function calls.

Bug: tint:458
Change-Id: Ia98489e3a6d62eea2e423c6344b6e35b8f9649f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39101
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-27 21:49:06 +00:00
Ryan Harrison d5c0b8e851 Restrict Windows to Win10 bots
Win7 is not supported by Chromium builds anymore, so upstream has
introduced breaking changes.

BUG=tint:465

Change-Id: I6856f706bacf353808a2f7c536fbf8bb84ae9acd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39064
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-27 19:24:25 +00:00
Ben Clayton dd69ac3505 Automatically run the TypeDeterminer when building programs
Removes the need for Dawn to use the TypeDeterminer directly.
TypeDeterminer errors will be added to the Program diagnostics list.

Change-Id: I4cfb405e7e6b0e94727296eea872a3ddc4412b66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38921
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-27 19:23:55 +00:00
Ben Clayton 844217fa34 Add Diagnostics to Program, reader::[wgsl,spirv]::Parse()
By putting diagnostics into the program, we can hold all the diagnostic messages for parsing and type determination in one place.
This also means that we can simplify the public WGSL and SPIR-V Parser interfaces to a single function.

Change-Id: Ib6ab5fa180addd45c4aaf0c6b192d47182ffb50a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38920
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-27 18:49:05 +00:00
dan sinclair 21b52b60b6 Revert "Remove support for # comments."
This reverts commit 6e570a9360.

Reason for revert: Missed Dawn tests

Original change's description:
> Remove support for # comments.
>
> This CL removes support for parsing # style comments. Only the //
> comments are accepted now.
>
> Change-Id: I062c2a86149ecf828723c74f7168243678ee5870
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38823
> 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>

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

Change-Id: Iaf19ab9def92ad10c27d70480d259e25f3da719d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39061
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-27 18:32:16 +00:00
dan sinclair 3a5b15d4e5 Record when an identifier expression is a swizzle.
This CL updates the type determiner to record if an identifier
expression is a swizzle and then uses that in the MSL and HLSL generator
to output the swizzle name directly.

Change-Id: I77c0e1e80dce9e2f09cbbd37476a146b06555ee2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38960
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-27 17:39:35 +00:00
David Neto 36194197ac spirv-reader: textureLoad explicit Lod sometimes
WGSL requires an explicit level-of-detail for textureLoad
for sampled textures and depth textures

Fixed: tint:462
Change-Id: I43758b002da91af9901d12664861ace971833020
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38828
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2021-01-26 21:58:34 +00:00
dan sinclair 34ac1afd99 Remove old texture type support.
This CL removes all of the old texture type names in favour of the new
variants.

Change-Id: Icb3c9ed8e39c8d7320fd6a6706b8029fcb3e5947
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38826
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-26 21:44:54 +00:00
dan sinclair c2972cfa60 Remove support for the old _idx builtins.
This CL removes the old _idx variants of builtins in favour of the
_index versions.

Change-Id: I1678b5fae63c9d4f7f63feabf7410a58505d397a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38825
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-26 20:21:31 +00:00
dan sinclair 67beed1b94 Remove support for the set decoration.
This CL removes the set decoration support, it has been replaced by the
group decoration.

Change-Id: Ib9ca94872d39e5da9dbe18bba3cae6d64320e55d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38824
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-26 20:18:51 +00:00
dan sinclair 6e570a9360 Remove support for # comments.
This CL removes support for parsing # style comments. Only the //
comments are accepted now.

Change-Id: I062c2a86149ecf828723c74f7168243678ee5870
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38823
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-26 19:28:51 +00:00
Ben Clayton 1461cd96d6 Add diag::List::add_error() helper
Refactors a common pattern in the tint codebase.

Change-Id: Ia8a70d952fd8c204facd0120f24e43ccc9305622
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38840
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 18:52:11 +00:00
Ben Clayton a6b9a8eb2f Split Program into Program and ProgramBuilder
Program is now immutable*, and remains part of the public Tint
interface.

ProgramBuilder is the mutable builder for Programs, and is not part of
the public Tint interface. ast::Builder has been folded into
ProgramBuilder.

Immutable Programs can be cloned into a mutable ProgramBuilder with
Program::CloneAsBuilder().

Mutable ProgramBuilders can be moved into immutable Programs.

* - mostly immutable. It still has a move constructor and move
  assignment operator - required for practical usage - and the
  semantic information on AST nodes is still mutable.

Bug: tint:390
Change-Id: Ia856c50b1880c2f95c91467a9eef5024cbc380c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38240
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 1f7e18bbc0 ast::Builder: Add shortcuts to the Program methods
This builder will be merged into ProgramBuilder, where these will become methods.
To breakup this change, perform the refactoring as a separate change.

Bug: tint:390
Change-Id: I2c9151cd9f198e99d88eaf296dd994293df6c425
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 8d391f7a10 ast::TypesBuilder: Change const fields to getters
This is required in order to support move operators for TypesBuilder.

Bug: tint:390
Change-Id: I9667bda5f5be267df092f5cd94dc40db053ae6e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38555
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton deb02019d5 transform: Fix multiple mutability issues with VertexPulling
ConvertVertexInputVariablesToPrivate() mutated the source program global variables, and copied them into the destination program.

Symbols and types were assigned across the program boundary without cloning.

Bug: tint:390
Change-Id: I03c8924e6ba94b745e74de0ab57f8a489e85cc50
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38554
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 5d9b1c38c2 Add CloneContext::Replace()
Instructs the clone context to replace a single object instance with a given replacement.
Will be used to fix brokenness in transforms.

Bug: tint:390
Change-Id: I17bf1cdf7549f697281ca7c286bdb5771e5a6f1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38553
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 3bd1f81889 hlsl & spriv writers: Remove const_cast hacks
Use the new type::Manager::Wrap() function to build a new temporary type manager that wraps the program's type manager.

This allows the writer to construct temporary new types (if they weren't already in the program) without actually mutating the program.

Bug: tint:390
Change-Id: Icadab42d66e0a88c494bd21b3a4f7bae2ed13832
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38552
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton a458c57662 type::Manager: Add Wrap()
Wrap returns a new Manager created with the types of `inner`.

The Manager returned by Wrap is intended to temporarily extend the types of an existing immutable Manager.

Bug: tint:390
Change-Id: I46bebf8b83cf7987ddcf2513c54f9f885a028c60
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38551
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 44bec80e5f Demangler: Change signature of primary Demangle() function
Have this take a SymbolTable instead of a Program.
Program will be split into Program (immutable) and ProgramBuilder (mutable). We'll need Demangler to support both.

Bug: tint:390
Change-Id: I6447dd9674919d4867ed8ba126880cdfd9bf7128
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38550
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton d7137d7233 Program: Remove deprecated symbol methods
Fixup all usages

Bug: tint:390
Change-Id: If861b044eae006af2fd86d348de6ba62f448bc6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38549
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton cf757e3a89 Program: Remove deprecated types and nodes methods
Fixup all usages

Bug: tint:390
Change-Id: I14c9a0420be7da2d26bf21bce96ca0ded0978711
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38548
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 83158f214f Program: Remove deprecated function methods
Fixup all usages

Bug: tint:390
Change-Id: I949235908e50702d6c8b2e7e2299594879653e01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38547
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 1b3d6e460c Program: Remove deprecated constructed-type methods
Fixup all usages

Bug: tint:390
Change-Id: I739a7625cd385cb889369ab7c766462fbcd7cf12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38546
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton a86f4effe4 Program: Remove deprecated global variable methods
Fixup all usages

Bug: tint:390
Change-Id: I2e239dfc77872acb9f0b2ee5494350605dd780a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38545
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton a07396a13c Reintroduce ast::Module as the root AST structure
Holds the global variables, constructed types and functions.

Deprecate the functions on program that forward on to the module.
These will be fixed up in another change.

Bug: tint:390
Change-Id: I47b6921a7d84be18113dec830c8435d4e0d4182d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38544
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 9f7a414505 Namer: Take a SymbolTable instead of a Program
Program is going to undergo some heavy refactoring.
Reduce unnecessary dependencies to what Namer actually wants.

Change-Id: Ie411da113a2728321c52ba0a72ae7c2139469886
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38543
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton d542a2875f SymbolTable: Rename GetSymbol() to Get()
The Symbol suffix is unnecessary, given the class name

Change-Id: Ibf222555a8bf5c3e4b6cf27e8006573570b1bd48
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38542
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton c40f627bea Migrate from using ast::Module to Program
Enforce all places where Dawn passes in or returns a ast::Module, now takes a `const Program* ` or returns a `Program`.

As the end goal of all this is to have immutable Programs, all Program inputs take a pointer instead of moving the actual object.

As consumers of a Program are now all const, we have to const_cast to work around all the places we've been incorrectly mutating a ast::Module.
These const_casts are temporary, and will be fixed in the next set of changes.

Depends on https://dawn-review.googlesource.com/c/dawn/+/38522

Bug: tint:390
Change-Id: Ie05b112b16134937d1b601e9b713ea4ec4e1c677
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38541
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton be610ba987 Add TypeDeterminer::Run()
This is a temporary function to help with Dawn migration.
It will be removed after the migration to using Program and ProgramBuilder is complete.

Bug: tint:390
Change-Id: I98c73a6b8102eebf48a889315a376195f9379f63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38556
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-25 22:09:18 +00:00
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
Vasyl Teliman 579f6a0450 Fix typos in CMakeLists
Change-Id: Ieeafecd850b9b18e18596fbe6d41df9ff2944b80
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38102
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-18 21:39:14 +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
Ryan Harrison 7edf1fbc20 Initialize transform manager to null in fuzzer
BUG=chromium:1167337,chromium:1167634,chromium:1167759

Change-Id: Id7eeab225bd29862e43d18f1e44c6ec8b99e26d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38160
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>
2021-01-18 19:48:54 +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