Commit Graph

2092 Commits

Author SHA1 Message Date
James Price a67f8a44bb writer/spirv: Fix constant initialization
The code to auto-generate initializers for overridable pipeline
constants was in the non-const code path, so move it to the right
place and fix the tests that were wrongly testing non-const variables.

Bug: tint:254
Change-Id: Ifc96681492768ecf844f67e114377cc643ef7609
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50040
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-06 09:30:42 +00:00
Ryan Harrison 0aeb77c40f Fix GCC builds
BUG=tint:778

Change-Id: If06e453b6fd58b8c74bed996532b3b9f9f7804ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50044
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-05-06 08:20:52 +00:00
David Neto b4a8a15bd2 spirv-reader: arithmetic tests: make valid SPIR-V
Bug: tint:765
Change-Id: I8994647edd29513d48d5154c15e7dd429771c2ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49822
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-05 23:27:52 +00:00
David Neto 922779bcf5 spirv-reader: conversion tests: make valid SPIR-V
Bug: tint:765
Change-Id: I18ed7f007fc9b15c51cddbb6b0edbca79ed1569c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49821
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-05 21:24:34 +00:00
Ryan Harrison bc94cd68f8 Interrupt fuzzer if invalid program is generated
If a a valid shader is input into Tint an valid shader should be
output, if the output is invalid then there is a bug in Tint.

BUG=tint:721

Change-Id: Id3fe80eeb65fa55276d74e2f4868e276bd52ec86
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50000
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-05 21:12:22 +00:00
David Neto ba08d7bca3 spirv-reader: update tests to use valid SPIR-V
This CL: all SPIR-V modules in parser_impl_module_var_test.cc

Bug: tint:765
Change-Id: I2e8427aea729793a4e34e2ac0c6fc689f65bda04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49645
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-05 20:54:02 +00:00
James Price 202d97d846 writer/spirv: Add type to constructor cache key
This prevents two initializers with different types from incorrectly
using the same OpConstantComposite instruction.

Fixed: tint:777
Change-Id: I2cdef9d5b0a83c26cbd4be318fed218e6f3e93b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49981
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-05 19:38:12 +00:00
Ben Clayton 58f93c9e26 Build fixes
Two incompatible changes landed simultaniously.
Also fix a warning about variable shadowing.

Change-Id: I84c9ba48fb87a348a5b0e622ca2fdb191f95a6b2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49964
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-05-05 18:00:52 +00:00
Ben Clayton 8e1d177590 Remove Clone() from sem::Types
These should always be generated by the resolver, not manually constructed by transforms.

This also fixes duplicate intrinsic output from DecomposeStorageAccess.

Bug: tint:724
Change-Id: I979d55f7b141f38c0504dc72cc3c63e8353ac14f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49881
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-05 16:55:22 +00:00
James Price 8c6808fa13 transform/Spirv: Add EmitVertexPointSize logic
This is disabled by default and can be enabled via transform data. The
separate EmitVertexPointSize transform will be removed once Dawn
starts using the Spirv sanitizer to do this.

Bug: tint:753
Change-Id: I676c4cef5bc53f2dbf2330645faa4a0f2bfe11bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49980
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-05 16:54:52 +00:00
Ben Clayton 6c1cf6569e sem::Matrix: Pass the column type to the constructor
It's common to want this when indexing matrices.

Change-Id: Ic60a3a8d05873119d78a3cb0860d129e33ac3525
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49880
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2021-05-05 16:48:32 +00:00
Brandon Jones b432f232b5 Add Transform For External Textures
Adds a transform to reclassify single-plane texture_external types into 2d sampled textures. Adds a unit test for the transform.

Bug: dawn:728
Change-Id: Id1f88565aeacbfea47b140181c78ad122edbdae8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49641
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-05 16:38:12 +00:00
Ben Clayton c9ee7ebd93 Prepare for having TypesBuilder return ast::Types
Instead of a typ::TypePair.

Bug: tint:724
Change-Id: Ife8fac86093eb128bc98974e1f6614a73c42a9e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49753
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-05 16:19:22 +00:00
David Neto dee76fff44 spirv-reader: update tests to valid SPIR-V
Bug: tint:765
Change-Id: I4312f9aa94fd813aeb9b388c10303f967057066f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49644
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-05 16:12:32 +00:00
David Neto 6e2461096a spirv-reader: set failure bit when SPIR-V validation fails
The error message was already being logged, but the status
flag was not being set.

Change-Id: I7f6f2f45c15a64dd089e221c62218afe9e774edd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49643
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-05 16:03:02 +00:00
David Neto 01c3ce7c03 test-all: allow specification of one output format
It's the second argument
This moves the subdirectory argument to the third position.

Change-Id: I91f7a8171f6de51e697a04c1407a1992b5c1c0db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49642
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-05 15:45:42 +00:00
Ben Clayton bd7e8442b8 sem: Add constructor nullptr assertions
Catch the nullptrs early.

Change-Id: Ie8ee30355c79c6cbd589831f6587752b125d45c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49754
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-05 10:48:22 +00:00
Ben Clayton a67583cde3 ast: Remove ProgramIDOf(ast::Type*)
This was a stub implementation copypasta'd from the semantic types.
By removing this, ProgramIDOf(ast::Node*) will be used instead, and these checks will actually work.

Bug: tint:724
Change-Id: I72f2fc5d89d81fb485b3549cb8138517c83c9482
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49752
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-05 10:26:51 +00:00
Ben Clayton 563cb58078 ast: ModuleCloneTest - check cloned program is valid
Helps catch brokenness before asking the developer to stare at AST dumps.

Change-Id: Id39602225ad2d4a1b72dcdf998b164feda870cf1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49751
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-05 10:23:11 +00:00
David Neto 58a3624935 Add --dump-spirv option to tint_unittests
The --dump-spirv option tells tint_unittests to output the
SPIR-V assembly text for a module which did not make the SPIR-V reader
fail.  This lets us get extract a corpus of SPIR-V modules, and
lets us more easily verify that the test shaders are valid in the first
place.

Also:
- Add test/extract-spvasm.py to split that output to separate SPIR-V
  assembly files
- Add optional second argument test/test-all.sh to specify a directory
  look for input files.
- BUILD.gn:  Add dependency from //test:tint_unittests_main to
  //test:tint_unittests_config to pick up source dependency on
  the internal header of the SPIRV-Tools optimizer, needed by
  the indirection through src/reader/spirv/parser_impl_test_helper.h

This is useful for bulk testing

Fixed: tint:756
Change-Id: I4fe232ac736003f7d9be35544328302d652381ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49605
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-05 09:46:31 +00:00
Ben Clayton 02ebf0dcae ast: Migrate to using ast::Type
Remove all sem::Type references from the AST.
ConstructedTypes are now all AST types.

The parsers will still create semantic types, but these are now disjoint
and ignored.
The parsers will be updated with future changes to stop creating these
semantic types.

Resolver creates semantic types from the AST types. Most downstream
logic continues to use the semantic types, however transforms will now
need to rebuild AST type information instead of reassigning semantic
information, as semantic nodes are fully rebuilt by the Resolver.

Bug: tint:724
Change-Id: I4ce03a075f13c77648cda5c3691bae202752ecc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49747
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-05 09:09:41 +00:00
James Price 781de097eb writer/spirv: Fix static array accessors
If the array accessor expression uses a literal index, generate an
OpCompositeExtract instruction. Dynamic indices will be handled in a
follow-up patch.

Fixed: tint:767
Change-Id: I79a980d7d558a49def30816d04dcaa566f284c8f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49701
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-05-05 02:35:41 +00:00
David Neto df48b955b2 spirv-reader: update tests to wrap parser impl
This is a step to being able to dump the SPIR-V for
successfully converted modules.

Bug: tint:756
Change-Id: Ifa48c88835ff10824c542a4e13d8a2d3a7f7f484
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49604
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-04 20:17:41 +00:00
Ben Clayton c6ed25cd3e Prepare tests for switch to AST types
Register all aliases, and don't share type nodes

Bug: tint:724
Change-Id: I7ac20c8a75f232fa7fe1e8c1a5690f411888f6e4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49750
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 19:02:01 +00:00
Ben Clayton 02ada29af2 Add Transform::CreateASTTypeFor()
Reconstructs the AST nodes needed to build the given semantic type.

Bug: tint:724
Change-Id: Iadf97a47b68088a6a1eb1e6871fb3a7248676417
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49745
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 18:13:21 +00:00
Ben Clayton 3e5e4fd8e5 spirv: Add calls to MaybeCreateTypename()
typ::Types originating from ConvertType() will hold direct pointers to ast::Struct and ast::Aliase. These must not be used directly. Instead TypeNames should be created to refer to these.

Bug: tint:724
Change-Id: I7f511e0da56e5d3ac587cdb22b0baf38474bed1e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49746
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 18:13:11 +00:00
Ben Clayton e5b315084d CloneContext: Support inplace cloning
Add a new constructor that only takes a ProgramBuilder.
This allows cloning objects to and from the same ProgramBuilder.

Also clean up tests.

Change-Id: I7c7bbaced4956f9094d0a6231aa4d7f7b6f17d4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49744
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 18:06:31 +00:00
Ben Clayton 49a545c919 ast::Module: Move ConstructedTypes() to typ::Type
And add a few additional helper methods.
Stepping stone to having the module only reference AST nodes.

Bug: tint:724
Change-Id: Ib321dadce5f739afe4f71cbafde9dd2d1c6431bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49743
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 18:03:11 +00:00
Ben Clayton 0f88b31503 ProgramBuilder: Add more helpers
And use MaybeCreateTypename() in more places.

Bug: tint:724
Change-Id: I232229c76205e148a2235dc5706522adb0789bcc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49742
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 17:36:31 +00:00
Ben Clayton 89952d0412 Fix all doxygen warnings
Change-Id: Ic312bc3771a69765b43f1a7c025f1f57783823c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49741
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-04 17:20:31 +00:00
Antonio Maiorano ca992196d2 spirv reader: do not add duplicate constructed types
My last CL (https://dawn-review.googlesource.com/c/tint/+/49542) made it
so that AST nodes are re-created every type we resolve a spirv type id
to a tint type. This creates duplicate nodes, most of which are cleaned
up at the end of parsing. However, duplicates added as global
constructed types are not handled, so this CL makes sure we do not add
said duplicates.

Bug: tint:769
Bug: tint:724
Change-Id: Ifab46aa3b843a841c4371659dbec64891fdabc9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49760
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-04 14:51:11 +00:00
Antonio Maiorano 1b898d56b4 spirv parser: create ast types along with sem types
The spirv parser now creates ast types along with sem types via
typ::Type. All sem::Type* were replaced with typ::Type, and its `ast`
member is used over the `sem` member to make it easier to migrate to
ast-only.

The parser was written to take advantage of the fact that types were
resolved to semantic types during parsing. For instance, a mapping of
spirv typeid to sem::Type* was used throughout (`id_to_type_`) to
resolve types once, and to support type aliasing. Since the goal is to
only create AST types, and to resolve only in the Resolver, I made many
changes to remove this dependency on semantic types. For instance, we
now always call ConvertType(typeid) instead of looking up via
id_to_type. Similarly, the `signed_type_for_` and `unsigned_type_for_`
maps were replaced with `UnsignedTypeFor` and `SignedTypeFor` functions.

Bug: tint:724
Change-Id: I3aee3928834febd71b473d6a8d8cb77b1ac94e21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49542
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-03 20:49:40 +00:00
Ben Clayton b6831c3395 castable.h: Fix warning
> clang --version
Apple clang version 11.0.3 (clang-1103.0.32.29)

../src/castable.h:199:11: error: definition of implicit copy assignment operator for 'CastableBase' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated]

Seems to only be raised with this particular flavor of clang?

Change-Id: I9a549c753cd28a11855138a97823e7c1c92fab25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49532
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-30 21:27:02 +00:00
Ben Clayton 1a492a27db writer/hlsl: Begin migration to ast::Types
The HLSL writer doesn't really care much for ast::Types, so most of the work here is repointing the logic to fetch the resolved, semantic type.
Output for aliases has changed, as the semantic type resolves away aliases.

Bug: tint:724
Change-Id: I6eb9d5c2fbcd62eef0f9dd145360714db649e13f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49530
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:22:49 +00:00
Ben Clayton ccab6bd694 reader/spirv: Return early if MakeExpression() fails
Bug: tint:762
Change-Id: If17e666cf459117c52ece73cb20ea8f70ed1fcd5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49531
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-04-30 20:22:19 +00:00
Ben Clayton fbec46fba9 Resolver: Generate mapping for ast::Type -> sem::Type
Currently untestable as nothing currently calls Type(const ast::Type* ty).

Bug: tint:724
Change-Id: I92dd772acd758b0960a7e9a19f15c91414ab505c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49527
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:20:19 +00:00
Ben Clayton f34cb1fe70 writer/msl: Begin migration to ast::Types
The MSL writer doesn't really care much for ast::Types, so most of the work here is repointing the logic to fetch the resolved, semantic type.

Bug: tint:724
Change-Id: I017b83c9f661cc01cbde377991aab184c1733348
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49529
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:19:09 +00:00
Ben Clayton 44539d85b2 writer/spirv: Begin migration to ast::Types
The SPIR-V writer doesn't really care much for ast::Types, so most of the work here is repointing the logic to fetch the resolved, semantic type.

Bug: tint:724
Change-Id: I7647e17b015bac8394bc0fc76daceb7c0a391a47
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49528
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 20:13:19 +00:00
Ben Clayton 1737485a05 ast: Add ast::NamedType
Have ast::Struct and ast::Alias derive from it.
NamedType currently derives from ast::Type, but this might change in the future.

Bug: tint:724
Change-Id: I46ab7751c89176f4dec34d63247d2459d02ab6bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49525
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 19:58:49 +00:00
David Neto 77a7518c95 Add fallback when realpath doesn't exist
Fixed: tint:763
Change-Id: Id5b687faea82d3e77b8e98607913640fffef6af7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49620
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-30 19:49:39 +00:00
Ben Clayton 3068dcb3d7 sem::Function: Add ReturnType()
This is the resolved, semantic, return type of the function.

Bug: tint:724
Change-Id: I4ef9f7874414a3ea48131d0102da776f6d82a729
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49526
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 19:24:29 +00:00
Ben Clayton fa9af4b0ef writer/spirv: Return error message in Disassemble
Instead of printf-ing and returning an empty string.
When there's a lot of other test output, it can be really hard to actually spot the error message.
With the error being returned, this will likely appear in a EXPECT_EQ() style error message.

Change-Id: I733741a68de4843e986037c5e309c5a4c3d66124
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49522
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 19:23:49 +00:00
James Price e87ded8567 Rename builtin constant_id to override
There are no downstream usages, so we can skip deprecation. Allowing
the ID to be omitted will be done in a separate patch.

Fixed: tint:754
Change-Id: I3bd6de4d0f426fc3c66708bfd5b411a4051b375b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49581
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-30 17:14:19 +00:00
Ben Clayton 083b591783 writer/wgsl: Emit ast::Types
This takes precedence over semantic types.

WGSL should be printed as faithfully as possible to the parsed program.
The semantic nodes are more abstract than the AST - aliases are folded
away, decorations may be absorbed into the semantic types, etc.

Bug: tint:724
Change-Id: I500af3d20e4ea3f9bfcb7664f0ad2360aeeecd68
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49350
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 16:01:29 +00:00
Ben Clayton ae7b747789 Kokoro: Add configs for a linux UBSAN build
Bug: tint:760
Change-Id: If13fe1d8b63f058471aa19854277ca413e23f384
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49524
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-30 15:01:08 +00:00
Ben Clayton 275eb7e4e4 reader/spirv: Clean up disjoint AST nodes
Perform a program clone at the end of parsing to remove any unreachable AST nodes.
Actually fixing the parser to never create these looks like a huge amount of work.

Fixed: tint:749
Change-Id: Ib956634257e0933c9702d6be22f79942f7cf4c51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49520
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-30 10:43:19 +00:00
Ben Clayton 9481156eb9 Fix Undefined Behaviour
All caused by calling Castable::As<> on nullptr objects.

Bug: tint:760
Change-Id: I0a408b3cd58086cfeab5a1af34d643f50f304948
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49523
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-30 10:16:45 +00:00
Zhaoming Jiang 30c03a5d50 HLSL writer: Translate the built-in function "mix" into "lerp"
The built-in function "mix" in WGSL should be translated into the
intrinsic function "lerp" in HLSL according to the HLSL document.

With this patch the dawn sample CubeReflection will be able to run
correctly with tint generator on D3D12 backend.

Bug: tint:758
Change-Id: I7e84987c02fd2090d5e7af8f4aba995fc95a6fdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-30 08:47:06 +00:00
David Neto e08cc15dd9 spirv-reader: HLSL-IO: Convert input, output vars to private
Bug: tint:508
Change-Id: I5cd7c1b476112eb489f9e6acc94f7a1cf6e43b6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48863
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-29 22:04:55 +00:00
James Price 5f7f7c0f9e Revert "transform/EmitVertexPointSize: Handle entry point parameters"
This reverts commit e6307e5100.

Reason for revert: This change assumes that vertex shaders do not return void, but the validation for this is currently disabled since CTS still has vertex shaders that return void.

Original change's description:
> transform/EmitVertexPointSize: Handle entry point parameters
>
> Generate a new struct that contains members of the original return
> type with the point size appended to it, and replace return statements
> as necessary.
>
> The SPIR-V sanitizer then special-cases this builtin when handling
> entry point IO to always use a RHS which is a literal.
>
> Fixed: tint:732
> Change-Id: Id718632a5e671f3e7c82a304f5bc1fc223a6c8ee
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49440
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: James Price <jrprice@google.com>
> Auto-Submit: James Price <jrprice@google.com>

TBR=bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com

Change-Id: I6113b2d8994eb088cb890a6af52e392b2d5a45f6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49582
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-29 21:29:36 +00:00