This was done in ValidateArray(), but this comes after the call to DefaultAlignAndSize(), which will ICE if the type is not storable.
Change-Id: Ia3f1b640f42a45362487c3156237b59ea6fed68b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53043
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This was calling Type() without actually checking that the resolve succeeded.
Have the caller resolve the AST type to the semantic type, so that there's a sensible place to handle errors.
Change-Id: I8fae91854377994f68a924fe8104a48a8afe150e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53042
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Formerly, tmpnam_s was used to ensure a unique file name, but then we'd
append an extension to it, invalidating its uniqueness. Instead, we now
do our own uniqueness check by attempting to create a unique empty file
for write with new names until it succeeds.
Bug: tint:812
Change-Id: I90b85074ad2281f9904f24e8fddda80d67e61ba7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53061
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Using WaitForMultipleObjects on the handles to stdout and stderr streams
is apparently not the right way to do this. Instead, we create 2
threads, one that reads stdout, and one that reads stderr, and we wait
on those threads, along with the process handle.
Bug: tint:812
Change-Id: I5975e4d649b58d0f8bffb76dec5a3f4079513e04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53060
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Performs output validation with spirv-val for SPIR-V (as before), HLSL
validation with DXC, and MSL validation with the Metal Shader Compiler.
Disable HLSL tests that fail to validate
Bug: tint:812
Change-Id: If78c351b4e23c7fb50d333eacf9ee7cc81d18564
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51280
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This should be a u32, but we are missing validation rules for builtin
types (opened crbug.com/tint/861 for this). This meant that we were
generating invalid HLSL for this test.
Change-Id: Ib2189d98e5e515e41374372c0f8963df04eb1b01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53001
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
PrintWGSL() was using the moved program, triggering an ICE
Change-Id: I8976feac8712cc883d1b1b4bdca35a929bcb846a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53040
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This allows them to be used in various places that WGSL allows, such
as function return types and parameters, and as the type of the RHS of
an assignment.
Fixed: tint:814
Fixed: tint:820
Change-Id: Idb6a901b9a34e96bb9733cc158191e7b3bafaa0e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52844
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>
Add a template file to generate intrinsic_table.inl and
include this from intrinsic_table.cc.
Speeds up execution of the unittests by 20 - 30%, and
reduces the executable size by a couple of percent.
Bug: tint:832
Change-Id: Ifa7f3c42202c92e97b46ed1716ece48660dd29dd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52504
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: David Neto <dneto@google.com>
Sometimes a value can come from a block which does not appear
in the structured block order. That block will never execute,
so we can safely use the null value instead.
Bug: tint:804
Change-Id: Idc1a6c4f76f14a1d76919a95e5a65e56018ce68f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
Used by the intrinsic definition generator.
Bug: tint:832
Change-Id: I000b1ebe067117e533b3edd8a3fac67a3cbc14c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52601
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
The LHS should be wrapped in parentheses if it has lower precedence
than the access. This fixes issues with pointer dereferences followed
by array accesses, where we were previously generating *a[i].
Change-Id: I639f94b642f32119350b0a0d23f4ff2a5d6c3c25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52843
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Pull the HLSL transformation out to a standalone transform that can be
used by both HLSL and MSL.
The new E2E tests do not yet pass for MSL because they produce array
assignments, which will be addressed in the next patch.
Fixed: tint:826
Change-Id: Idc27c81ad45e3d4ab96d82663927d2fc1384618e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52842
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Add a template file to generate parameter_usage.h and
parameter_usage.cc when using tools/intrinsic-gen
Bug: tint:832
Change-Id: I0ca4d092fdcda7d7846b968d43202f34450e516d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52644
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Add a template file to generate intrinsic_type.h and
intrinsic_type.cc when using tools/intrinsic-gen
Bug: tint:832
Change-Id: I35ddfd497d6ab424dc49a18a9fd7e5eb7f8363b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52643
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Parses the intrinsics.def file, then scans the source tree for .tmpl files.
Using both of these, it produces source files for use in tint.
Bug: tint:832
Change-Id: I718114f4c540b9d620899e89d5758f048377ee04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52642
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Have the resolver emit unique parameter names
Aslo: Update the parser tests to include ':' between parameter name and type.
This functionality landed a few changes up, but I missed this test from the change.
Bug: tint:832
Change-Id: If0d6d3a33bbcd8be4d70ee7182754158ed0da819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52641
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Change-Id: I01e8957496cea7e406f6381517cc04aa4f05d8fb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52801
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Will be used by the lookup table package, which is used by the intrinsic definition generator.
Bug: tint:832
Change-Id: I72c2dc5e37678dbaffc1a32e1631caa8ba6c690e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52600
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Part of the new intrinsic definition parser.
Bug: tint:832
Change-Id: I701072def1a4ca723d10d08b44c1e271b9458212
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Add tests.
This is going to be used by intrinsic-gen, a new tool
Bug: tint:832
Change-Id: Ib22ffa88a699be9c8dfdf3f8f6e32cff4ffc88e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52602
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Change the GenerateGLSLStd450 method to GetGLSLStd450 and have it
return the import id. That's the only interesting use.
Change-Id: I4fc70e702af160bc797680e5e75e9742e9e24f16
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52421
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
This test was not building, as relative imports are not allowed when using modules
Change-Id: I661870c0d676029a782fe2a05acb98d4544fbb95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52502
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Ground work for the new intrinsic definition parser.
Bug: tint:832
Change-Id: I0aff7f8cf5db4b6aa3a56939b944a37abc360cc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52501
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Ground work for the new intrinsic definition parser.
Bug: tint:832
Change-Id: I341ae11e36ef7af96ce7d01609a96e2c02425e87
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
The definition file for the WGSL intrinsics.
Will be parsed by a new `intrinsic-gen` parser to generate the IntriniscTable and tests.
Bug: tint:832
Change-Id: I3c523b6d86faa59150e2b6fb302d27c06f0e3cbe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52503
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Signed zeros are emitted.
Subormal numbers are emitted as hex float.
Handling Inf and NaN is unresolved in the spec.
See https://github.com/gpuweb/gpuweb/issues/1769
NaN tests are disabled, due to platform dependence.
Windows x86-64 seems to always set the high mantissa bit
on NaNs.
Fixed: tint:76
Change-Id: I06c69b93b04c869a63ec2f574022996acc7a6dbe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52321
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This avoid duplicating the logic in two places, and makes it easier to
implement according to the spec.
Bug: tint:376
Change-Id: If62f508e2c76b5b661e66aae9ff20b8e874a65d8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52323
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
MaybeEmitCombinatorialValue() didn't check that MakeOperand() or RectifySecondOperandSignedness() didn't error, leading to ICEs.
Bug: crbug.com/tint/804
Change-Id: Ic78487a70a591e718c7b5936c6678e7a19c4b626
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51927
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Previous logic relied on the fact that for most operations, for a given
lhs type, there was exactly one rhs type allowed, except for
multiplication. This is no longer true in the spec, so making this test
work is more complex now. Instead, we simplify the test by having it
take the cartesian product of all possible (type * type * op), and
skipping any triplet not found in the all_valid_cases table.
Bug: tint:376
Change-Id: Icc76158823630e34dc8f25dfb0a0827545693108
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52322
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
The LHS should be wrapped in parentheses if it has lower precedence
than the access. This fixes issues with pointer dereferences followed
by member accesses, where we were previously generating *a.b.
Fixed: tint:831
Change-Id: I8a194ad4f54c80a01c24eb983ec8064037575216
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51963
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Add a transform that pushes these into the entry point and then passes
them by pointer to any functions that need them.
Since WGSL does not allow non-function storage class at
function-scope, add a DisableValidation attribute to bypass this
check.
Fixed: tint/726
Change-Id: Ic1f4cd691a54c19e77a60e8ba178508e4249bfd9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51962
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>
Inserts a new node at the end of a (potentially empty) list.
Change-Id: Ibd487b995aee4a3ae2c3d17b5eb6e8562c43a1c4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52320
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Inserts a new node at the start of a (potentially empty) list.
Change-Id: Ie2896fa3e1beabeb89f64e69a84091986ffbf7a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51369
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
BUG=chromium:1212166
Change-Id: I605fd926e0235da4f8e5b60bd471971dc1bded32
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52021
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>