Follows the basic shallow-clone pattern of type::Manager::Wrap(),
which this new method uses.
Use ProgramBuilder::Wrap() in the writers, where we were previously
using type::Manager::Wrap(). This simplifies some of the logic
(especially around AppendVector()).
This is now required as semantic information is generated inside the
writers for newly constructed AST nodes, and we need to register
this semantic info so it can be fetched later.
Change-Id: Ia362204a1f13054e50545baeb7d269f210a36826
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39004
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Will hold the mutable fields that currently reside in the otherwise immutable-AST.
Change the AST string methods to accept a `const semantic::Info&`. This is required as some nodes include type-resolved information in their output strings.
Bug: tint:390
Change-Id: Iba494a9c5645ce2096da0a8cfe63a4309a9d9c3c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39003
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
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>
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>
`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>
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>
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>
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>
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>
This reverts commit 2f7fea1f19.
Reason for revert: breaks autorollers
Original change's description:
> Extract demangler out to separate source set
>
> And add this as a dep to libtint_core_src and tint_ast_clone_fuzzer.
>
> Should fix chromium autoroller
>
> Change-Id: Ic5f43bae85e010839a1940c1ae2d570a9613d269
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37708
> Commit-Queue: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
> Reviewed-by: dan sinclair <dsinclair@chromium.org>
TBR=rharrison@chromium.org,dsinclair@chromium.org,bclayton@google.com
Change-Id: If872d1655e13dd5d67f898a3d9a43c76b2866973
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37845
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
And add this as a dep to libtint_core_src and tint_ast_clone_fuzzer.
Should fix chromium autoroller
Change-Id: Ic5f43bae85e010839a1940c1ae2d570a9613d269
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37708
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
BUG=tint:445
Change-Id: Ic342c7e83827bcc57bfd134dec92b03cb9708a70
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37540
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This removes the requirement of targets that depend on libtint needing
to include the transitive deps to access somethings like headers.
BUG=tint:447
Change-Id: I52a86b93e517f2745f04711f508a838f8f6850b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37720
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>
Revert "Revert 3 fuzzing CLs, since they are preventing rolling into Chromium."
This reverts commit 1d9935cf37.
Also adjusts BUILD.gn file, so that Chromium build can find all the
needed symbols.
BUG=tint:58,tint:59,tint:193,tint:194,tint:199,tint:436
Change-Id: I3fe71ff52c8156f30fccfaab0bf7f647f158aea4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37460
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>
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>
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>
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>
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>
Revert "Adding fuzzing for Transforms"
This reverts commit 4a29008c7e.
Revert "Add fuzzers for various emission paths"
This reverts commit 39545b7e7c.
Revert "Create common utility class for fuzzing"
This reverts commit 766e31d507.
Change-Id: Ia4e4ea2a4a5f423ea5bfa8ca9659c4028b558b45
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37180
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Fuzz all transforms being applied together, and fuzz each transform
separately.
BUG=tint:436
Change-Id: I53cf2e05c69f495f27bfa428f55ec033a85a612a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36945
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
BUG=tint:58,tint:59,tint:194,tint:195
Change-Id: Ibca5efbcd608489dcb7c6c45a5fcf596b97165dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36901
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
This moves the usage of Tint in the fuzzers into a single class. This
will be expanded in the future to support emitting shaders, so fuzzing
tests, just need to indicate which reader & writer they want to use,
instead of having each test implement all of the API usage logic
directly.
BUG=tint:199
Change-Id: Id081a374014b7640a07b267e544ddeba3e6329dd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36760
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The new module clone tests require the WGSL reader and writer in order
to function. This Cl adds those dependencies to the BUILD.gn file.
Change-Id: I34cd9a7de13a99145bad1f559c23d181f4fb7739
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34683
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
The AST clone fuzzer was accidentally named the same as the
SPIRV-Reader fuzzer. This Cl renames to fixup the conflict.
Change-Id: I757163718dc4e2097564427f4ac9f97a6cba9d55
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34680
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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>
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>
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>
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>
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>
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>
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>
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>
This CL moves the namer into the context object and makes it a parameter
to the various generators. The old constructor is maintained until we've
updated downstream repos.
Bug: tint:273
Change-Id: I49b2519c4250be21fb73374b16e7c702b727078f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32580
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This Cl adds an ast::Builder class which provides a series of helper
methods to make creating AST nodes simpler.
Change-Id: Ife57f27e598d575681f7192d65fab968191699b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32560
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Use synchronization tokens to ensure the parser can resynchronize on error.
Bug: tint:282
Change-Id: I8bb033f8a723eb8f2bc029e1ffc8350174c964e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32284
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This Cl hashes the OpName, OpEntryPoint and OpMemberName strings so we
are no longer passing user provided strings through into the resulting
SPIR-V binary.
Bug: tint:273
Change-Id: I0ca2c65d0cd2800c54d867ab698c7751c341778c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32061
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
For values of type T* and std::unique_ptr<T>.
This allows us to replace all occurances of `res.value->member` with: `res->member`, which also asserts that `res` is not in an error state.
Brings the verbosity back down to pre-expect and pre-maybe levels.
Bug: tint:282
Change-Id: Ib00018affca53ac5e71ee2140e7e0cd607b83715
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This is the first step in unifying the way decorations are parsed - i.e. instead of parsing decorations in different ways based on the predicted grammar that follows, we can parse decorations blocks in a unified way, then later verify what we have is as expected.
`StructDecoration` has been transformed from an `enum class` to a proper class so it can derive from `Decoration`.
Bug: tint:282
Bug: tint:291
Change-Id: Iaf12d266068d03edf695acdf2cd21e6cc3ea8eb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31663
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
For linux and windows consoles.
Still needs hooking up to `samples/main.cc`
Bug: tint:282
Change-Id: If8430572708ea7d8788ef05d5379886be89fcb17
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31564
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Diagnostics will be used for printing parser / validator error mesasges.
Diagnostics are collected into a `diag::List`, and can then be formatted into a human readable message with `diag::Formatter`.
Bug: tint:282
Change-Id: I8bbef3db22b72d62cb9467c878d9a346890589ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31480
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This is the first step in improving the error messages produced while parsing.
The `line` and `column` information of `Source` has been moved to `Source::Location`.
`Source::Range` has been added that contains a `Location` interval - allowing error messages to highlight the full region of the error.
The `File` information provides an optional file path, and pre-splits the content into lines. These lines can be used to print the full line containing an error.
This CL contains a few temporary changes that help split up this work, and to ease integration with Tint.
Bug: tint:282
Change-Id: I7aa501b0a9631f286e8e93fd7396bdbe38175727
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31420
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
This CL merges the StorageAccess enum with the AccessControl enum. The
enum is moved up to src/ast and placed in its own file for clarity.
Change-Id: I95a905a399b5d2e046ea1ea429b35f2064510c2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31242
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
These are _mostly_ covered in the over various test files, but unlike those, these new tests always parse from the root translation unit.
These new tests also use a new testing class which may be extended to verify error output for different error styles (verbosity, colors, etc).
Change-Id: I105488f9b16d90279af4cc418a1c845b6e239e9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31263
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This CL adds the AST for an AccessControlType. This type contains an
access control (ReadOnly, WriteOnly, or ReadWrite) along with another
type pointer.
Bug: tint:208 tint:108
Change-Id: I2eed03f8760239f7e71dc2edd4a19a7c1661746e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31060
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
This also involves a reorganization of the code into its own
subdirectory.
BUG=tint:253
Change-Id: If05018da2662e923e659b485576704f3a6bcd062
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30340
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This CL updates the WGSL parser to allow array decorations to accept
multiple blocks. The stride decoration on arrays was turned into a
proper decoration object instead of just storing the stride directly.
Bug: tint:240
Change-Id: I6cdc7400d8847e3e043b846ea5c9f86cb795cf86
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29780
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
This class is used to examine a module and get information about its
contents. This is the getting side of shader of reflection. Future
work will add transforms that perform the setting side of reflection.
In addition to the basic class and infrastructure, this CL adds a
GetEntryPoints() function demonstrate it works. More functionality
will be added in later CLs.
BUG=tint:257
Change-Id: If41dbb6c93302e0332754c086c75729d6ffe04d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29320
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This CL holds a simpler manager to hold and execute multiple transforms.
Bug: tint:206
Change-Id: I45f6b55134f871167704f3549c4e4c72ef806c3a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29121
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This CL adds a Transformer base class from which the transformers will
inherit.
Bug: tint:206
Change-Id: I542eacb05d9a92af46d172a5803c245472c0e22c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29120
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL adds a buffer array accessor clamping transform to
the available transforms in Tint.
Bug: tint:101
Change-Id: If9d5b0fb2c3adba723ce2185870b0e10981103a6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28980
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL adds AST support for the constant_id decoration.
Bug: tint:150
Change-Id: Ifde5a5325f770567ea24129e786953d89f3f514b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29100
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL removes the cast operator and converts the tests over to using
type constructors.
Bug: tint:241
Change-Id: I2526acb61f5624b2e1c068612a2ddcc748c92aed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28860
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL moves the transform folder from src/ast to src/. The transforms
operate on the AST, but they aren't part of the AST so I think the top
level folder makes more sense.
This will possibly cause issues when rolling if the transform is being
used.
Change-Id: Ibd7c94474168a7a4bdf38321f4e12ad111c80323
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28941
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL updates Tint to use 'bitcast' instead of 'as' for the OpBitcast
conversions.
Bug: tint:241
Change-Id: I53a80de10421b2d9cc009527eebe5ff07e1285c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28801
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
This CL removes the import mechanism, the identifier paths and updates
all of the standard library methods to be builtins.
Bug: tint:242
Change-Id: If09b98a155ae49ced3986ba2c9b517a060693006
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28720
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL removes the EntryPoint node and transitions everything to the
stage decoration.
Change-Id: Ib2840155905c8fa60ff35870f0c4b6705efb73ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28705
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
This CL adds the emission of StageDecoration to entry point functions.
EntryPoint nodes are still emitted. We duplicate the function emission
if there are multiple entry points pointing to the same function.
Change-Id: Icb48a063f5c6a30948bbe2c37c7fce7431af5864
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28665
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This CL updates the hlsl writer to emit stage decorations.
Change-Id: Ic9ae9fbd47537f141949e27c876d37e6d4dcd97d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28704
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This CL updates the MSL writer to emit data base on the pipeline stage.
Change-Id: I9fb2e146f0c898d9703d69a6a92f535757106bba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28703
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This CL updates the SPIRV-Writer to emit entry point information based
on the function stage as well as EntryPoint nodes.
Change-Id: I1fa937cbb2159b31516b0189216d679e03f0384d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28702
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This CL adds parsing of the stage decoration to the WGSL parser. The
decoration is not hooked up yet so it's effectively ignored.
Change-Id: I8d86c55cee189f993c10b6da31a9c388ba452021
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28664
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This CL adds parsing of the `workgroup_size` function decoration.
Change-Id: Ia90efc2c014ac0e1614429280cc903d30cf8171d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28663
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
This CL adds the workgroup_size decoration to functions and emits as
needed from the various backends.
Change-Id: Ifffde239e68047f6419c6980eca70c4efa9822c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28662
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This CL extends the function AST object to allow function decorations to
be attached.
Change-Id: I5b16aa2e6927792368b7f88047c0229e258b5bd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28661
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
This Cl adds the AST, WGSL-Reader and SPIRV-Writer support for the
`texture_multisampled_2d` type.
Bug: tint:237
Change-Id: Ib3eb831227b49f32162801f1e1b4e474774c78b3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28480
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This CL adds 6 unit tests for validating switch statements.
v-switch01: switch statement selector expression must be of a scalar integer type
v-switch02: switch statement must have exactly one default clause
v-switch03: the case selector values must have the same type as the selector expression
v-switch04: a literal value must not appear more than once in the case selectors for a switch statement
v-switch05: a fallthrough statement must not appear as the last statement in last clause of a switch
Bug: tint: 6
Change-Id: I0283afec22e56097b6f63c8455da23b87dfe26dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27740
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This missing in Dawn was being shadowed by spvc also including it.
BUG=dawn:521
Change-Id: I609cfcca74821ad07c0fd9e6fadf2c22fba40df0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27901
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This CL updates TestHelper to be a templated class and converts the test
suites into using statements based off that template.
Bug: tint:7
Change-Id: I747434e7c6a8ecae353df448f06153e982dcec44
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27500
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This CL updates the HLSL backend to take the output stream as a
parameter. This is needed because there are cases where we have to
generate the resulting stream out of order. This will allow that to
happen.
Bug: tint:7
Change-Id: Id1877a07e536a84da0555f207d1030588d44c034
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27440
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This Cl adds support for imported methods to the HLSL backend.
Bug: tint:7
Change-Id: Ib906542915670dcc916d48d9e5d64d7032ba829a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26928
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This CL adds the beginning of intrinsic emission for the HLSL backend.
The `outer_product`, `is_normal` and `select` intrinsics are currently
missing.
Bug: tint:7
Change-Id: Ice7a2b285eeb52041e3accd9751e127d6c5a0177
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26927
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>