Commit Graph

1930 Commits

Author SHA1 Message Date
Ben Clayton 89036852cc Don't build test_main.cc in chromium builds
Chromium has its own test main() entrypoint.

To ensure that Chromium doesn't panic about memory leaks with the tests that exercise the ICE cases, we have to explicitly call the FreeInternalCompilerErrors() functions in these tests (at least until I can add this to end of Chromium's test main() function)

Change-Id: I2ea5109fcdb5f68f56a19709a1ec35ed72c0f760
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42025
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-18 20:23:09 +00:00
Ryan Harrison 94cfbbeb5f Extract more StorageTexture information
BUG=tint:489

Change-Id: I03a15fdd156bf0c85b1afebb6e0e26fd44dff51f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42060
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-02-18 20:11:49 +00:00
Ben Clayton 15daded41b hlsl/writer: Fix output for texture intrinsics and types
Fixed: tint:146
Change-Id: Icf356faf7bee364a0783c717ee76ea98056b4401
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42022
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 16:49:48 +00:00
Ben Clayton 1d5a7eb82f semantic::Function: Clean up ReferencedXXX() return types
Use a type alias for the most common and lengthy return type.

Drop the `const` from the return type - it is (or at least should be) meaningless.

Fix `auto& referenced_variables =` local variable declaration in inspector.cc.
You cannot take a reference to a non-ref return value of a function.
I have no idea why the compiler wasn't erroring about this.

Change-Id: Icc0b4a9bf4b4c9d03b44670eda27214ef04ad41c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42021
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-18 16:36:18 +00:00
Ben Clayton 3a9a55eec6 ICE macros: Use '<<' for error message
Lessens the friction of using these macros.
Also allows you to add a message to TINT_UNREACHABLE(), which you couldn't do before.

Change-Id: Ida4d63ec96e1d99af71503e8b80d7a5a712e6a47
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42020
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 16:33:38 +00:00
Ben Clayton 41085503e1 Add hlsl::TestHelperBase::Validate()
Looks for DXC on PATH.
If found, it will invoke DXC with the shader program generated by the writer to verify the shader can compile.

Change-Id: Iad8b4021bac16d01214b500ddb89b5f743927ce9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41943
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 16:19:09 +00:00
Ben Clayton ce7e18e87c Add tint::Command
Command is a helper used by tests for executing a process with a number of arguments and an optional stdin string, and then collecting and returning the process's stdout and stderr output as strings.

Will be used to invoke HLSL and MSL shader compilers to verify our test generated code actually compiles.

Change-Id: I5cd4ca63af9aaa29be7448bb4fa8422e6d42a8ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41942
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 15:49:08 +00:00
Ben Clayton a87fda9225 Add tint::TmpFile
TmpFile constructs a temporary file that can be written to, and is automatically deleted on destruction.

Will be used to create a temporary source file for verifying generated HLSL and MSL against their shader compilers.

Change-Id: Ieaa6f257b93f4f2193dafe6297603816f6964928
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41941
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 15:39:00 +00:00
Ben Clayton 7206e25798 Remove deprecated APIs
Remove the Parser classes from the wgsl and spirv namespaces.
These have been replaced with a Parse() method.

Remove the TypeDeterminer::Run() method, this was not called by tint and
the TypeDeterminer is now non-public API.

Change-Id: I5ddb82768da04398ab3958d1647be44f9fe30c21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41840
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-17 20:15:25 +00:00
Ben Clayton 6b4924fb0e Add TINT_UNREACHABLE() and TINT_ICE() helper macros
Appends an error message with the tint compiler source location to the
provided diagnositic list, and then calls the global error handler if
one is set.
Tests and the sample app now register an error handler to print the
diagnostic list to stderr and abort when NDEBUG is not defined.

All uses of assert(false) have been fixed up to use these macros.

Change-Id: I2f63e51ed86ac23883301d280070bd1a357c6cb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-17 20:13:34 +00:00
Ben Clayton c7ca7668cc Fix TypesBuilder::builder pointer initialization
When copying or moving a ProgramBuilder, we always want the ProgramBuilder::ty to point back to the owner.
We were previously std::move()'ing the ty field, which is not correct - this will result in the TypesBuilder pointing to the wrong ProgramBuilder.

I'm not sure why we've not seen any issues with this using clang, but running under MSVC immediately highlighted this brokenness.

Change-Id: I4293bb00ac4fbdfa66d12b1504a7bd060e014cd6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41861
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-17 16:23:52 +00:00
Ben Clayton 34ae7d2ce7 wgsl/parser: Avoid stack overflows
Most recursive control flow passes through Sync().
Error out if the Sync() function is recursively called too many times.

This replaces the more specific kMaxConstExprDepth, which also passes
through Sync().

Fixed: chromium:1178436
Change-Id: I64a05f9f6a4fe6d2b53a3ca75642b30e98c7a35f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41724
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-17 16:16:02 +00:00
Ben Clayton 52296de528 Add tint::Cloneable base class
The CloneContext was previously dealing with pointers to CastableBase, which has no guarantees that the object was actually cloneable.
Add a Cloneable base class that CloneContext can use instead.

Improves readability and produces cleaner compiler errors if you try to clone a non-cloneable object.

Change-Id: I4352fc5dab3da434e4ab160a54c4c82d50e427b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41722
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-17 13:17:39 +00:00
Ben Clayton f81df124f6 Add utils/unique_vector.h from TypeDeterminer
Add tests.

Change-Id: I064fbbe2387ebe980776ee99ed2ff48d6ea5d5b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41621
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-17 13:10:49 +00:00
Ben Clayton 43a160dcbb Validator: Strip out unreachable code
A large chunk of validation is now handled by the IntrinsicTable. Remove this.

Also fail validation and propagate diagnostics from the Program to the validator if attempting to validate a broken program. This should prevent undefined behaviour if the user forgets to check the program.IsValid() after parsing.

Change-Id: I2972e8ce296d6d6fca318cee48bc6929e5ed52db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41549
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-02-17 01:08:41 +00:00
Ben Clayton 4602ce7195 ast: Remove @notes about semantic info not being cloned
Semantic info is no longer part of the ast, so it is now odd to mention semantic info on a clone method for the AST.

Improve the documentation around cloning on the Program methods and the CloneContext.

Change-Id: Ib1cf255acfd994521aaa5add2789e5117db6b072
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41548
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-02-17 01:01:03 +00:00
Ben Clayton 81a29fe555 ProgramBuilder: Remove storage parameter from [Global]Const()
Storage classes are unused for constants.

Also trim extra arguments to these variable constructor functions that are already defaulted to the same value.

Change-Id: Ia0b44364de000bfb8799de15827ce08fcce5f5be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41541
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-02-17 00:26:52 +00:00
Ben Clayton 37571bc32d ProgramBuilder: Swap parameter order for Var and Const
Move the storage parameter after type.
Const() has no use for storage classes, so this parameter will be removed in the next change.
This reordering keeps Var() and Const() parameter types identical for the first two non-optional fields

Change-Id: I66669d19fa2175c4f10f615941e69efcab4c23e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41540
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 23:57:01 +00:00
Ben Clayton 4b9e7f92b9 transform::Hlsl: Hoist array initializers out of expressions
Move these into a separate const variable declaration statement just above the before the use of the array initializer.
HLSL does not allow array initializers as part of a sub-expression

Fixed: tint:406
Change-Id: I98f93f2eca172865691831011c852de5e57c5ad6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41484
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-02-16 23:21:51 +00:00
Ben Clayton f77771e21b CloneContext: Add InsertBefore()
Inserts objects before others when cloning

Change-Id: Ibf247abae3aeb3d351048f1182db2a2b42b2c677
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41547
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 23:09:31 +00:00
Ben Clayton e909744640 CloneContext: Use As<T>() instead of static_cast<T>
And assert that the cast succeeded.

There is a danger with Replace() or ReplaceAll(), where you can end up replacing a node with another node of an incompatible type for some reference of that object. Previously this would silently cast to the incorrect type, and Bad Things would happen. Now we will assert in this situation.

I have not observed this issue happening (all current uses of Replace() and ReplaceAll() are believed to be safe). This is just an edge case I've spotted and wanted to add some safety belts for.

Change-Id: Icf4a4fe76f7bc14bcc6b274de68f7d0b3d85d71f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41546
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-02-16 22:27:11 +00:00
James Price ea9e471e30 [spirv-writer] Add support for sample index/mask builtins
Use a sanitizing transform to convert scalar `sample_mask_{in,out}`
variables to single element arrays.

Add the `SampleRateShading` capability if the `sample_index` builtin
is used.

Bug: tint:372
Change-Id: Id7280e3ddb21e0a098d83587d123c97e3c34fa1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41662
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-02-16 21:44:13 +00:00
James Price 1413733be8 [wgsl-reader] Add support for sample index/mask builtins
Bug: tint:372
Change-Id: I2cbadf31f350c49ae0689d8b05f3f7a92d074efd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40560
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-02-16 21:37:01 +00:00
James Price c9af597997 [semantic] Add semantic::Variable::Users()
Returns a list of ast::IdentifierExpression* nodes that reference the
variable.

Change-Id: I36f475c6ddf5482f9ae9b432190405625f379f0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41661
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 21:15:01 +00:00
Ben Clayton 45b18ce064 Fix CMake build, fix doxygen warning
inspector_test.cc: Remove unused method
test_helper.h: Fix comment type on member

Change-Id: I53b1392fa1fa8154efdcd471d1df1bbf27e04dc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41728
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 20:56:21 +00:00
Ben Clayton f97b9c9310 Add semantic::Statement
Add Stmt() accessor on all semantic::Expressions so the owning statement can be retrieved.

Change-Id: I5d584335a6d137fdeab0b8d74a161fcae9b46080
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41545
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-02-16 18:45:45 +00:00
James Price e7dab3c9ea [ast] Rename Builtin::kSampleId to Builtin::kSampleIndex
Other builtins use WGSL terms instead of SPIR-V terms too, and the
WGSL writer is relying on the output of `operator<<(Builtin)`, which
just stringifies the name of the enum. This also matches the
equivalent `semantic::Usage::kSampleIndex` enum.

Added test coverage for WGSL builtin generation.

Bug: tint:372
Change-Id: I8077d22c4a5ddf67b1ad07e7365453db74db8e7d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41660
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
2021-02-16 18:21:41 +00:00
Ryan Harrison d086c147d0 Add support fo extracting information about Storage Textures
BUG=tint:489

Change-Id: I28e4b0e568aea463971e9d2f5a04f04e942e2564
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41600
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 15:10:23 +00:00
Vasyl Teliman 652d40a3d1 wgsl-reader: Add support for nested array accessors
Bug: tint:501
Change-Id: I23f4e73696f48d29b3f9d63997fa1c5004cf4d34
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41622
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-02-16 14:53:49 +00:00
David Neto 909c166034 spirv-reader: ignore NonSemantic. extended instructions
This is the first step in being able to read code generated
by Clspv.

Actively ignore the instructions instead of applying stripping
transform before hand. That way we have a chance at properly counting
instructions, which helps produce better diagnostics.

Bug: tint:3
Change-Id: I82bde88897485380d70dc8b287c3843eae5489b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41641
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 14:51:48 +00:00
James Price c8fa020a5e Add missing WGSL writer test files to BUILD.gn
These files were added in dfd1714, but only added to CMakeLists.txt.

Change-Id: I775e8fef68b2f4900a6c562533512f0eda01b795
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41700
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 14:39:48 +00:00
Ben Clayton 545c9742d5 Cloning: move arguments to create() into temporary locals
In C++ argument evaluation order is undefined. MSVC and Clang evaluate these in different orders, leading to hilarity when writing tests that expect a deterministic ordering.

Pull out all the argument expressions to create() in the clone functions so a cloned program is deterministic in its ordering between compilers.

Change-Id: I8e2de31398960c480ce7ee1dfaac4f67652d2dbc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41544
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-02-11 20:27:14 +00:00
Ben Clayton 7b6bcb6e0b Fix AST declaration order when cloning Programs
Change 41302 correctly fixed up Module::Clone(), but this wasn't actually called by the CloneContext, as Module::Clone() returns a new Module, where as the CloneContext needs to clone into an existing Module.

Refactor the code so that this duplicated logic is moved into a single Module::Copy() method.

Fixed: 1177275
Change-Id: Ia8c45ef05e03b2891b5785ee6f425dd01cb989c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41542
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-02-11 20:23:03 +00:00
dan sinclair dc9d3e0cd5 Roll dependencies
Roll third_party/googletest/ 389cb68b8..f3ef7e173 (40 commits)

389cb68b87..f3ef7e173f

$ git log 389cb68b8..f3ef7e173 --date=short --no-merges --format='%ad %ae %s'
2021-02-04 absl-team Googletest export
2021-02-03 dmauro Googletest export
2021-02-03 absl-team Googletest export
2021-02-02 absl-team Googletest export
2021-02-02 absl-team Googletest export
2021-02-02 absl-team Googletest export
2021-02-02 dmcardle Googletest export
2021-02-02 absl-team Googletest export
2021-02-01 absl-team Googletest export
2021-01-27 absl-team Googletest export
2021-01-27 absl-team Googletest export
2021-01-26 absl-team Googletest export
2021-01-26 absl-team Googletest export
2021-01-25 absl-team Googletest export
2021-01-25 absl-team Googletest export
2021-01-22 absl-team Googletest export
2021-01-20 absl-team Googletest export
2021-01-20 ofats Googletest export
2021-01-19 absl-team Googletest export
2021-01-19 absl-team Googletest export
2021-01-19 krzysio Googletest export
2021-01-19 absl-team Googletest export
2021-01-16 dreamer.tan Fix link to Google Test Primer
2021-01-15 absl-team Googletest export
2021-01-15 absl-team Googletest export
2021-01-14 absl-team Googletest export
2021-01-14 absl-team Googletest export
2021-01-10 krystian.kuzniarek fix a broken link
2021-01-13 dmauro Googletest export
2021-01-13 dmauro Googletest export
2021-01-13 absl-team Googletest export
2021-01-08 absl-team Googletest export
2021-01-07 absl-team Googletest export
2021-01-05 absl-team Googletest export
2021-01-05 absl-team Googletest export
2021-01-05 absl-team Googletest export
2020-12-29 absl-team Googletest export
2021-01-06 davidben Restore GTEST_ATTRIBUTE_PRINTF_ on ColoredPrintf
2021-01-03 krystian.kuzniarek remove explicit function overloads of CmpHelper?? for BiggestInt arguments
2020-12-25 mattias.ellert Fix gtest-help-test failure on GNU/kFreeBSD

Created with:
  roll-dep third_party/googletest

Roll third_party/spirv-headers/ faa570afb..75b30a659 (4 commits)

faa570afbc..75b30a659c

$ git log faa570afb..75b30a659 --date=short --no-merges --format='%ad %ae %s'
2020-08-19 jason Add header changes for SPV_EXT_shader_atomic_float_min_max
2021-01-27 jason.ekstrand Re-run buildSpvHeaders to fix indentation
2021-01-19 dneto Header generator: Check enumerant ordering
2021-01-05 ben.ashbaugh add function control bitfield reservation section reserve bit 16 for an upcoming Intel extension

Created with:
  roll-dep third_party/spirv-headers

Roll third_party/gpuweb-cts/ 89ba81c39..d836e71f2 (20 commits)

89ba81c395..d836e71f29

$ git log 89ba81c39..d836e71f2 --date=short --no-merges --format='%ad %ae %s'
2021-02-11 corentin Implement some of api:validation:vertex_state (#461)
2021-02-10 kainino standardizeExtent3D
2021-02-10 kainino factor out makeBufferWithContents
2021-02-10 kainino add more texture format subtypes
2021-02-09 kainino roll types
2021-02-10 kainino renames in operation test helpers
2021-02-03 kainino use new helpers, subcases, selectDevice in operation tests
2021-02-03 kainino [trivial] Move helpers to util/texture/image_copy.ts
2021-02-10 jamesprice.dev Remove explicit storage class from samplers/textures (#464)
2021-02-08 enrico.galli Add button to print creation stack to console in /standalone/ (#457)
2021-02-08 corentin Update the test plan for validation/vertex_state (#458)
2021-02-05 shrekshao Update wgsl comments from # to // (#456)
2021-02-04 kainino Use subcases in copyImageBitmapToTexture tests (#453)
2021-02-04 kainino Update copyBetweenLinearDataAndTexture tests for new bytesPerRow/rowsPerImage rules (#452)
2021-02-03 kainino fix "INFO: subcase:" prints (#454)
2021-02-01 9856269+sarahM0 [wgsl] validation v-0040: uniform and storage buffer are declared with group and binding decorations. (#428)
2021-02-01 kainino Loosen precision in multisample resolve operation test (#446)
2021-02-01 shrekshao Add sampler anisotropy tests (#437)
2021-02-01 tojiro Update defaultQueue->queue, OUTPUT_ATTACHMENT->RENDER_ATTACHMENT to match latest spec (#449)
2021-02-01 kainino add todos in createView tests (#450)

Created with:
  roll-dep third_party/gpuweb-cts

Roll third_party/spirv-tools/ 297723d75..cfa1dadb1 (6 commits)

297723d75a..cfa1dadb1e

$ git log 297723d75..cfa1dadb1 --date=short --no-merges --format='%ad %ae %s'
2021-02-10 dj2 Update a few virtuals to overrides. (#4143)
2021-02-05 46493288+sfricke-samsung spriv-val: Vulkan image gather constant component (#4133)
2021-02-05 46493288+sfricke-samsung spirv-val: Fix/Label UniformConstant VUID (#4134)
2021-02-05 46493288+sfricke-samsung spirv-val: Add Vulkan Invariant Decoration VUID (#4132)
2021-02-02 46493288+sfricke-samsung spirv-val: label tests for VUID 04657 (#4119)
2021-02-01 46493288+sfricke-samsung spirv-val: Add Vulkan PSB64 convert VUID (#4122)

Created with:
  roll-dep third_party/spirv-tools

Change-Id: I5632e3eed6d8e8731faeb4800e903a8893a60f9f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41560
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-11 15:04:03 +00:00
Ben Clayton 5585f0789c Add SymbolTable::New()
Generates a new unnamed symbol.
Useful for creating temporaries in transforms.

Change-Id: I3aa037e4a6b2d400f24e01bbb3555af68da26748
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41480
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-11 14:54:41 +00:00
Ryan Harrison 5d64f60a60 Add ability to get all bound resources in a single call
Also adds to the binding struct what type of resource it is.

BUG=tint:489

Change-Id: I8ce56a1a613b330150545781cb42d2afeaa69375
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41460
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-02-10 22:16:05 +00:00
Ben Clayton 5bde7c054a tint.h: Remove the type_determiner.h include
This is no longer public-api

Change-Id: I030d37b0d1dbd38ea3ec6d19c47b15d7ce9d0667
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41482
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:48:55 +00:00
Ben Clayton 8b1906d996 Validation tests: Check the Program is valid
If the program is invalid, then the content of the program is undefined.
Don't attempt to test undefined behavior.

Remove the one remaining test that was using an invalid program.

Change-Id: I4bb77b8048768717a312ed94b96efb3416274b63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41384
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:47:04 +00:00
Ben Clayton 47c4d18375 Move intrinsic overload tests from Validator -> TypeDeterminer
TypeDeterminer now does overload resolution. Move these tests to the right place.

Change-Id: I27a4fccac34ded00f9828a77cc25ccfe1cb5c0ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41383
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-02-10 21:42:35 +00:00
Ben Clayton 2522b29f7d type_determiner_test.cc: Rename ImportData to Intrinsic
Change-Id: I3ecf7e1480ee3b50815b9cb1d37ac397eada348f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41382
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-02-10 21:40:36 +00:00
Ben Clayton 81da283b2c Add type::Type::UnwrapAliasIfNeeded()
Unwraps aliased types until reaching a non-alias.

Change-Id: I6546d60b7cbe07d4c8cc5a0b439329af8b468ca9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41500
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:40:15 +00:00
Ben Clayton 46d78d731b ProgramBuilder: Add Symbol overloads of Var(), Const(), Global(), GlobalConst()
Useful if you have a symbol already

Change-Id: Ib9e15ea761f58ee67dc3cc722d9129cd5369d92b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41481
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:34:26 +00:00
Ben Clayton faca02d438 IntrinsicTable: Fix a number of TODOs
And add tests for IntrinsicTable.

Drop all the type unwrapping - be precise:
* Display the actual argument types in the signature mismatch message
* Only dereference pointer arguments if the parameter does not expect a pointer

Correctly match access control on storage types

Note that I was mistaken in tint:486 - the TypeDeterminer is resolving identifiers to variables correctly as pointer types. The confustion here was probably due to all the UnwrapAll() calls, which have now all gone.

Fixed: tint:486
Change-Id: I239eabd1fedfc082566c4af616ccfc58786cae25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41280
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:34:25 +00:00
Ben Clayton 2101c35f3b Stub sanitizer transforms for the hlsl, msl & spirv writers
These transforms will perform work to massage the Program into something consumable by the given writer.

Change-Id: I8989e8d4bc1a9cae7ce1f8764c8f3811db3bd04d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41483
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:22:03 +00:00
dan sinclair c2118b0dcb Fixup build issues.
This CL adds some override decorations for various destructors and turns
of Werror for the spirv-tools build.

Change-Id: I10ac72cfaee247334f6db2918230283b1f975955
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41420
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-10 16:57:24 +00:00
Ben Clayton 22a9f175e0 Add missing #include to fix CMake build
Change-Id: I3ff04a2e9f4b04ffad924b15c4c5049360651705
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41381
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-02-10 16:41:23 +00:00
James Price dfd1714174 [wgsl-writer] Emit globals in declared order
Instead of emitting all global variables and then functions, emit
global declarations in the order they were added to the AST.

This fixes issues where the reording might generate an invalid WGSL
program from a valid input (e.g. when declaring a global variable with
the same name as a variable inside a function that precedes it).

This also unifies the implementation of Generate() and
GenerateEntryPoint(), to avoid implementing the same logic twice.

Change-Id: I60a4e5ed4a054562cdcc3d028f8d577434a6d713
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41303
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-02-10 15:34:37 +00:00
David Neto 0c7f97626f spirv-reader: support OpCompositeInsert
This generates intermediate variable to stuff the component into,
then a constant definition to evaluate the result for later use.

Bug: tint:3
Change-Id: If2e6bb24e2b1e621c3602509eb3237c40f53897b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41360
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 15:05:56 +00:00
James Price c0f30195a0 [validation] Validate globals in declared order
Instead of validating all global variables and then functions,
validate global declarations in the order they were added to the AST.

This fixes false-positive "redeclared identifier" errors when a global
variable is declared after a function that declares a variable of the
same name, and false-negative "identifier not declared" errors when a
global variable is declared after a function that tries to use it.

Change-Id: Ibf5e5265bc2f8ca892096f0420757b70e1984525
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41302
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-09 23:22:32 +00:00
James Price 558385357f [ast] Capture global declaration order
Adds a vector<CastableBase*> to ast::Module which stores the list of
global variables, functions, and types, in the order that they were
declared.

This will be used to fix validation and backend issues around name
uniqueness.

Change-Id: I14491f6ebc0fc7341bd3fb3b3f408faa234a91f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41301
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-09 21:39:10 +00:00