Commit Graph

15 Commits

Author SHA1 Message Date
dan sinclair 46c32d882d Early out Is checks.
This CL adds a check to the `Is` castable methods to determine if the
target type is `final`. If the type being compared too is `final` we
bail out early in the walk up the hierarchy as it won't be a parent
class.

Change-Id: Ieba4dd686e47207a3db0cf3a8ea46fbc1a8d1c91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96600
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-07-20 15:53:14 +00:00
Ben Clayton 4a92a3c904 tint: Optimize sem node lookup
Add a 'NodeID' to each ast::Node which is the sequentially allocated
index of the node. Use this in sem::Info to map the AST node to the
semantic node, instead of using a std::unordered_map.

Optimised very hot code by entirely eliminating map lookups, and
dramatically reducing cache misses (lookups are usually sequentually
ordered).

Timings running
'webgpu:shader,execution,expression,call,builtin,atan2:f32:inputSource="const";vectorize="_undef_"'
with dawn/node, using SwiftShader:

    Without change: 3.22647107s
    With change:    3.10578879s

Bug: tint:1613
Change-Id: I22ec48d933b2e5f9da04494bff4e979e6f7b1982
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96140
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-18 20:50:02 +00:00
dan sinclair 3a2a279714 Fixup various warnings in Tint which were accidentally suppressed.
When enabling the SPIR-V reader or SPIR-V writer we were suppressing
-Wnewline-eof, -Wold-style-cast, -Wsign-conversion, and -Wweak-vtables
for the `libtint` cmake target and anything that depended on that
target. Because we'd build all readers/ writers by default this caused
us to never hit those warnings.

A recent change to the cmake build sets the Tint backend based on
the Dawn backend. So, there is a much higher chance of not building
the SPIR-V support if you're on a Mac or Windows machine.

This CL removes the suppression of the warnings, adds specific pragmas
into the SPIR-V reader code which imports the SPIRV-Tools headers
and fixes up the warnings which were then firing due to checking
for the new warnings.

Change-Id: I0d0be6aa3d0b692e939ce8ff924dfb82c82792fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94901
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-29 14:38:15 +00:00
Ben Clayton 2032d03400 tint/transform: Remove use of StorageClass on parameter
Parameters don't have storage classes or access qualifiers. This was
just (ab)using the fact that a parameter uses the same AST type as a
'var'.

Also simplify the parameter disable validation logic.

Bug: tint:1582
Change-Id: Ic218078a410f991e7956e6cb23621a94a69b75a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93603
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-15 19:32:37 +00:00
Ben Clayton 2ae29830db tint: Add ast::ParameterList, use it
This is currently identical to ast::VariableList, but once we break
ast::Variable up, this will become a different vector type.

Bug: tint:1580
Change-Id: Ib2db5772996a63cd1989e36f1034dc1fbd3b371a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93601
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-15 10:14:27 +00:00
Antonio Maiorano 08f4b557fc Implement atomicCompareExchangeWeak returning struct instead of vec2
Also fixed implementation of this atomic in GLSL. It was emitting code
that would not compile because, as for HLSL, we must pass in the
variable directly to atomic funcs, not via an in/out arg to a function.

Bug: tint:1185
Change-Id: Id0e9f99d6368717511ef3a94473634c512e10cb8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91881
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-05-31 13:20:28 +00:00
Ben Clayton e5a67ac891 tint: Remove ast::CallExpression -> sem::Call implicit mapping
With abstract materialization, any ast::Expression may map to the new
sem::Materialize node. Because of this, we can't assume that an
ast::CallExpression maps to a sem::Call, as it might be wrapped by a
sem::Materialize.

Remove the mapping, and fix up all the code that was relying on this.

Fixes are done by either:
• Calling `UnwrapMaterialize()->As<sem::Call>()` on the semantic
  expression. This is done when the logic may assume it's possible for
  the expression to be a Materialize node.
• Using the explicit sem::Info::Get<sem::Call>() template argument to
  cast the semantic type to sem::Call. This is done when the logic
  either knows it is impossible for the expression to be a Materialize.

The backends have been stubbed, as we'll want to emit the constant value
for these nodes. It's likely that we'll just use the FoldConstants
transform to strip all Materialize nodes from the tree. For now, be
defensive.

Bug: tint:1504
Change-Id: If9231b300fc30c7fe886c17a804ead8ee2988285
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90533
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2022-05-19 21:50:59 +00:00
Ben Clayton 0ce9ab042e tint: Change all ProgramBuilder literals to 'i' or 'u' suffix
Unsuffixed integer literals are currently treated as i32,
but will shortly become AbstractInteger. To keep tests behaving
identically to how they are currently, change all test literals
to using either 'i' or 'u' suffixes.

Bug: tint:1504
Change-Id: Ic373d18ce1c718a16b6905568aec89da3641d36b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88845
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-05-05 20:23:40 +00:00
Ben Clayton 8822e2966a tint: Merge [S|U]intLiteralExpression
Merge SintLiteralExpression and UintLiteralExpression with
IntLiteralExpression. IntLiteralExpression has a new Suffix field which
indicates whether the literal is either a:
• 'i' suffixed integer literal
• 'u' suffixed integer literal
• no-suffix integer literal

Have the SPIR-V reader produce no-suffixed literals for i32 types, to
keep this change small. In future changes the SPIR-V reader will
produce 'i' suffixed types for these.

Have all consumers of IntLiteralExpression treat unsuffixed integers the
same as 'i'-suffixed literals. Unsuffixed will be treated as abstract in
future changes.

Removed SemHelper::TypeOf(const ast::LiteralExpression* lit).

Fixed: tint:1510
Bug: tint:1504
Change-Id: I443f41984e637ddd948182ee756af1010c5f8226
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88842
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-04 22:18:49 +00:00
dan sinclair 41e4d9a34c Consistent formatting for Dawn/Tint.
This CL updates the clang format files to have a single shared format
between Dawn and Tint. The major changes are tabs are 4 spaces, lines
are 100 columns and namespaces are not indented.

Bug: dawn:1339
Change-Id: I4208742c95643998d9fd14e77a9cc558071ded39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87603
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-01 14:40:55 +00:00
Ben Clayton 01004b7732 tint: Remove '_type' suffix from file names
These suffixes existed because the GN build errored when there were two files sets with the same name (ast + sem).
This is no longer required as the GN build splits these into two separate targets.

Change-Id: Ib451da33a5f4aa5c867cb99419dd252766dc3daa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88308
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-28 18:49:04 +00:00
dan sinclair b5599d35f9 Condense namespaces in tint/transform.
This PR condenses the namespaces in the tint/transform folder.

Change-Id: Idf448870ccf90f892b9186f7aab7bb0ac9deda17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86029
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-04-07 16:55:14 +00:00
Ben Clayton dc0e31cfaa sem: Remove Type::type_name.
Remove last remaining uses, and fix up a whole lot of tests.

Bug: tint:1383
Change-Id: Id2a11fc2d748b72823f4a077bcd6ba7be705a02b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82744
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-03-07 18:34:57 +00:00
Ben Clayton 4cb1329181 Move BlockAllocator from src/tint to src/tint/utils
Change-Id: I4bca9413d73d0095a3e0de23bcc4de956bf3b98e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82740
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-03-04 21:09:24 +00:00
Ryan Harrison dbc13af287 tint->dawn: Shuffle source tree in preperation of merging repos
docs/    -> docs/tint/
fuzzers/ -> src/tint/fuzzers/
samples/ -> src/tint/cmd/
src/     -> src/tint/
test/    -> test/tint/

BUG=tint:1418,tint:1433

Change-Id: Id2aa79f989aef3245b80ef4aa37a27ff16cd700b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-02-21 15:19:07 +00:00