Commit Graph

1952 Commits

Author SHA1 Message Date
Ben Clayton f4c0d54423 Resolver: Add test for continue after var decl
Bug: tint:17
Change-Id: Ibd51269d60447fa0d6408fbaf5b6d023a95073f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44050
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-10 23:15:09 +00:00
James Price 7e17bfbfd9 [validator] Remove obsolete rules and tests
Entry points are now allowed to have parameters and return types as
part of the changes made in:
https://github.com/gpuweb/gpuweb/pull/1426

Bug: tint:512
Change-Id: I20caa940f6d194f62ce1dfa5d247927c5b5a9628
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44080
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-10 22:36:59 +00:00
Ben Clayton d9250a5a21 Parallelize cpplint
On my machine this reduces the time taken from 23 seconds -> 2 seconds

Change-Id: I676b89251fc183171cc3d955873960b00cb48bc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44164
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-10 15:18:39 +00:00
Ben Clayton 8454d824d4 ast: Replace IsValid() with TINT_ASSERT()
The readers must not produce invalid ASTs.
If readers cannot produce a valid AST, then they should error instead.
If a reader does produce an invalid AST, this change catches this bad behavior early, significantly helping identify the root of the broken logic.

IsValid() made a bit more sense in the days where the AST was mutable, and was constructed by calling setters on the nodes to build up the tree.
In order to detect bad ASTs, IsValid() would have to perform an entire AST traversal and give a yes / no answer for the entire tree. Not only was this slow, an answer of 'no' didn't tell you *where* the AST was invalid, resulting in a lot of manual debugging.
Now that the AST is fully immutable, all child nodes need to be built before their parents. The AST node constructors now become a perfect place to perform pointer sanity checking.

The argument for attempting to catch and handle invalid ASTs is not a compelling one.
Invalid ASTs are invalid compiler behavior, not something that should ever happen with a correctly functioning compiler.
If this were to happen in production, the user would be utterly clueless to _why_ the program is invalid, or _how_ to fix it.
Attempting to handle invalid ASTs is just masking a much larger problem.

Let's just let the fuzzers do their job to catch any of these cases early.

Fixed: chromium:1185569
Change-Id: I6496426a3a9da9d42627d2c1ca23917bfd04cc5c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44048
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-03-10 11:41:49 +00:00
Antonio Maiorano 6ce58becd2 Fix VS clang-cl build
* Disable "undefined-var-template" in code, rather than in build files
* Add back some missing headers required when building in this context
* Make sure gtest/gmock do not override the default runtime library

Change-Id: I12c05943fc1d2dee4733ae70db7da026f67e0dad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44180
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 21:51:50 +00:00
Ben Clayton 5fb87dd915 Resolver: Validate if() conditions are bools
Fixed: tint:317
Change-Id: Ica56dfb12d6b1a45e61d0d791f723414b464da5f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44163
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:17:28 +00:00
Ben Clayton 2c41f4fbdf Resolver: Split tests into multiple files
Try and make sense of the huge number of tests we have.

Rename tests so they have a consistent naming style.

Change-Id: I0c089d5945778a8718480a1a2f854435e7b0e79a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44162
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:12:57 +00:00
Ben Clayton 786cea419d Add resolver::TestHelper
First step in splitting out resolver tests into multiple files

Change-Id: I58c66ad5e348a50b3e028dff5749cfacb273ea62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44161
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:10:27 +00:00
Ben Clayton c7dcbae41c Resolver: Place into a resolver namespace
I'm going to start pulling apart the resolver tests into separate files, and the test helper shouldn't go into the root tint namespace.

Change-Id: Ie7d131c5b92837c6c9df05b2938cf014a0402ce2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44160
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:08:48 +00:00
Ben Clayton 9430cb4775 Resolver: Validate usage of break
Also remove unused fields of Resolver (block_to_info_, block_infos_). We can put them back when they're actually needed.

Fixed: tint:190
Change-Id: I1a02a24eca7fba32b8e1120abb88040138a39c6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44051
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:06:37 +00:00
Antonio Maiorano 5e9eb2037d spir-v builder: fix loop-scoped variable not found in continuing block
Make sure variables from the loop block remain in scope for
continuing block. Note that we need to do this because the continuing
block is a sibling of the loop body block in the AST, rather than a
child.

Added test.

Fixed: tint:526
Change-Id: If622995e3aac4cd3c06c2dbd87ffcaa36b0f09c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43680
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-09 14:41:17 +00:00
Ben Clayton 6341fa5801 CMake: Remove TINT_ENABLE_SHARED_CRT
And if tint is being built as a sub-project of another project, default to not building documentation or tests.

See dawn-review.googlesource.com/c/dawn/+/43961.

Change-Id: I1133511822efe3d1fc35675ed599de76914d1881
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44045
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-09 13:55:37 +00:00
Ben Clayton 01df2a7cee Add TINT_ASSERT()
Replacement for the places where we currently use assert(), and there is no sensible place to put the error into a diag::List.

Change-Id: Id154340b0353f8a3e8962771263f1cc87dce2aa4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44047
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-09 13:52:18 +00:00
Ben Clayton 5b36d2c612 Remove all unnecessary includes
All includes from .cc to .h are preserved, even when transitively included.

It's clear that there are far too many includes in header files, and we should be more aggressive with forward declarations. tint:532 will continue to track this work.

There are, however, plenty of includes that have accumulated over time which are no longer required directly or transitively, so this change starts with a clean slate of *required* includes.

Bug: tint:532
Change-Id: Ie1718dad565f8309fa180ef91bcf3920e76dba18
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44042
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-09 11:11:17 +00:00
Ben Clayton 5f0ea11365 Rename TypeDeterminer to Resolver
Move out of the src root and into its own subdirectory
Rename methods to remove the 'Determine' prefix.

Fixed: tint:529
Change-Id: Idf89d647780f8a2e7495c1c9e6c402e00ad45b7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44041
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-09 10:54:37 +00:00
Antonio Maiorano fd31bbd3f1 TD: validate continue statements bypassing body variables
We now keep track of scopes as a tree of BlockInfos that track variables
declared in each scope. For loop scopes, we store the index of the first
variable (if any) that follows the first continue statement. Using this
data structure, when parsing expressions, we validate that used
variables in continuing blocks are not bypassed by a continue statement
in the parent loop block.

Also:
* Validate that continue statements are in a loop in TD. This error is
already caught by the spir-v writer, but better to catch it here.
* Add more utility functions to ProgramBuilder to make it easier to
write tests

Fixed: tint:17
Change-Id: I967bf2cfb63062bac8dcca113d074ba0fe2152e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44120
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-09 10:26:57 +00:00
Ben Clayton b78251fdcd Add tools/trim-includes: Script to clean up includes
Change-Id: I37e98f7bf6cc4f6a10eaae6b87b2c8e46dcdee18
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43885
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-08 20:49:47 +00:00
Ben Clayton fe2ceb9b5d reader/wgsl: Remove ParserImpl::diagnostics()
Put all errors straight into the ProgramBuilder::Diagnostics()

Fixes a TODO. Kills an assert().

Bug: chromium:1185569
Change-Id: I4e6f3b06106c3cfe75cf2bcdfc56b14ad73e81d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44046
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-08 16:17:55 +00:00
Ben Clayton acc7712e25 Add an OWNERS file
Change-Id: I90012e62e7fcc7fb396e10c8c4fd2ca1e4a41ba4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44044
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-08 16:07:55 +00:00
Ben Clayton 13ee0fbdf3 Move msl_test.cc to correct source_set
Should fix dawn's autorollers

Change-Id: I6d46af611a3fc699eabeec92b395d9df48cc03fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44040
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-03-05 15:02:45 +00:00
Ben Clayton f9f48c60f7 transform/Renamer: Pass through swizzles and intrinsics
These must not be mangled.

Bug: tint:273
Change-Id: I05b02bf785c9d6ab587996bfed284e89912cd0cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43941
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 23:37:25 +00:00
Ben Clayton 97b92178c5 writer/msl: Remove the renaming logic
This is now entirely handled as transforms.

Bug: tint:273
Change-Id: Ib3c0db7b5ecf024b6ae2aed7788e4b582d07c4ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43983
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-04 23:24:05 +00:00
Ben Clayton 37d2b35d59 transform::Msl: Rename reserved keywords
This change begins the work to move the reserved keyword remapping out of the writer and into the sanitizer transform.

If the transform::Renamer is in use, then these symbols should never have to be remapped - however for debugging purposes it is often nice to be able to emit code that isn't entirely mangled.

The logic in the msl writer will be removed as a followup change

Bug: tint:273
Change-Id: I76af03ff80388a48d9dd80a5b5fdfe21f3c8e7a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43982
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 23:03:25 +00:00
Ben Clayton f25d51977a Move IntrinsicType parsing to semantic/intrinsic.h
Keeps the enum / parse / print code all together.

Change-Id: I78e5e15b6a97d3aec619a94e4390ecc4a77ab478
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43980
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 23:00:46 +00:00
Ben Clayton dee7d36f8a reader/wgsl: Tail-call optimize expression methods
Fixes stack overflows in complex arithmetic expressions

Fixed: chromium:1182709
Change-Id: I5f5470cf59525725a437f26672904e9653b447a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43940
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 22:52:05 +00:00
Ben Clayton d1781fd0af Remove tint::Namer
Replaced with tint::transform::Rename and was never used.

Bug: tint:273
Change-Id: Icf0b19b389377f3c9a6efcf3ca232ba294775f9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43981
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-03-04 21:00:15 +00:00
Ben Clayton 798876e7eb Optimize demangling
Don't continually replace the string in-place.
Makes pathological fuzzer tests ~140x faster to run.

Fixed: chromium:1182606
Change-Id: I48bd39ecb8488e34c9e75da52b5e9f355ca896ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43920
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-03-04 16:29:05 +00:00
Ryan Harrison f76f3081af Add dumping inspected bindings for shader
Adding a flag to the tint sample binary that allows you to dump what
the inspector is reflecting about the bindings in a shader.

This has already helped me identify one blindspot in the validator.

BUG=tint:530

Change-Id: I6709f1d8f8391a1419d07abebf210e9e358e0861
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43820
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 15:30:35 +00:00
Ben Clayton e18a18bc1c Add transform::Renamer
Renames symbols.
Currently only supports renaming to a symbol with a monotonic increasing suffix.

Change-Id: I7ae67a7b1740ac0e83c1821643cf7b8b1959f84d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42842
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-04 11:12:45 +00:00
Ben Clayton 5ca9741b69 CloneContext: Add support for transforming symbols
Will be used by a Renamer transform

Change-Id: Ic0e9b69874f51103f0beec7745d32a9f8419e93a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42841
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-04 10:42:55 +00:00
David Neto ec44eef965 spirv-reader: handle OpUndef at module scope
Fixed: tint:523
Change-Id: I47639c8f701ca049c7215874cdea27f86d8a415b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43760
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-03 19:58:04 +00:00
Ben Clayton 5a13258981 TD: Fix O(2^n) of reachable-by-entry-point
Re-jig the code so that this can be performed in O(n).

Fixed: tint:245
Change-Id: I6dc341c0313e3a1c808f15c66e0c70a7339640e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43641
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-03-03 19:54:44 +00:00
Ryan Harrison 04d93c88a0 Add inspector support for DepthTexture reflection
BUG=tint:527

Change-Id: I4f017993ffa85515b5b646bd9cf15c4b6d50c441
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43700
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-03 13:46:43 +00:00
Ben Clayton 7732ca51c4 Rename TINT_INSTANTIATE_CLASS_ID()
to TINT_INSTANTIATE_TYPEINFO()

ClassID isn't a thing any more.

Change-Id: Ie1c0d4a95e58ef7166d3cab5ef733a2dfc702345
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42921
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-02 20:51:18 +00:00
Ryan Harrison 2f8df72930 Reland "Remove deprecated textureLoad overloads with no level param"
This is a reland of cc4c22ebaa

Original change's description:
> Remove deprecated textureLoad overloads with no level param
>
> BUG=tint:516
>
> Change-Id: I7004e0dbd44d703c684118136b05b84cf609c6ba
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42703
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Ryan Harrison <rharrison@chromium.org>

Bug: tint:516
Change-Id: Ic52893c78046cd54575cea51c244f6df5a4f843c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43620
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-02 20:31:58 +00:00
Ben Clayton e879143801 Pull Is() out of castable and into a new TypeInfo
Allows you to query type inheritance without having an instance of the type.

Also add TypeInfo::name. Helpful for decent error messages. Strings can be removed from NDEBUG builds if we consider them too large.

Change-Id: Ie501b37f46e63d956cc020f8c9b68e91737472f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42920
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-02 20:30:08 +00:00
Ryan Harrison 5cfd4f5a07 Revert "Remove deprecated textureLoad overloads with no level param"
This reverts commit cc4c22ebaa.

Reason for revert: Broke Dawn e2e tests w/ SwiftShader

Original change's description:
> Remove deprecated textureLoad overloads with no level param
>
> BUG=tint:516
>
> Change-Id: I7004e0dbd44d703c684118136b05b84cf609c6ba
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42703
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Ryan Harrison <rharrison@chromium.org>

Bug: tint:516
Change-Id: I6b7857304872fd0048c23999ac223ce9dcaf7fe1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43540
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
2021-03-02 12:39:34 +00:00
Ben Clayton 1653668355 Remove deprecated transform APIs
Change-Id: I330b52ed6b485690a64c74fe34bebfe02fb52598
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42265
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-03-02 11:53:42 +00:00
James Price a349e54149 Remove unused testing files
Change-Id: I0af37c775a818a5a76baa48fb8e55b38c6b40eee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43480
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-01 23:22:19 +00:00
James Price 9062f13202 Rename test file for consistency
We use _test.cc for everything else, so this makes globbing for test
sources simpler.

Change-Id: I6d1a3ad0f3bbeaabe981fbce66967de7e2f9e4d5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43481
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-01 22:51:39 +00:00
Antonio Maiorano 364b30f7de spirv builder: allow unsigned int cases for switch statements
Change-Id: If7a8955961b56925cae538249d4e17495d3f8e1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42901
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-03-01 22:44:19 +00:00
Ryan Harrison cc4c22ebaa Remove deprecated textureLoad overloads with no level param
BUG=tint:516

Change-Id: I7004e0dbd44d703c684118136b05b84cf609c6ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42703
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-03-01 21:54:49 +00:00
Antonio Maiorano fe2b417f83 Validate swizzles don't mix between rgba and xyzw
Added test.

Bug: tint:79
Change-Id: Ibb17cc2d9198403cdf6a2e456ad29d906deac9f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43460
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-01 20:01:39 +00:00
Antonio Maiorano 05d9bffdbd Make IntLiteral store and return a u32 value
With this change, the base IntLiteral class now stores a u32, and
derived UintLiteral and SintLiteral are implemented in terms of it. This
will allow us to improve the current pattern of casting down to each
derived type to retrieve the value.

Change-Id: I0c1e56c5e04333a0d3d5f30a3fb28e784f785843
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42900
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-02-26 22:56:16 +00:00
Ben Clayton a8b20bec7b CloneContext: Drop the first CloneContext* parameter from the ReplaceAll() callback
You have to have the CloneContext in order to call ReplaceAll() in the first place. The overhead of capturing the pointer in the closure is negligible.

Cleans up the callsites.

Change-Id: I3a0fd808517d69f19756f590f3426e5ba226c57e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42840
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-26 19:33:56 +00:00
Ben Clayton d5638c93c5 BoundArrayAccessors: Add more tests
Bug: tint:521
Change-Id: I0a9ea7f487b052d1ee6ffa5be079d18633acc72c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42844
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-02-26 18:53:36 +00:00
Ben Clayton 4bd4b8fecb .gitignore: Add default.profraw
Emitted in the CWD when you run executables with the coverage enabled.
I find myself running the unittests from the project root a lot, and this file is annoying to skip when staging code.

Change-Id: I25557c941b2723aa300fcde827d281b054cbf2fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42843
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-26 18:39:08 +00:00
Antonio Maiorano 6ce2edfa1f Validate sign of RHS matches LHS for scalar variable declarations
Statements like `var u : u32 = 0;` should fail because '0' is a signed
integer being used to initialize an unsigned variable.

Added test.

Bug: tint:79
Change-Id: I34f6d21b4355167f49f9a8b5d4ed34a808823185
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42702
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-02-26 18:25:56 +00:00
Ryan Harrison e5c105d40a Add testing for 1D w/ level textureLoad overload
BUG=tint:516

Change-Id: Ic075dc52618bc6d2492e82538f0f02d45f925ddf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42700
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-02-25 23:57:28 +00:00
dan sinclair 2aaf7b5c76 [MslWriter] Emit using statement for metal
This CL updates the MSL backend to emit a using namespace for metal
instead of using the `metal::` prefix.

Bug: tint:463
Change-Id: I63d3ea5b5a56e61d71cd6d17a51a5120363ea007
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42741
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-02-25 21:17:47 +00:00