Commit Graph

674 Commits

Author SHA1 Message Date
James Price 61306b882d [wgsl-reader][wgsl-writer] Fix implicit handle storage class for textures
Unwrap the type before checking if it is a handle type, to account for
access decorations.

Bug: tint:332
Change-Id: I8af9749fec1e2f5dbd7c3bec0b73e506ae111a28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40540
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 15:08:49 +00:00
David Neto 6d1687fb01 spirv-reader: vertex_index always has u32 store-type
Fixed: tint:483
Change-Id: Ie26941ab751425dfbc0924ea21bee32dc0f92527
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40623
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 15:02:49 +00:00
Corentin Wallez 3c568f188d Revert "spirv-reader: add disabled test for compare sampling with explicit Lod"
This reverts commit 4a7981e300.

Reason for revert: Empty GTest Values() causes compilation error in Chromium.

Original change's description:
> spirv-reader: add disabled test for compare sampling with explicit Lod
>
> This is blocked by discussion at W3C
> https://github.com/gpuweb/gpuweb/issues/1319
>
> Bug: tint:482
> Change-Id: Ic3a2b32fb09a431edbd7716a394a9eb3f163fb85
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40621
> Commit-Queue: Ben Clayton <bclayton@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Auto-Submit: David Neto <dneto@google.com>

TBR=dneto@google.com,bclayton@google.com

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

Bug: tint:482
Change-Id: I637c40950cd343196c2703c9854f584bf8f1c084
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40603
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-02-08 09:49:09 +00:00
David Neto 4a7981e300 spirv-reader: add disabled test for compare sampling with explicit Lod
This is blocked by discussion at W3C
https://github.com/gpuweb/gpuweb/issues/1319

Bug: tint:482
Change-Id: Ic3a2b32fb09a431edbd7716a394a9eb3f163fb85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40621
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-02-05 22:06:03 +00:00
David Neto a2fa690cda spirv-reader: sample_mask_in, sample_mask_out
TODO: passing pointer to them as a function parameter

Bug: tint:471
Change-Id: Ibd55bdc77a2bfb0f5712dd9bf332910999b8d0d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40123
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-04 22:12:30 +00:00
James Price 1f2d38c826 [wgsl-writer] Omit the storage class for handle types
These types have an implicit storage class of UniformConstant.

Bug: tint:332
Change-Id: I78c5b2a085e543ebba7d5e92b8f11550d0cd4d49
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40400
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
2021-02-04 18:35:40 +00:00
James Price 0ff5e0bfb8 [wgsl-reader] Remove explicit storage class from samplers/textures
Automatically set the storage class to UniformConstant.

Producing an error if an explicit storage class is given is deferred
until downstream users have caught up.

Bug: tint:332
Change-Id: I70e7390dc95d6f578a0fdeb675ca63a8b5b4fa26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40160
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
2021-02-04 18:26:00 +00:00
David Neto ef6eefdc8f spirv-reader: builtin conversions for sample_mask_in, sample_mask_out
Enum conversion of builtins depends on storage class.

Bug: tint:471
Change-Id: I0b93c26139f72c70786b9b70f1016e62e1df62f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40122
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-04 17:34:00 +00:00
David Neto f4329f57e5 spirv-reader: GLSLStd450RoundEven maps to round
This is from the resolution to https://github.com/gpuweb/gpuweb/issues/1381

Bug: tint:3
Change-Id: If4158d8ff3bffce0e82d2230e5df5650193e7541
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40180
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-04 16:22:50 +00:00
Alan Baker c63e1c0791 Implement data packing intrinsics
* Fix how the HLSL writer determines how to use a RWByteAddressBuffer
* Fix how the HLSL writer decides the register space for a storage
  variable
* Fix inference of hlsl format in the tint executable
* Add support for data packing intrinsics
  * type determination
  * validation
  * writers
  * spirv reader

Bug: tint:340, tint:473, tint:474
Change-Id: I45dc8fd7c6f9abc7d30f617c7e3d713d7965b76e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40342
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-04 16:17:49 +00:00
David Neto a568701d61 spirv-reader: support sample_id builtin variable
TODO: support sample_id declared with signed integer store
type, and then having the pointer passed to a helper function.

Bug: tint:471
Change-Id: Iac303ff6118b2d2d518e5070a8d589dcd3616f39
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40020
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-02-03 22:01:46 +00:00
Ben Clayton 1618f4be4e Add semantic::Call, IntrinsicCall, TextureIntrinsicCall, use them.
semantic::Call derives from semantic::Expression, and Type() is the return type of the function
Pull the mutable semantic field from ast::Identifier and into a new semantic nodes.
Have the TypeDeterminer create these new semantic nodes.

Note: This change also fixes the node that holds the semantic information for a call.
Previously this was on the identifier, and this is now correctly on the CallExpression.
The identifier of the CallExpression should resolve to the target function, not the return type.
Functions can currently be represented as a type, and the identifier of a CallExpression now has no semantic information.

Bug: tint:390
Change-Id: I03521da5634815d35022f45ba521372cbbdb6bc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40065
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-03 21:02:25 +00:00
Ben Clayton 48b384168c type::StorageTexture: Remove set_type()
The subtype of a storage texture is statically determinisic from the ImageFormat, and does not need to be late-set by the TypeDeterminer.

Add StorageTexture::SubtypeFor() helper for returning the subtype for a given ImageFormat, and add the subtype as another immutable constructor parameter.

Bug: tint:390
Change-Id: Ibe732293e3142064b60f4e666a7eb39ae8db50e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40064
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-03 20:28:26 +00:00
Ben Clayton b17aea159c Add semantic::Variable, use it.
Pull the mutable semantic field from ast::Variable and into a new semantic::Variable node.
Have the TypeDeterminer create these semantic::Variable nodes.

Bug: tint:390
Change-Id: Ia13f5e7b065941ed66ea5a86c6ccb288071feff3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40063
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-03 17:51:09 +00:00
David Neto f2d687137c spirv-reader: support OpImageQuerySamples
Bug: tint:109
Change-Id: I1a7677c9322f5f2f01d6bf436222b58ab9bdbf95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39721
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-02 15:07:25 +00:00
Ben Clayton 42d1e097e6 Have ProgramBuilder::Func() register the function
With the ast::Module::Functions().

Also remove pointless calls to td.Determine() that will automatically be
done when the program is built.

Change-Id: Ia7506e430b04d91d4f6b02fb6b678d0ea9912bcd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39900
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-02 14:29:15 +00:00
David Neto d277f3a85a spirv-reader: support OpImageQueryLevels
Bug: tint:109
Change-Id: I1bb7bbdca2322df28e7b22225e4b1bfdb74dbf73
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39720
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-01 23:43:44 +00:00
David Neto 1d2bcb99d6 spirv-reader: support OpImageQuerySizeLod
It queries the dimensions and array levels of a sampled image.

Bug: tint:109
Fixed: tint:423
Change-Id: Ia9ac0ee84b0282dbde8729a1698c9b21943723d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39682
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-02-01 22:47:54 +00:00
David Neto 4d098a7b75 spirv-reader: WGSL does not support OpImageQueryLod
Bug: tint:109
Change-Id: Ife61dca63c605a456407140d5c4fdb6b4bfa97a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39681
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-02-01 21:47:04 +00:00
David Neto 7ecf92a53c spirv-reader: support OpImageQuerySize
Change-Id: I27ad580ae84f18a69b31700f56bbbcf59d3818e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39680
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-02-01 19:44:24 +00:00
James Price 4cec1429d7 Add tokens for left and right shift
Manually split `>>` and `>=` tokens when looking for a `>` to
correctly parse ptr/array/vec declarations and initializations.

Bug: tint:171, tint:355
Change-Id: Iee89a844fd999e337ae44ef9b192cc122fbf9e54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39362
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-01 18:23:23 +00:00
James Price a6ced4d0b4 [wgsl-reader] Add support for constant_id decoration
Bug: tint:155
Change-Id: I207fd87d0708c66ea0fe7de81b156db98eea8e60
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39560
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-01 14:59:13 +00:00
David Neto 45f1832f11 spirv-reader: support OpVectorInsertDynamic
Change-Id: I30b9ad14faf921c3ec0bf47729480d4f7d37f561
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39161
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-29 21:32:11 +00:00
Ben Clayton 708dc2d040 Simplify calls to ast::Node::[to_]str()
Add helpers on Program and ProgramBuilder that significantly simplify
usage.
Also demangle - this also reduces a bunch of copy-pasta code.

Change-Id: I6215c346e7f6e49c20aced058a6150603253ed93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39342
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-29 11:22:40 +00:00
Ben Clayton dd1b6fca9f Introduce semantic::Info
Will hold the mutable fields that currently reside in the otherwise immutable-AST.

Change the AST string methods to accept a `const semantic::Info&`. This is required as some nodes include type-resolved information in their output strings.

Bug: tint:390
Change-Id: Iba494a9c5645ce2096da0a8cfe63a4309a9d9c3c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39003
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-29 10:55:40 +00:00
David Neto 63049a420e spirv-reader: support OpVectorExtractDynamic
Use array-access syntax

Fixed: tint:450
Change-Id: Ida90180015cace8cfa94c0116c3e37c3c6d59212
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39222
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2021-01-28 22:21:29 +00:00
David Neto ad27ee8c10 spirv-reader: Handle OpInBoundsAccessChain for storage class translation
Fixed: tint:457
Change-Id: I25410a1e59cbc78f76da65c28312a8ddd6b3319b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39220
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-28 21:22:39 +00:00
dan sinclair 875e966a66 Revert "Remove support for the set decoration."
This reverts commit 67beed1b94.

Reason for revert: CTS Roll happened just before this fix landed in CTS.

Original change's description:
> Remove support for the set decoration.
>
> This CL removes the set decoration support, it has been replaced by the
> group decoration.
>
> Change-Id: Ib9ca94872d39e5da9dbe18bba3cae6d64320e55d
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38824
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dneto@google.com,dsinclair@chromium.org,bclayton@google.com

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

Change-Id: I89dec6d2663e18ac8e15ae3c7a5ffb443591f6b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39360
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-28 20:27:39 +00:00
dan sinclair 5ad2d0087b Revert "Remove support for the old _idx builtins."
This reverts commit c2972cfa60.

Reason for revert: Looks like CTS in Chrome doesn't have this change yet.

Original change's description:
> Remove support for the old _idx builtins.
>
> This CL removes the old _idx variants of builtins in favour of the
> _index versions.
>
> Change-Id: I1678b5fae63c9d4f7f63feabf7410a58505d397a
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38825
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dneto@google.com,dsinclair@chromium.org,bclayton@google.com

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

Change-Id: I29b6016f2e9e0b6245e22e2e18ff2f8c9a17dc74
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-28 16:49:11 +00:00
dan sinclair 30c1f25a7a Reland "Remove support for # comments."
This reverts commit 21b52b60b6.

Reason for revert: Dawn fixes landed, trying again.

Original change's description:
> Revert "Remove support for # comments."
>
> This reverts commit 6e570a9360.
>
> Reason for revert: Missed Dawn tests
>
> Original change's description:
> > Remove support for # comments.
> >
> > This CL removes support for parsing # style comments. Only the //
> > comments are accepted now.
> >
> > Change-Id: I062c2a86149ecf828723c74f7168243678ee5870
> > Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38823
> > Commit-Queue: dan sinclair <dsinclair@chromium.org>
> > Commit-Queue: Ben Clayton <bclayton@google.com>
> > Auto-Submit: dan sinclair <dsinclair@chromium.org>
> > Reviewed-by: Ben Clayton <bclayton@google.com>
>
> TBR=dneto@google.com,dsinclair@chromium.org,bclayton@google.com
>
> Change-Id: Iaf19ab9def92ad10c27d70480d259e25f3da719d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39061
> Reviewed-by: dan sinclair <dsinclair@chromium.org>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dneto@google.com,dsinclair@chromium.org,bclayton@google.com

# Not skipping CQ checks because this is a reland.

Change-Id: I91a478237bc9853108e1ce97b9fdc2ce01841998
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39221
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-27 22:30:55 +00:00
James Price 186af2f6ad [wgsl-reader] Fix struct constructor expressions
The parser was matching struct constructors as function calls.

Bug: tint:458
Change-Id: Ia98489e3a6d62eea2e423c6344b6e35b8f9649f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39101
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-27 21:49:06 +00:00
Ben Clayton dd69ac3505 Automatically run the TypeDeterminer when building programs
Removes the need for Dawn to use the TypeDeterminer directly.
TypeDeterminer errors will be added to the Program diagnostics list.

Change-Id: I4cfb405e7e6b0e94727296eea872a3ddc4412b66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38921
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-27 19:23:55 +00:00
Ben Clayton 844217fa34 Add Diagnostics to Program, reader::[wgsl,spirv]::Parse()
By putting diagnostics into the program, we can hold all the diagnostic messages for parsing and type determination in one place.
This also means that we can simplify the public WGSL and SPIR-V Parser interfaces to a single function.

Change-Id: Ib6ab5fa180addd45c4aaf0c6b192d47182ffb50a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38920
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-27 18:49:05 +00:00
dan sinclair 21b52b60b6 Revert "Remove support for # comments."
This reverts commit 6e570a9360.

Reason for revert: Missed Dawn tests

Original change's description:
> Remove support for # comments.
>
> This CL removes support for parsing # style comments. Only the //
> comments are accepted now.
>
> Change-Id: I062c2a86149ecf828723c74f7168243678ee5870
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38823
> Commit-Queue: dan sinclair <dsinclair@chromium.org>
> Commit-Queue: Ben Clayton <bclayton@google.com>
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>

TBR=dneto@google.com,dsinclair@chromium.org,bclayton@google.com

Change-Id: Iaf19ab9def92ad10c27d70480d259e25f3da719d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39061
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-27 18:32:16 +00:00
David Neto 36194197ac spirv-reader: textureLoad explicit Lod sometimes
WGSL requires an explicit level-of-detail for textureLoad
for sampled textures and depth textures

Fixed: tint:462
Change-Id: I43758b002da91af9901d12664861ace971833020
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38828
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2021-01-26 21:58:34 +00:00
dan sinclair 34ac1afd99 Remove old texture type support.
This CL removes all of the old texture type names in favour of the new
variants.

Change-Id: Icb3c9ed8e39c8d7320fd6a6706b8029fcb3e5947
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38826
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-26 21:44:54 +00:00
dan sinclair c2972cfa60 Remove support for the old _idx builtins.
This CL removes the old _idx variants of builtins in favour of the
_index versions.

Change-Id: I1678b5fae63c9d4f7f63feabf7410a58505d397a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38825
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-26 20:21:31 +00:00
dan sinclair 67beed1b94 Remove support for the set decoration.
This CL removes the set decoration support, it has been replaced by the
group decoration.

Change-Id: Ib9ca94872d39e5da9dbe18bba3cae6d64320e55d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38824
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-26 20:18:51 +00:00
dan sinclair 6e570a9360 Remove support for # comments.
This CL removes support for parsing # style comments. Only the //
comments are accepted now.

Change-Id: I062c2a86149ecf828723c74f7168243678ee5870
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38823
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-26 19:28:51 +00:00
Ben Clayton 1461cd96d6 Add diag::List::add_error() helper
Refactors a common pattern in the tint codebase.

Change-Id: Ia8a70d952fd8c204facd0120f24e43ccc9305622
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38840
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 18:52:11 +00:00
Ben Clayton a6b9a8eb2f Split Program into Program and ProgramBuilder
Program is now immutable*, and remains part of the public Tint
interface.

ProgramBuilder is the mutable builder for Programs, and is not part of
the public Tint interface. ast::Builder has been folded into
ProgramBuilder.

Immutable Programs can be cloned into a mutable ProgramBuilder with
Program::CloneAsBuilder().

Mutable ProgramBuilders can be moved into immutable Programs.

* - mostly immutable. It still has a move constructor and move
  assignment operator - required for practical usage - and the
  semantic information on AST nodes is still mutable.

Bug: tint:390
Change-Id: Ia856c50b1880c2f95c91467a9eef5024cbc380c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38240
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 8d391f7a10 ast::TypesBuilder: Change const fields to getters
This is required in order to support move operators for TypesBuilder.

Bug: tint:390
Change-Id: I9667bda5f5be267df092f5cd94dc40db053ae6e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38555
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 44bec80e5f Demangler: Change signature of primary Demangle() function
Have this take a SymbolTable instead of a Program.
Program will be split into Program (immutable) and ProgramBuilder (mutable). We'll need Demangler to support both.

Bug: tint:390
Change-Id: I6447dd9674919d4867ed8ba126880cdfd9bf7128
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38550
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton d7137d7233 Program: Remove deprecated symbol methods
Fixup all usages

Bug: tint:390
Change-Id: If861b044eae006af2fd86d348de6ba62f448bc6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38549
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 83158f214f Program: Remove deprecated function methods
Fixup all usages

Bug: tint:390
Change-Id: I949235908e50702d6c8b2e7e2299594879653e01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38547
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 1b3d6e460c Program: Remove deprecated constructed-type methods
Fixup all usages

Bug: tint:390
Change-Id: I739a7625cd385cb889369ab7c766462fbcd7cf12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38546
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton a86f4effe4 Program: Remove deprecated global variable methods
Fixup all usages

Bug: tint:390
Change-Id: I2e239dfc77872acb9f0b2ee5494350605dd780a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38545
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton c40f627bea Migrate from using ast::Module to Program
Enforce all places where Dawn passes in or returns a ast::Module, now takes a `const Program* ` or returns a `Program`.

As the end goal of all this is to have immutable Programs, all Program inputs take a pointer instead of moving the actual object.

As consumers of a Program are now all const, we have to const_cast to work around all the places we've been incorrectly mutating a ast::Module.
These const_casts are temporary, and will be fixed in the next set of changes.

Depends on https://dawn-review.googlesource.com/c/dawn/+/38522

Bug: tint:390
Change-Id: Ie05b112b16134937d1b601e9b713ea4ec4e1c677
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38541
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton d59cedb5a5 Add tint::Program as a wrapper of tint::ast::Module.
`tint::Program` will become the new public API object for a parsed shader program.
For now, have Program be a simple wrapper around ast::Module so we can migrate Dawn's use of the public tint API.

Add new Program variants of public APIs for places that returned or took a Module.

Remove Reset() methods from Generators, they aren't used, and make the migration harder.

Change-Id: Ic5bee46ceb109ea591ba7fec33685220b244a1ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-25 18:14:08 +00:00
David Neto aee7acaaea spirv-reader: refactor getting image, sampler
Change-Id: I6620781f620067e4df8f7e39f2bb2a80b32f9ecf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38180
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-01-25 15:16:58 +00:00
Ben Clayton 6761160dc1 ast: Move Module function methods to FunctionList
Module will be split into Module (immutable) and ModuleBuilder (mutable).
By moving these methods to the FunctionList, we can deduplicate a bunch of common logic.

Bug: tint:390
Change-Id: I3fd85200aae4e8dc3d5afce8c9aaa6512809a3a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38363
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 18:45:50 +00:00
Ben Clayton 281b602f59 type::Manager: Simplify interface and use BlockAllocator
Internally use BlockAllocator to allocate the types.
When we optimize the allocation patterns of BlockAllocator, this will now benefit both AST nodes and types.

Remove Reset(). It was not used.

Remove type::Manager::Get(std::unique_ptr<type::Type>) - this was used (via Module::unique_type) in one place, which has easily been migrated to using the standard Module::create<>.

Replace all remaining uses of std::unique_ptr<> of types in tests with the standard create<> so we can guarantee uniqueness of the types.

Change-Id: Ib0e1fe94e492b31816450df5de0c839a0aefcb9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38362
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 16:35:10 +00:00
Ben Clayton 1e29f4beb0 Move CloneContext and Traits from src/ast to src/
CloneContext clones the AST, types, symbols and in the future semantic info.
3/4 of these are non-ast, so promote these up to the root.

Bug: tint:390
Change-Id: I49619796e6f81f9ab64f79413a12c87312cb1901
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38361
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 16:20:40 +00:00
Ben Clayton 207b5e2de1 Move tint::ast::type to tint::type
Despite `tint::ast::type::Type` being in the AST namespace, these classes are clearly not AST nodes:
* They don't derive from ast::Node
* They're deduplicated by the type manager
* None of the types have an Source - they have no lexical declaration point
* The fact we have `ast::Struct` and `ast::type::Struct` clearly demonstrates what is an AST node, and what is a type.
* We have code scattered in the codebase (TypeDeterminer, writers, etc) that create new types after parsing - so clearly not part of the original syntax tree.

Types in tint are closer to being semantic info, but due to the parse-time generation of types, and tight dependency of ast::Nodes to types, I'd be reluctant to class these as semantic info. Instead, put these into a separate root level `tint::type` namespace and `src/tint` directory.

The fact that types exist in the ast::Module has already caused bugs (https://dawn-review.googlesource.com/c/tint/+/37261). This is a first step in separating out types from the ast::Module.

Bug: tint:390
Change-Id: I8349bbbd1b19597b8e6d51d5cda0890de46ecaec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38002
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 15:42:10 +00:00
Vasyl Teliman e1abcb4564 wgsl-reader: support multiple case selectors
Bug: tint:454
Change-Id: I5a046e19f66b5807723e96593ea6ba107ef69e6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38261
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-20 21:53:13 +00:00
David Neto ed14524b1e Refactor getting number of coordinate dimensions
Change-Id: Ibafffb29bc33c722b8a4da25ed7a9c1986d13a24
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38162
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2021-01-19 03:29:35 +00:00
dan sinclair 336bb0b4dd Update storage_buffer storage class.
This Cl updates the `storage_buffer` storage class to just be `storage`.

Change-Id: Ibfaecbb0862bd60d39665eb937c0b6300899e177
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38161
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-18 21:06:34 +00:00
dan sinclair d7335fa974 Update builtin idx names.
This CL upldates the vertex_idx, instance_idx and global_invocation_idx
builtins to use the full _index names. The original values still exist
until we can update downstream users.

Change-Id: Icd02601eeb15704d5463158541c07816d98e5383
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37940
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-18 15:51:13 +00:00
dan sinclair c068cfc139 Support the group decoration.
This CL changes the set decoration to a group decoration. We still parse
`set` until downstream users can be updated.

Bug: tint:338
Change-Id: I610d1ed769b3a26c117ad6d875f8a99a3d5b7754
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37920
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-15 12:22:16 +00:00
David Neto 0e17caa361 spirv-reader: expand OuterProduct to primitive ops
Bug: tint:3
Change-Id: Id6de3554d945bc743a484e80b494690c26552079
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37660
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-01-14 19:01:27 +00:00
Ben Clayton 8121fe3367 Add missing doxygen comments
Change-Id: Ia4b1a5bc1d046633a7f1f91e23659d237d35e640
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37842
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-14 15:52:52 +00:00
Ben Clayton 1f14595723 reader/wgsl: Remove duplicate lexer logic
See:
https://dawn-review.googlesource.com/c/tint/+/37780/1/src/reader/wgsl/lexer.cc#750

Bug: tint:286
Change-Id: I6d39fdfefad619beb65ad1d496b27925da3db8ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37840
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-14 14:15:02 +00:00
dan sinclair 904c5b9621 Add texture_storage_yy parsing.
This CL adds support for the decorated texture storage tokens. The old
_ro_ and _wo_ tokens still exist until downstream users are updated.

Bug: tint:286
Change-Id: I4ddc50be3b22bd3feeab41b3b4fe4ded63e6e59a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37780
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-14 08:34:46 +00:00
dan sinclair d50a3041fa Remove access control from StorageTexture.
This CL removes the access control value from the storage textures and,
instead, wraps in an type::AccessControl. This matches the current spec
where the access is an annotation on the type as opposed to part of the
type.

Bug: tint:286
Change-Id: Ia944ed8557fbf490d78db2a1b49c31d0aba08728
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37740
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2021-01-13 18:48:11 +00:00
dan sinclair 1c200cffd0 Remove outerProduct.
The community decided to remove outerProduct from WGSL. This Cl removes
the pieces from Tint.

Change-Id: Ib1735867e4a7ca852a72549fc8c9bd86e8de22b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37600
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-12 22:00:58 +00:00
David Neto 559f4e66d5 Remove stdout output from test
Change-Id: If1c4b72f636f7aa9d8fac81b5172dd050b06dc32
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37500
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-12 18:25:58 +00:00
David Neto 4651a6ee8b spirv-reader: explicitly reject combined-image-sampler
This was already rejected, but with a not-very-useful message.
Error out more consciously and issue a higher level, more informative
error message.

Fixed: tint:442
Change-Id: I3643b98d17f55b44b9dcf86aa828010bb39fcd8e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37242
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-01-12 15:24:18 +00:00
Ben Clayton d221738e20 Add diag::Formatter::Style::print_newline_at_end
Automatically prints a newline at the end of the last diagnostic in a list. Defaults to true.

Disabled for many tests that assume no newline at end of string.

Change-Id: Id1c2f7771f03f22d926fafc2bebebcef056ac5e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-11 21:09:22 +00:00
David Neto 3f245ed362 spirv-reader: convert arity of textureLoad on depth texture
Fixed: tint:439
Change-Id: I151e388a1ea11bdcb5cebf0441a73ddcaf8a6f54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37063
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 19:04:49 +00:00
dan sinclair c8c31560de Remove name fields
This CL removes the name fields from the various AST nodes now that the
symbols are used everywhere.

Change-Id: I73e8fa8958aa6e6f0159b12b63176b12c418f525
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36762
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 16:24:32 +00:00
dan sinclair e65e4bd2c5 Remove IdentifierExpression::name().
This CL removes the name method from IdentifierExpression. The usages
have been converted over to the symbol.

Change-Id: Id751c2fc4a43bd5414fbaf8a8a66ecffb3838e48
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36801
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 4ac6568821 Remove Function::name().
This CL removes the function name accessor and changes all usages to use
the symbol.

Change-Id: I19b92bf1bc557ba14e68ef8cb381487a4ad1f7ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36821
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair eb737c25db Remove StructMember::name().
This CL removes the name accessor from the struct member. Usages have
been replaced with symbol usages.

Change-Id: Idd9c5b34f0b5503ffee84e0c82d69aa65b1df7ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36820
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-11 16:24:32 +00:00
dan sinclair e76a86a22c Remove StructType::name()
This CL removes the name accessor from the StructType. All usages are
updated to use the symbol.

Change-Id: I65d793e9609a1663facce955bdb89e60f11f382a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36800
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
dan sinclair 396b02342f Remove Variable::name().
This CL removes the name getter from the Variable class. All usages are
updated to use the symbol.

Change-Id: I3e4d86d2124d39023cad6113c62230c1757ece71
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36780
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 16:24:32 +00:00
David Neto f51d965bef spirv-reader: Reject dref sampling with Bias or Grad
Bias and Grad image operands are not supported for
depth-referencde sampling.

Fixed: tint:440
Change-Id: Ic2bf995f7c7b791b8e3a7ceb3514b10220dda8a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37062
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-11 14:53:29 +00:00
David Neto 1e01c2c116 spirv-reader: rename variable
Rename the state variable describing whether the "Level"
suffix should be used to indicate the level-of-detail variant
of a texture builtin.

Bug: tint:3
Change-Id: I21fdfcace06575e7f9586d7bfc22200f9c1176fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37004
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-08 15:44:44 +00:00
David Neto 8144af91b4 spirv-reader: ignore PointSize builtin declared at module-scope
Fixed: tint:434
Change-Id: Ia29d0f7227e838fc5f9dd4ca521b5fd6b9a88637
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36761
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-07 01:38:41 +00:00
Ben Clayton 9bbf8252a9 wgsl: Treat // as comment
Also support # as comments for now while we migrate.

See:
https: //github.com/gpuweb/gpuweb/issues/1262
https: //github.com/gpuweb/gpuweb/pull/1326
Change-Id: I3547f575c35f4fd46b95f0f2d8b79f4015364c83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36680
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-01-06 19:54:01 +00:00
David Neto 6cad63c2ad spirv-reader: support OpArrayLength
Fixed: tint:431
Change-Id: I727ca8200118e0b93b42c5f7d9e97bc4afd97830
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36460
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-01-05 21:21:50 +00:00
Ben Clayton 9894867678 reader/wgsl: Fix parsing of matrices.
https://gpuweb.github.io/gpuweb/wgsl.html#matrix-types :
"matNxM<T>	Matrix of N columns and M rows"

Fixed: tint:432
Change-Id: Ib8fdb836b02c5e6be87acea850f095355545adbd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36421
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 20:53:10 +00:00
David Neto a35b57f91f spirv-reader: rename to isNan, isInf
Fixed: tint:418
Change-Id: I09185880c838d437f84c4ef85528b4d807c0b340
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36440
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 19:22:30 +00:00
David Neto 938ff5f482 spirv-reader: ImageQuerySize can be on readonly image
Fix how handle usage is collected.  OpImageQuerySize
is usable for *any* image that is either MS=1 or Sampled=0 or 2.
(Sampled=0 is not allowed by Vulkan).
So it's usable by storage images or multisampled image.

OpImageQuerySizeLod is usable by Sampled=1 MS=0 images, ie. sampled
images.

Fixed: tint:422
Change-Id: Ibfbcab2daa8b38f17758a0428a08cb9660496bac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36061
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-01-05 16:10:40 +00:00
Ben Clayton 1637cbb868 cleanup: Refactor tests to use ast::Builder helpers
Change-Id: I5bf1dac217c9c6192c0637d98c4a38196d41cbe8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36382
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 15:44:39 +00:00
Ben Clayton dbfe2de982 reader/spirv: Move common test name to fixture name
Helps with test grouping, and more importantly fixes a lint error about
the line length exceeding 80 characters, which cannot otherwise be
sensibly fixed as the formatter wants the fixture name to be unsplit.

Change-Id: I54b32e3516250b4064cd66a618f2239982aaf2d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36381
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-05 15:41:25 +00:00
Ben Clayton e6e704145b Remove all Source{} smell from tests
Switch all remaining AST stack allocations in tests to using create<T>() which will automatically inject the current Source as the first parameter.

Most remaining uses of Source{} in the codebase are places where we need to fix.

Bug: tint:396
Change-Id: I24655800b50d6ad52e682a7339022972e9b354d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36380
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-01-05 15:29:29 +00:00
David Neto 9a644c7903 spirv-reader: Restrict use of ConstOffset
Only permitted for image sampling (and later gather).

Only permitted for 2D, 2D Array, and 3D textures

Fixed: tint:408
Change-Id: Ib97bd17e45046ec8a2147b46899bf52ad9a8f883
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35980
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-17 20:32:12 +00:00
David Neto d1469c60c1 spirv-reader: fix arity for depth texture builtins
Texture buitins on depth textures always result in scalar f32.
Corresponding operations in SPIR-V always result in vec4<f32>.

When translating to Tint AST, wrap the generated texture builtin
in a type constructor to vec4, with the builtin result as the
x component.

Fixed: tint:411
Change-Id: Idf26a1cbc7e875bc8a97bf3c0b342c0220c6d4b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35900
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-17 16:29:31 +00:00
dan sinclair a57f842be9 Add Symbol to Variable.
This CL adds a Symbol to the Variable AST node along side the name. The
name will be removed in a future CL.

Change-Id: I1c05e5595392b1c4a0afa82387d97b2b4472bade
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35881
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-16 21:42:30 +00:00
David Neto e5d288be5e spirv-reader: ignore storing 1.0 to PointSize builtin
If you try to load it, return 1.0f instead.
Some cases of copy-object of intermediates are unhandled,
and will error out.

This is being done as an aid to porting GLSL Vulkan shaders
that do store 1 to gl_PointSize.

Fixed: tint:412
Change-Id: Ia33dc70bca630dccfbf11644f71d6be4b3f43f1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35861
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-16 20:50:10 +00:00
David Neto e9b90f755b spirv-reader: generalize skip reasons
Bug: tint:412
Change-Id: Ie9dd230361019ec929f4d36215e7058a893bbe0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35860
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-16 20:42:10 +00:00
Ben Clayton d94cbf6023 reader/spirv: Fix permissive GCC warning
... about getters having the same name as the type they return. Prefix getters with `Get`, remove unused ones.

Also remove the cases field, the compiler helpfully now tells us it is unused.

Change-Id: I7e3fcdae3818cee5aae8b70b48e9b0507a8d3b45
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35743
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-12-15 21:06:28 +00:00
dan sinclair 36e22f0f3b Add symbol to member name.
This CL adds the symbol to the struct member. The name will eventually
be removed when the symbol is used everywhere.

Change-Id: Ie97f61509804992b44b22396773a635efbc4458e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35780
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-15 16:43:18 +00:00
Ben Clayton 11276ef97d spirv-reader: Fix texture[Load|Store] with lod
Don't suffix texture intrinsics with `Load` unless it's a `textureSample`.

Discussion:
d46b4fa3ca (diff-709b5c343d59ae10cbabe69f9df1eee9e2dbb6e9d848632fa94357083d6e0a34)

Bug: tint:109
Bug: dawn:399
Change-Id: Ic42ef9f8681dd04bd8f4c901c6d4cdc5f4166d26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35423
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-12-15 12:34:38 +00:00
Ben Clayton 5aad70a069 Move all Source constructor params to be the first
This consistency can be utilized by the ast::Builder to inject the source parameter if it isn't provided.

Bug: tint:396
Bug: tint:390
Change-Id: I2f19002131e79daae799b8cbe918eb192d6bfc75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35503
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 21:10:07 +00:00
David Neto 7b2f8d010f spirv-reader: reject sampling operations on non-float textures
Fixed: tint:350
Bug: tint:109
Change-Id: I754ff4ade03dabb70a1eb5706a65c48a0a7d35a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35581
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-14 20:34:37 +00:00
Ben Clayton d408f2465a Remove BlockStatement::insert()
Bug: tint:396
Bug: tint:390
Change-Id: I719b84804164fa801ded505ed56717948f06c7a7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35502
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:31:17 +00:00
Ben Clayton db5ce658b5 Remove BlockStatement::append()
Bug: tint:396
Bug: tint:390
Change-Id: I3b558a8961f9890f24d1aa3d6647ec095e5fe1cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35421
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:25:27 +00:00
Ben Clayton ed70caf6a5 Improve error messages raised by SpvParserTest
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);

is a less-idiomatic way of writing:

    EXPECT_EQ(xxx, yyy);

The latter also provides a diff when two strings do not match.

Refactor these to:

    auto got = xxx;
    auto expect = yyy;
    EXPECT_EQ(got, expect);

So that the error message clearly shows which one is the generated, and which one is the reference.

Change-Id: I781437ee63abdff3a67798b09e958be603c21313
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35507
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:16:29 +00:00
David Neto f9e8da1d06 spirv-reader: convert unsigned ConstOffset
Bug: tint:109
Fixed: tint:348
Change-Id: Ie3d1a6b6276ccb5184c5138d38931f7674324d59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35580
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-14 19:50:49 +00:00
Ben Clayton b833f1572b reader/spirv: Remove use of BlockStatement::append()
Introduce `StatementBuilder`s , which may hold mutable state, before being converted into the immutable AST node on completion of the `BlockStatement`.

Bug: tint:396
Bug: tint:390
Change-Id: I0381c4ae7948be0de02bc13e54e0037a72baaf0c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35506
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-14 19:48:47 +00:00
David Neto 2353bd0d3d spirv-reader: convert coordinate type when unsigned
In SPIR-V, coordinates for ImageRead, ImageFetch, ImageWrite are
integral.  When they are unsigned, they must be converted to signed.

Fix tests for image sampling and dref sampling that used integer
coordinates. SPIR-V requires them to be floating point.

Bug: tint:109
Fixed: tint:346
Change-Id: If33c8970b9d8f7d934d3e582194fe6ed83eff7e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35560
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-14 17:31:37 +00:00
dan sinclair 24bbbbb25f Add Symbol to struct type.
This CL adds a Symbol to the struct type along side the name. The name
will be removed in a future CL when the symbol is used everywhere.

Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-14 16:01:37 +00:00
Ben Clayton bcf37549c8 ast: Remove Struct constructors that don't take a Source
And swap the `decorations` and `members` parameters, as decorations come last for other constructors.

Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9b814c1de24b6c987f0fbb9e6f92da7c352caa2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35163
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 12:52:44 +00:00
Ben Clayton 4543d1a232 ast: Remove StructMember constructor that doesn't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9f8f7428d2308c3b1a9a8d2137e2e3c6d1d13e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35162
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 12:18:04 +00:00
Ben Clayton bbefff63a3 ast: Remove statement constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 11:58:44 +00:00
Ben Clayton 1ff59cd0e2 ast: Remove expression constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I7f823e2489101b43c1b21a6b89c248695a3f35b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35160
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:38:13 +00:00
Ben Clayton 5ed161b2d9 ast: Add Source argument to literals
Bug: tint:396
Bug: tint:390
Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:35:43 +00:00
Ben Clayton 604bc72dd9 ast: Remove Node::set_source()
All nodes that don't have a Source constructor will need to have one added.
We can then find all missing Source mappings with a search for `Source{}`

Bug: tint:396
Bug: tint:390
Change-Id: I06f9689d4da0f3fd1bd757c7358dcc65f15dc752
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35018
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:24:53 +00:00
dan sinclair 4226b6a1d8 Add Symbol to alias.
This CL adds a Symbol alongside the name in the Alias type. The name
will be removed in a future CL.

Change-Id: I23fa77566cc7a2aead783b64c34c0cc3195df24b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35461
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 19:35:03 +00:00
dan sinclair 6b59bf45aa Add a symbol to the Identifier AST node
This CL adds a Symbol to the identifier to represent the name. The name
still exists but will be removed in a future CL when the namers are in
place.

Change-Id: Ic3cc8ad0d99e3bea6eb1ff1ce212e7de67991aec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35460
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 19:16:13 +00:00
David Neto 5b3c9f1c62 spirv-reader: refactor, add ToI32 helper
- The create function is available locally without needing
  to go through ast_module_.
  But go through ast_module_ during member initialization.
- Add ToI32 helper.
  - Use it during possible conversion of the sample index

Bug: tint:3
Change-Id: I8224119f780486d769697910dfa3dd9fb5413259
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35541
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 18:35:43 +00:00
dan sinclair a41132fcd8 Add a symbol to the Function AST node.
This Cl adds a Symbol representing the function name to the function
AST. The symbol is added alongside the name for now. When all usages of
the function name are removed then the string version will be removed
from the constructor.

Change-Id: Ib2450e5fe531e988b25bb7d2937acc6af2187871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35220
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-11 18:24:53 +00:00
David Neto cd9e5f6e91 spirv-reader: Support multisampled textures
Only ImageFetch is supported.

Converts the signedness of the sample operand as needed.

Bug: tint:109
Bug: dawn:399
Change-Id: I1d00ff4452af123457bb1841d872afcf2c591c48
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35540
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-12-11 18:19:33 +00:00
Ben Clayton a80511e021 ast: Merge DecoratedVariable into Variable
Remove all Variable setters (with exception to set_storage_class() which is called by the TypeDeterminer)

Bug: tint:390
Change-Id: I172667e21e2b02e85dcea6703aa1e608ec718250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35015
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-11 13:07:02 +00:00
David Neto ccc67252ff spirv-reader: support OpBitCount, OpBitReverse
Bug: tint:3
Change-Id: I81580136621ab51a9852e1d692ddad2457b9aab9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35340
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 18:51:51 +00:00
David Neto 287f6f12ef spirv-reader: support more integer builtins
Support:
 - SAbs
 - UMax, SMax
 - UMin, SMin

Add tests for operand and result conversion for UClamp.
SClamp was already tested.

Bug: tint:3
Change-Id: I9b9278843ca5243991b330b27764756137da4ee4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35302
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-10 15:22:51 +00:00
David Neto 3ca59444cd spirv-reader: remove redundant disabled test
Testing result signedness conversion was already covered
in https://dawn-review.googlesource.com/c/tint/+/35180

Change-Id: I2f7b1caf512ceb81fbe2ea6a2037de61dea25c96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35360
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 15:22:11 +00:00
David Neto 5213c400eb spirv-reader: convert signedness of texturing result when needed
Fixed: tint:382
Change-Id: I786e1f5d5d122a82ef29c733e514bf3b45651c5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35180
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 17:09:50 +00:00
Ben Clayton 7f04e5c1e2 Implement textureLoad()
Bug: tint:140
Bug: tint:143
Bug: tint:144
Bug: tint:145
Bug: tint:146
Bug: tint:147
Change-Id: I8f41abac2e355c121e8868aa708ae51d0db87665
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34960
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 15:57:00 +00:00
David Neto 350330bb46 spirv-reader: Fix signedness for extended instructions
SClamp is the only implemented instruction that is affected, so far

Bug: tint:405
Change-Id: I21c1cdd3e70fc3a64046f0473569ba906048cd37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35240
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:18:36 +00:00
David Neto 6ff8cdb991 spirv-reader: support ldexp
Bug: tint:3
Change-Id: I6a9204b19c5b4d631634b9a585a0081eaead9c1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35046
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:13:46 +00:00
David Neto 195917c0be spirv-reader: Support many more float builtins
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Fixed: tint:214
Change-Id: I10f7df66875ccda968fc5654b4f1c1d3a6ac23ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35062
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 14:29:03 +00:00
David Neto eb7865cd0d spirv-reader: Support NClamp, NMin, NMax
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Change-Id: I48503be68128d2a0659bef7057e890cb9c0617ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35080
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 23:45:47 +00:00
Ben Clayton 8b0ffe9185 ast::type: Remove Array::set_decorations
Move to constructor

Bug: tint:390
Change-Id: If6c65b7305db7f9977c0cc9884a8f551e07de050
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35014
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-07 22:19:27 +00:00
Ben Clayton 602c025aa0 ast: Remove Function::set_body()
Bug: tint:390
Change-Id: I525086868c6470ba39fe8c4ede7390e74c9489ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35012
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:17:47 +00:00
Ben Clayton d0dda258cc ast: Remove ReturnStatement constructors that don't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I2b81929e362ccf75145ebc45028dd973a77ae068
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35010
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:09:57 +00:00
Ben Clayton 321e5a9d7e ast: Remove Variable constructor that doesn't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:08:07 +00:00
David Neto b4b29639a1 spirv-reader: simplify GLSL.std.450 tests
Use variables with names rather than constants
which elaborate to a lot of text in the AST.

Change-Id: Ic284bbd4019e50308c5836768df01c6a9525c004
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35061
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 21:02:27 +00:00
David Neto 201fa87a6d spirv-reader: list missing GLSL.std.450 instructions
Add a TODO for them

Change-Id: I038e4384ae44d87544ae040b2e5ba193415e01b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35060
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 20:55:07 +00:00
Ben Clayton 234b7de460 ast/function: Remove [set|add]_decorations()
Move them to the constructor

Bug: tint:390
Change-Id: I30bb6a1de060b790bf5202194d020d4e3889a307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35008
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:45:14 +00:00
Ben Clayton 9838768599 ast: Remove IfStatement::set_else_statements()
Move it to the constructor.

Bug: tint:390
Change-Id: Ib4ac1a1c83aa59963472ac7c14c9e0cbcf2734e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35007
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:11:24 +00:00
David Neto 4d6635858e spirv-reader: support UClamp, SClamp
Fixed: tint:383
Change-Id: I101370a82379363a4fb1f725e010eedc2da059ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35042
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-07 19:53:54 +00:00
David Neto 4f8b96e13c spirv-reader: texture level and array index are signed
Fixed: tint:394
Change-Id: Ic81c7167d65e7a8d09363a62848b74928fdc2798
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35043
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-07 18:17:14 +00:00
dan sinclair c35176eadf Remove the context object.
This CL strips the context object out of Tint.

Change-Id: Id0dcb9c557b217c03a8d9ac08fc9fe1c799f3fdc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34742
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 16:03:54 +00:00
Ben Clayton bd018d254d Improve error messages raised by SpvParserTest
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);

is a less-idiomatic way of writing:

  EXPECT_EQ(xxx, yyy);

The latter also provides a diff when two strings do not match.

Refactor these to:

  auto got = xxx;
  auto expect = yyy;
  EXPECT_EQ(got, expect);

So that the error message clearly shows which one is the generated, and which one is the reference.

Change-Id: I299204a615aa3e68cd82d19ce892ab33aabe2f08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35006
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 15:57:04 +00:00
dan sinclair 685cb02ea8 Remove internal usage of Context.
This CL removes all internal usage of the Context object. It is still
accepted as a parameter until we update Dawn, but all usage is removed.

The namer has been removed from the SPIR-V backend with this change and
the emitted names reverted to their non-modified version.

Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-02 21:17:58 +00:00
dan sinclair 573d8939f4 [ast] Remove more set methods.
This CL updates the SPIRV-Reader to not require set methods for various
AST expressions.

Change-Id: Ieb9a8fcc1746d3051e5b663559127ca63b45a388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34642
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-02 19:13:48 +00:00
Ben Clayton c15d0a73ee Unrevert "[ast] Remove unused constructors and setters".
Hopefully the trybot issue is now resolved.

This reverts commit 5792783e72,
unreverting commit 4d28b27935.

Change-Id: I2855bf17c5025a3d349e7fce16fdca342517aad3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34564
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 18:48:58 +00:00
Austin Eng 41083cbca4 spirv-reader: Fix bug with passing stack-allocated variable
When handling OpCompositeExtract, the SPIRV reader uses a
stack-allocated U32 type instead of one heap allocated by the
type manager. This causes type determination later to dereference
a garbage address.

Change-Id: I7d60b6dbf8310e53565d7db47eac4dd92b1bbfa0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34684
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-12-02 16:30:38 +00:00
Ben Clayton f8971ae74d Fixup all doxygen tags
We've been using |blah| in various places to markup code, however this is not doxygen markup. So instead:

* If the code links to a parameter, use `blah`.
* If the code links to a member field, use #blah.
* If the code links to a method use blah().
* If the code is somewhere unlinkable use `blah`.

Change-Id: Idac748a4c2531b5bae77e1a335e3d3ef6fab48b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33787
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-02 15:31:08 +00:00
dan sinclair 5792783e72 Revert "[ast] Remove unused constructors and setters."
This reverts commit 4d28b27935.

Reason for revert: Seeing weird build breakage ...

Original change's description:
> [ast] Remove unused constructors and setters.
>
> This CL removes unused default constructors and various set methods
> from the AST classes where they are not longer required.
>
> Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com

Change-Id: I9d5bf6fd6d47131650c964cad4e17a1cbe86b040
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34682
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 15:18:59 +00:00
dan sinclair 4d28b27935 [ast] Remove unused constructors and setters.
This CL removes unused default constructors and various set methods
from the AST classes where they are not longer required.

Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 14:31:38 +00:00
Ben Clayton 1b6a8ce165 Post migration to castable cleanup
Change-Id: I5c47b1736bd850548cb1c9c7a6f69242d8626173
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34460
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-01 21:07:27 +00:00
David Neto 782f6a5e3e spirv-reader: support textureLoad
Both OpImageRead and OpImageFetch map to WGSL textureLoad.

Bug: tint:109
Change-Id: I3c99840c2e62c52dcaaf7177773a3c972de90cc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34425
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-01 20:37:37 +00:00
David Neto 91ad3961df spirv-reader: support textureStore
Fixes: tint:381
Change-Id: I401cebcd94b92365037228e0bd50b67bc8d12ab8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34424
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-01 20:33:07 +00:00
dan sinclair 2478ae78bb [wgsl-reader] Remove keywords which aren't in spec.
This CL updates the WGSL-Reader to remove the decoration keywords as
they are no longer reserved in the spec. The old `::` token is removed
as well as namespaces don't exist anymore.

Change-Id: I1dfa16c1d7e4866f6c2f9ea7b4f93a48ff5a23d7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34481
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-01 20:10:47 +00:00
Ben Clayton f1b0e1ee57 ast/type: Remove Type suffix from all types
They already exist in a `ast::type` namespace, so `ast::type::BlahType` is just stuttering.
This is more important now that Is<> and As<> use the full type name.

Change-Id: I7c661fe58cdc33ba7e9a95c82c996a799786661f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34321
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton acf7643518 Replace Literal::(Is|As)* with Castable
Change-Id: I842483890b369d63c23dba475b6738bffe5cfdbd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34319
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton aedca4288c Replace Variable::(Is|As)* with Castable
Change-Id: I7a49287af079d53cee095fa2243dd21757546b56
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34318
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00