Commit Graph

1533 Commits

Author SHA1 Message Date
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
Ben Clayton c1f7e90417 Fix typo in FirstIndexOffset::Data
s/first_index_offset/first_instance_offset

Change-Id: I7f77490cf5e75002baaedcb319140dd329a087ac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42461
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-25 14:11:50 +00:00
Ben Clayton 2432e3429d Rework TINT_INSTANTIATE_CLASS_ID() to avoid complex static initializers
The chromium tests for static initializers get upset about the call to
ClassId::New() in a global variable initializer.

Instead, take the address of a unique 'token' variable to generate the
unique identifier.

This is similar to how things were before
https://dawn-review.googlesource.com/c/tint/+/42460
but of taking the address-of the token in the header, we're instead
taking the address-of inside the cpp file, avoiding the DLL issues
that 42460 addressed.

Change-Id: Id18c5b90b365b0960fac347729a4927528d34c07
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42462
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-25 13:41:30 +00:00
dan sinclair f8fa6cf43c Register function symbol in TypeDeterminer after processing body.
This CL removes the registration of functions to after the function body
has been processed. This allows us to catch recursive calls where the
function calls itself. Prior to this we'd find the called function and,
if the function was an entry point, end up in a loop trying to walk all
the callers. With this change, the function is not found when we do
the lookup and we exit as expected.

Bug: tint:258
Change-Id: Ie0173207b788e87de39867a5aa41e8cc13ec33de
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42520
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-24 22:11:34 +00:00
Ben Clayton 80cb20de7c Fix ClassIDs for DLL usage
If ClassID::Of<T>() is used inside tint and used outside tint for the same type, and tint is built as a DLL, then the address of the Unique<T>::token can resolve to different addresses, entirely breaking Castable.

Replace address-of for a unique symbol with a single static counter that's incremented for each use of TINT_INSTANTIATE_CLASS_ID().

Change-Id: I40dc81b1273110291d90a1d5ec05428f7e703c6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42460
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-24 21:03:34 +00:00
dan sinclair 72260e44ae Remove parsing of StringLiteral.
The StringLiteral token was removed from the spec when all usage was
removed. This CL removes the remaining parsing bits from Tint.

Change-Id: I02f5dbdbad649c62c22c69a55616e0087a0f56d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42440
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-24 18:56:34 +00:00
dan sinclair 8feb9b847f Update the rounding modes to match the spec.
The spec was clarified that a value of .5 rounds towards the even value.
This matches the HLSL `round` method. This CL updates SPIR-V to use the
`RoundEven` GLSL450 call and the `rint` MSL call so they match the spec
requirements.

Change-Id: I97ce2e29b9639ad72b6846b32dbe3abb8d9f6cff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42421
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-24 18:01:54 +00:00
Ben Clayton eb496d0a4d transform: API cleanup
Transforms are meant to be reusable. Those that hold state cannot be used concurrently.
State leakage between runs is dangerous.
To fix this:
* Add transform::Data - A new base class for extra information emitted by transforms.
* Add transform::DataMap - A container of Data, keyed by type.
* Add a transform::DataMap field to Transform::Output.
* Have FirstIndexOffset emit a FirstIndexOffset::Data.
* Deprecate the getters on the transform.

Mutability of the transform config is also dangerous as setters can be called while a transform is actively running on another thread.
To fix:
* Expose a VertexPulling::Config structure and add a constructor that accepts this.
* Deprecate the setters on VertexPulling.

Also deprecate Transform::Output::diagnostics.
Put all the transform diagnostics into the returned Program. Reduces error handling of the client.

Change-Id: Ibd228dc2fbf004ede4720e2d6019c024bc5934d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42264
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-24 15:55:24 +00:00
Ben Clayton 94b36c3e86 src/transform: Remove @notes that are no longer true
The transform::Manager no longer does anything special. It is now a container of transforms that acts like a single transform.

Change-Id: I5e51e250cfa610b651445b7cd5efd29811c56d2e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42261
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-24 15:08:54 +00:00
Ben Clayton 03eaff3b0a wgsl::ParserImpl: Use sync() for postfix_expr()
postfix_expr() handles `[]` array accessors and call expressions `()`.

Have postfix_expr() use sync to parse these:
* It will use the end bracket token to attempt to resynchronize the parser on error
* It also considers maximum parser recursion depth, avoiding stack overflows

Fixed: chromium:1180573
Change-Id: I8c1c62c68e24a564e0e4e7d0de9f5a3fa7032369
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42222
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-24 14:21:52 +00:00
Ben Clayton 6d612ad478 TypeDeterminer: Resolve swizzles
Have the TD resolve swizzles down to indices, erroring out if they're not valid.

Resolving these at TD time removes swizzle parsing in the HLSL writer, and is generally useful information.

If we don't sanitize in the TD, we can end up trying to construct a resulting vector of an invalid size (> 4) triggering an assert in the type::Vector constructor.

Fixed: chromium:1180634
Bug: tint:79
Change-Id: If1282c933d65eb02d26a8dc7e190f27801ef9dc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42221
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-24 14:15:02 +00:00
Ben Clayton 8b1851dbdc ClassID: Support use as unordered map / set keys
Change-Id: Ia6c21dfc33445ba828b2f244d8a3479fb3328805
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42263
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-24 13:51:32 +00:00
Ben Clayton ce9229cd2e Program: Fix move of diagnostics.
Add test.

Change-Id: Ide47df8b3a946818ed9a8ffd62411284f568609b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42262
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-02-24 13:51:13 +00:00
Ben Clayton 33a8cddb2d TypeDeterminer: Error if an IdentifierExpression to a callable is not called
IdentifierExpressions that resolve to functions and intrinsics were not being assigned a semantic::Expression as there is no function / intrinsic type to give them. This lead to NPEs in the writers when these identifiers were reached and TypeOf() is called.

Adding a new tint::type::Callable is an option, but until functions become a type in the language, this seems like a very large and debatable change.

Attempting to detect IdentifierExpressions with no semantic node in the validator is another option, but this is clunky as it has to detect incomplete semantic info from the TD, and cannot identify whether this actually resolved to a function or an intrinsic.

Instead we now error in the TD if encounter an IdentifierExpression that resolves to a function or intrinsic which is not called (ident is not followed with parenthesis).

Fixed: chromium:1180544
Fixed: chromium:1180814
Change-Id: I121dd194356419f94b09c7ee1ed544a350a114b3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42220
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-02-24 13:31:22 +00:00
Ryan Harrison 13dbbc6797 Remove references 1D Array texture dimension
WGSL recently removed this concept, since it didn't exist in WebGPU,
so excising it from the code.

BUG=tint:515

Change-Id: Ibbca6bd643fd96c2fb10bd33f471c9e9e58de535
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42320
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-02-24 05:05:21 +00:00
Ben Clayton 00eb8dfa8b Update docs/arch.md with new design
Change-Id: I8deb4416ac2f1e14f8b863b80a20c23550ed05e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40383
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-23 16:08:09 +00:00
Ben Clayton 767df5f03b Fix infinite spin in wgsl parser
If the parser hits a `maximum parser recursive depth reached` situation, then we need to try and resynchronize the parser.

If we fail to do this, then the synchronized_ flag may remain true, and the parser will believe progress is still being made.
In this situation the parser may try to reparse the same token, forever.

By calling sync_to() we either find the end of the block, and forward progress can be made, or synchronized_ is set to false, and the parser can error out cleanly.

Add test case from fuzzer report.

Fixed: chromium:1180128
Change-Id: I893077677fd3dfbd4b9b400cd32db842b06db500
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42029
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-19 20:01:43 +00:00
Ben Clayton 527a0bbf25 Have Program::IsValid() return false unless built
An unbuilt program doesn't have an ast::Module, so Program::AST() will just explode.

* Have a Program default to false for IsValid()
* Initialize the ast_ field to nullptr. This was previously floating.
* Return from CommonFuzzer::Run() earlier if the InputFormat is not recognised.

Fixed: chromium:1180130
Fixed: chromium:1180157
Change-Id: I9b67daa10746f386f44919a7b9ac5c171092d6e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42028
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-02-19 19:04:18 +00:00
Ben Clayton 3bb3116bdf hlsl/writer: Validate texture intrinsics with DXC
Change-Id: I4cb8f9a700842e43facbd83cd9af24a00a74658f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42023
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-19 12:45:45 +00:00
Ben Clayton 53d057c572 Add tint_unittest flags for enabling DXC validation
HLSL validation will be disabled by default, and is now opt-in with
--validate-hlsl and/or with a --dxc-path

Change-Id: Ia98d7b1fbba50168bbe85c7982b73598100016d7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42024
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-19 12:39:25 +00:00