Commit Graph

1803 Commits

Author SHA1 Message Date
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
James Price 3eaa450984 [ast] Add ast::Module::AddFunction()
Remove the non-const ast::Module::Functions() getter.

Change-Id: I365eece04837ee6bd51147d226c73e04ce5d9bd4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41300
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
2021-02-09 21:26:21 +00:00
Alan Baker cd17ea88e3 Implement data unpacking intrinsics
* Add support for data unpacking intrinsics
  * spir-v reader
  * type determiner
  * intrinsic table
  * spir-v, hlsl and msl writers

Bug: tint:341
Change-Id: I8f40d19d59a4699af75cd579fe8398c735a77a59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41320
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Alan Baker <alanbaker@google.com>
2021-02-09 21:23:00 +00:00
James Price 2a284b2a13 [hlsl-writer] Add support for sample_mask builtins
Bug: tint:372
Change-Id: Ie3fe7f6853396ff6a4ff47045b98b3b561bf1340
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40561
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-02-09 19:22:45 +00:00
James Price 2b5acacbd4 [msl-writer] Add support for sample_mask builtins
Bug: tint:372
Change-Id: Ib1d9dc525fbc180b603241c4746cbbd54077a489
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40640
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-02-09 19:13:25 +00:00
Ben Clayton 3e8060b4e3 Add type::Type::FriendlyName()
Gives a WGSL-like string for the given type.

Also cleans up some code in IntrinsicTable.

Change-Id: I89a2fadb5291b49dcbf43371bb970eef74670e2c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40605
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-09 18:52:34 +00:00
Ben Clayton 6f48851f27 writer/spirv: Validate arrayLength()
This was tested but the output was not run through the validator.
Once the AST is actually correct, the output is validated correctly.

Fixed: tint:266
Change-Id: I83bb53323c124c8fbaa3cd9b80524f89c2e30557
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40601
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-09 18:45:14 +00:00
Ben Clayton 7b7d69854d TypeResolver: Fix TypeOf() for CallExpression
While traversing and resolving the AST, TypeOf() was called to look up
the semantic node for the given AST expression in order to fetch the
resolved type. However, for CallExpression semantic nodes are
constructed at the end of the AST traversal, and GetType() for these
would unexpectedly return nullptr, causing a crash.

To fix, have TypeDeterminer maintain an internal map of ast::Expression
to resolved type. Always populate this internal map whenever SetType() is
called. At the end of the AST traversal, have CreateSemanticNodes()
construct the semantic nodes for any ast::Expression nodes that do not
already have a semantic node assigned.

With this, GetType() will always return the type set with SetType().

Fixes tint -> dawn autoroller.

Fixed: tint:488
Change-Id: I2830c496d9b2e4807ec01ed69aeafb3912f4a890
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40606
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-02-09 17:38:05 +00:00
dan sinclair 81302443f7 Fix building with gcc.
This CL renames the Parameters using statement to ParametersList so it
doesn't conflict with the Parameters method which is used later to
return the ParametersList.

Change-Id: I2ac19ba52fc0834e5a35b4b35a210dcc170866fc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41240
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-02-09 15:37:44 +00:00
Ben Clayton ab10db454b writer/spirv: Fix intrinsic calls with ptr 'out' parameters
Use the new semantic::Intrinsic::Parameters() information to determine whether a parameter is a pointer.
Don't generate a load if the parameter expects a pointer.

Fixed: tint:361
Change-Id: I1420a6b0e22d52f67a5e52151fb073ac33df5bd5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40508
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 23:07:45 +00:00
Ben Clayton 06d8db2bcb Add texture intrinsics to the IntrinsicTable
Automatically implements verification of texture intrinsic overloads.

Bug: tint:449
Change-Id: I74858902ddcc02337641dd422b800378215b0c7a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40507
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 22:59:44 +00:00
Ben Clayton 59d24735d0 Add IntrinsicTable
Provides a centeralized table for all intrinsic overloads.

IntrinsicTable::Lookup() takes the intrinsic type and list of arguments, returning either the matched overload, or a sensible error message.

The validator has expectations that the TypeDeterminer resolves the return type of an intrinsic call, even when the signature doesn't match. To handle this, create semantic::Intrinsic nodes even when the overload fails to match. A significant portion of the Validator's logic for handling intrinsics can be removed (future change).

There are a number of benefits to migrating the TypeDeterminer and Validator over to the IntrinsicTable:
* There's far less intrininsic-bespoke code to maintain (no more duplicate `kIntrinsicData` tables in TypeDeterminer and Validator).
* Adding or adjusting an intrinsic overload involves adding or adjusting a single Register() line.
* Error messages give helpful suggestions for related overloads when given incorrect arguments.
* Error messages are consistent for all intrinsics.
* Error messages are far more understandable than those produced by the TypeDeterminer.
* Further improvements on the error messages produced by the IntrinsicTable will benefit _all_ the intrinsics and their overloads.
* The IntrinsicTable generates correct parameter information, including whether parameters are pointers or not.
* The IntrinsicTable will help with implementing autocomplete for a language server

Change-Id: I4bfa88533396b0b372aef41a62fe47b738531aed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40504
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 22:42:54 +00:00
Ben Clayton 316f9f6b6d Add semantic::Intrinsic
semantic::Intrinsic derives from semantic::CallTarget, which can be obtained from the Target() accessor on the CallExpression.

Flesh out semantic::Parameter to contain a `Usage` - extra metadata for the parameter.

The information in `Intrinsic` is enough to remove the `semantic::IntrinsicCall` and `semantic::TextureIntrinsicCall` types.

Change-Id: Ida9c193674ad8605d8f12f6a1d27f38c7d008434
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40503
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-08 22:31:44 +00:00
Ben Clayton bab3197fda ProgramBuilder: Add more helpers for Members / Arrays
Add overloads of TypesBuilder::array() that take a stride parameter.
Add overload of ProgramBuilder:Member() that has an offset

Change-Id: If8337e410e73eade504432599a9798bbc511382e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40600
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 21:16:21 +00:00
Ben Clayton 4c51d97a5c Validator: Change the error message for v-0031
It previously said:

"a struct containing a runtime-sized array must be in the 'storage' storage class"

This had be looking at the variable's storage class, when the error was actually trying to tell me I needed `[[block]]` on the struct declaration.

Change-Id: I7a23a0c0c35508bdac20c808d2635592638dfa77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40602
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-02-08 21:14:52 +00:00
Ben Clayton a51aa1f805 Fix intrinsic tests so arguments match an overload
Change-Id: I8c5464e3198c6a3b154f5f3433466955e203efee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40502
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-08 21:10:11 +00:00
James Price 21692def05 Skip SPIR-V validation when not generating SPIR-V
Otherwise the sample app crashes when using --dawn-validation with a
non-SPIR-V output format.

Change-Id: Ic6e03e758747602d15f3a1d5b9d9cefee1aad527
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41120
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 20:45:11 +00:00
Ben Clayton b57c19d450 Change StorageTexture::SubTypeFor() signature
So that it takes a type::Manager instead of a ProgramBuilder.
Makes this callable from places that has the former and not the latter.

Change-Id: Ie968617ae944cc6621c17467a4f7caadacba548f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40505
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 20:35:01 +00:00
Ben Clayton 3b4f3d2860 Fix tests so they only exercise legal texture overloads
textureLoad():
* Does not operate on cube textures
* Does not have a `level` parameter for storage textures
* Requires an `array_index` argument for arrayed texture types

textureSample():
* Only supports f32 data types for sampled textures

Bug: tint:449
Change-Id: I30b3a0c32245d5e6c4b1f3aeef112a67ffb1d055
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40506
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 20:24:52 +00:00
Ben Clayton 599d8f8c0d Rename intrinsic.cc to sem_intrinsic.
For consistency with the other .cc file names in this directory.
The reason we need the sem_ prefix is because all the tint lib code is compiled as a single target, and .GN cannot cope with .cc files with the same file name, even if they're in different directories.
This could be fixed by building each directory as a separate target, but we have circular dependencies that currently make this impossible.

Change-Id: I2f1379ff11dd863f81662449f73d67832f0a8a4e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40501
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 20:11:22 +00:00
Ben Clayton 052ab89a1e Rename semantic::Intrinsic to semantic::IntrinsicType
This allows us to create a semantic::Intrinsic class that holds more information about the particular intrinsic overload.

Change-Id: I180ddb507ebc92172badfdd3a59af346f96e1f02
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40500
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 19:53:42 +00:00
Ben Clayton 2ddb1783c5 Add semantic::CallTarget, have Function derive from it
CallTarget holds parameter information. This is simple to extract from an ast::Function.
CallTarget will also be used for intrinsics, which can be overloaded. CallTarget will hold the resolved overload parameter signature.

Bug: tint:361
Change-Id: I4dadc4a99293f12ede9e9cbd9132ba5f9b9830ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40284
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-08 19:13:19 +00:00
David Neto 7efea888fa spirv-reader: instance_index must have u32 store type
Fixed: tint:485
Change-Id: I73613ae916b2d86b25470f292e5bf5cd5c7f288b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40582
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 16:12:09 +00:00
James Price 61306b882d [wgsl-reader][wgsl-writer] Fix implicit handle storage class for textures
Unwrap the type before checking if it is a handle type, to account for
access decorations.

Bug: tint:332
Change-Id: I8af9749fec1e2f5dbd7c3bec0b73e506ae111a28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40540
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 15:08:49 +00:00
David Neto 6d1687fb01 spirv-reader: vertex_index always has u32 store-type
Fixed: tint:483
Change-Id: Ie26941ab751425dfbc0924ea21bee32dc0f92527
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40623
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 15:02:49 +00:00
Corentin Wallez 3c568f188d Revert "spirv-reader: add disabled test for compare sampling with explicit Lod"
This reverts commit 4a7981e300.

Reason for revert: Empty GTest Values() causes compilation error in Chromium.

Original change's description:
> spirv-reader: add disabled test for compare sampling with explicit Lod
>
> This is blocked by discussion at W3C
> https://github.com/gpuweb/gpuweb/issues/1319
>
> Bug: tint:482
> Change-Id: Ic3a2b32fb09a431edbd7716a394a9eb3f163fb85
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40621
> Commit-Queue: Ben Clayton <bclayton@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Auto-Submit: David Neto <dneto@google.com>

TBR=dneto@google.com,bclayton@google.com

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

Bug: tint:482
Change-Id: I637c40950cd343196c2703c9854f584bf8f1c084
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40603
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-02-08 09:49:09 +00:00
David Neto 4a7981e300 spirv-reader: add disabled test for compare sampling with explicit Lod
This is blocked by discussion at W3C
https://github.com/gpuweb/gpuweb/issues/1319

Bug: tint:482
Change-Id: Ic3a2b32fb09a431edbd7716a394a9eb3f163fb85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40621
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-02-05 22:06:03 +00:00
David Neto a2fa690cda spirv-reader: sample_mask_in, sample_mask_out
TODO: passing pointer to them as a function parameter

Bug: tint:471
Change-Id: Ibd55bdc77a2bfb0f5712dd9bf332910999b8d0d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40123
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-04 22:12:30 +00:00