Commit Graph

3002 Commits

Author SHA1 Message Date
Ben Clayton 8085671ed2 test: Add missing cases for UBO dynamic loads
Looks like a typo in the test cases I wrote.

Change-Id: Ieb4d8ce28827e47ab0baef7b1178395d97f90ace
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69841
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-17 14:54:07 +00:00
Brandon Jones bf7ec8f70b Add MultiplanarExternalTextureTransform and Tests
Implements MultiplanarExternalTextureTransform to allow transforming a
texture_external binding into two texture_2d<f32> bindings and a uniform
buffer binding. Transforms textureSampleLevel and textureLoad calls with
a texture_external parameter into custom functions that can handle both
single-plane RGBA or bi-planar YUV. Includes tests.

Bug: dawn:1082
Change-Id: Icb6d8b0f3773feca01c833171f07230c3531f3aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68620
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-11-17 12:10:16 +00:00
Stephen White ae4487f3f9 GLSL: rename all identifiers prefixed with gl_.
In GLSL, all identifiers beginning with gl_ are reserved (not just those
explicitly named in the spec), and so any found in WGSL must be renamed.

Bug: tint:1304
Change-Id: I92ed7ec674620f67775378ecb8debcfdb4b5bbb4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69701
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-16 19:13:36 +00:00
shrekshao 4b6eb0c6e3 Remove unreferenced variables in SingleEntryPoint Transform
For overridable constants without explicit ID, replace the
decoration with explicit ID to avoid ID changes impacted by stripped
away variables.

Bug: tint:1155, dawn:1137
Change-Id: I7d76c08952cfa870403ee2653411b2b6ee2af7b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69500
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-11-16 18:33:07 +00:00
Stephen White b9170c65fc GLSL: fix vector relational ops.
In GLSL, relational operators are only valid for scalar operands. For
vector operands, lessThan, greaterThan, etc must be used.

Bug: tint:1303

Change-Id: Ia800f89111630c756dc1b30ef0c6858fb520fb16
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69561
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-11-16 16:16:56 +00:00
Vadim Shtayura 90eb5aa292 Declare "role/configs.validator" binding.
It defines who is allowed to call LUCI Config validation API to
validate this LUCI project's configs. This is usually done by
presubmit jobs, and thus configs.validator role is assigned to
try job task accounts.

Previously this ACL was defined in the global "config-validation"
group. It is deprecated and being replaced with per-project ACLs
defined in per-project configs (like in this CL).

There's still a global ACL to allow any googler to call
the validation API in any LUCI project they are allowed to see.
Thus the per-project binding applies only to service accounts
(they are not googlers).

Note: this CL was generated semi-automatically and reviewers are
picked automatically based on OWNERS file.

BUG=chromium:1068817

Change-Id: Iec55d5e4ea7325406a1f3dd1f9fef598ec5ad29a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69181
Auto-Submit: Vadim Shtayura <vadimsh@google.com>
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-11-16 15:17:12 +00:00
Stephen White 2fe0f4b42b GLSL: add .expected.glsl files for all tests.
Bug: tint:1301
Change-Id: Id3a591a2fa0dfdb112046d5c57defbae07483e0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69480
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-16 15:15:36 +00:00
Antonio Maiorano 2551458aef fix-tests: fix when gtest outputs absolute source paths
Since CMake 3.21, the Ninja generator now outputs absolute paths to
source files, rather than relative. These paths are what __FILE__ gets
mapped to during compilation, and is what gtest outputs for test
failures. This broke fix-tests, which assumed a build-relative source
path. This change detects when the source file path is absolute, and
converts it to a build-relative one.

Also, on Windows, absolute paths include the drive with a colon
character, so I added matching the colon to the regex for the path
portion.

Change-Id: I065161d65f098023376b7e479d8a24a83beb1df7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69440
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-16 15:09:56 +00:00
Ben Clayton 04e62a12d8 reader/wgsl: Remove type tracking from the parser
This is the responsibility of the resolver, not the parser.
Required to handle out-of-order declarations.

Fixed: tint:888
Bug: tint:1266
Change-Id: I0cbdbe7f721a88bba89c0394a72a20e20b600000
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69106
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-15 20:45:50 +00:00
Ben Clayton 8492d727a7 test: Shuffle files around.
In an attempt to better follow the guidelines in docs/end-to-end-tests.md.

Change-Id: Id012004e8a376598bb69cf364ca7ca0735632a2e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69342
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-15 20:45:50 +00:00
Ben Clayton 735dca8393 ast: Remove TypeConstructorExpression
Add a new 'Target' to the ast::CallExpression, which can be either an
Identifier or Type. The Identifier may resolve to a Type, if the Type is
a structure or alias.

The Resolver now resolves the CallExpression target to one of the
following sem::CallTargets:
* sem::Function
* sem::Intrinsic
* sem::TypeConstructor
* sem::TypeCast

This change will allow us to remove the type tracking logic from the WGSL
parser, which is required for out-of-order module scope declarations.

Bug: tint:888
Bug: tint:1266
Change-Id: I696f117115a50981fd5c102a0d7764641bb755dd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68525
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-15 20:45:50 +00:00
David Neto d12f48828b wgsl-reader: give better diagnostic for bad token at end of input
Change-Id: I332229fc4ad3ffef4d75c8e9a7d83a06a2c034dd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69360
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-11-15 20:31:44 +00:00
Stephen White bf209ffc9d GLSL: implement texture sample and store functions.
Change all the texture types to the GLSL equivalents. Note that some
types don't actually exist in GLSL ES, e.g., 1D textures, but this
will be handled later.

Change all the texture functions from HLSL-style to GLSL (e.g.,
texture.Sample(...) -> texture(texture, ...). Note that depth
comparison functions are probably wrong.

Implement writeonly storage texture type and functions.

Samplers are skipped entirely in the GLSL backend, with the assumption
that they will already have been combined into GLSL-style combined
samplers and textures by the client code.

Move the SingleEntryPoint transform above the RemovePhonies pass. This
ensures that texture variables are not optimized out. (Otherwise some
tests produce valid but not very useful results.)

Add the builtin-functions to the GLSL keywords list for renaming.
They're not keywords, but they can't be identifiers either.

Bug: tint:1298, tint:1299

Change-Id: I86c4547fcdd1eba80be98f6c05b939f345fd4c3e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69200
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-11-15 18:01:54 +00:00
Stephen White 6d643deefa GLSL: fix "mix" intrinsic.
GLSL's mix is "mix", not "lerp".

Bug: tint:1297
Change-Id: Ie1894d28a35385511fcb5e3474856af82a6cc763
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69281
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-15 13:35:48 +00:00
Stephen White e1761d5852 GLSL: fix Position built-in variable.
Position maps to gl_Position in vertex shaders, and gl_FragCoord in
fragment shaders.

Bug: tint:1296
Change-Id: I22069af2c82bb03521f2721d16c29ba98c85f3f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69280
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-15 13:33:58 +00:00
Ben Clayton 4cfa725fb3 Use ProgramBuilder::Construct() where possible
Replace all calls to create<ast::TypeConstructorExpression>() with
Construct(). TypeConstructorExpression will be folded into
ast::CallExpression, but the Construct() call signature will remain
identical.

Bug: tint:888
Change-Id: Ifb28a90ccf5184c8090c2e32fa8c82f3996dfa33
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69108
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-12 13:53:49 +00:00
Ben Clayton 5a40c6564c sem: Add new TypeConstructor and TypeCast CallTargets
Nothing yet creates or uses these.

Also add Constant to sem::Call.
These will be needed for TypeConstructors / TypeCasts.

Bug: tint:888
Change-Id: I5b8c64062f3262bdffd210bb012db980c5610b26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69107
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-12 13:53:49 +00:00
Ben Clayton 2194a842ba ProgramBuilder: Remove Literal() helpers
Now that all LiteralExpressions derive from Expression, and Expr()
already handles literals, there's no reason to have this duplicated
functionality.

Bug: tint:888
Change-Id: I677b04a3cc325311ef25f6b9983fee7548e830f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69105
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-12 13:53:49 +00:00
Ben Clayton 9de93ca105 ProgramBuilder: Don't wrap call-exprs with a call-stmts
ast::CallExpression will soon encompase function & intrinsic calls,
along with type-constructors and type-casts. The latter two cannot be
wrapped with a CallStatement, so change
ProgramBuilder::WrapInStatement() to always assign the expression to a
temporary.

Fix the few places that actually relied on this behavior to use
CallStmt() explicitly.

Bug: tint:888
Change-Id: I48b8a2be73128df9cd2b4bdcc00ae81c4a872359
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69104
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-12 13:20:46 +00:00
Ben Clayton a539d8d33c utils: Add utils::Transform
An element-wise vector transformation utility function.
Similar to JS/TS's map() method on arrays.

Change-Id: I4baf52daa918f2e7bf5f9b4af13894fe66826f7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69103
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-12 13:04:06 +00:00
Ben Clayton e7a94965c1 BUILD.gn: Fix gn check error
The 'tint_unittests_src' source_set needed to depend on gmock_and_gtest,
which is normally done with the 'tint_unittests_source_set' template,
but this is the root source_set for the unit tests.
To fix, these root-level sources have been moved to
'tint_unittests_core_src' which uses the 'tint_unittests_source_set'
template.

Change-Id: I0d76c55c744646fd7deff22406a668f8c6cdf519
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69220
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2021-11-12 11:33:17 +00:00
Ben Clayton 6cdb1bf7c0 resolver: Fix constant propagation for POC
Pipeline overidable constants are not compile-time constant.
If a module-scope const has an [[override]] decoration, do not assign
the constant value to it, as this will propagate, and the constant value
may become inlined in places that should be overridable.

Also: Rename sem::GlobalVariable::IsPipelineConstant() to
IsOverridable() to make it clearer that this is not a compile-time known
value. Add SetIsOverridable() so we can correctly set the
IsOverridable() flag even when there isn't an ID.

Change-Id: I5ede9dd180d5ff1696b3868ea4313fc28f93af4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69140
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-11-11 19:12:36 +00:00
Ben Clayton 3fe243b282 BUILD.gn: Split up unit tests into separate source sets
Prevents errors when we have the same _test.cc file in two different
directories.

Change-Id: I62eaea9452762670b7a24cdb2d7b0bef4fe52280
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69102
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-11 16:23:55 +00:00
Ben Clayton 1a8171c08b traits: Add SignatureOf helper
This a more powerful version of the ParamType class.
It provide all the same information as before, plus function return type
and number of parameters.

Change-Id: If03feed0c1b94434fa95340b6b6277621b4f81b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69100
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-11 16:07:12 +00:00
Ben Clayton 5c9a80b6f6 ast: Add 'Expression' suffix to literals (2/2)
Literals are now expressions, so in keeping with all the other
expression types, suffix the class name with Expression.

I'm not overly keen on requiring everything to have an Expression
suffix, but consistency is better than personal preference.

Note: this should have been part of 30848b6, but I managed to drop
this change instead of squashing it. Opps.

Bug: tint:888
Change-Id: Idfaf96abe165a6bf5028e60a160e7408aa2bf9db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68943
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-10 19:23:07 +00:00
Ben Clayton 6595b386b5 ast: Rename 'array accessor' to 'index accessor'
This cleans up the remnants of ArrayAccessorExpression which was renamed
in a838bb718.

Change-Id: Ie2c67a49e63774d8b153ec17c3185652708a91e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68942
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-10 19:23:07 +00:00
Antonio Maiorano 8bc1a3045d HLSL: workaround FXC sometimes failing with 'not all control paths return a result' in functions with discard
To fix this, we trick the compiler by wrapping the function body with an
if (true) { <function body> } followed by returning an unused value of
the return type.

Bug: tint:1081
Change-Id: I763bf768f40d07a1045f0a70017bb40d488c8428
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68822
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-10 14:38:34 +00:00
Antonio Maiorano bb1a9930c1 test-runner: don't generate for excluded paths on Windows
Script would erroneously generate for files in excluded paths because of
slash differences.

Also make the output display the path to the MSL and HLSL executable
being used.

Change-Id: I0bf55dd461c96b7b910f7a9aa9756ab2006c2a33
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68821
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-10 14:34:55 +00:00
James Price ae4b3ffe6b spirv-reader: Add interpolate(flat) to integral pipeline IO
This is now required in WGSL, and will soon become an error in Tint.

Bug: tint:1224
Change-Id: Ide98c4c0b7aac86a2b43f7e02abde3d8a297dce4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-11-09 17:35:34 +00:00
Ben Clayton 72b6bb94c2 ast: Remove ConstructorExpression
ConstructorExpression is abstract, and now only has a single class deriving
from it - TypeConstructorExpression. Just use that instead.

Bug: tint:888
Change-Id: I7ee52ad645bcd8a8a68710c63a1fdf834b5b2a24
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68842
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-09 09:35:00 +00:00
Ben Clayton a838bb718b ast: Rename ArrayAccessorExpression to IndexAccessorExpression
The object is not always an array. The index can be applied to vectors
too.

Change-Id: Ifb63d1862090d28cb48d692870e9dd01ddbce5df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68841
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-09 09:35:00 +00:00
Ben Clayton 30848b6594 ast: Add 'Expression' suffix to literals
Literals are now expressions, so in keeping with all the other
expression types, suffix the class name with Expression.

I'm not overly keen on requiring everything to have an Expression
suffix, but consistency is better than personal preference.

Bug: tint:888
Change-Id: Ida1f1b98c71d5d0fe6399bca938010cd5d3a00c3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-09 09:35:00 +00:00
Ben Clayton 575c4efe2f Remove ScalarConstructorExpression
Just make Literal an expression. The ScalarConstructorExpression
provides no real value, aside from having a ConstructorExpression base
class that's common between ScalarConstructorExpression and
TypeConstructorExpression. TypeConstructorExpression will be folded into
CallExpression, so this hierarchy will serve no purpose.

First step in resolving the parser ambiguity of type-constructors vs
type-casts vs function calls.

Bug: tint:888
Change-Id: I2585d5ddbf6c0619a8f24c503e61ebf27c182ebe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68524
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-09 09:35:00 +00:00
Antonio Maiorano f3f8ec3845 Update test expectation files
Some pass DXC, but not FXC (e.g. continue_in_switch).
Some now pass (e.g intrinsics/gen/atan2/*.hlsl)
Some now fail gracefully instead of asserting (e.g. 807.spv)

Change-Id: I92b17fcadc7850de5bd93ff07507cea7e5487fc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68820
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-08 20:16:48 +00:00
Ben Clayton 11ab43ddb9 docs: Add a doc about end-to-end testing
Change-Id: I65bd3ac1b21bd67cdd854e36f38769a824f442db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68523
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-11-05 22:47:16 +00:00
Ben Clayton e9c6a64147 test-runner: Add support for GLSL
This is not included in the default for 'filter' as it is far from ready.
Also: Don't generate SKIPs in the excluded directories.

Change-Id: I02cb40c1bf8adebc77e9e5102988dd41e4b1f7a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68522
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-05 22:45:23 +00:00
Ben Clayton 51aed1c732 main: Return non-zero status code on GLSL validation error
Change-Id: I55b49cec665947fb735037f762ae8692d990c24d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68521
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-11-05 22:45:23 +00:00
Antonio Maiorano 02acf59184 HLSL backend: work around FXC ignoring switch with only default case
In HLSL code, if a switch statement has only a default case, FXC will
effectively ignore the code in that case. In this change, we detect this
and work around it by emitting the code in the default block without the
switch.

Bug: tint:1188
Change-Id: I69b405cdb4c669fb093eb49aa138923419dcf8f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68440
Kokoro: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-11-05 20:39:07 +00:00
Ben Clayton 189dc7d3fd instrinsics: Implement dot() for integer vector types
Fixed: tint:1263
Change-Id: I642ea0b6c9be7f04930cf6ea1a8059825661e326
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68520
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-11-05 18:37:16 +00:00
Ben Clayton a9156ff091 Rework Resolver so that we construct semantic types in a single pass.
The semantic nodes cannot be fully immutable, as they contain cyclic
references. Remove Resolver::CreateSemanticNodes(), and instead
construct and mutate the semantic nodes in the single traversal pass.

Give up on trying to maintain the 'authored' type names (aliased names).
These are a nightmare to maintain, and provided limited use.

Significantly simplfies the Resolver, and allows us to generate more
semantic to semantic references, reducing sem -> ast -> sem hops.

Note: This change introduces constant value propagation across constant
variables. This is unlocked by the earlier construction of the
sem::Variable.

Change-Id: I592092fdc47fe24d30e512952511c9ab7c16d7a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68406
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-05 16:51:38 +00:00
Ben Clayton 2423df3e04 sem: Rename Function methods
Explicitly name references as either Direct or Transitive.
Rename workgroup_size() to WorkgroupSize().
Remove the return_statements. These were not used anywhere.

Change-Id: I7191665db9c3211d086dd90939abec7003cd7be7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68405
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-04 22:29:22 +00:00
Ben Clayton cc26a4166d utils: Add index operators to UniqueVector
And put it into the utils namespace.

Change-Id: Ib4c6fadc63954196d572148d0e96ffec6e3bbb38
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68404
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-04 22:29:22 +00:00
Ben Clayton 89d8b2b7a5 Clean up the ScopeStack interface
There's no need for the ScopeStack to include 'global' information. This
is easily obtainable from the element type.
Replace the get-by-reference, with a simpler return value.

Change-Id: Ic6f4c0f656a2019417d68ffb3fe85ba8343ad15e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68403
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-11-04 22:29:22 +00:00
Ben Clayton 307eff0da4 utils: Add more functionality to EnumSet
Add equality operators for EnumSet <-> Enum.
Add unidirectional iterator.
Add ostream support.

Change-Id: I8ea9e905bf17e618c6b12004200d37f65ccfb68c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68402
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-04 22:29:22 +00:00
James Price 85170d76bc Disallow taking the address of a vector component
Update or remove tests that try to do this.

Fixed: tint:491
Change-Id: I1f351a4abf68ae9bc6b100885fb1bcea08b31211
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68242
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-11-04 19:55:57 +00:00
James Price def9d97609 spirv-reader: Sink pointer-to-vector-component
WGSL does not support pointer-to-vector-component, so the SPIR-V
reader needs to sink these pointers into their use.

Bug: tint:491
Change-Id: Ib5ae87d2f6bbac13280314ba11369d7ced505b56
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68241
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-11-04 19:55:57 +00:00
Ben Clayton e7323f1a36 Cleanup intrinsic table tests
These were using `[EXPECT|ASSERT]_THAT` when they could be using `[EXPECT|ASSERT]_EQ`

Change-Id: Id967571ed121b5805f15b16d263c03c716296e1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68401
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-11-04 19:36:25 +00:00
Stephen White c5aab619f3 GLSL: implement bitcast operators.
Bug: tint:1265
Change-Id: I6768bde2be8da7281c9516528485e49f6c7c0460
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68380
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-04 17:40:15 +00:00
James Price e0e45a4d47 Remove --dump-ast from help text and README
This flag was previously removed.

Change-Id: I8b6ed8dd8966fcf7b587a65e78dcc06c2b2a9cd2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68240
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>
2021-11-03 16:43:05 +00:00
Stephen White e9216ce595 GLSL: emit [] for runtime-sized arrays, not [0].
Bug: tint:1262
Change-Id: Ic58729f075353f957c5d974c742b531e1e2cf518
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-01 19:23:46 +00:00