Commit Graph

1363 Commits

Author SHA1 Message Date
Sarah Mashayekhi 34f90a0097 [validation] make validator directory
Change-Id: Ia5caea84b48b37f0bee9582ee4c8514da4ee3978
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31981
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-06 17:31:15 +00:00
Ryan Harrison cc2305dd95 [inspector] Extract Sampler resource binding information
Adds in method to get resource binding information for non-comparison
samplers along with tests. Additionally some of the infrastructure for
implementing an equivalent comparison sampler code path is included.

BUG=tint:257

Change-Id: I5775bbd6233e1014bea54c5281d460544ab8383d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31920
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-05 20:09:50 +00:00
dan sinclair 795bf4c716 Fixup emitting duplicate globals in HLSL.
This CL fixes the issue with duplicate globals being emitted in HLSL if
used in multiple entry points. Tests are added for the other backends to
verify the issue does not exist there.

Bug: tint:297
Change-Id: I16d7504e8458fd375c6e1896758fe180ad963871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31880
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-05 14:52:32 +00:00
dan sinclair eff1fb88fc [wgsl-reader][wgsl-writer] Update storage texture type name.
This Cl updates the storage textures to have `storage` in the name. So,
`texture_ro_1d` -> `texture_storage_ro_1d`

Bug: tint:286
Change-Id: I0a9ea02f15de2681d64e272cb42be51a940b6a13
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31840
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-04 22:19:33 +00:00
Ben Clayton 88dc2a4895 wsgl parser: Unify logic for all decorations
Parse all decorations with the same function, and create a
`ast::DecorationList`. Once the parser has progressed to the consumer of
the decorations, we attempt to downcast these to the required type,
erroring if they're the wrong kind.

While the error message could be improved further, this greatly reduces
the headscratching around crbug.com/tint/291.

Also knocks another 223 lines off parser_impl.cc.

Bug: tint:291
Bug: tint:282
Change-Id: I7506faeb56d876e5446d900c7c134669a9db6409
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31660
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:55:31 +00:00
Ben Clayton 786bc92002 wsgl parser: Add expect_block(), use it
`expect_block()` takes a start and end token, along with a function to parse a lexical block body.

This reduces code, keeps error messages consistent, and also gives us a future place to try resynchronising the parser so we can have more than one error emitted.

`expect_paren_block()` and `expect_brace_block()` are convenience helpers for providing the start and end tokens for common block types.

Bug: tint:282
Change-Id: I432a0301727b131a6fce875687b952dfc6889a4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31736
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:08:51 +00:00
Ben Clayton b8791a5129 wsgl parser: Add expect_builtin()
Mirrors expect_pipeline_stage()

Bug: tint:282
Change-Id: I413c87b3684c1f5cfec0c4acd7d3a5160d4b24a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31735
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:06:21 +00:00
Ben Clayton 32ba9b6722 wsgl parser: pipeline_stage() -> expect_pipeline_stage()
The only place that calls `pipeline_stage()` expects a stage to exist, so follow the `expect_` pattern.

Bug: tint:282
Change-Id: Ie18d24ed25a5f882e66a8e553e53b4fb52dcf6fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31734
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:00:31 +00:00
Ben Clayton 53e619f7e9 wsgl parser: Use match() for more trivial patterns
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: I75ac50ef4a2435cfd42e95e851fa1f3524d1dd63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31733
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-04 19:11:41 +00:00
dan sinclair a7e1492a6a [wgsl-reader][wgsl-writer] Support new sampled texture syntax.
This CL updates Tint to support the `texture_1d` format for sampled
textures. This is alongside the old `texture_sampled_1d` to allow
migration time.

The WGSL writer will always output the new form when converting to WGSL.

Bug: tint:286
Change-Id: I96f0308ad3c28ade96bcab7e24aa0b405e3c4f05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31380
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-04 19:03:21 +00:00
Ben Clayton 4ce7a93202 wsgl parser: Add optional Source* out params
... to match() and expect_ident().

The uses of these two functions frequently want to know the souce of the matched token.

Bug: tint:282
Change-Id: I5279fc2e0834f48d419c6d8c9888189f6212c44a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31732
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 18:39:41 +00:00
Ben Clayton 0371cc4a8d wsgl parser: Use expect_ident()
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Id6e219222a5967bb4b6d67e54816f669c38d0c19
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31731
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-04 16:34:10 +00:00
Ryan Harrison 77f7bb5b00 [inspector] Refactor to handle access control wrapped uniform-buffers
Updates the extraction code to assume that the StructType will be
wrapped by an AccessControlType. Tests are changed to match this
behaviour, and some minor naming clean up occured.

BUG=tint:257

Change-Id: I888ac2fae228531e956437afb937082a142d5736
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31780
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 16:08:00 +00:00
Ben Clayton 443039a58f wsgl parser: Use expect() for call r-parenthesis
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ibbbb98bb6f080dd338af7de415c6e86298d910e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31730
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 15:48:20 +00:00
Ben Clayton 67c37197d6 wsgl parser: Use expect_[nonzero_]uint()
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: If89265dfe4356468d610dab931c906aa3260ce5a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31728
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:27:51 +00:00
Ben Clayton 0358d1bc1b wsgl parser: Use expect() for parenthesis checks
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ie5059599ed538bc589d594d7f16aa3db6774110b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31727
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:25:21 +00:00
Ben Clayton 5c58a06515 wsgl parser: Use match() for trivial patterns
Replace uses of peek, test, return-or-next with match().
Reduces code.

Bug: tint:282
Change-Id: I5e53601746e78efd007773cfea7109483c5e1630
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31726
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:21:51 +00:00
Ben Clayton f7fc63b8e3 wsgl parser: Use expect() for semicolon checks
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ifddb63b65d44427e0680bb25837fcb24ca854eb0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31725
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:17:51 +00:00
Ben Clayton d70f251188 wsgl parser: Add match() and expect() helpers
These will be used to simplify common parser patterns.

Bug: tint:282
Change-Id: Ia281b9aa66b98f4afc726e876fe8aeae5ff4f12c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31724
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:14:40 +00:00
Ben Clayton a47b277b26 Fix build
https://dawn-review.googlesource.com/c/tint/+/31760 landed just after https://dawn-review.googlesource.com/c/tint/+/31722, which added a new parameter to all decorator constructors.

Add the missing parameters to fix the build.

Change-Id: Id8360dd23dd59096ffdff0cf523c3323ac01b431
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31729
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:12:51 +00:00
Ben Clayton 88cd156fd9 wgsl parser: Replace set_error() with add_error()
Have slightly different overloads.

Long term we will want to be able to emit more than one error in a single parse.

Bug: tint:282
Bug: tint:291
Change-Id: Ide61c6ca75d45065e917b8fa16a097048397e31b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31723
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-04 02:23:10 +00:00
Ryan Harrison e862fde45c [inspector] Extract Read Only Storage Buffer data
BUG=tint:257

Change-Id: Ie9486726b2a164971d720f4496a87a0bd118ebde
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31760
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-11-03 22:19:50 +00:00
Ben Clayton 34a2eb1999 Add Source parameter to decoration constructors
Once a `Decoration` has been parsed, it'll be placed into a `DecorationList` and validated later in the parse. In order to create error diagnostics that refer back to the decoration, we need to know its source.

Bug: tint:282
Bug: tint:291
Change-Id: I38de708adbd041601b61d7e0a4d0402e9a2fe526
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31722
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 21:48:20 +00:00
Ben Clayton 35298800a6 ast: Have all decorations derive from base class
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>
2020-11-03 21:40:20 +00:00
Ryan Harrison 4735f01193 Move diagnostic/printer.h into the public API
Bug: None
Change-Id: I6dc33f3e589de80b225199fb01a0d80df774ada3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31740
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-03 19:13:50 +00:00
Ben Clayton 1a61e8613e formatter: Remove colon line prefix with no source
If a diagnostic has no Source information, don't start the diagnostic line with a colon.

Bug: tint:282
Change-Id: I80c4103e31556b2769d4b4c2a98dce21a2e1c233
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31662
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-03 18:27:29 +00:00
Ben Clayton 06c892a6ec diagnostic/printer: Print newline at end of tests
Otherwise other test messages will continue from the same line as the pretty colors.

Bug: tint:282
Change-Id: I14727b4faa7bbca490523cdd6941fa09dc6b514a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31661
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-03 17:56:29 +00:00
Ben Clayton f8bd106041 Fix all warnings when building with CMake + clang
Change-Id: I987b4580f5f99584649b2b189369a0b962b0c3d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31721
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 17:46:49 +00:00
Ryan Harrison a28d19b18d Add tests for MinBufferBindingSize
BUG=tint:283

Change-Id: Id198175d232680ca89e04561b8b7510f41d982f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31106
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 16:53:59 +00:00
dan sinclair d5fd7e02ba Fixup lint errors.
This CL fixes up the various lint errors.

Change-Id: If4d3077b55aadec33980452c43917194d803fac6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31680
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-03 16:26:09 +00:00
Ben Clayton de6938789c Add test for bad function attribute
This test reproduces the unhelpful error message described in tint:291.

Bug: tint:291
Change-Id: Ie93cc59d981691981ba978b690d11c93dfe46ae0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31571
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 15:33:19 +00:00
Ben Clayton d59a5da9e5 Have tint executable use the diagnostic printer
Will now print with better formatting and colors on terminals that support it.

Bug: tint:282
Change-Id: Ibff341cb1dc2dcbda6fa0d72e24fdcb172990138
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31570
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 13:15:19 +00:00
Ben Clayton ecea5c8aec Make Formatter a non-interface
I had originally created `Formatter` as an interface as I was intending to implement this differently for linux and windows (for terminal coloring).

Color printing is instead implemented by the `Printer` interface / PIMPL classes.

Replace the multi-boolean constructor with a `Style` struct, as this will make life easier when we want to add / remove flags.

Bug: tint:282
Change-Id: I630073ed7a76c023348b66e8a8517b00b2b6a0d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31569
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 21:16:38 +00:00
dan sinclair 28f7764704 [spirv-writer] Generate load in Unary Op generation.
When generating a unary operation we need to make sure we correctly
generate the load otherwise the resulting SPIR-V will be invalid. This
CL adds the required GenerateLoadIfNeeded call into the unary
generation.

Bug: tint292
Change-Id: Ia04314726afdda8f63a78e8e52f996681373db6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-02 19:43:08 +00:00
Ben Clayton 2e6cc992c8 Implement diagnostic color printing
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>
2020-11-02 19:26:28 +00:00
Ben Clayton 2d89d98fe1 Fix all doxygen warnings
Bug: tint:282
Change-Id: I6c243c30f4477bb972dc737c8b3ff9cc2e0a91f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31568
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 18:02:18 +00:00
Ben Clayton cd5e4a8083 Remove Parser constructors that take a string
... for the content. Everything should be using a `Source::File*` now.

Bug: tint:282
Change-Id: I9bebb94995a946a5919ba6503f2b0ee2058f0fb1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31482
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 17:55:18 +00:00
dan sinclair 3d0e273ec3 Make doxygen happy.
This CL adds some code comments to fixup doxygen warnings.

Change-Id: I0d0f4b20a1023691141b2f49f82f4538ffe18614
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31600
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-02 16:03:38 +00:00
Ben Clayton 3d54f13613 Use the new diagnostics for wgsl the parser
Keep the `ParserImpl::error()` format identical to the old error style for now.
Use the explicit `ParserImpl::diagnostics()` method for the error message tests, updating the tests to match the new, improved output.

Bug: tint:282
Change-Id: Ia7e1237170f0f5203a8cfa256322df29e90e2791
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31481
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:56:28 +00:00
David Neto 0a06243a70 spirv-reader: support scalar spec constants
Translate OpSpecConstantTrue, OpSpecConstantFalse, and OpSpecConstant.
The latter only can be used with integer or float scalars.

If the constant has a SpecId decoration, then generate a module-scope
decorated constant.  Otherwise generate a module-scope constant without
decorations.

Register the ID so we know to use the declared const identifier in
expressions later in the module.

Bug: tint:156
Change-Id: Icd6e9b60225ced7ee99963c4f85cec1eb0e3ae6b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31541
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:44:27 +00:00
Ben Clayton f0740ae0f2 Add tint::diag namespace for diagnostics
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>
2020-11-02 15:41:08 +00:00
Ben Clayton 580d6c7f3e Produce end ranges for tokens and AST nodes
This includes a couple of position fixes in `lexer.cc`.

The source for identifiers (vars, params, etc) now refer to the identifier, not the first token of the construct.

Bug: tint:282
Change-Id: I58cb8422a4af1c7dc5f84431fd7f06b823b514c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31444
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:25:18 +00:00
Ben Clayton a3bcde2c10 Rm line() & column() from wsgl::Token & ast::Node
Use `source().range.begin.line` and `source().range.begin.column` instead.

Bug: tint:282
Change-Id: I6c9bf8766d6db2c9d8e7e1b8bafb2eea93e065d8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31441
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:17:50 +00:00
Ben Clayton fc5a9cfaf7 Remove tint::Source(size_t, size_t) constructor
This was a temporary overload to break up the changes into smaller chunks.
Change all call sites to use one of the other constructors.

Bug: tint:282
Change-Id: I500fe9700d22f72312827808caa22f7feef7b294
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31440
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:07:47 +00:00
David Neto 74023424da Remove stale TODO
Change-Id: I1b7dbbc0290c48309c9cbf00a432e3beccd27bcf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-02 14:56:47 +00:00
Ben Clayton 5bee67fced Add File & Range information to tint::Source
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>
2020-10-30 20:44:53 +00:00
dan sinclair 17e0deaeba One command per line
Change-Id: I35253ef04c307af85e07f0c4f9691ab0dcacc6fe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31384
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-30 15:03:21 +00:00
Ben Clayton 5d40a5621b Add ParserImplTestWithParam to reduce boilerplate
There were a number of places where we were declaring classes derived from `testing::TestWithParam<T>` and then adding the same `parser()` helper logic.

Move this common logic down to a new `ParserImplTestWithParam<T>` class, and derive from that instead.

Removes a whole bunch of copy-pasta.

Change-Id: I8f308b77817fd6327c045d2fdee4462b7f32897a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31401
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-29 19:19:34 +00:00
dan sinclair bfc2fceb84 Use min for bounded array accessing.
This CL updates the BoundArrayAccess transform to use `min(u32(val),
size)` instead of `clamp(val, 0, size)` so as to reduce the number of
instructions needed to clamp within range.

Bug: tint:285
Change-Id: Ic12bd67f3d755c8e52590f0585bac114ba9eaa94
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31360
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-29 17:56:06 +00:00
dan sinclair c8b2d23e9d [spirv-writer] Emit access control information.
This CL adds emission of the decorations for the access control flags.

Bug: tint:208 tint:108
Change-Id: I3286132dad8edd2586228dc6e87749ad49451739
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31082
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-29 14:45:02 +00:00