Commit Graph

1904 Commits

Author SHA1 Message Date
Ben Clayton a965ad4d3a src/writer: Split UnaryOp TEST_P into TEST_Fs
Once the resolver correctly handles address-of and indirections,
the logic around these will be different enough that a parameterized
test no longer makes sense.

Bug: tint:727
Change-Id: I79c138b12bd6f49d9dbee02c62e594a9b1b4a2db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51185
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-17 15:52:57 +00:00
Ben Clayton fe0910fa37 ProgramBuilder: New helpers,change WrapInStatement
Add AddressOf() and Deref()
Add overloads of Expr() that take a source
Change WrapInStatement() to create a `let`. Unlike `var`, `let` can be
used to hold pointers.

Bug: tint:727
Change-Id: Ib2cd7ab7a7056862e064943dea04387f7e466212
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51183
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-17 15:51:47 +00:00
Ben Clayton bcd909efa4 reader/spirv: Add bool operator to TypedExpression
Use this to check that type and expr are both not nullptr.

Cleans up the random mix of checking `expr`, `type` or both.

Change-Id: I84eb4a16e0dc22e18d6868f62c0314effe9858a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51184
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-17 15:00:17 +00:00
Ben Clayton c88fbe0fb2 reader/spirv: Add Reference type
Currently unused, but will be soon.

Also add String() methods on all the types ifndef DEBUG.
Again unused, but these are helpful for debugging type related bugs.

Bug: tint:727
Change-Id: I7598fd7f68f4819ef4b60dbfc08322fd004d9152
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51180
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-17 14:56:27 +00:00
Ben Clayton 85bdf1753e ast: Rename UnaryOp::kDereference to kIndirection
This is what it is (currently) called in the spec

Bug: tint:727
Change-Id: Ie24f42499ed20c0c45ef4e9474bc6bb6a19bfa36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51181
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-17 14:48:37 +00:00
Alastair F. Donaldson ac90829e1c Create a semantic class for block statements
Semantic information about block statements the resolver would
temporarily create while resolving is now exposed in a
sem::BlockStatement class.

In the process, semantic information about statements in general is
overhauled so that a statement has a reference to its parent
statement, regardless of whether this is a block.

Bug: tint:799
Bug: tint:800
Change-Id: I8771511c5274ea74741b8c86f0f55cbc39810888
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50904
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-15 14:48:46 +00:00
James Price 43f50eaf86 validator: Validate attributes on non-entry point functions
Also validate that workgroup_size is only applied to compute stages,
and not duplicated.

Fixed: tint:703
Change-Id: I02f4ddea305cad25ee0a99e13dc9e7fd1d5dc3ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51120
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-05-14 20:41:03 +00:00
Ben Clayton e9f5f63ea0 Resolver: Fix UB with nullptr method calls
Change-Id: Iaa098d7851ffaf01aac384fe623c94809948fe2e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51182
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-14 20:05:43 +00:00
James Price 72f6ba4efe Fix Kokoro build
Change-Id: I6f6f643c4f793e0af846a581f37576bca2caea9d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51140
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-14 19:46:53 +00:00
Antonio Maiorano dc4e6c1844 Remove sem::AccessControl
In preparation for implementing
https://github.com/gpuweb/gpuweb/issues/1604, this change removes the
sem::AccessControl node. Instead, the ast::AccessControl::Access enum is
now on the sem::StorageTexture class, as well as on sem::Variable. For
sem::Variable, the field is set when the variable's type is either a
storage buffer or a storage texture.

Bug: tint:802
Change-Id: Id479af36b401d067b015027923f4e715f5f69f25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51020
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-14 17:51:13 +00:00
David Neto fdf56c325d spirv-reader: support OpCopyMemory
Bug: tint:3
Change-Id: I779593c379b1f24cb805b69e788c467e64af6db3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51041
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-14 15:24:23 +00:00
James Price a2d6793efa Remove ast::Variable::constant_id()
The backends now use sem::Variable::ConstantId() instead, since the
AST does not have the correct ID when the parameterless version of the
override attribute is used.

Change-Id: I816295c8b2e4baa1671c9d042920bf001b1b4336
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50845
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-05-14 12:26:33 +00:00
David Neto 81759d0009 spirv-reader: add test for bad continue-block from single-block loop
Prove this error is caught by SPIR-V validation.
This requires a recent version of SPIRV-Tools.

Fixed: tint:793
Change-Id: I30977de7c4d1c291ab9ea13df80189426a842521
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51040
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-14 12:26:03 +00:00
James Price df8b2783a4 reader/wgsl: Add support for [[override]]
The Resolver, Inspector, and backends already handle this form of the
attribute correctly, so this is straightforward.

Fixed: tint:755
Change-Id: I8c394f1e58d64827d8a53b81402e30a472ca5441
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50844
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-05-14 11:48:03 +00:00
James Price 2edb8d4064 inspector: Expose map of names to constant IDs
This will be needed by Dawn to handle overriding pipeline constants by
name in the API.

Bug: tint:755
Change-Id: I857d8ef086b1964dac8d5cfff5c78d794234e8a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50843
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-05-13 23:35:42 +00:00
James Price 60ade8939a writer/wgsl: Fix build
Generator::Generate() no longer takes an argument.

Change-Id: Ibee65ffd6672fb1507aec33c7690c5b05ce51fac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50960
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-05-13 23:01:12 +00:00
James Price 26e0312de2 writer: Use semantic info for constant IDs
This enables the backends to emit overridable constants that had no ID
specified in the attribute.

Bug: tint:755
Change-Id: I86587205e065715257f546b546e792a5262562e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50842
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-13 21:35:42 +00:00
James Price f2f3bfc677 resolver: Allocate IDs for named pipeline constants
Keep track of any constant IDs specified in the shader, and then
allocate IDs for the remaining constants when creating the semantic
info.

Bug: tint:755
Change-Id: I6a76b1193cac459b62582cde7469b092dde51d5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50841
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-13 20:32:32 +00:00
James Price 8650247ddb ast: Support override decorations without IDs
Bug: tint:755
Change-Id: I33f6535b4f3f03826d6f4dd531dc6967f476402b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50840
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-05-13 20:11:22 +00:00
Ben Clayton 09587e1d86 reader/wgsl: Parse '&' and '*'
Bug: tint:727
Change-Id: I1a2c93017b934fd0884570412f5ed25bf15991bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50820
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-13 16:56:32 +00:00
Ben Clayton 52b06fb4c5 ast: Add address-of and dereference unary ops
Nothing currently generates these.
Resolver currently doesn't know how to handle these.
Backends currently stubbed enough to build without warnings.

Bug: tint:727
Change-Id: I4b9863ae098b903b51a63c36c10bc6e390efbbb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50746
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-13 13:36:32 +00:00
Ben Clayton 688fe4477d writer/wgsl: Cut dependencies on sem info
There's now one remainin use of the semantic info in the WGSL writer - the transformation of [[offset]] into padded fields.
This does not belong in the WGSL writer, but instead part of the transform::Wgsl sanitizer.

Bug: tint:798
Change-Id: I95ba11f022c41150cc12de84a4085cd7d42019fe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50822
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-13 12:38:12 +00:00
David Neto 9b1ee6bdea spirv-reader: HLSL-IO: Emit entry point as wrapper
Bug: tint:508
Change-Id: I68fa85726c5223b020a323a3d65b062133e96232
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49120
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-12 21:09:41 +00:00
Ben Clayton f6c84e4d45 Use StorageClass::kNone for ast local var decls
To declare a local variable, we write `var name : type`, not `var<function> name : type`.
This change fixes all the places where we were feeding StorageClass::kFunction into variable declarations.

Note that the resolved, semantic variable correctly infers the `kFunction` StorageClass.

Change-Id: I6221fabae1de0435044f29b9a91808421d5cace6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50821
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-12 21:08:22 +00:00
David Neto 884a4e2172 spirv-reader: Refactor decoration-getting for vars
Bug: tint:508
Change-Id: Ib176eb5e0dfdd6901635a9dd627aa9c7316f0a80
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49301
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-12 17:02:51 +00:00
David Neto 858d7a33f1 spirv-reader: valid SPIR-V in function_var tests
Bug: tint:765
Change-Id: Iab3eb6f612150153abfcd87a702c9a24ee5cf66a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50605
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-12 14:35:51 +00:00
Ben Clayton 3103a1f666 BindingRemapper: Allow for binding point collisions
Add a new parameter to BindingRemapper::Remappings that allows resulting binding points to collide.

When enabled, the output of the transform contains two or more module-scoped variables with the same binding point, used by the same entry point, then these variables will be decorated with an internal decoration to disable validation for the collision.

This is to work around collisions generated for the HLSL backend where the variables actually exist in different register classes, which is permitted by D3D12.

The transform will only generate these decorations if it needs to.

Fixed: tint:797
Change-Id: Id8a87523801bd0cd0dd54227ebabd4299bc20c27
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50742
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-12 13:30:51 +00:00
Ben Clayton 451f2cc68a Add ast::DisableValidationDecoration
An [[internal]] decoration that specifically disables certain validation checks.
Begin with a single kFunctionHasNoBody mode.
Migrate the Resolver to using this instead of allowing any InternalDecoration to disable the checks for no-body.

Bug: tint:797
Change-Id: I213b9a6844a456775ede06d60e456d9f77a449d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50741
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-12 12:54:21 +00:00
Ben Clayton ad393296d5 Fix all linter warnings
Change-Id: Ic55036ea8fee583ffe81fb6345ec3870d368302d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50745
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-12 11:33:51 +00:00
Ben Clayton 5df7661659 Resolver: Move common logic into Variable()
Variable() is called for globals, locals and parameters. Much of the logic is the same.

Move all the common logic down into Variable(). This:
* Removes some yucky default parameters
* Adds type validation that was missing for globals (broken tests fixed)
* Gives me a single place to implement the Reference type wrapping

Bug: tint:727
Change-Id: I70f4a3603d7fa781da938508aa2a1bc80ec15d77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50580
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-12 10:41:21 +00:00
Brandon Jones ecd31c5ee6 Remove texture_external overload for textureSample and add textureSampleLevel
Removes the texture_external overload for textureSample and replaces it
with a texture_external overload of textureSampleLevel to match merged
spec. Adds a transform that adds the implicit level parameter to
textureSampleLevel. Modifies unit tests to reflect change.

Bug: dawn:728
Change-Id: I2dbc9232b4343db1075be79fda0054231860f3b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50701
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-12 10:37:03 +00:00
James Price 42f8999af5 writer/wgsl: Ensure that test programs are valid
Make all test programs valid.

Change-Id: Id7eb790519e3dec30a5b826f06585d277995b9b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50720
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-05-12 10:06:21 +00:00
David Neto 6344d4c2f5 spirv-reader: Substitute 1.0 for scalar normalize
WGSL only has vector normalize, not scalar.
Scalar normalize is always 1.0, so return that directly.

Bug: tint:765
Change-Id: I08332c20922f5834f65284b9aaeb22995423171d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50603
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-12 04:35:01 +00:00
David Neto 32b5018c5d spirv-reader: Don't mention handle storage class
Emit AST equivalent to:

  var foo: sampler;

instead of

  var<handle> foo: sampler;

This is necessary to pass new checks in the resolver.

Change-Id: I5eca30ace5871086bc3c1783cde2225f1aee34ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50602
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-12 01:14:01 +00:00
David Neto facd33199a spirv-reader: textureDimensions returns 3-elem vec for Cube,CubeArray
Fixed: tint:787
Bug: tint:765
Change-Id: If5cebb21bf169765f3baf8a5aec4a3dace19d707
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-05-11 23:16:31 +00:00
David Neto b5236b2783 Fix linter complaint
But I liked the comment where it was.
I think the linter was wrong, but it doesn't like my argument.

Change-Id: Ie3bb6e2b4bd08fae6d72a076622b1e74f517f23c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50680
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-11 18:32:52 +00:00
Antonio Maiorano ce0b1c1c88 Fix test: "matrix scalar element type must be f32"
Bug found when passing program through spirv writer and then reader.
This failed in the writer.

Bug: tint:792
Change-Id: I512798240710fd262da81a73d6646deb975ac5e9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50563
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-11 14:26:40 +00:00
James Price 77daee15bd Remove legacy EmitVertexPointSize transform
This has been moved into the Spirv sanitizer, and Dawn is now using
this path.

Change-Id: Iffcbbc1c84e6bad0ebc51ded82d998bb307e2d6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50564
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-11 13:16:10 +00:00
Antonio Maiorano fe7f7b33fb Fix test: "No OpEntryPoint instruction was found"
Bug found when passing program through spirv writer and then reader.

Bug: tint:792
Change-Id: I2acb17554b122c840cf3cc69149f6e004fb37bc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50562
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-11 13:11:30 +00:00
Brandon Jones 97a7d266e0 Transform textureLoad calls for texture_external
Adds a transform that adds an additional 'level' parameter to textureLoad calls
when used with a texture_external. Adds a test for the textureLoad
transform. Additionally adds a test for calls to textureDimensions with
a texture_external.

Bug: dawn:728
Change-Id: I613ce8185e9a4c49529fd8e48323e586c95dde04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50420
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-11 10:35:43 +00:00
David Neto 5a839b5818 spirv-reader: handle tests, valid SPIR-V, part 5
Bug: tint:765
Change-Id: I77772e8105da9d52baa996919a39dc7a85dbedcd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50460
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-11 04:31:53 +00:00
David Neto 2e80c83d7b spirv-reader: handle tests SPIR-V validity, part 4
Bug: tint:765
Change-Id: I6c25ed2c9d40d686e75517815b9d31d544d913ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50424
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-11 03:43:43 +00:00
David Neto b7b30b7598 spirv-reader: fix texel type for textureStore
Fixed: tint:381
Change-Id: I7521bac842b59c16c596e1cea39a14700a9e7f9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50449
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-11 02:15:23 +00:00
David Neto 3dcf2398b7 spirv-reader: handle tests SPIR-V validity, part 3
Bug: tint:765
Change-Id: I22a4851218a3dbcc95d17334e6c6ff41393c7016
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50448
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-11 01:47:43 +00:00
David Neto cc1e9e04fd spirv-reader: fix Grad-based tests
Bug: tint:765
Change-Id: I5512553a27e8f3f8d00b72c5039fb489450e3874
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50447
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-11 00:39:03 +00:00
David Neto 36eba06811 spirv-reader: remove multisampled_2d_array support
The only multisampled texture type supported by WGSL is
texture_multisampled_2d

Fixed: tint:780
Change-Id: Ie968311c802f858d087a411cda8f336627ad657b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50446
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-10 23:20:23 +00:00
David Neto 716299075a spirv-reader: handle tests: make valid SPIR-V, part 2
Bug: tint:765
Change-Id: Ide499367637c460ebc1083da1de90b47ece21280
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50445
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-10 22:21:43 +00:00
David Neto 65a60c5c31 spirv-reader: handle test: make valid SPIR-V, part 1
Bug: tint:765
Change-Id: Ie203b6ee6ec481e9ff87421969723e2f4e77d9aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50444
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-10 21:26:06 +00:00
Antonio Maiorano f25ad24d1b Fix test: "unknown case statement" from spirv reader
Bug found when passing program through spirv writer and then reader.

Bug: tint:792
Change-Id: I904b959ba1d540b4377f8b9027286182ee0c34e9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50561
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-10 21:11:36 +00:00
David Neto 1959cdec99 spirv-reader: rename test class for handle tests
Bug: tint:765
Change-Id: I8eb5eb40d2014c770a90f0ec74fed19f8203ece3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50443
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-10 20:57:06 +00:00
Antonio Maiorano e0448d3d64 ProgramBuilder: make Const helpers require a constructor arg
This was originally used to find and fix tests that were not
initializing constants, but these were independently fixed by jrprice@
recently (see https://dawn-review.googlesource.com/c/tint/+/50042)
recently. Still, this change is useful to avoid this happening again.

Bug: tint:792
Change-Id: I0119a1a6ade7a70a0d110ef0aac80f4eaf37a7b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50560
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-10 20:42:56 +00:00
David Neto a083f329a7 spirv-reader: import tests: make valid SPIR-V
Bug: tint:765
Change-Id: If6dc558a86bb64dfb7f61d237e774f41f735c732
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50442
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-10 20:34:26 +00:00
Ben Clayton ad19a63c54 Add sem::Reference
Bug: tint:727
Change-Id: I904d33b6c0678f478b4687fcc08589dc3cfd379d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50541
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-10 19:45:46 +00:00
Ben Clayton 3f968e7b05 Resolver: Validate resource binding decorations
Validate that:
* That resource variables have resource bindings
* Only resource variables have resource bindings
* That a [[binding]] decoration is paired with a [[group]]
* That binding points are not reused in the same entry point

Fixed: tint:235
Fixed: tint:645
Bug: tint:645
Change-Id: I2542934b4c6a2b4bbde48242932c04c796033a90
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50500
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-10 19:16:46 +00:00
Ben Clayton 6ba446fa5e Remove "Is" tests
These originate from a time before Castable, and there were hand-written Is<T>() methods on each of the base types.

Castable has its own tests that ensure the Is<T>() and As<T>() work as expected.
We don't need to check that this logic works for every type that derives from castable.

Change-Id: Iaa376dc4b4b5ee413a83fc5f9113cd3ef91dfe4a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50540
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-10 18:27:31 +00:00
Ben Clayton eebf0c97d9 Fix lint errors
Change-Id: Ia31d9fed7c9695e7f3e4d26fc3acf073ef42002d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50308
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-10 18:21:36 +00:00
Ben Clayton f14e0e1c8c Rename all type UnwrapXXX() methods
Give them sensible names.
Make them act consistently.
Remove those that were not used.

Change-Id: Ib043a4093cfae9f81630643e1a0e4eae7bca2440
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50305
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-10 18:06:31 +00:00
Ben Clayton fcda15ef67 Move storage_class validation from wgsl to resolver
We don't want the WGSL parser to have to maintain type lookups.
If the WGSL language is updated to allow module-scope variables to be declared in any order, then the single-pass approach is going to fail horribly.

Instead do the check in the Resovler.
With this change, the AST nodes actually contain the correctly declared storage class.

Fix up the SPIR-V reader to generate StorageClass::kNone for handle types.
Fix all tests.

Bug: tint:724
Change-Id: I102e30c9bbef32de40e123c2676ea9a281dee74d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50306
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-10 18:01:51 +00:00
Ben Clayton a34fa0ecb7 Remove sem::Alias
With the parsers now using ast::Types, nothing should be producing these any more.

This change also removes Resolver::Canonical(), which is now unneeded as there are no sem::Aliases to remove.

Bug: tint:724
Change-Id: I0c1a49f49372c1fcc37864502f07c5c76328d471
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50304
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-10 17:38:01 +00:00
Ben Clayton cbbe576415 reader/spirv - add type hierarchy
Don't create disjoint AST type nodes.
Instead use a new bespoke type hierarchy that can Build() the required
AST nodes.

Change-Id: I523f97054de2c553095056c0bafc17c48064cf53
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49966
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-10 17:25:21 +00:00
Brandon Jones c705b6caac Add external_texture_transform to backend writers
Adds the external texture transform to always run in the spirv, msl, and hlsl writers.

Bug: dawn:728
Change-Id: I15a96e877e1e88f9a4a4b015cf47251b41b18e35
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50024
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2021-05-10 16:15:31 +00:00
Ben Clayton 8f96595540 ExternalTextureTransform: Fix undefined behavior
WGSL now supports type inferencing with `let` declarations, so `var->type()` may return nullptr.
Calling a method (`Is<T>()`) on a nullptr object is UB. Instead used the free-function form which can handle nullptr objects.

Change-Id: I8faf875e1550eac1306ad731a65f3662bc4e5b43
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50307
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <brandon1.jones@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-10 16:06:51 +00:00
David Neto 1f68519dee spirv-reader: make valid SPIR-V for derivative tests
Bug: tint:765
Change-Id: I81a905e73d7435d85cffab4ff804934015de065b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50441
Reviewed-by: Alan Baker <alanbaker@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-05-10 16:01:11 +00:00
David Neto 799cecedb7 spirv-reader: rename test class for GetDecorationsFor
Bug: tint:765
Change-Id: I2b9a78baf45ba20168e23209f5d4cbf9bb231c7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50440
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-10 13:54:06 +00:00
Antonio Maiorano 9fdfa1e323 Resolver: validate else condition is boolean
Bug: tint:786
Change-Id: I5e4987e4eeb0608c640fc5c8ea035c8dca0ef187
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50461
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-10 13:46:06 +00:00
David Neto 6a56744b55 spirv-reader: make valid SPIR-V for memory tests
Bug: tint:765
Change-Id: I0760a46d2a4409dca0d8873fd87d815f7d0cbaab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50023
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 22:59:24 +00:00
David Neto 24fdbf9ec8 spirv-reader: named type tests are deliberately invalid SPIR-V
Bug: tint:765
Change-Id: I1a1a6fb6eef3fe7d0d7fbe5e6ce819ae89978f3f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50022
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 22:22:34 +00:00
David Neto 92ba7ee75c spirv-reader: logical instruction test validity
Bug: tint:765
Change-Id: Idcba9020f16987f6ed63a03b1fc560872aa7a1c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50021
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 21:45:04 +00:00
David Neto 9b26923b63 spirv-reader: validity for user name tests
Bug: tint:765
Change-Id: Iad711d911137e2f66be28ac8238389f5b68c1d20
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50020
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 21:35:54 +00:00
Ben Clayton 2e1a284cbb writer/spirv: Simplify member accesses
Using semantic info.

Change-Id: Iec9a592d9d66930535ead78fab69a6085a57a941
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50302
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-07 21:05:54 +00:00
Ben Clayton 4cd5eea87e sem: Fold together sem::Array and sem::ArrayType
There's now no need to have both.
Removes a whole bunch of Sem().Get() smell, and simplifies the resolver.

Also fixes a long-standing issue where an array with an explicit, but equal-to-implicit-stride attribute would result in a different type to an array without the decoration.

Bug: tint:724
Fixed: tint:782
Change-Id: I0202459009cd45be427cdb621993a5a3b07ff51e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50301
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-07 20:58:34 +00:00
David Neto 6732e8561c spirv-reader: CFG tests: make valid SPIR-V
Bug: tint:765
Change-Id: I84ea018478feafc4a5c03052832acae8cf3f15b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49940
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 20:33:05 +00:00
Ryan Harrison 74490e118e Test that entry point IO attributes are of valid types
BUG=tint:773

Change-Id: I94e8624647c645efe7ed558caa3d3bd05dd72f63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50260
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-07 20:28:04 +00:00
David Neto ff7a5f8dc9 spriv-reader: CFG tests: end with OpFunctionEnd
Bug: tint:765
Change-Id: Ib72c2fcd94bd8058ddfbd7e1fc7b1d968d0429ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49843
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 19:47:04 +00:00
David Neto 25df959dad spirv-reader: Rename test class for CFG tests
This makes it easier to triage test failures.

Bug: tint:765
Change-Id: I72d12e9eff3466d3d02952edce14499a61a4782b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49842
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-07 19:05:54 +00:00
Ben Clayton fb13f025a3 writer/wgsl: Only generate from the AST types
Remove the legacy generation path that uses the semantic types.

Bug: tint:724
Change-Id: I38128ab2049cb1dcea333c24453d6636b0ebb8c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50300
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-07 15:05:44 +00:00
Ben Clayton ba6ab5e6bd sem: Fold together sem::Struct and sem::StructType
There's now no need to have both.
Removes a whole bunch of Sem().Get() smell, and simplifies the resolver.

Bug: tint:724
Fixed: tint:761
Change-Id: I756a32680ac52441fd6eebf6fc53dd507ef5e538
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49961
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-07 14:49:34 +00:00
Ben Clayton 33d0f6aa08 Fix UBSAN error
As() was being called on a nullptr object.

Change-Id: Iedd7f1c57d12f1ad5ea2af60317817841f5d1392
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50303
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-07 14:15:14 +00:00
James Price 698d01383c writer/spirv: Fix dynamic array accessors
If the initial array accessor in a chain uses a non-literal index, use
the path that copies the source to a function variable, and then
perform a load from the OpAccessChain result if necessary.

Fixed: tint:426
Change-Id: Ie2f3f388170c02c1d6b73355f0b3bc49c3d3a4e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49800
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-05-06 21:45:03 +00:00
Antonio Maiorano a2580d6720 spirv reader: replace typ::Type with ast::Type
Bug: tint:724
Change-Id: Idaf807dd1ff75af8e0044731e7362c0915ae7e54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50200
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-05-06 21:23:13 +00:00
Ben Clayton 467184fb06 reader/spirv: Remove debug spew
Change-Id: I2e3c9e681f2d33aaa83a27525e5e0f231f6a8973
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50221
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-05-06 20:40:33 +00:00
Ben Clayton fe5c305891 Fix all doxygen warnings
Fixed: tint:776
Change-Id: I26e7dc36b19cf38612f6d530a9e774ac519d70e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50220
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-06 16:26:53 +00:00
David Neto e21ad1438e spirv-reader: fix signedness for shifts
Fixed: tint:675
Change-Id: Ib754191284a62b9f4be56dc8d38e5319345ab9bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49824
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-06 16:21:53 +00:00
Ben Clayton b82acac68e Resolver: Clean up diagnostics
Don't have a separate diagnostic list, just put the errors straight into the ProgramBuilder's diagnostics.
This also fixes an issue where we were taking the stringified diagnostic list and creating a single error on resolution failure. This was the cause of the `error: error:` messages sometimes seen.

Also fix a stupid negated-logic bug around the "resolving failed, but no error was raised" ICE.

Change-Id: Iddf1f61e4be21137731dfc204210562abbf612b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49963
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-06 16:04:03 +00:00
Ben Clayton 0600796092 ast::Struct: Remove Clone() hack
Semantic types are no longer cloneable, entirely avoiding the issue this hack was working around.

Bug: tint:724
Change-Id: Iec876beccfda476a5539fb4d669eeba24d263500
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49962
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-06 16:03:33 +00:00
Ben Clayton b7bd0e12d1 reader/wgsl: Migrate to AST types
Bug: tint:724
Change-Id: I484813dd139122244cd09829ab5b035cec9981e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49960
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-06 15:57:13 +00:00
Ben Clayton 58750eab19 sem: Have sem::Type derive from sem::Node
Having a common base class will tighten up some of the dynamic casting that we do.

Bug: tint:724
Change-Id: I45c6f200e1ec242ddb08ce75bd1c4c037a21a38d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49882
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-06 15:52:33 +00:00
Ryan Harrison a0174e613f Add fuzzing for transform::VertexPulling
Includes a significant refactoring of helper functions in
tint_common_fuzzer.cc/.h

BUG=tint:722

Change-Id: I1fdab0113bae02c4a0bf8da0d1b7729f05a2fc5b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49902
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-06 15:43:33 +00:00
David Neto 4f34e7897b spirv-reader: bit tests: make valid SPIR-V
Bug: tint:765
Change-Id: I79474aa959165b2b54eea352c4d71a04fea6ba51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49823
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-06 15:35:33 +00:00
James Price d2be7cea90 reader/wgsl: Allow constants without initializers
This is valid when they are overridable constants. The resolver will
validate whether or not this is the case.

Change-Id: Ic6659c58e5046117f64794efec3300b0245a5e91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50043
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-05-06 13:42:03 +00:00
James Price 08df57a75c validator: Require constants to have initializers
Unless they are pipeline overridable.

Fixed several tests that were violating this.

Change-Id: Ibb10e03bb150086a4d9e68a3f7b2d3e21f282918
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50042
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>
2021-05-06 13:37:13 +00:00
James Price ab3a9218b7 validator: Disallow [[override]] on non-const vars
Only allow them on constants, where no other decoration is valid.

Change-Id: I83f19667adb1dd4ebbba86827324a45a8f1a80a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50041
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-05-06 12:36:52 +00:00
James Price a67f8a44bb writer/spirv: Fix constant initialization
The code to auto-generate initializers for overridable pipeline
constants was in the non-const code path, so move it to the right
place and fix the tests that were wrongly testing non-const variables.

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

Change-Id: If06e453b6fd58b8c74bed996532b3b9f9f7804ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50044
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-05-06 08:20:52 +00:00
David Neto b4a8a15bd2 spirv-reader: arithmetic tests: make valid SPIR-V
Bug: tint:765
Change-Id: I8994647edd29513d48d5154c15e7dd429771c2ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49822
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-05 23:27:52 +00:00
David Neto 922779bcf5 spirv-reader: conversion tests: make valid SPIR-V
Bug: tint:765
Change-Id: I18ed7f007fc9b15c51cddbb6b0edbca79ed1569c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49821
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-05-05 21:24:34 +00:00
David Neto ba08d7bca3 spirv-reader: update tests to use valid SPIR-V
This CL: all SPIR-V modules in parser_impl_module_var_test.cc

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

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

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

This also fixes duplicate intrinsic output from DecomposeStorageAccess.

Bug: tint:724
Change-Id: I979d55f7b141f38c0504dc72cc3c63e8353ac14f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49881
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-05-05 16:55:22 +00:00