Any struct which is used as the store type of a buffer variable needs
to have a block decoration. If that struct is nested inside an array
or another struct, we wrap it inside another struct first.
This removes the SPIR-V backend's reliance on the [[block]] attribute,
which will soon be deprecated and removed.
Bug: tint:1324
Change-Id: Ib6ad54f24a3e4a090da9faeed699f266abcb66ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72082
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Replace all validation rules that rely on the block attribute with the
new rules based on fixed-footprint types.
Bug: tint:1324
Change-Id: I02656537bee66e6e1af95875e503a37bf23d4a6b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72081
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
These test vector constructors with an explicit element type.
Bug: tint:1334
Change-Id: I3d0f626e42850e841cffd70241274e32dcb75fbb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72142
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Move these under test/expressions, and rework the directory structure so we can test vector arguments and inferred element types.
Bug: tint:1334
Change-Id: I411fd7ce1ecdd50c6ef9b79be8407c09a6d38240
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This transform does not use the top-level ctx.Clone() method, so we
need to manually copy the applied transforms over to the destination
program.
This fixes the GLSL backend, where this transform was dropping the
applied transforms and breaking a required transform dependency later
in the chain.
Change-Id: I3db688fe35dfbe67468b9941f739cb2ecf3a843b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This fixes errors like "error X3500: array reference cannot be used as
an l-value; not natively addressable". Note that FXC treats matrices
like arrays. We still get this error for dynamically indexed arrays in
structs.
Also improved HLSL assign tests, and add missing ones for vector
indexing.
Manually removed 20 e2e skip hlsl SKIP files that are now passing with
this change.
Bug: tint:1333
Change-Id: If23881a667857a4d4ec6881e72666af0a666ef10
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71982
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
All writers implemented, along with resolving and validation.
TODO: SPIR-V Reader.
Bug: tint:1330
Change-Id: I8ba2f6023749474f80efb8a5422ac187e6c73a69
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71820
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
It seems we haven't run our e2e tests with FXC validation in a long time
- at least not since we've added the vk-gl-cts corpus.
Locally disabled exclusion of "/test/vk-gl-cts/" in test-runner/main.go,
and ran:
./test/test-all.sh out/build/x64-Debug/tint.exe --format hlsl --fxc --generate-skip
These will need to be manually removed once the skips aren't needed by
deleting them all, and re-running as above.
Bug: tint:940
Change-Id: I27e395e69f5e1bd7d234f3155f40396b751720d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71981
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
If TINT_SYMBOL_STORE_DEBUG_NAME is 1, Symbol instances store a
`debug_name_` member initialized with the name of the identifier they
represent. This member is not exposed, but is useful for debugging
purposes.
Bug: tint:1331
Change-Id: Ia98e266aefc1ca26bbf30c6ece73d9eac8afdbd7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
FXC is buggy, and I recently landed changes in Dawn to run with "/O0"
rather than /"O2" because of these bugs. Let's make sure Tint end-to-end
tests do the same. Also do the same when running against DXC.
Bug: dawn:1203
Change-Id: I1a30f16dee8306bd645d87b3ccb0cc87691c5972
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71800
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
The VM has been updated to Kokoro 14.04, and now the docker instance
requires escalated privileges in order to run some sanitizer builds.
Change-Id: Icebbb1597dcdb67a854cb61ff7b0c0c11952b7f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71921
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Fix dependency graph traversal for bitcasts. These were not being traversed, leading to an ICE if the bitcast type was an alias, as the symbol was not resolved for later use by the resolver.
Add missing validation for bitcasts. We were permitting any bitcast that wasn't a being cast to a pointer type, when the spec only allows:
* numeric_scalar to numeric_scalar
* vecN<numeric_scalar> to vecN<numeric_scalar>
Add lots of tests.
Fixed: chromium:1276320
Change-Id: I9e5487ec7649ac543f73fc878e7e282bf932d8cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71681
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Migrate some of the validation logic over to use the results of behavior
analysis.
The most significant changes are:
* Unreachable-statements now consider merge-points of control flow. For
example, if all branches of a if-statement or switch-statement either
return or discard, the next statement will be considered unreachable.
* Unreachable statements are no longer an error, but a warning. See
https://github.com/gpuweb/gpuweb/issues/2378.
* Statements that follow a loops that does not break, or have a
conditional will now be considered unreachable.
* Unreachable statements produced by the SPIR-V reader are now removed
using the new RemoveUnreachableStatements transform.
Some other new changes include additional validation for the continuing
block for for-loops, to match the rules of a loop continuing block.
The new cases this validation is testing for are not expressible in
WGSL, but some transforms may produce complex continuing statements that
might violate these rules. All the writers are able to decay these
complex for-loop continuing statements to regular loops.
Bug: tint:1302
Change-Id: I0d8a48c73d5d5c30a1cddf92cc3383a692a58e61
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
writer::spirv::Function attempted to append a trailing OpReturn if the
function does not end with a terminating instruction. This wasn't
considering functions that have a non-void return type.
This has now been moved to spirv::Builder::GenerateFunction(),
where we can actually examine the function return type, and generate a
zero-expression to return if we need to.
Note: this was masked by WGSL validation that required all functions to
end with a return statement.
Bug: tint:1302
Change-Id: Iddfeda25a956622c318b8235dc6fc093a2a5c26d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71604
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Just having a "error: blah" emitted without any additional context is not helpful without seeing the parsed SPIR-V as WGSL.
Change-Id: I6bf665f7fd3ce2637ec1ab020b2215f7fd5ee482
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71603
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This change implements the behavior analysis for expressions and
statements as described in:
https://www.w3.org/TR/WGSL/#behaviors
This CL makes no changes to the validation rules. This will be done as a
followup change.
Bug: tint:1302
Change-Id: If0a251a7982ea15ff5d93b54a5cc5ed03ba60608
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68408
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
The SwitchCaseBlockStatement was bound to the BlockStatement of an ast::CaseStatement, but we had nothing that mapped to the actual ast::CaseStatement.
sem::CaseStatement replaces sem::SwitchCaseBlockStatement, and has a Block() accessor, providing a superset of the old behavior.
With this, we can now easily validate the `fallthrough` rules directly, instead of scanning the switch case. This keeps the validation more tigtly coupled to the ast / sem nodes.
Change-Id: I0f22eba37bb164b9e071a6166c7a41fc1a5ac532
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71460
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Produces a direct SEM -> SEM pointer, reducing AST <-> SEM hopping.
Change-Id: I233b4c47d4e55b5f2c6e14ed08699a302b8fb64d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71321
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Adds functionality and tests for performing the multiplanar external
texture transform on texture_external parameters in user-defined
functions.
Bug: dawn:1082
Change-Id: I15f23e639a6cd24ed3428055420908f05b69c0c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Some versions of clang warn as error without this:
error: definition of implicit copy constructor for 'EnumSet<tint::ast::PipelineStage>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
Change-Id: I02cee0b1f7b70d74f29da0067e888b50acf27ee1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71600
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Add assignment operators and methods for adding, removing and operators for performing set arithmatic.
Change-Id: I13d30734354f503180f75480866b54034f647c2a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71320
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Nothing currently does the analysis to calculate these.
Change-Id: Ia2103102fbf36109f357aebf32cdfda24d6d8155
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68407
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Changing Mac version from 10.15 to 10.15|11
Also removes realms experiment, since it is no longer active and
lucicfg was emitting a warning about it.
BUG=chromium:1273569
Change-Id: I97308249c8cc21e677cbac9b34cd09aa4b471660
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71220
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Break up Resolver::Statement() into multiple resolver functions.
Move simple statement validation out to resolver_validation.cc
Change-Id: Ifa29433af0a9afa39a66ac3e4f7ca376351adfbf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71102
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This new expectation file was added with a similar parent that changed the expected output.
Bug: tint:1112
Change-Id: Icb6175f68b6459385933d39e07460eb863ecb9ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71101
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This reverts commit 401d694d03.
Reason for revert: No Mac-11 in luci.flex
Original change's description:
> Update Mac version and remove stale experiment
>
> Moving Mac version from 10.15->11
>
> Also removes realms experiment, since it is no longer active and
> lucicfg was emitting a warning about it.
>
> BUG=chromium:1273569
>
> Change-Id: Ib0962a1330985da82336ea93cc9014c2439b452b
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71020
> Auto-Submit: Ryan Harrison <rharrison@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
TBR=cwallez@chromium.org,rharrison@chromium.org,bclayton@google.com,noreply+kokoro@google.com,tint-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I66d3d1dbed04ecee2ebf8566e3eb126977728a1a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1273569
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Now that I've landed this change to Dawn to disable FXC optimizations:
https://dawn-review.googlesource.com/c/dawn/+/70700,, we can reland this
change. The Tint-into-Dawn roll was failing because FXC would miscompile
certain loops into infinite loops when not unrolled.
Also reland
test/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.hlsl
Bug: tint:1112
Bug: dawn:1203
Change-Id: I641d68864b833e0fbe3b117d397b89ae96482536
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
If we encounter a global twice, the stack vector was not popped, which could trigger false cyclic-dependency errors. Because the cyclic dependency did not actually exist, later logic could break, expecting to find a global->global edge which did not exist.
Fixed: chromium:1273451
Change-Id: I9d99f1aeeaea042d9ed847a878c4717803122240
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70980
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
It's surprising that the fuzzers didn't find this, but I've confirmed that at least one of the fuzzers will fail with this case.
By adding a e2e test case, this will be used as a seed for the fuzzer corpus.
Bug: tint:1321
Change-Id: Ibf4bfa50bf376ae4cba401dfc31a2498fa3b9eec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70982
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Moving Mac version from 10.15->11
Also removes realms experiment, since it is no longer active and
lucicfg was emitting a warning about it.
BUG=chromium:1273569
Change-Id: Ib0962a1330985da82336ea93cc9014c2439b452b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71020
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
RemovePhonies was transforming:
_ = f32(1)
_ = vec2<f32>(1.0, 2.0)
into:
f32(1)
vec2<f32>(1.0, 2.0)
Which the resolver gets grumpy about, as these are expressions, not statements.
Fixed: chromium:1273230
Change-Id: Ie85d3cee705fa3f792db686c021d76331e241f17
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70960
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Accidental commit of my test file for checking tint behavior.
Add to the .gitignore file so I don't accidentally check this in again.
Change-Id: Ie67f04cc307fa180d3a65d867a1777d008be8e17
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70981
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
The default implementation of this was generating random data for
the underlying pointers of std::unordered_map, leading to crashes
when the map was accessed. This CL populates the map in a
structured manner with pseudo-random data.
Bug: chromium:1273001
Change-Id: Ic20ecab85bedba2a59587ebe4a5016be6e53e6f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70701
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
BUG=tint:1019
Change-Id: Ia462080877a97348c5589bfa71231a832a7ebfd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70081
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
If the HLSL sanitizer errors, then there may be no ArrayLengthFromUniform::Result, so we check the pointer before attempting to dereference it.
Bug: chromium:1273230
Change-Id: I9575d20748720623a94ac86f45da14302b20440a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70740
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Add transform::Unshadow to renamed shadowed symbols. Required by a
number of other transforms.
Replace Resolver symbol resolution with dep-graph.
The dependency graph now performs full symbol resolution before the
regular resolver pass.
Make use of this instead of duplicating the effort.
Simplfies code, and actually performs variable shadowing consistently.
Fixed: tint:819
Bug: tint:1266
Change-Id: I595d1812aebe1d79d2d32e724ff90de36e74cf4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70523
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
They are always used together, and can actually be simplified when
combined.
This transform cannot currently deal with shadowing, and will need
need to depend on a new 'unshadow' transform.
Fixes a long-standing bug where we'd get an ICE if we attempt to inline
a pointer let declaration with side-effects in a for-loop initializer.
Fixed: tint:1321
Bug: tint:819
Change-Id: I236fed688e33a4996e47310b5ece44c991b5249f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70661
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
The error message has recently changed, and is causing rolls to fail.
I don't see any reason why we're testing SPIR-V val here. Just remove the test.
Bug: tint:912
Change-Id: Ia24f81a8cc86edafe893493279f7aaa73f1d746a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70666
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
These have all been removed from the spec as we cannot guarantee they will behave as expected on the various backends.
Bug: tint:1312
Change-Id: I9d7d81cfdc44489fffe08c5183ed8da84901a024
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70665
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Looks like this should have been part of bc5d8f6b
Bug: tint:1112
Change-Id: I62e98bbb5f8ca29a171d5d5baa65af55b3a090d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70664
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>