Commit Graph

2072 Commits

Author SHA1 Message Date
Ben Clayton a80511e021 ast: Merge DecoratedVariable into Variable
Remove all Variable setters (with exception to set_storage_class() which is called by the TypeDeterminer)

Bug: tint:390
Change-Id: I172667e21e2b02e85dcea6703aa1e608ec718250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35015
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-11 13:07:02 +00:00
David Neto ccc67252ff spirv-reader: support OpBitCount, OpBitReverse
Bug: tint:3
Change-Id: I81580136621ab51a9852e1d692ddad2457b9aab9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35340
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 18:51:51 +00:00
dan sinclair d8591088fb Cleanup some includes
Change-Id: I4f6a871cb38a2af53583c582831990c2d76e38b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35102
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-10 18:42:41 +00:00
dan sinclair 1e0472cdba Update namer to use symbol table.
This Cl updates the various namer objects to work off the symbol table
instead of names.

Change-Id: I94b00a10225d0587f037cfaa6d9b42e2a8885734
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35101
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-10 18:40:01 +00:00
Ben Clayton 591268db48 Implement textureWrite()
Bug: tint:368
Bug: tint:140
Bug: tint:143
Bug: tint:144
Bug: tint:145
Bug: tint:146
Bug: tint:147
Change-Id: I1b6943d8663fbac8fbaa77a4804afb5a20fdb5e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35320
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 18:39:41 +00:00
Ben Clayton 3a7bba8c98 Rework the FirstIndexOffset transform
So that it transforms more on clone than in-place.

Bug: dawn:548
Bug: tint:390
Change-Id: I0127bc02c4e0e88c924042c491d274363422cc52
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35420
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 17:47:41 +00:00
dan sinclair 89caee197c Add a symbol table.
This CL adds a table which maps symbols to strings. This will allow us
to remove the use of std::string in the various AST nodes and refer to
the symbols instead.

Change-Id: I902641b3e546a2a44b3b2a39ce4f019cdcbeacc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35100
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-10 16:56:02 +00:00
David Neto 287f6f12ef spirv-reader: support more integer builtins
Support:
 - SAbs
 - UMax, SMax
 - UMin, SMin

Add tests for operand and result conversion for UClamp.
SClamp was already tested.

Bug: tint:3
Change-Id: I9b9278843ca5243991b330b27764756137da4ee4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35302
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-10 15:22:51 +00:00
David Neto 3ca59444cd spirv-reader: remove redundant disabled test
Testing result signedness conversion was already covered
in https://dawn-review.googlesource.com/c/tint/+/35180

Change-Id: I2f7b1caf512ceb81fbe2ea6a2037de61dea25c96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35360
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 15:22:11 +00:00
Ben Clayton 7fbd67a132 Fix CMake build when TINT_BUILD_FUZZERS=1
The `libtint-fuzz` target needs to be defined before reference.

Change-Id: I030f4b3b93a095bd353aa6cff402e351d5b77dca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35381
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 14:33:31 +00:00
Ben Clayton e1bea58ca4 Fix HLSL emission of cbuffers
Despite the documentation claiming otherwise, the DXC doesn't allow
these to be anonymous.

Change-Id: I853d11970890106b8fd4d6b8bb321940f0658bd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35281
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-10 13:09:21 +00:00
David Neto c82eeeef07 re-enable Tint testing
Fix a typo in CMake variable naming

Change-Id: I46049669f5fdcf07cbfb2ec11ad99de212a8edc4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35301
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-12-09 18:15:30 +00:00
David Neto 5213c400eb spirv-reader: convert signedness of texturing result when needed
Fixed: tint:382
Change-Id: I786e1f5d5d122a82ef29c733e514bf3b45651c5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35180
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 17:09:50 +00:00
Ben Clayton 7f04e5c1e2 Implement textureLoad()
Bug: tint:140
Bug: tint:143
Bug: tint:144
Bug: tint:145
Bug: tint:146
Bug: tint:147
Change-Id: I8f41abac2e355c121e8868aa708ae51d0db87665
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34960
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 15:57:00 +00:00
Ben Clayton 7a0daa233d transform: Fix Manager::Run() with no transforms
If there are transforms added to the manager, then Run() would output an empty module. Fix this.

Bug: tint:390
Bug: tint:389
Change-Id: I439fe7a28816761f3702e304ef130b7a6992ecce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-09 15:15:20 +00:00
Corentin Wallez f3717fa249 CMake: Add a flag to control whether to built tint_unittests
Bug: dawn:605
Change-Id: I03860c263746939112e03544fbc3579631423c37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35282
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-12-09 14:47:30 +00:00
David Neto 350330bb46 spirv-reader: Fix signedness for extended instructions
SClamp is the only implemented instruction that is affected, so far

Bug: tint:405
Change-Id: I21c1cdd3e70fc3a64046f0473569ba906048cd37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35240
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:18:36 +00:00
David Neto 6ff8cdb991 spirv-reader: support ldexp
Bug: tint:3
Change-Id: I6a9204b19c5b4d631634b9a585a0081eaead9c1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35046
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:13:46 +00:00
David Neto cb5dd552c2 Fix doxygen for src/transform/first_index_offset.h
Change-Id: I29cee48b3b757373f90768af545a7449f60a5f26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35142
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-08 22:15:34 +00:00
Enrico Galli 3d449d2be5 [transform] Add first index offset transform
Adding new transform to workaround D3D's vertex/instance_index always
starting from 0

Bug: dawn:548
Change-Id: I048f39e76e236570f3ce337a77d804384ee659a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34600
Commit-Queue: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 21:07:24 +00:00
Ben Clayton 6c85272d62 Fix spelling mistake in comment
Change-Id: I559e2348b1d61aa2db8c0cdfd284bd4aa98a86c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34462
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 19:56:44 +00:00
Ben Clayton 3982bb8c28 Update texture intrinsic writer tests for signed params
All unsigned texture intrinsic parameters were recently changed to signed: https://github.com/gpuweb/gpuweb/pull/1271

Update the writer tests to match. The spirv reader side of things will also need to be updated.

Bug: tint:391
Change-Id: I280f223f2556355f4b6538ae1ef446e33b017c9f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34820
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-08 19:39:34 +00:00
David Neto 195917c0be spirv-reader: Support many more float builtins
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Fixed: tint:214
Change-Id: I10f7df66875ccda968fc5654b4f1c1d3a6ac23ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35062
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 14:29:03 +00:00
David Neto eb7865cd0d spirv-reader: Support NClamp, NMin, NMax
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Change-Id: I48503be68128d2a0659bef7057e890cb9c0617ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35080
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 23:45:47 +00:00
Ben Clayton 8b0ffe9185 ast::type: Remove Array::set_decorations
Move to constructor

Bug: tint:390
Change-Id: If6c65b7305db7f9977c0cc9884a8f551e07de050
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35014
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-07 22:19:27 +00:00
Ben Clayton dec971328d ast: Remove unused Struct::set_decorations()
Bug: tint:390
Change-Id: If0aeb618ef15c64e7379501ec88a448bc4d7e015
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35013
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 22:15:57 +00:00
Ben Clayton 602c025aa0 ast: Remove Function::set_body()
Bug: tint:390
Change-Id: I525086868c6470ba39fe8c4ede7390e74c9489ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35012
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:17:47 +00:00
Ben Clayton 2190a8f480 ast: Remove ReturnStatement set_value()
Unused.

Bug: tint:390
Change-Id: If2832da7181e168f8a3bb8c986d8ee2d469b25b2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35011
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:11:47 +00:00
Ben Clayton d0dda258cc ast: Remove ReturnStatement constructors that don't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I2b81929e362ccf75145ebc45028dd973a77ae068
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35010
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:09:57 +00:00
Ben Clayton 321e5a9d7e ast: Remove Variable constructor that doesn't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:08:07 +00:00
David Neto b4b29639a1 spirv-reader: simplify GLSL.std.450 tests
Use variables with names rather than constants
which elaborate to a lot of text in the AST.

Change-Id: Ic284bbd4019e50308c5836768df01c6a9525c004
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35061
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 21:02:27 +00:00
David Neto 201fa87a6d spirv-reader: list missing GLSL.std.450 instructions
Add a TODO for them

Change-Id: I038e4384ae44d87544ae040b2e5ba193415e01b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35060
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 20:55:07 +00:00
Ben Clayton 234b7de460 ast/function: Remove [set|add]_decorations()
Move them to the constructor

Bug: tint:390
Change-Id: I30bb6a1de060b790bf5202194d020d4e3889a307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35008
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:45:14 +00:00
Ben Clayton 9838768599 ast: Remove IfStatement::set_else_statements()
Move it to the constructor.

Bug: tint:390
Change-Id: Ib4ac1a1c83aa59963472ac7c14c9e0cbcf2734e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35007
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:11:24 +00:00
David Neto 4d6635858e spirv-reader: support UClamp, SClamp
Fixed: tint:383
Change-Id: I101370a82379363a4fb1f725e010eedc2da059ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35042
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-07 19:53:54 +00:00
David Neto 4f8b96e13c spirv-reader: texture level and array index are signed
Fixed: tint:394
Change-Id: Ic81c7167d65e7a8d09363a62848b74928fdc2798
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35043
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-07 18:17:14 +00:00
dan sinclair c35176eadf Remove the context object.
This CL strips the context object out of Tint.

Change-Id: Id0dcb9c557b217c03a8d9ac08fc9fe1c799f3fdc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34742
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 16:03:54 +00:00
Ben Clayton bd018d254d Improve error messages raised by SpvParserTest
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);

is a less-idiomatic way of writing:

  EXPECT_EQ(xxx, yyy);

The latter also provides a diff when two strings do not match.

Refactor these to:

  auto got = xxx;
  auto expect = yyy;
  EXPECT_EQ(got, expect);

So that the error message clearly shows which one is the generated, and which one is the reference.

Change-Id: I299204a615aa3e68cd82d19ce892ab33aabe2f08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35006
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 15:57:04 +00:00
Ben Clayton d1398203f9 Remove more unused AST setters
Bug: tint:390
Change-Id: Ia15414e73ba921c0880556f4d43af783f1d497ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35005
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-07 14:53:14 +00:00
Ben Clayton b8a3078bbe Remove DAWN_USE_NEW_TINT_TRANSFORM_API
The legacy code path has now been removed from dawn:
https://dawn-review.googlesource.com/c/dawn/+/34900

Bug: tint:390
Bug: tint:389
Change-Id: Id897bae3d29c7ff5bb0e2e32db1a4b493d4fe715
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35004
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-07 14:23:44 +00:00
Ben Clayton 00b77a80ab Rework all transforms to transform-on-copy
instead of transform-in-place.

This is a public API breaking change, so I've added the `DAWN_USE_NEW_TINT_TRANSFORM_API` define which is used by Dawn to know which API to use.

As we're going to have to go through the effort of an API breaking change, use this as an opportunity to rename Transformer to Transform, and remove 'Transform' from each of the transforms themselves (they're already in the transform namespace).

Bug: tint:390
Bug: tint:389
Change-Id: I1017507524b76bb4ffd26b95e550ef53ddc891c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34800
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-04 09:06:09 +00:00
Ben Clayton 0f37afb74e Refactor transformer tests
Transformers will be moving to a transform-on-copy model, instead of transform-in-place.
Rework the tests to handle this.

Bug: tint:390
Change-Id: Id53a0ba0bd365472940d116bd686e450a29e5028
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34571
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 20:25:29 +00:00
Ben Clayton ad0b2cb841 ast/builder: Add more builder helpers
Will be used by the transforms

Change-Id: Id4cece30f1ef4cbeb7cf4d7ca8d0e775b4ab4c7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34570
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 20:22:59 +00:00
Ben Clayton 8e6cd2e680 Fix doxygen warnings about missing docs
Change-Id: I6bfade1db4b3e1a8c63a0bba16303925554ca6cc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34569
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 18:21:49 +00:00
Ben Clayton 2bc6840d3c Add ast::CloneContext::ReplaceAll()
ReplaceAll() registers `replacer` to be called whenever the Clone() method is called with a type that matches (or derives from) the type of the first parameter of `replacer`.

`replacer` must be function-like with the signature: `T* (T*)`, where `T` is a type deriving from CastableBase.

If `replacer` returns a nullptr then Clone() will attempt the next registered replacer function that matches the object type. If no replacers match the object type, or all returned nullptr then Clone() will call `T::Clone()` to clone the object.

Example:

```
  // Replace all ast::UintLiterals with the number 42
  CloneCtx ctx(mod);
  ctx.ReplaceAll([&] (ast::UintLiteral* in) {
    return ctx.mod->create<ast::UintLiteral>(ctx.Clone(in->type()), 42);
  });
  auto* out = ctx.Clone(tree);
```

This is to be used by Transforms that want to replace parts of the AST on clone.

Bug: tint:390
Change-Id: I80a0e58aa3711f309f58a504f6b6a06f6c546ea1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34568
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-03 18:10:39 +00:00
Ben Clayton 5f8061bd39 Castable: Minor tweaks
Prefix the fully-qualified Unique name in TINT_INSTANTIATE_CLASS_ID with :: as there might (however unlikely) be a nested 'tint' namespace.

Move the test structures in castable_test back into the anonymous namespace. This means `TINT_INSTANTIATE_CLASS_ID` needs to sit outside the anonymous namespace, but prevents global namespace pollution.

Change-Id: I035e9568c081fee120726106dc2150c4990c3881
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34567
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-03 17:44:19 +00:00
Ben Clayton f1f10e6571 Add src/traits.h
Contains some intimidating template magic for inferring the first parameter type of a function or function-like.

Will be used by the CloneContext for transforming the AST while cloning.

Bug: tint:390
Change-Id: I432059d13e65fa0f0f3e52588eb43abe9a4efadd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34566
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-03 17:14:29 +00:00
Ben Clayton 76d12f0f5a Add EmitVertexPointSizeTransform
EmitVertexPointSizeTransform is a Transformer that adds a PointSize builtin global output variable to the module which is assigned 1.0 as the new first statement for all vertex stage entry points.

If the module does not contain a vertex pipeline stage entry point then then this transformer is a no-op.

Bug: tint:321
Change-Id: I0e01236339d9fa1ceab3622af0931a1199c33b99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34561
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-03 14:54:09 +00:00
dan sinclair 685cb02ea8 Remove internal usage of Context.
This CL removes all internal usage of the Context object. It is still
accepted as a parameter until we update Dawn, but all usage is removed.

The namer has been removed from the SPIR-V backend with this change and
the emitted names reverted to their non-modified version.

Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-02 21:17:58 +00:00
dan sinclair 573d8939f4 [ast] Remove more set methods.
This CL updates the SPIRV-Reader to not require set methods for various
AST expressions.

Change-Id: Ieb9a8fcc1746d3051e5b663559127ca63b45a388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34642
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-02 19:13:48 +00:00