Commit Graph

2988 Commits

Author SHA1 Message Date
Alastair Donaldson a96dce9c89 Remove SPIR-V reader fuzzers
Fuzzers that exercise the SPIR-V reader are being moved to OSS-Fuzz.
This change removes them from the Chromium build so that they cease to
be run by ClusterFuzz. The change also applies a small refactoring to
the fuzzer build rules, so that the tint_ast_clone fuzzer is specified
together with other fuzzers that require the WGSL reader and writer.

Bug: chromium:1243084
Change-Id: I4f5d12a679366634c7cad3e7ac18075bb046a8ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <afdx@google.com>
2021-08-25 16:14:43 +00:00
James Price 87cce20f67 test: Remove many expected files
For these tests, we only really care that we can successfully consume
them and generate valid output for each backend. Having the expected
files in the tree generates significant churn for any change to how we
generate backend code, which makes it hard to inspect diffs.

Change-Id: Ic98c248081144c0fb1791f1303eaf6d459548e3d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62720
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-08-24 22:49:42 +00:00
Ben Clayton 568136dd10 Reduce OWNERS to 4 people
only picks 5 out of N.

Change-Id: I0e9d2e4bfa1050681dd88af918d040d42484f140
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62442
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-24 09:59:31 +00:00
James Price 85d2e448de msl: Overload matrix-vector arithmetic operators
These operators are not defined in the metal namespace when the vector
operands are packed.

Fixed: tint:1121
Change-Id: I2e8f4302e08117ca41bac6c05fb24a70d1215740
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62480
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-23 21:45:23 +00:00
James Price 46978033a7 msl: Only emit packed vectors when the width is 3
MSL vectors with other widths already match WGSL's rules for alignment
and size.

Change-Id: I237052372463ea8323eab47c3b4ca90c6d8afcc3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62600
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-23 21:45:23 +00:00
Ben Clayton 6d60c046e8 resolver: Validate that parameter names are unique
Fixed: chromium:1242330
Change-Id: I7a5c32f55b5a4d5898c1fe4efeee084dfeb15346
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62444
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-08-23 19:01:19 +00:00
Ben Clayton 367f5df5c3 castable: Infer Is() TO type from predicate
For the Is() overload that takes a predicate function, infer the cast target type from the single parameter of the predicate.

Removes noise.

Change-Id: Ie6248c776ca1f9d50808e03e9685056fd3819217
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62441
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-23 15:16:42 +00:00
Ben Clayton 1fa6f5ce9b resolver: Validate calls to void callables
Calls to functions and intrinsics that do not return a value must only be used by a call statement.

Fixed: chromium:1241460
Change-Id: I0f940c942b55a5212367dbf9e261083beb4560ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62440
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-21 08:50:40 +00:00
James Price f6a49d69b4 msl: Add `matrix` to list of reserved keywords
This is in the metal namespace, which we import fully.

Change-Id: I986cdebbe1897ad0b433bc0260480dd8839f93e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62400
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-08-20 13:28:09 +00:00
James Price d47a7ef0cf validation: Reject decorations on local variables
These are never valid. The WGSL parser cannot produce them, but the
SPIR-V reader can since these are not always caught by spirv-val.

Fixed: chromium:1239557
Change-Id: Ie19e4534ffb73b61beaa42046b18b2b8a3f7f65b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62020
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-08-17 16:09:00 +00:00
James Price 91181b906f Add robustness transform to tint_inspector_fuzzer
Fixed: chromium:1239800
Change-Id: I7d60b683028773697a38454a6902a9093465ade2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62140
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-08-16 20:48:39 +00:00
James Price 06c86a551e validation: disallow non-constructible assignments
The storage type of an assignment has to be constructible, which
prevents stores to atomic or runtime-sized array types.

Change-Id: Ie7bb703bb4c6953a4ddf0286f39d0d3e17b5b1d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61801
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-08-13 15:20:42 +00:00
James Price cbbb420952 validation: disallow atomic type constructors
The type of a type constructor must be constructible, which forbids
atomics. Add checks for non-constructible types when validating arrays
and structures, and then error on any type that isn't explicitly
matched in the outer function. Replaces the separate check for
pointers, which is no longer necessary.

This also removes the validation for "an expression must not evaluate
to an atomic type". The only test that we had for this is no longer
valid (since the type constructor it used is now rejected). There are
no other ways of hitting this particular error, since other validation
rules will always kick in first.

Change-Id: I2172b57ee4e8ee3066aaf0cedc4a26aaca642376
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61800
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2021-08-13 15:20:42 +00:00
James Price 8094553c8a msl: Automatically remap binding numbers in exe
Remap all resources into a flat namespace, to allow tests to pass when
multiple resources use the same binding number.

Fixed: tint:959
Change-Id: I58ed07c789e1ea90fc370ceba73b9d8292902549
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61261
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-12 19:47:20 +00:00
Ben Clayton 080fdf2ac0 writer/hlsl: UnwrapRef() on atomic types
Fixed: tint:1113
Change-Id: I9aa255f5b308cc4d53b0ea40407cc398096a502c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61780
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-08-12 18:23:10 +00:00
James Price 13463daa95 test: Add MSL result for test that now passes
The location decoration in the test source was recently changed to fit
in MSL's allowed range.

Change-Id: Ia8ff2cc453f5af3ed084ede42546ef6750bd27a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61260
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-12 18:18:41 +00:00
James Price 2cbf265aec transform: Remove unused function
This was shared by the shader IO transforms, but is no longer used
after they were refactored.

Bug: tint:920
Change-Id: I879468bbacda6ecb59c4b49ef2434753df74644c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61121
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-12 18:18:41 +00:00
James Price 67473c7a6c Add test for var with inferred non-constructible type
Follow up to this bugfix:
https://dawn-review.googlesource.com/c/tint/+/61660

Change-Id: I357e1fd859c844c3285ea6077c0e58d225e01c6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61682
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-08-12 03:40:49 +00:00
Ryan Harrison b73a12cc5d Ensure that string and container are initialized before use
On OSX, under ASAN the fuzzer is causing a null reference due to
.empty() being called on a null.

BUG=chromium:1237630

Change-Id: I73e627eadaa162af451f809c4abe8ec685d8b95c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61681
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-08-12 03:40:31 +00:00
Ryan Harrison 3bcbfc7862 Use foo->source() instead of foo->type()->source() in errors
In these circumstances foo->type() may be null.

BUG=chromium:1238462

Change-Id: I77ed142e3f61f6af52a07e59e290f65613af3514
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61660
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-08-11 19:59:44 +00:00
Shiyu Liu 36747d7046 Remove const from GetNode return type
This is to make sure that compiler won't crash when creating data
types using the result from GetNode function from node_id_map.

Change-Id: I96fad13d3494de4808e29d6952e5e88e697f8516
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61381
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Paul Thomson <paulthomson@google.com>
Commit-Queue: Paul Thomson <paulthomson@google.com>
2021-08-11 16:43:45 +00:00
Vasyl Teliman 4ebede411e Run fuzzer unit tests in Kokoro
This CL adjusts the scripts to be able to run AST and regex
fuzzer unit tests in Kokoro. Only clang is supported for now.

Change-Id: Ibc9ebb9cf0dc40f47317abf88875aa738811919d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61642
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Vasyl Teliman <vasniktel@gmail.com>
2021-08-11 14:10:05 +00:00
Vasyl Teliman 9e3e54b932 Reuse moved-from tint::Program variables
Currently, it's impossible to move a tint::Program instance into a
variables that has been moved. This CL fixes that.

Bug: tint:1105
Change-Id: Idc04cf2bb569d1cffc2c309117fc4615c41ac76a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61640
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2021-08-11 13:50:24 +00:00
Ryan Harrison 5085efb748 Add robustness pass to ast and regex fuzzers
Fixed: tint:1104
Change-Id: I4ea3aa283c1c4b5e55f507dbc104b21c8bedb63b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61521
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: James Price <jrprice@google.com>
2021-08-11 13:02:45 +00:00
Ryan Harrison bfb27f00d7 Actually use inputs in vertex pulling fuzzer
I have checked the other fuzzers, and they appear to be correctly
using the generated inputs.

BUG=tint:1099

Fixed: 1099
Change-Id: I691e16ef4130e374894550fcf8e3d5565224a656
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61440
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-08-10 18:01:35 +00:00
Shiyu Liu 0c22b1aaea Update node_id_map & FindMutators structure
Added function in node_id_map to check a given id is valid and fresh.

Currently, the structure of FindMutators declares node_id_map as const, which causes issues when we want to call `GetFreshId` from the argument that is passed by reference. A simple work around is to pass a non-const node_id_map as argument directly. That way `GetFreshId` function in node_id_map can continue to be non-const and conveniently update next fresh id whenever a fresh id has been taken.

Change-Id: Ia7e1d247cf92dfefd2ef7e7c1b4bf32363d9ce3f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61100
Reviewed-by: Paul Thomson <paulthomson@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Paul Thomson <paulthomson@google.com>
2021-08-10 16:43:15 +00:00
James Price 34f7eedf74 test: Update expected test output
This new test was added around the same time as the entry point IO
rework, so the (now incorrect) test output made it past the bots.

Change-Id: I89fc4041b9cd00cd363ba61d07371554263eca96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61460
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-08-10 16:16:55 +00:00
Vasyl Teliman 32e905f4cb Fix infinite loop
Fix the infinite loop caused by 6e459fecb7.
That commit changed the behaviour of a sem::Statement::Block method for
sem::BlockStatement instances. Now, the method returns the block itself
instead of the outer block which causes an infinite loop when iterating
over a chain of blocks.

Change-Id: I0eab3f7f166dbe38477bbefd222edb9cf0da53b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61060
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-08-07 17:33:20 +00:00
James Price b2619443d9 reader/spirv: Propagate errors during composite extraction
This prevents nullptr dereferences when invalid OpConstantComposite
instructions make it past spirv-val.

Fixed: chromium:1231650
Change-Id: Iddfe04dcfdce382096ae7dec7af8718b579f7951
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61080
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-08-06 20:31:59 +00:00
Ben Clayton 1a1c42ef12 reader/spirv: Partially handle MatrixStride on matrix arrays
SPIR-V spec states:
> Each structure-type member that is a matrix or array-of-matrices must have be decorated with a MatrixStride Decoration

As already pointed out in https://dawn-review.googlesource.com/c/tint/+/59840, we were not handling arrays-of-matrices.
To do this correctly, we need the ast::StrideDecoration to be placed on the Matrix type, which is a much bigger change to support.
For now, chase the type, and error if we have a custom MatrixStride on an array of matrices, otherwise drop the decoration.

Bug: tint:1049
Fixed: tint:1088
Change-Id: Idcb75b3df88040836a03a14e0ca402ebee7be9a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60923
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-08-06 19:48:32 +00:00
Jiawei Shao b612c50593 Inspector: Add input [[sample_mask]] to EntryPoint
This patch adds the missing input [[sample_mask]] to EntryPoint in
the Inspector and the related unittests to inspector_test.cc.
According to the latest WGSL SPEC [[sample_mask]] can be used as
both fragment shader input and output.

Bug: dawn:802, dawn:1032
Change-Id: I80640f26c7d771e35039fd7f3c941859729f26ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61020
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-08-06 00:26:31 +00:00
egj 608738d59b Regex fuzzer: replace the value of an integer with
a value in the set {INT_MAX, INT_MIN, -1 or 0}.

A mutation that replaces the value of a randomly-chosen integer with a value
in the set {INT_MAX, INT_MIN, -1, 0}.

Fixes: tint:1093.

Change-Id: I5ec69e1813785760ed6e7b06d0cbd9c481f69ade
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alastair Donaldson <afdx@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
2021-08-05 22:24:20 +00:00
Ben Clayton a958c89aae Add all team members to OWNERS file
ClusterFuzz uses this file to determine the CC list for new bugs.
If ClusterFuzz thinks a bug is scary, it'll restrict visibility to the assignee and people CC'd on the issue.
As we go into OT, we want the whole team to be able to see these issues, so expand the OWNERS to the whole team.

Change-Id: Idf717eb5f09c1712ceb4cf58174c59c4032fa5f6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61061
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2021-08-05 21:31:59 +00:00
James Price 11c6fcdb51 spirv: Use generic transform to process shader IO
The refactored CanonicalizeEntryPointIO transform makes it much easier
to handle SPIR-V style IO as well, and doing this removes a lot of
duplicated code. Remove all of the SPIR-V transform code for shader IO
and vertex point size.

Bug: tint:920
Change-Id: Id1b97517619b4d2fd09b45d5aee848259f3dfa77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60840
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-05 17:34:19 +00:00
James Price 11e172ab64 msl: Add generator option to emit [[point_size]]
This option is passed through to the CanonicalizeEntryPointIO
transform, which adds it to the set of builtin shader outputs for all
vertex shaders in the module.

Bug: tint:1000
Change-Id: Ibba4adde2c468b11ebfd7012fcb42ee48aad04e4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60522
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-05 16:21:59 +00:00
Antonio Maiorano 15e89fa7b7 Add '-tint_dump_input=true/false' to fuzzers to dump input spv/wgsl to a file
When enabled, the input spv/wgsl is dumped to a file named
"fuzzer_input_<hash of file>.spv/wgsl".

Note that this adds the setting to all the fuzzers in the root of
fuzzers/, but not to tint_ast_fuzzer, tint_regex_fuzzer, nor
tint_spirv_tools_fuzzer as they currently to their own CLI parsing.

Change-Id: I268ffd842b94be1cbb78eb199d5662712ff71053
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-08-05 15:52:58 +00:00
Sarah 4038fa7f43 validation: atomics access mode and storage class
Bug: tint:901 tint:909
Change-Id: Ibbcdd80ddbe2aa9940bbd73bb404349afc633836
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60080
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-05 15:18:29 +00:00
Jiawei Shao b5025dbc82 Inspector: Add all fragment builtin inputs to EntryPoint
This patch adds all the fragment builtin inputs (position, front_face,
sample_index) to EntryPoint for the validation on the total number of
fragment inputs. According to Vulkan SPEC: "All variables in both the
built-in interface block and the user-defined variable interface count
against these limits".

BUG=dawn:802

Change-Id: I8a8503c1a33646b50f010c6b6e38d74de9a40ff5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59421
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-08-05 00:22:38 +00:00
James Price a5d73ce965 transform/shader_io: Generate a wrapper function
This is a major reworking of this transform. The old transform code
was getting unwieldy, with part of the complication coming from the
handling of multiple return statements. By generating a wrapper
function instead, we can avoid a lot of this complexity.

The original entry point function is stripped of all shader IO
attributes (as well as `stage` and `workgroup_size`), but the body is
left unmodified. A new entry point wrapper function is introduced
which calls the original function, packing/unpacking the shader inputs
as necessary, and propagates the result to the corresponding shader
outputs.

The new code has been refactored to use a state object with the
different parts of the transform split into separate functions, which
makes it much more manageable.

Fixed: tint:1076
Bug: tint:920
Change-Id: I3490a0ea7a3509a4e198ce730e476516649d8d96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60521
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-04 22:15:28 +00:00
Ben Clayton 3e92e9f8ba Fix structure builtin emission
Fix the Renamer to preserve builtin structure member names.
Fix the HLSL writer to emit the modf / frexp result type even if there is no private / function storage usage of the types.

Fixed: chromium:1236161
Change-Id: I93b9d92980682f9a9cb090d07b04e4c3f6a2f705
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60922
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-04 22:03:28 +00:00
Ben Clayton 63e7ad699c diag: Remove ICE bug report message
We're about to go into a Chrome Origin Trial, and crbug.com/tint is not the correct place to file Chrome related bugs.
Move this message to the tint executable, which is code not used by chrome.

Change-Id: Ib33630164fa5d7bec3c581e5eca6ff188921eef8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60562
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2021-08-04 20:19:28 +00:00
Ben Clayton ecadfc111b tools: Support adding tint flags to the test cases
Starting a test case with `// flags: <flags>` will
append the <flags> to the tint executable for that test case.

Let's you specify things like `// flags: --transform XXX`, which lets us
end-to-end test a particular set of transforms.

Change-Id: I181e9f7e7c1fba5e3a47cf58aee462b51e4b6e3b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60921
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-08-04 20:02:15 +00:00
James Price 5c61d6d12c msl: Fold &* when converting module-scope vars
This transform was previously converting this code:
```
var<private> v : f32;
fn foo() {
  bar(&v);
}
```

into this:
```
fn foo(vp : ptr<private, f32>) {
  bar(&*vp); // Invalid, since ptr args must be &ident
}
```

Fixed: tint:1086
Change-Id: Ic9efafa219c89a11a4d6e1d11fc69b3c0b9a5464
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60520
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-04 19:18:38 +00:00
egj 98fbf241d8 Regex fuzzer: identifier mutation
Mutates a WGSL-like string by replacing a randomly-selected identifier
with a different randomly-selected identifier.

Change-Id: Iecf45ad2800677cf3609b30d415520e5f2a05ba0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60561
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alastair Donaldson <afdx@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
2021-08-04 07:12:20 +00:00
Ben Clayton 51750f15d2 writer/hlsl: Don't emit literal integer divide-by-zeros
FXC errors on these, and they are undefined behavior in WGSL.

Bug: tint:1083
Change-Id: I7643fdc6991f8729f274535b603b761398412398
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60500
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-08-03 17:51:32 +00:00
David Neto 72dad76c21 Add end2end tests for recent SPIR-V reader updates
- reduce output location value
- texture_depth_multisampled_2d
- matrix stride handling
- ldexp for unsigned second argument

Change-Id: Ib0782838dfa93fc637118cbf1faea67cf2406dd5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60460
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-08-03 17:38:49 +00:00
Antonio Maiorano 72f9ce98d1 HexFoat: detect exponent overflow and report errors
Make ParserImp::const_literal() bubble up any error by the tokenizer.
These were being ignored.

Also:
* Detect and report significand too large
* Detect and report missing exponent
* Fix invalid mantissa overflow detection for fractional trailing zeroes
* Fix zero with non-zero exponent triggering an assert, and instead,
make the result zero (added tests for this).

Bug: chromium:1235132
Bug: tint:77
Change-Id: I364a4c944121a2c55ff3161de1bb50126c8a5526
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60680
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-08-03 17:12:59 +00:00
egj b75e4b96a6 Regex fuzzer: Change the region boundaries
Changes the interval boundaries to exclude the first delimiter
that encloses a region.

Change-Id: Ia9186e584d9038b4220cad11d418fa9881e51e8d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60346
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alastair Donaldson <afdx@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
2021-08-02 20:56:39 +00:00
Ben Clayton c0fbce65d8 writer/hlsl: Inline fallthrough case statements
FXC does not support fallthrough case statements (DXC does).

Fixed: tint:1082
Change-Id: I82e1add5455e438056259f773f34bf9db05970b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60480
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-08-02 12:58:19 +00:00
Ben Clayton 8ebff3dc85 Revert "Update SPIR-V Tools fuzzer"
This reverts commit 5a53634764.

Reason for revert: This is making the Dawn -> Chromium roller fail.

https://github.com/KhronosGroup/SPIRV-Tools/pull/4407 introduces a new mandatory parameter to the spvtools::fuzz::Fuzzer constructor, which does not exist in Chromium's version of SPIRV-Tools (d9f89257855a2784323512cd9568b6610bcae581).

The roll of SPIRV-Tools into Chromium is currently blocked by another issue, and is a couple of weeks behind ToT. See https://autoroll.skia.org/r/vulkan-deps-chromium-autoroll.

Note, that https://github.com/KhronosGroup/SPIRV-Tools/pull/4407 is going to block the eventual roll of SPIRV-Tools in Chromium, as there's no way this code can compile for both pre and post roll.
I'll try and fix this after unblocking this roll

Original change's description:
> Update SPIR-V Tools fuzzer
>
> Updates spirv-tools DEPS to pull in some recent spirv-fuzz changes, and
> modifies the SPIR-V Tools fuzzer so that inapplicable transformations
> are ignored.
>
> Change-Id: Ibdea6e9bc35224efe148133eced341168f7ce7b7
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60209
> Auto-Submit: Alastair Donaldson <afdx@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
> Commit-Queue: Ryan Harrison <rharrison@chromium.org>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I4ebcfcfab16e760f64cb8dc622dfb6ef4f1eccf0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60560
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2021-08-02 11:13:49 +00:00