Commit Graph

8203 Commits

Author SHA1 Message Date
Ben Clayton 727503d205 tint/resolver: Pass std::function by ref
Avoids a copy

Change-Id: Ief4e7985b41c50f102be27a8a3fa9a690166511f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116868
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-14 18:09:17 +00:00
Antonio Maiorano ee665a4240 tint: add precise float mod polyfill and enable it for HLSL
HLSL's % operator results in less precise results than expected.

Bug: tint:1799
Change-Id: I1a9572288a0e536f0fc9c0748a25dcf58551e57b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119760
Kokoro: Kokoro <noreply+kokoro@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-02-14 16:12:59 +00:00
Ben Clayton 971318f7a2 tint: Replace all remaining AST types with ast::Type
This CL removes the following AST nodes:
* ast::Array
* ast::Atomic
* ast::Matrix
* ast::MultisampledTexture
* ast::Pointer
* ast::SampledTexture
* ast::Texture
* ast::TypeName
* ast::Vector

ast::Type, which used to be the base class for all AST types, is now a
thin wrapper around ast::IdentifierExpression. All types are now
referred to using their type name.

The resolver now handles type resolution and validation of the types
listed above based on the TemplateIdentifier arguments.

Other changes:
* ProgramBuilder has undergone substantial refactoring.
* ProgramBuilder helpers for type inferencing is now more explicit.
  Instead of passing 'nullptr', a new 'Infer' template argument is
  passed.
* ast::CheckIdentifier() is used for more tests that check identifiers,
  including types.

Bug: tint:1810
Change-Id: I8e739ef49435dc1c20a462f3ec5ba265661a7edb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118723
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-14 13:52:43 +00:00
Ben Clayton 03b09f1099 tint/sem: Add FunctionExpression
Will be generated for expressions that resolve to functions.

Bug: tint:1810
Change-Id: I334729c9499be7b1c4ab229c1845a4d5f06fa107
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119701
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-14 00:33:43 +00:00
Jiawei Shao 7c2fa23a7e Implement the optional feature "bgra8unorm-storage" on D3D12
This patch adds the support of the optional feature "bgra8unorm-storage"
on D3D12 when the platform allows using DXGI_FORMAT_B8G8R8A8_UNORM as
UAVs.

According to D3D12 documents, enabling the flag
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS when creating textures requires
"either the texture format must support unordered access capabilities at
the current feature level. Or, when the format is a typeless format, a
format within the same typeless group must support unordered access
capabilities at the current feature level".

Bug: dawn:1641
Test: dawn_end2end_tests
Change-Id: If16271b5da52423e73ad4f7ba258af83dbf66dd2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119345
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-14 00:29:52 +00:00
Jiawei Shao 01456d97ea Implement the optional feature "bgra8unorm-storage" on Vulkan
This patch implements the optional feature "bgra8unorm-storage" on
Vulkan. As SPIR-V doesn't support 'bgra8' as a valid image format,
we have to create an image view with RGBA8Unorm format on the
BGRA8Unorm texture when we want to use it as a storage texture.

Bug: dawn:1641
Test: dawn_end2end_tests
Change-Id: I4aeea96ae872fe4e6367c535afb6ab896b952453
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118021
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-02-14 00:27:34 +00:00
Ben Clayton a5b9e96b39 tint/reader/spirv: Work around pointers to null store types.
Bug: tint:1838
Change-Id: I84564a1b9888634808af2a1c7bb1e77c80947216
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119700
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2023-02-13 21:22:21 +00:00
Austin Eng 151913d29b VideoViewsTests: add test which uses a sampler per plane
This test sees flaky failures.
 - Check the entire checkerboard texture contents to get more
information.
 - Add a test which uses seperate sampling states to see if DX12
driver has difficulty sampling multi-planar formats using a
single sampler.
 - Also, double check support for the NV12 format in case
something in the driver flakily exposes support.

From https://dawn-review.googlesource.com/c/dawn/+/47660

Bug: dawn:733
Change-Id: I766907ff648f1dc35387902a70c3fb65debcaecd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119343
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
2023-02-13 18:35:04 +00:00
Austin Eng 44032e5084 Unblock multi-mip stencil textures on Metal
These textures still have some outstanding issues on both Intel and AMD,
where the wrong subresource can be read from.
Zero-initialization workarounds have been enabled to ensure that even
when the wrong subresource is read, uninitialized data is not read.

Bug: dawn:704, dawn:791, dawn:838
Change-Id: Ib118eff0c5ed5e7812fa70e88ece5317c1af13b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116849
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-02-13 18:04:00 +00:00
Austin Eng 20881f39e7 Add basic Adapter blocklist
Adds a basic adapter blocklist and adds two cases to it.

By default, the blocklist is disabled until Chromium can enable it
explicitly - perhaps based on --enable-unsafe-webgpu or some other
flag. It will be switched to default to true in the future.

about://gpu would disable the blocklist so all the adapters are
visible there, but WebGPU would enable it. Trusted users of Dawn
that are aware of potential bugs may also disable it.
One downside is that about://gpu won't surface directly that an
adapter is on the system, but blocklisted for WebGPU. Something
like that can be added in the future, if necessary.

In the future, this should probably be merged with Chromium's
software_rendering_list.json, but that list doesn't support
multi-adapter systems well (for blocklisting just one adapter),
and it doesn't understand all the information we need for the
current blocklist.

Bug: dawn:1254, dawn:1196, tint:1753
Change-Id: I992bcd10dd5d3f5b23319fc4ec699b06bb1117da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119061
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-13 17:10:44 +00:00
Li Hao 9ee3c7afcc Fix timestamp period for timestamp-query-inside-passes on Metal
Still a missing condition to enable timestamp period calculation at
device initialization on Metal.

Refactor GPUTimestampCalibrationTests.cpp to check timestamp query
correctness on both D3D12 and Metal backends.

Bug: dawn:1193
Change-Id: I69feeaea0df309e15c008647d76b11899dcdc727
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-02-11 09:30:38 +00:00
Jiawei Shao f5cee3fadf Enable the optional feature bgra8unorm-storage on Metal
This patch adds the support of the optional feature "bgra8unorm-storage"
and enable it on  Metal.

Bug: dawn:1641
Test: dawn_end2end_tests
Change-Id: Id58cefd8735f46b8d1807376ebcfada10df2890e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111380
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-02-11 02:53:53 +00:00
Austin Eng 2c8bea1f9e Add a toggle to keep Metal depth stencil textures initialized
To avoid uninitialized reads of depth stencil data, where the Metal
driver incorrectly binds/loads the wrong depth stencil subresource,
always keep all depth stencil subresources initialized. This means
that textures are initialized on creation, and StoreOp::Discard is
never used - Store is used instead.

Texture initialized state is still set as-if the Discard occured, so
Dawn will try to zero-initialize the subresource if it is read from.
In many cases, this will work correctly, and the application will
read back 0, as expected. In some cases, Metal will bind the wrong
subresource, and the previous contents will be read. This is wrong,
but at least it is not uninitialized data.

Bug: dawn:838
Change-Id: I3cc87073d52de60283e3b683bbee7809db803018
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119344
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-11 00:00:12 +00:00
Ben Clayton 1131d31761 tint/ast: Remove ast::StorageTexture
Instead use ast::TypeName.

Also improve the validation and diagnostics around providing template
arguments to types that do not accept them.

Bug: tint:1810
Change-Id: I4241d50ce0425ab721157686889e918993482876
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119284
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-10 19:24:24 +00:00
Ben Clayton c66b5e6922 tint/resolver: Fix null dereference
When performing binary / unary ops with non-value expressions.

Bug: chromium:1414658
Change-Id: I7b92f63890da1d9e20e7a1f692fe1fcd28a6f79d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119481
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2023-02-10 15:54:54 +00:00
Corentin Wallez e268e5b854 BackendVk: Remove VVL suppressions for a fixed VVL issue.
Fixed: dawn:1627
Change-Id: I7949c0604b1aa5f96f22c9191413485f6226e270
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119480
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-02-10 15:54:04 +00:00
Antonio Maiorano ec20758675 tint: polyfill remainder to handle negative operands
Bug: tint:1802
Change-Id: Ie9baa045feda08523e5ca4f5ce94b6db7d4477e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119100
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-10 15:01:02 +00:00
Ben Clayton a5fec206c9 tint/ast: Remove ast::DepthTexture and ast::DepthMultisampledTexture
Instead use ast::TypeName.

Bug: tint:1810
Change-Id: Id9fe641d193967cb27cea97e9c25b75c5fe2f1a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119122
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-10 02:34:21 +00:00
Zhaoming Jiang 63b777b552 Dawn: Refactor device toggles
This CL refactor the logic adapter creating device toggles set when
creating device and the way device holding its toggles. This CL also
introduce the concept "toggle stage", currently "device stage" only but
in future will add "instance stage" and "adapter stage" for instance and
adapter toggles. No changes on Dawn API.
More details:
1. Introduce `TogglesState` objects that represent the complete toggles
   state of a device (and will used for instance and adapter in future).
2. When creating a device, adapter set up a TogglesState object for it
   in `AdapterBase::CreateDeviceInternal` and
   `Adapter::SetupBackendDeviceToggles`, no other place would change
   the device's toggles state. This change simplify the logic.
3. Introduce the `ToggleStage` enum for every toggle and `TogglesState`
   object. Currently we only have `Device` toggle stage, but in future
   will have `Instance` and `Adapter` for instance and adapter toggles.

Bug: dawn:1495
Change-Id: Ifafac6a6a075b5b9a733159574ae5b6d4f3ebde9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118030
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2023-02-10 01:43:55 +00:00
Ben Clayton 4906b03963 tint/ast: Remove ast::ExternalTexture
Instead use ast::TypeName.

Bug: tint:1810
Change-Id: Ia1ae61b2bffd386f8958c8164e2223df5f8ac91c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119121
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-09 23:59:07 +00:00
Ben Clayton ed3389faee tint/ast: Remove ast::Sampler
Instead use ast::TypeName.

Bug: tint:1810
Change-Id: Ia2641d661cab70d110c975d5f0d0e76628816cb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119120
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
2023-02-09 23:56:42 +00:00
Ben Clayton 6e0a51521f tint/ast: Remove scalar types from ast::*
Instead use ast::TypeName for all of these.

Bug: tint:1810
Change-Id: Ie51a69bf40648a9da73c0a1de2cd96a93d4eac76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117892
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-09 23:33:24 +00:00
Ben Clayton eb30a0ddee tint/resolver: Fix validation of type constructor without assignment
Tint used to validate that type initializers and conversions were not
used as statements. The WGSL specification has been recently updated to
allow this, but Tint requires more work to correctly handle these as
statements.

For now, restore the validation.

Bug: tint:1836
Bug: chromium:1414489
Change-Id: I9f6aabece26c30b0a0d789ae0dfa10d6f43ee4dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119360
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-09 23:19:42 +00:00
Bruce Dawson 0755fdbc8f Use $windows_sdk_version instead of constant
Dawn was using a hard-coded constant for the Windows SDK version number
but that makes upgrading the Windows SDK to build Chromium impossible.
This change uses the newly created $windows_sdk_version to solve this
problem.

This new variable was added in crrev.com/c/4234366

Bug: tint:1719
Change-Id: I6a9f74f542d3517c046d74178a41e1e4d5887e7f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119340
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-02-09 22:44:31 +00:00
Ben Clayton 031e2f5585 tint/resolver: Resolve builtin enumerators
'address space', 'access' and 'texel_format'

Bug: tint:1810
Change-Id: If471912fcef57f7579d76c8c4edd663d1c0311ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119125
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-09 15:35:27 +00:00
Ben Clayton 0ddddb00cb tint/resolver: Start handling sem::Expression
Change Resolver::Expression() and Resolver::Identifier() to return a
sem::Expression instead of a sem::ValueExpression.

This is required as IdentifierExpressions may resolve to non-values.

Handle expressions that resolve to types, when they are expected to
resolve to a value.

Bug: tint:1810
Change-Id: I1cb069e3e736fc85af7bc395b388abe153b1f65a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-09 15:35:27 +00:00
Ben Clayton 4e4cada291 tint/transform: Simplify Renamer transform
Take advantage of the fact that all AST nodes now use an
`ast::Identifier` instead of directly using Symbols.

This will be important for ensuring that un-keyworded identifiers will
be preserved.

Bug: tint:1810
Change-Id: If5c3e9f00b4c1c14a6f11bd617bd8b895250fb7e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119285
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-09 15:35:27 +00:00
Ben Clayton f973d514a1 tint: Add ast::CheckIdentifier() test helper
A bunch of template magic to recursively test that an identifier (and
template arguments) matches the given values. Will be heavily used for
AST and parser tests.

Bug: tint:1810
Change-Id: I8d83090352c345f0ce1ac7840e163eea96eac8a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119124
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-09 11:59:47 +00:00
Ben Clayton b75252b7aa tint/ast: Change TypeDecl::name to an ast::Identifier.
The goal here is to have all AST nodes use an identifier instead of
symbols directly. This will greatly simplify the renamer transform,
and gives the symbol a Source location, which is helpful for
diagnostics and tooling.

Change-Id: I8b3e05d05886c6caa16513a5cfb45d30f7a8d720
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119283
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
2023-02-09 10:34:14 +00:00
Ben Clayton 651d9e2558 tint/ast: Change Variable::symbol to Variable::name
Variable::name is an ast::Identifier.

The goal here is to have all AST nodes use an identifier instead of
symbols directly. This will greatly simplify the renamer transform,
and gives the symbol a Source location, which is helpful for
diagnostics and tooling.

Change-Id: I71fe3e8df3d22b12d4a3430c41f236ddf5bc0b9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119282
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-09 10:34:14 +00:00
Ben Clayton 199440e37c tint/ast: Change StructMember::symbol to StructMember::name
StructMember::name is an ast::Identifier.

The goal here is to have all AST nodes use an identifier instead of
symbols directly. This will greatly simplify the renamer transform,
and gives the symbol a Source location, which is helpful for
diagnostics and tooling.

Change-Id: I1156653a48b02997ec0a9077b174401f65a13457
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119281
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-09 10:34:14 +00:00
Ben Clayton ce31d187ef tint/ast: Change Function::symbol to Function::name
Function::name is an ast::Identifier.

The goal here is to have all AST nodes use an identifier instead of
symbols directly. This will greatly simplify the renamer transform,
and gives the symbol a Source location, which is helpful for
diagnostics and tooling.

Change-Id: I723a9a104668758db2cb32051efa1f6d3c105913
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119280
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-09 10:34:14 +00:00
Ben Clayton 057a733758 tint: Allow IdentifierExpressions to be templated
Required for nested template arguments, like `array<vec2<i32>, 2>`

Bug: tint:1810
Change-Id: Ibf24ec8918ef7698232cb2ea0cb786144d6f0604
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119123
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-08 23:29:28 +00:00
Yunchao He 2d41a015d7 Report error immediately if pass ends twice
The previous code reports error till command encoder finish.

This change also updates webgpu-cts expectations.txt accordingly.

Bug: dawn:1578

Change-Id: I1fe758a02d9cfdb1440e3cabf10aea0bd60b9c59
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116842
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2023-02-08 22:04:10 +00:00
Brendon Tiszka d0b284b00b Add Dawn Wire Server LPM Fuzzer [1/N]
Add scaffolding for structured Dawn wire fuzzer.

This CL contains a basic fuzzer for Dawn wire server
that shows some simple design ideas:

1) A basic protobuf spec that is generated using dawn.json
2) conversion from protobuf message to a dawn wire server
command.

This is not the complete implementation and serves as a
foundation for the fuzzer so that subsequent CLs will be
easier to review.

Bug: chromium:1374747
Change-Id: Ife1642dda13d01d3308bdd5fe56cf85978399fd3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109406
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brendon Tiszka <tiszka@chromium.org>
2023-02-08 20:43:18 +00:00
Ben Clayton cf0e9301b2 tint: Improve the output of DependencyGraph
Add ResolvedIdentifier to hold the resolved AST node, sem::BuiltinType
or type::Builtin.

Reduces duplicate builtin symbol lookups in Resolver.

Bug: tint:1810
Change-Id: Idde2b5f6fa22804b5019adc14c717bebd8342475
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119041
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-02-08 15:18:43 +00:00
Ben Clayton 9e36723497 tint: Rework TypesBuilder::array() to take attribute list
Instead of having the stride be yet another integer argument, make the
stride explicit by adding an attribute list parameter. This is more
consistent with other nodes.

Bug: tint:1810
Change-Id: I916d810f29afd172b878ded48b6701e8b299b13f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119040
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-08 14:17:37 +00:00
Ben Clayton 5b50790d70 tint/reader: Use ProgramBuilder helpers
Eases the migration to unkeywording types.

Bug: tint:1810
Change-Id: If9ccdbf963550774b85b8cd15df8e37c271cde93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118987
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-08 12:35:19 +00:00
Ben Clayton 35089ee437 tint: Use ProgramBuilder::Bitcast()
Change-Id: I3187027c8d24cfc0a18ed317a6586037346c97a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118986
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-08 01:11:27 +00:00
Loko Kung 831ff0e39d Deprecates clearColor, clearDepth, and clearStencil values.
- Removes remaining usages of the values in Dawn and removes tests.
- Note that the values will be removed from the JSON entirely in
  follow up CL after Chromium side changes.

Change-Id: I30ccb3c412cd97047065ad515f6a5ff4de642420
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117593
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2023-02-07 23:51:11 +00:00
Ben Clayton d775a26d82 tint: Use ProgramBuilder::CallStmt()
Change-Id: I963d1c859b5bbb8d86f67194e7c0963dfc0e5b29
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118985
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-07 21:28:09 +00:00
Ben Clayton 1ebada0dad tint: Use ProgramBuilder::Return()
Change-Id: I2de08d2d9274b0a849e44a5dafbeaf2a731318ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118984
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-07 21:28:09 +00:00
Ben Clayton 6adb65c488 tint: Use ProgramBuilder::Discard()
Change-Id: If71a771a65510ec7daa003f02958002d3fa83e3b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118983
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-07 21:28:09 +00:00
Ben Clayton 17aa653fa9 tint: Remove body_attributes param from ProgramBuilder::Func()
This belongs on Block(), not Func().

Also make Func() smarter about the `body` argument, allowing the caller
to pass an ast::BlockStatement*, ast::Statement* or nullptr.

Change-Id: I8ac6c1598b37f2a94615b452c5eb37671b4305fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118982
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-07 21:28:09 +00:00
Ben Clayton 1906857a50 tint: Remove ast::Void
WGSL does not have a void type. Functions that do not return a value
simply omit the return type from the function signature.

Change-Id: Id45adc008dce46115552e7dc401a2e27ae10eeb4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118981
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2023-02-07 21:28:09 +00:00
James Price d9c0f2178d tint/resolver: Make pointer aliasing a hard error
Fixed: tint:1675
Change-Id: I620ac9854395b35acd8d42090f854e37360983db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119001
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-07 19:40:01 +00:00
Ben Clayton 01ac21cc9a tint: Rename ProgramBuilder::Construct() to Call()
Once all ast::Type derived classes are removed, there will be no
distinction between a type initializer / conversion and a function call.

Bug: tint:1810
Change-Id: Ic10fd1a0364a564d24dbe2499af0f1424641596c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118980
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-07 16:14:25 +00:00
Jiawei Shao c272282e97 D3D12: Allocate renderable 2D textures as committed resources on Intel GPUs
This patch adds a workaround on Intel Gen9.5 and Gen11 GPUs to always
allocate renderable 2D textures as committed resources instead of
placed resources to mitigate a driver bug about CreatePlacedResource().

Bug: dawn:1628
Change-Id: I38062115d94933bd58e571c812ff6888e9781df6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100640
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-02-07 15:09:58 +00:00
Ben Clayton ad73301856 tint/type: Rename ShortName to type::Builtin
These will include the builtin language types.

Bug: tint:1810
Change-Id: I695a9ee833e1035eb1d17913d709038ae4c561d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118502
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-02-07 13:35:58 +00:00
Peng Huang fd1e8a44f2 [GL] track buffer usage
With this CL, GL backend and other backends will use the similar way
to track buffer usage, so the GL MapAsync(Write) will not synchronize
GL commands anymore.

Change-Id: I9f8dfeb58faaed09ed62550371a30a680cd607d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118140
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-02-06 23:29:11 +00:00
James Price fc2083a616 tint: Make CreateScalar and ZeroValue members
This avoids the need to pass the `use_runtime_semantics_` flag at each
callsite.

Change-Id: I2cce3f147226e1295b5dfa0239beeacd519d5bb4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118641
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-06 22:01:48 +00:00
James Price 40ffda4b5e tint/const-eval: Add flag to use runtime semantics
Add a flag to resolver::ConstEval to turn all overflow and range
errors into warnings, and return a valid (usually zero) value instead
of utils::Failure as defined by the WGSL spec for expressions
evaluated at runtime.

Change-Id: Icdce512306aabe717591134a1b4ba2d9c668f29c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118640
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-06 18:52:13 +00:00
Antonio Maiorano b3d5fb19bb Fix dump_shaders for Vulkan backend in CMake build
Change-Id: I6670abe2fbc77418a5923643db0d377d38212288
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118620
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-02-06 18:30:09 +00:00
dan sinclair c1799cc75a Add a `tint_info` command.
This CL adds a second command `tint_info`. The `tint_info` command can
be used to dump information about a WGSL program to the console. This
includes things like the inputs and outputs to an entrypoint along
with structure information like offsets and alignments.

Bug: 1825
Change-Id: Ia2fb4be08b39c1a592f78a388d34edf9af8b6a0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118643
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-06 16:28:37 +00:00
Ben Clayton 0b4a2f1f50 tint: Add sem::Expression
A new base class for sem::ValueExpression, which other types of
expression can derive from.

Example: sem::TypeExpression - an expression that resolves to a type.

Bug: tint:1810
Change-Id: I90dfb66b265b67d9fdf0c04eb3dce2442c7e18ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118404
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-02-05 22:59:40 +00:00
Ben Clayton ef1811a18b tint: static_assert that Sem.Get() template arg is needed
Change-Id: I91a73c22bd417fd9f32d45a1c91ffcb8f8d83d82
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118405
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-05 14:33:08 +00:00
Ben Clayton ad3156551c tint/ast: Add AccessorExpression
New base class to IndexAccessorExpression and MemberAccessorExpression.

Simplfies code that operates on both of these.

Change-Id: I02ce2e8180d7c1836f0b4d8e629e707e19e3539e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118403
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-05 12:36:50 +00:00
Ben Clayton 3fb9a3fba1 tint/sem: Rename Expression to ValueExpression
ast::IdentifierExpression may also resolve to a type or core enumerator

Bug: tint:1810
Change-Id: I85e3bea67e1146215079ec47430784f2fb39043d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118402
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-02-04 21:20:26 +00:00
James Price 98dc5a86cc tint/ast: Make DiagnosticControl a plain struct
Introduce DiagnosticDirective, which contains a DiagnosticControl
struct (as does DiagnosticAttribute).

Bug: tint:1809
Change-Id: I204001266ee472d2ee2827614a306acad53f12ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118060
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-04 12:20:55 +00:00
David Neto 85e13bcd68 spirv-reader: fix emission of INT_MIN literal
Fixed: tint:1818
Change-Id: Ieb19f874d248a3a1c11c96f5ae06c4db14e0c811
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118540
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-03 22:00:07 +00:00
Austin Eng 4dffbd3f16 Suppress RegressionDawn1083 with depth32float-stencil8 Mac AMD
Bug: dawn:1651
Change-Id: I2f8977ba5793d90419bd27cb7381fceaa4cb891c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-02-03 21:14:16 +00:00
James Price 132d8c7a7d Add flag to disable derivative_uniformity for SPIR-V ingestion
Add a chained struct for Dawn-specific options for SPIR-V ingestion to
contain this new flag.

Bug: tint:1890
Change-Id: I1332ff20c91f29a84c21550a37f11bc7d9c956ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118421
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-02-03 19:38:46 +00:00
Zhaoming Jiang 6315289ee8 Dawn: Make Adapter initialize supported feature never error
This CL make vulkan adapter checks essential Vulkan extensions and
features in InitializeImpl rather than InitializeSupportedFeaturesImpl.
This change makes InitializeSupportedFeaturesImpl never result in Error
for all backend, and this CL change the return type of
InitializeSupportedFeaturesImpl from MaybeError to void.

Bug: dawn:1495
Change-Id: If59c5aa5281776226c157451ee5119052d33ac24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118031
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-02-03 19:13:12 +00:00
Yuly Novikov 76d4892f36 Remove obsolete format of SYNC-HAZARD-WRITE-AFTER-READ messages
Bug: chromium:1412096, dawn:1225
Change-Id: I3734ad139b9e57102cbf8a7ec2bb053c491eb734
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118503
Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-02-03 18:21:49 +00:00
Ben Clayton 2117f80f8b tint: Reduce repetition for ty.type_name()
Rename the type_name() method with  operator().

`ty.type_name("blah")` becomes `ty("blah")`

Change-Id: Ia0b2bc304e7bb208c2e40a469332044b394535d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118401
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-03 14:01:43 +00:00
Ben Clayton 2cdf134b2b tint: Add ast::TemplatedIdentifier
Will be used to replace all type identifiers that take templated arguments.

Bug: tint:1810
Change-Id: I31ad8dc4826375a783143cc33f336d8a4860613c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117893
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-03 13:24:18 +00:00
Ben Clayton 89a717bacf tint: Have ast::TypeName use ast::Identifier
Consistency with the other AST nodes.

Change-Id: I8db3d237c27fea44c80101ed3d24b62832d45c18
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118360
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-03 13:22:17 +00:00
Ben Clayton 12914eedf6 tint: Have ast::DiagnosticControl use ast::Identifier
Instead of ast::IdentifierExpression.
The name is not an expression.

Fixed: tint:1257
Change-Id: I3161d20f584bfedf730b9257233f9dfcb064298a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118344
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
2023-02-02 22:20:32 +00:00
Antonio Maiorano f031ca2d44 tint/hlsl: fix assignment to matrix element
When calling the generated helper, the column and row arguments were
swapped.

Improved the unit tests to actually show this, rather than passing in a
single value for both column and row.

Bug: tint:1824
Bug: tint:1333
Change-Id: I32a92dec5e594dabd9d8d2b08474c0d6f3645520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118420
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-02-02 22:16:42 +00:00
Ben Clayton a4117ca21b tint: Have ast::MemberAccessorExpression use ast::Identifier
Instead of ast::IdentifierExpression
The member is not an expression, but a name.

Fixed: tint:1257
Change-Id: I879ddf09c3e521a18cef85422bb2f8fe78cddf5b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118343
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-02-02 20:44:53 +00:00
Ben Clayton 6cba18b0fc tint: Have ast::IdentifierExpression use ast::Identifier
The additional nesting is somewhat unfortunate for pointer
indirection overhead, but this simplfies logic like
transform::Renamer, which can continue to find all the
identifier nodes in the program.

Bug: tint:1257
Change-Id: I8d51dd80dc4c51ef59238959029b8511f1edf70d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118342
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-02-02 20:37:19 +00:00
Austin Eng 08027c662e Modernize some internal WGSL syntax
Change-Id: I4706e517608d436fa646537fec9e930ae47d1c40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118029
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-02-02 20:17:46 +00:00
Corentin Wallez 0761764256 BackendVk: Add suppressions for new formatting of VVL errors
Bug: dawn:1225
Change-Id: Icc15a8bdad48d9cabed96af62e011a531ea7f5c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118400
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-02 17:33:38 +00:00
Ben Clayton 999db74a24 tint: Have ast::CallExpression use ast::Identifier
Instead of ast::IdentifierExpression.
The name is not an expression, as it resolves to a function, builtin or
type.

Bug: tint:1257
Change-Id: I13143f2bbc208e9e2934dad20fe5c9aa59520b68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118341
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2023-02-02 15:16:28 +00:00
James Price 6e31bc24b1 tint/parser: Use = for source of assignment
Change-Id: I09ebd529fad775d0ce74fc56e2d7ff161a33f15a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118380
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-02 15:05:21 +00:00
Ben Clayton c87b1fe8c9 tint: Add ast::Identifier
An identifier node that is not an expression.

Will be used by:
* CallExpression
* DiagnosticControl
* IdentifierExpression
* MemberAccessorExpression
* TypeName

Bug: tint:1257
Bug: tint:1810
Change-Id: I1de719d8c570992fed08789c35ca6c4409789520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118340
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2023-02-02 15:04:31 +00:00
James Price 92226dbfc3 tint/reader/wgsl: Add source info to loop bodies
Also for continuing blocks.

Change-Id: Ic4a5f30fc0b882f1051c4995bd2b228c5ccc6d17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118321
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-02-02 13:01:42 +00:00
James Price f6a48ee351 tint/reader/wgsl: Add source info to compound statements
Change-Id: I251dd3d061a32042368b170ba2a38d16e8b2d9dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118320
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-02 12:40:53 +00:00
James Price 70f968d098 tint: Fix masked ParameterRequiredToBeUniform
Reset the visited state of nodes before traversing to determine a
parameters requirements with respect to the function return value,
otherwise we may not capture a parameter->retval relationship
correctly.

Fixed: tint:1822
Change-Id: I9802a89fe1c8331b2f9dae594ccb045f339396fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118080
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-02 02:28:27 +00:00
James Price 072f83c682 tint/uniformity: filter should not affect result
A derivative_uniformity diagnostic filter should not affect the
uniformity of the return value of a derivative builtin.

Fixed: tint:1815
Change-Id: I58e714978dab747598af5136dc9808a5a658c60e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118001
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-02 00:29:27 +00:00
James Price d9f659670d tint: Handle @diagnostic on block statements
Use expect_compound_statement() in all the places that use
compound_statement in the WGSL grammar.

Handle attributes on statements inside Resolver::StatementScope, so
that the logic can be reused for the various places where block
statements are used. This will also make it easier to reuse this logic
when we allow these attributes on other types of statement in the
future.

Add an `EmitBlockHeader()` helper to the WGSL writer to reuse the
logic for emitting attributes on block statements for all the places
that use them.

Bug: tint:1809
Change-Id: Iac3bb01f5031e6134c1798ddafdad080412c8bef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-02-01 23:14:10 +00:00
Austin Eng e60a579c19 Add workaround to blit depth to depth
Fixes T2T depth copies on Mac Intel where the destination
subresource is a non-zero mip/layer.

Fixed: dawn:1083
Change-Id: If344b46c3fd436d857906850fc0ac5ccb4b93e1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117592
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-01 22:49:39 +00:00
Antonio Maiorano eab1f62629 tint/hlsl: for default-only switch, only emit condition if it has side-effects
This fixes edge-cases, like the condition expression being a type-cast,
which DXC apparently sees as a variable re-declaration. Example:

fn foo(x : f32) {
  switch (i32(x)) {
    default {
    }
  }
}

was emitted as HLSL:

void foo(float x) {
  int(x);
  do {
  } while (false);
}

The `int(x)` is seen as a re-declaration of `x` by DXC.

We fix this by only emitted the condition expression if it has
side-effects (which currently means it contains a call expression).

Bug: tint:1820
Change-Id: I7e4320fa09ea2d634c9e324cb0b752b0ee7dcde9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118161
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-02-01 15:46:34 +00:00
Antonio Maiorano 635c5d0f04 tint/spir-v backend: emit OpSRem instead of OpSMod for remainder
operation

Bug: tint:1802
Change-Id: I690ef658874ba8d0d9cd8efa2a91324db175650b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118100
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-31 19:09:05 +00:00
Austin Eng 3da942086d Expand metal combined ds workaround
This workaround is needed unless the system is MacOS 13.1+
with architecture at least AMD gcn-4.

Bug: dawn:1389
Change-Id: I3a85be150a0c5ca8b0b74e4b097906f278dd3049
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118023
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-01-31 18:13:43 +00:00
Brandon Jones a5f8e8e34a Check to ensure pMessageIdName is not null
Previously we were checking against a list of skipped messages using
both the pMessageIdName and pMessage from a Vulkan debug info callback.
The spec, however, indicates that the pMessageIdName may be NULL.

This change checks to see if that value is NULL before doing any further
checks, and if so always indicates that the message should not be
skipped. (No other code in Dawn references the pMessageIdName.)

See the appropriate page of the Vulkan spec for details:
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDebugUtilsMessengerCallbackDataEXT.html

Change-Id: Idd8bf312db31d6cea8e6ce42a47254f182b1070e
Bug: chromium:1411047
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117594
Kokoro: Kai Ninomiya <kainino@chromium.org>
Kokoro: Brandon Jones <bajones@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-31 04:11:17 +00:00
Brandon Jones 574b94e566 Change External Texture Rotation To Counter-Clockwise
When rotation metadata is added to videos by ffmpeg, it is specified as counter-clockwise. Dawn should follow this format to avoid confusion during integration.

Bug: chromium:1316671
Change-Id: I99ff30bffb1664aafd060d9a5bb1b15845388386
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117912
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-30 18:26:11 +00:00
Austin Eng 00dbf0bf67 Add workarounds to blit a buffer to a depth/stencil texture
Works around issues on Metal Intel where CopyB2T and WriteTexture
with depth/stencil textures do not work correctly.
Fixes test failures with depth16unorm in the CTS.

Deletes UseTempTextureInStencilTextureToBufferCopy in favor of
the stencil blit. The former supposedly fixes a problem where
the stencil data is not flushed into the real stencil texture
by performing another T2T copy. This only works because the Metal
Intel backend also happens to allocate s8 as d32s8. Copying
the depth aspect as well seems to make the driver remember to
flush the data.
The stencil blit is a better fix for the problem since entirely
avoids getting the driver into a bad state where the stencil data
is not in sync.

Fixed: dawn:1389
Change-Id: If34b1d58996157036c164a5bc329e38b5e53f67a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117910
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-01-30 17:13:12 +00:00
dan sinclair f374b819d9 Remove `sig` deprecation.
This CL removes support for the `sig` member in `frexp`. It is now an
error if `sig` is used, the deprecation is removed.
`fract` should be used instead.

Bug: tint:1766
Change-Id: I991544b675caf31f22c8c9472a60c77811ff4efd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117920
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-30 15:34:49 +00:00
Corentin Wallez 97ad405216 Fix MSVC 14.29 errors:
- It doens't know which operator == to use when there is using
 EnumClassBitmask that looks like (a & b) == 0. Instead use just
 the form (a & b).
 - It doesn't do automatic capture of constexpr variables in lambdas so
 turn a couple constexpr into regular const.
 - It (correctly) warns that if constexpr (std::is_constant_evaluated())
 is always true, so remove the constexpr keyword.

 Bug: None

Change-Id: If7857abd1c30acb0736557844ff13f32a19d54cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117888
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Corentin Wallez <cwallez@chromium.org>
2023-01-30 14:49:27 +00:00
Zhaoming Jiang a12ff9abd1 Dawn: Deprecate DawnTogglesDeviceDescriptor with DawnTogglesDescriptor
This CL deprecates DawnTogglesDeviceDescriptor and replace it with
DawnTogglesDescriptor, which will be also used to provide instance
and adapter toggles with future CLs.

Bug: dawn:1495
Change-Id: I5f5cfdf38dcbcd237727a7f921462597b9301f1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117174
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-30 09:16:51 +00:00
Li Hao e463b1ffd7 Add the device id of Intel Raptor Lake to gpu_info.json
CopyToDepthStencilTextureAfterDestroyingBigBufferTests and
DepthTextureClearTwiceTest fail on Windows Intel Raptor Lake due to the
GPU device id is not in Intel Gen12 GPU list, so the toggle
D3D12ForceClearCopyableDepthStencilTextureOnCreation is not enabled.

Change-Id: I28ec0ad2e2fa4e351077e7c74fcbdbd43d255ed3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117173
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: yang gu <yang.gu@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-28 02:58:52 +00:00
James Price 7ce72de3a5 tint/renamer: Preserve diagnostic control names
Add a Dawn E2E test to make sure that diagnostic controls work through
the whole shader compilation flow.

Bug: tint:1809
Fixed: chromium:1410930
Change-Id: Icea31cfadbbc182008a8a07efcddb402954dd1c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117980
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-28 00:37:42 +00:00
Ben Clayton 42c5b2f675 tools/run-cts: Add --validate flag
Default to no-validation.

Change-Id: I4b3506e2addf580256175b13efbeb47f8ef96aaf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117881
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-26 16:03:08 +00:00
Ben Clayton 78e4530f59 code-coverage / turbocov fixes
Common:
* The turbocov build target (somehow) never got hooked up to the root CMakeLists.txt file. This is now fixed.

macOS:
* Emit coverage for 'AppleClang' compiler.
* Have run-cts find the tucked-away `llvm-profdata` executable.

Windows:
* Various fixes for building with clang
* Fix turbocov stdout CRLF corruption
* Fix bad JSON with backslashes

Change-Id: I481cceafe2e72b544e13168172fc1456e5df2005
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117880
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-26 15:57:27 +00:00
James Price ab52881bb5 tint/validator: Test @diagnostic on invalid places
It was already being rejected everywhere it should be, but now we
actually test this to make sure.

Bug: tint:1809
Change-Id: I07f1d24b12e9e41a162e0d19194d4897c33b5324
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117802
Kokoro: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-26 13:00:43 +00:00
James Price 2f2400bfdc tint/validator: Check for conflicting diagnostic controls
Two diagnostic controls conflict if they have the same rule name and
different severities.

This change also allows duplicate diagnostic attributes.

Bug: tint:1809
Change-Id: I7622dd947ffa03292ad3340161688e00862d5b24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117801
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-26 12:24:42 +00:00
James Price 2dbb7b4f6a tint/SingleEntryPoint: Handle diagnostic directive
Add some E2E tests to make sure that we actually produce valid code
for each backend when diagnostic filtering is present.

Bug: tint:1809
Change-Id: I5e903ac0d2ca385967211bb889f86cb85de8f418
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117590
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-26 11:31:19 +00:00
dan sinclair 1226320a5b Move ast_type.cc to type.cc.
This file is already in the ast/ folder, and has been marked as a TODO
to move for a while. Actually move.

Change-Id: I697ff903fc9906921e2768243bdfba581cf18d4e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117589
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-26 10:49:19 +00:00
dan sinclair 3076a8bf17 Add missing sem headers
This CL is based off of https://dawn-review.googlesource.com/c/dawn/+/113561
and adds the updates into `libtint_syntax_parser_src` to allow the
resolver to build correctly when the headers are added.

Change-Id: I5d14a88111ea1bf87bb2155d066b95378163e451
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117588
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-26 02:15:50 +00:00
Brandon Jones f68f2e06d7 Fix GatherDeviceInfo on Vulkan 1.0 devices
A bad assert was causing devices that only supported Vulkan 1.0, such as
the Nexus 5X, to crash when querying information about adapter
properties and features. This change removes the need for the ASSERT.

(Note that this does not guarantee WebGPU support on Vulkan 1.0 devices.
For example, the Nexus 5X does not have the fragmentStoresAndAtomics
feature, which is required for WebGPU.)

Bug: dawn:286
Change-Id: I7f884290f29ae7e9607933f6186feac2ce8af540
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117840
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-26 00:36:16 +00:00
dan sinclair 1a26e80318 Create a libtint_ast_src.
This CL moves the ast files into a libtint_ast_src source set. Similar
to sem, the headers are duplicated into the libtint_syntax_tree_src due
to the dependencies with program_builder.

This makes the sem and ast source sets be setup the same.

Change-Id: If51fac6fab6763c4dcf729061de6ef983a94063a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117587
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-25 22:40:28 +00:00
Austin Eng 97f56bd0b8 Clamp the stencil reference to 255
Fixed: dawn:1645
Change-Id: I908fe0a2cb029c7cc6cf94b066f0f842e0f1e224
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117532
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 20:57:49 +00:00
Peng Huang 8fc1758a3d Append pipeline barrier for mappable buffers for submissions
So the next MapAsync() call, doesn't need to record pipeline barrier
command into the pending command buffer, submit it, and wait for it
completion.

Bug: b/265152896
Change-Id: Ied7cbca24a7b1bc81c0a6402179452599aabfe9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116920
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 19:55:52 +00:00
Austin Eng e8870efb1b Handle Tint inspector reflection of bgra8unorm storage texture
The fuzzer produced a shader with this format and hit an UNREACHABLE
in Dawn.

Bug: dawn:1641, chromium:1410048
Change-Id: Ia5ba66a18fc718f7e6dd803f4229ecb12b02753e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117531
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 19:52:32 +00:00
dan sinclair a3e90618dc Remove libtint_core_src.
This CL removes `libtint_core_src` and folds the dependencies into
`libtint`. Uses have been updated to require the specific libraries they
depend on.

Change-Id: I91118cc9db376c53597a8e588db654b3a4105386
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117586
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 19:52:28 +00:00
dan sinclair 186fdaf815 Rename libtint_core_all_src to libtint_syntax_tree_src
This CL renames the source set to make it clear it does not include all
files in tint.

Change-Id: Ib37603ca8d46e2920d3f3c6d79a59a292493c3fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117585
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 19:22:25 +00:00
dan sinclair d108693b59 Move a few more headers to base_src.
This cl moves a couple more files up to `base_src` and splits tint.cc
out to a separate `initializer` source set.

Change-Id: I65347ac182f3434a57cc49f0eeb1024f6adb52b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117584
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-25 19:15:42 +00:00
dan sinclair b560dcdb9f Pull inspector out to gn source set.
This CL extracts the inspector from libtint_core_all_src and into a
libtint_inspector_src.

Change-Id: I0b138cc2e47526b8575b6f31cc3e15fc8bd92545
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117583
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-25 18:41:40 +00:00
dan sinclair 2da119a0ce Split constant and type out of libtint_core_all_src
This CL moves the constant and type headers out of the
`libtint_core_all_src` target. In order to do so a `libtint_base_src`
target is created with the bits of core_all that are required to build
constant/ and type/ along with all the util/ files.

Change-Id: Idb016f51e9dcaa84b6d7a14e4e5f62d4a46a4161
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117582
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-25 18:39:00 +00:00
James Price 58dd079e46 tint/resolver: Warn for unknown diagnostic rules
Suggest alternatives in the warning.

Bug: tint:1809
Change-Id: If55f162fbd44a1987b573888ca7cc02490f8b05e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117800
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 14:10:04 +00:00
James Price f629770bcd tint: Move "suggest alternatives" logic to utils
This will be used for suggesting alternative diagnostic rule names in
the Resolver.

Bug: tint:1809
Change-Id: Icc9af02937326f6f774fbaf2aeaa9314c88fdea6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117565
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-25 14:10:04 +00:00
James Price bb0229002d tint/uniformity: Violations are now errors
Switch the default severity for all uniformity violations to errors.

We now have an opt-out mechanism for deriviative operations (via
diagnostic filters), and a `workgroupUniformLoad()` builtin for
compute shaders.

Bug: tint:1809
Change-Id: I666c706d6195ca0d24ead14c4709e7f646bfcc64
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117741
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 01:24:46 +00:00
James Price f38ee3e073 tint/exe: Add --allow-non-uniform-derivatives flag
When used with the SPIR-V reader, this will insert a module-scope
diagnostic directive to suppress uniformity violations for derivative
operations.

Bug: tint:1809
Change-Id: I2305265231ccffad49461d194669ba598484e8e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117740
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 01:24:46 +00:00
James Price e657c470bd tint/uniformity: Add derivative_uniformity filter
Add additional `RequiredToBeUniform` nodes for each severity
level. When processing a call to a derivative builtin, look up the
severity from the semantic info for that AST node, and add an edge to
the corresponding `RequiredToBeUniform` node.

Propagate the severities to the callsite and parameter tags for a
function that contains a builtin.

Traverse that graph from each `RequiredToBeUniform` node to look for
violations at each severity level, starting with the most severe. Only
stop the analysis if an error is found, otherwise report the violation
and keep going.

Bug: tint:1809
Change-Id: I4ac838e85da3f4fb3d63f4892dce7f12b096f74b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117602
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 01:24:46 +00:00
James Price 5853205342 tint/sem: Record diagnostic severity modifications
Each sem::Node has a map which stores the diagnostic modifications
applied to that node. The sem::Info class provides a query to get the
diagnostic severity for a given AST node, by walking up the semantic
tree to find the tightest diagnostic severity modification. The
default severity is used if it was not overridden.

This allows components outside of the Resolver/Validator to determine
the diagnostic severity while walking the AST, which is required for
the uniformity analysis.

Bug: tint:1809
Change-Id: I4caf99d7412fb22fb1183b2c8cfde349da2fefd3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117601
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-25 01:24:46 +00:00
James Price 613fbcf79a tint: Add diagnostic and enable to ModuleCloneTest
Bug: tint:1809
Change-Id: I671440bf2b1f988eb39bd476841e92c3a7e58ae7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117600
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 23:13:38 +00:00
James Price c744a23d77 tint/reader/wgsl: Parse @diagnostic attributes
Future patches will expand the places where they can be used.

Bug: tint:1809
Change-Id: I74d87ce5164119ae1351380041f9ef4b1091d854
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117571
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
James Price 75326f88e6 tint/writer/wgsl: Handle diagnostic attributes
Bug: tint:1809
Change-Id: Id2176eff808b24bdb0e31c3eb397c32219ed59e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117570
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
James Price 8dd35110c2 wgsl/reader: Parse diagnostic directives
Bug: tint:1809
Change-Id: I9f129685f22f51f577b67050edeef8aeea0c0bc5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117569
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
James Price 02855b5060 tint/resolver: Handle diagnostic attributes on functions
Push a new diagnostic filter scope at the start of resolving a
function and process function attributes immediately.

Bug: tint:1809
Change-Id: I8a7f4a29e4b7556d0721ed28c49d795c166fea00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117568
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
James Price e8ea579bce tint/writer: Handle diagnostic directives
The WGSL writer emits them, the other writers ignore them.

Bug: tint:1809
Change-Id: I163d868005c076b8fd4602f13d3e267b16c474c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117567
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
James Price 81e55754e1 tint/resolver: Handle diagnostic directives
The Resolver parses the diagnostic rule and sets the updated severity
in a ScopeStack, which is stored in the Validator.

Automatically generate the diagnostic rule enum and its parsing logic
using intrinsics.def.

Add a "chromium_unreachable_code" diagnostic rule to test this.

Bug: tint:1809
Change-Id: Ia94db4321b8019f01d31a84da0fda25dfdf72f5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117566
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-24 21:01:36 +00:00
James Price 098e3d8f90 tint/dependency_graph: Handle diagnostic controls
Bug: 1809
Change-Id: I376d0758a09463b37e2d71040cc8add5897ef8bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117564
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
James Price 15bf15d55f tint/ast: Add global diagnostic controls to Module
Bug: tint:1809
Change-Id: I363abc60597a6c340d5a4b4d147fa7f5747c2d9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117563
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 21:01:36 +00:00
Ben Clayton 7d2b192439 tint: rename template argument token strings
Drop the `(opening|closing template argument list)` bit. It makes for messy diagnostics.

Change-Id: I92d29ece8a012362dd16da297089aab908571415
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117213
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
2023-01-24 19:31:51 +00:00
Ben Clayton f0d8edecee tint: Fix x86 build
Fixed: tint:1813
Change-Id: I97b7c0c0a4bfdda2f7e63983caddcfb3a1e19c2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117215
Reviewed-by: dan sinclair <dsinclair@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-24 19:29:54 +00:00
Ben Clayton 355b70d2be tint/reader/wgsl: Use ClassifyTemplateArguments()
For parsing.

Bug: tint:1810
Change-Id: I189d06136e79615d39c842aaa9ad58595f80283e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117210
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-01-24 19:28:14 +00:00
James Price ef5434dcd1 tint/ast: Add DiagnosticAttribute AST node
Bug: tint:1809
Change-Id: I297d050e001f5177a6697d8332713a1f41899b87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117562
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-24 18:44:27 +00:00
Ben Clayton 4ff2645d16 tint/reader/wgsl: Add ClassifyTemplateArguments()
Applies a heuristic to disambiguate less-than / greater-than from template argument lists.

This function is not currently used by the parser.

Bug: tint:1810
Change-Id: Ibd72dbae53b3159282177bf79c00ad0808b123a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117208
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-01-24 17:56:57 +00:00
Brandon Jones 6c8aa8aff9 Resolve some reader/writer dependency issues
The HLSL/MSL includes in data_builder.h appear unused, but gn was
flagging them as problematic when attempting to build with the
corresponding tint_build flags disabled.

module_clone_test.cc is dependent on the WGSL reader and writer, but
was not gated on the corresponding tint_build flags in BUILD.gn.

tint_unittests_transform and tint_unittests_glsl_writer were both
dependent on the WGSL reader/writer, so added it as an explicit
dependency.

Bug: dawn:286
Change-Id: I20906414e8173065eef9403c9e9c05286afeaee9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117580
Auto-Submit: Brandon Jones <bajones@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-24 15:16:43 +00:00
Ben Clayton c98d57d662 tint: Rename 'static_assert' to 'const_assert'
Bug: tint:1807
Change-Id: I2c2a205ada01ad14d0bf6620a3dc3ec84dd7ee67
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117212
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-24 14:59:43 +00:00
Ben Clayton 9dc48bcef3 tint: Rename 'type' to 'alias'
Bug: tint:1812
Change-Id: I50bd8b036b47b4ec223a81eda53bd658d19645e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117211
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-24 14:55:17 +00:00
dan sinclair dfb62150df Remove program_builder include from type/
The type/ folder had a hold over include of program_builder. The builder
isn't actually used in the types so this CL removes the include and adds
the relevant includes to fix building.

Change-Id: I787b398fe149f483d007bb623ab3ed42850875c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117581
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-23 20:33:42 +00:00
Ben Clayton 6fc130bfcc tint/reader/wgsl/lexer: Make '>>=' splittable
Could be split when matching template argument lists.

Bug: tint:1810
Change-Id: I34421d2a27a8b2294fa0201793e7340c0f172df7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117209
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-01-23 18:32:41 +00:00
James Price 5f3449f000 tint/ast: Add DiagnosticControl AST node
Automatically generate the diagnostic severity enum and its parsing
logic using intrinsics.def.

Bug: tint:1809
Change-Id: Ia7cc59202b389eeea49fd582f5821d271978f233
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117561
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-23 17:55:55 +00:00
dan sinclair 3272ac7e17 Pull unicode files out to own target.
This cl pulls the text/ files out of the all source list and into a
libtint_text_src source set.

Change-Id: I7f7e5d764e0590b07ee21a7e4510dbd5c2decce4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117620
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-23 16:27:05 +00:00
dan sinclair 3085e23fc7 Move SamplerKind out of ast and into type.
This CL moves the SamplerKind enum out of ast/sampler and into
type/sampler_kind. This breaks the dependency on ast from type.

Change-Id: Icaf82dd1cca5782bf66993441c7b478332bb76a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117607
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-23 16:24:12 +00:00
James Price ffe356d558 tint/lexer: Add 'diagnostic' keyword
Bug: tint:1809
Change-Id: I55ce14b8775a64c4f7ccbbd7e84094e9e4ee19a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117560
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-22 11:00:53 +00:00
dan sinclair 57c0bbc2a5 Move ast/texel_format to type/texel_format.
This CL moves the texel_format code from ast to type to remove the
dependency on ast from type.

Change-Id: Ie075b2315360dc782284a7b4b55a817a9de31d78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117606
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-21 23:51:25 +00:00
dan sinclair 61c16eb448 Move ast/access to type/access.
This CL moves the ast/access files into type/access to resolve the type
dependency on ast

Change-Id: Ic0973c5ad162166736abb07cf9bbed7efa91695b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117605
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-21 23:44:38 +00:00
dan sinclair e2ff3431f4 Split transforms out to their on source target.
This CL moves the transforms out of the `libtint_core_all_src` and into
a `libtint_transform_src` build target.

Change-Id: I44ac4d4a3da9f66b4b7f9e821ecced87d8b227f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117243
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-21 23:41:56 +00:00
dan sinclair 18b2158b4e Move ast/address_space to type/
This CL moves the ast/address_space to type/address_space. This breaks
the type dependency on ast for AddressSpace.

Change-Id: Icb48e7423e18904865ec735024eb3b9864c947c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117604
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-21 19:56:49 +00:00
dan sinclair 3cbf3fc4c5 Move TextureDimension to type/
This cl pulls TextureDimension out of ast/texture and into
type/texture_dimension removing a type dependency on ast.

Change-Id: Icf06ec32ee9051286f169ae9538c48416f513039
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117603
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-21 19:16:15 +00:00
dan sinclair d54dabeab5 Split the reader/ and writer/ out of libtint_core_all_src.
This CL splits the code in `reader/` and `writer/` out of the
`libtint_core_all_src` target and into individual `libtint_reader_src`
and `libtint_writer_src` targets. The various readers and writers are
updated to have the specific target as dependencies.

The `deps` are moved to being private from `public_deps`. The places
where dependencies were missing are updated.

Change-Id: I4e30113cdc6b1e1941efa34ce6579f8f501201ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117242
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-21 18:50:20 +00:00
Austin Eng 387d57c805 Metal: set both depth/stencil attachments for combined formats
Adds a toggle to workaround another issue where Metal fails to set
the depth/stencil attachment correctly for a combined depth stencil
format if just one of the attachments is used. The workaround forces
both attachments to be set, giving the unused one LoadOp::Load and
StoreOp::Store so its contents are preserved.

Bug: dawn:1389
Change-Id: Iacbefcc57b33bf11ca8fcacb03506301646fe59d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117175
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-01-21 02:42:15 +00:00
Zhaoming Jiang 899126f036 Dawn: Fix FeatureState of some features
This CL fix FeatureState for some experimental features to prepare for
refactoring adapter creation with adapter toggles. This CL also fix the
related unittests.

Bug: dawn:1495
Change-Id: Ibf043ed74c0bfc79c64986f2f96135d92adf3930
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116841
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2023-01-20 08:46:55 +00:00
Austin Eng 785ccde2f5 Expand AllowFormatReinterpretationWithoutFlag to consider ETC2/ASTC
Bug: dawn:1176
Change-Id: Iae674fb1c5198ca8767b71e2d5553e0a4a06b475
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117178
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-01-20 01:13:27 +00:00
Brandon Jones 13d14525c4 Fix builds that disable tint_build_spv_reader
If tint_build_spv_reader = false is set in a Chrome's build_overrides
then the tint_unittests_spv_reader_src begins failing with a bunch of
missing spvtools identifiers.

Most uses of spv_reader_src include it as a conditional dependency only
when tint_build_spv_reader is true, Chrome's `all` target always builds
it. This causes problems when critical includes are excluded due to the
tint_build_spv_reader setting. The solution is to not make use of the
TINT_BUILD_SPV_READER define at all in this subdirectory and instead
assume that the entire directory will be included or excluded as needed
at a higher level.

Additionally, one switch statement in tint_common_fuzzer needed to have
the scope of it's TINT_BUILD_SPV_READER exclusion reduced so that it
wouldn't trigger warnings that not all enum values were covered.

Bug: dawn:286
Change-Id: I53518e2fda497fe976721b5f087e2e21a170f5dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117244
Reviewed-by: dan sinclair <dsinclair@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-20 00:11:00 +00:00
Brandon Jones 61d2cf297a Making SPIR-V ingestion and validation optional
Browsers won't be exposing the ability to pass SPIR-V shaders, and the
ability to consume and validate them is adding a non-trivial amount to
the browser binary size on platforms like Android. To avoid that
overhead, this change puts those features behind a flag so that browser
usage can easily omit them.

Bug: dawn:286
Change-Id: Idf70683f2c4ccf479b723c00ba6914e27e4f765f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117241
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-19 21:17:42 +00:00
Peng Huang e3eb03f8a3 Add the last usage serial in Buffer
Add the last usage serial in Buffer, it is used for optimizing
MapAsync(), so the callback of MapAsync() is called when the last usage
serial is done instead of using the current pending serial when
the MapAsync() is called.

Bug: b/265151060
Change-Id: Ibc95d4e41d41896f0a49b0fd1068912b46ea14e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116693
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-19 20:33:32 +00:00
Ben Clayton f1fc8c8bc7 tint: Remove commented out includes
Change-Id: I046837b32f27b30920719c7067aae83887e0f039
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117205
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2023-01-19 17:15:00 +00:00
Corentin Wallez 8b5d804963 Revert "DISABLE WireBufferMappingReadTests.DestroyInsideMapReadCallback"
This reverts commit 1966ea9727.

Reason for revert: dawn:1619 has been fixed.

Original change's description:
> DISABLE WireBufferMappingReadTests.DestroyInsideMapReadCallback
>
> It is failing under ASAN but should be fixed after at the same time as
> issue dawn:1619 that makes mapping callbacks called only at the end of
> the BufferBase method.
>
> Bug: dawn:1619, dawn:1621
> Change-Id: Idfdb6e36432a47eaef63b46e041f1404a2562f40
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116284
> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Austin Eng <enga@chromium.org>

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

Bug: dawn:1619
Fixed: dawn:1621
Change-Id: Ib700147543c12b35005b718b50ed1b19245cf0ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117440
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-01-19 16:05:27 +00:00
Austin Eng 03b69ff573 Delete StagingBuffer in favor of mappable buffers
This CL removes StagingBuffer to start to unify implementation
code paths for WriteTexture/Buffer and CopyBufferToTexture/Buffer.

This will help implementing a buffer-to-stencil copy workaround.

Bug: dawn:1389
Change-Id: Ieb23b8d871f14544ef01445a495dc1077274c9f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117167
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-19 02:54:07 +00:00
Takahiro 44e9db3866 Allow reentrant buffer mapping operations in the mapping callback.
WebGPU clears [pending_map] before resolving or rejecting promises,
which means that the callback for .then or .catch is allowed to unmap,
remap, or do anything with the buffer assuming previous mapping
operations are entirely done the buffer.

Mimic this in Dawn by finishing all operations related to mapping
before calling callbacks they might trigger.

bug: dawn:1619
Change-Id: I9e5b82789a68f28a496a54c31bf9fe0ffde23ccf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-19 01:11:56 +00:00
Ben Clayton d03dceebf3 tint: Add bgra8unorm storage texture support
Polyfill this for the SPIR-V, HLSL and GLSL backends by replacing bgra8unorm with rgba8unorm, and swizzling.

Bug: tint:1804
Change-Id: I36638202840d7313001dff6c5b60dcb948988c34
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117204
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-18 19:42:03 +00:00
Austin Eng e2be18a7fd Workaround stencil to buffer copies on Metal Intel
Stencil to buffer copies don't capture contents
written in a rendering stage. Copying through an
intermediate texture fixes this problem on Metal Intel.

Add test for the code path that found the issue:
Nonzero-mip stencil copy, discard, then read

Bug: dawn:1389
Change-Id: I63d982df6bace4b5053d3c643b8abda1682490d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116851
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-18 17:55:14 +00:00
Peng Huang d3b8c489a1 Merge two queue submissions in Queue::SubmitImpl()
Currently Queue::SubmitImpl() may cause two queue submissions, one is
because of Tick() call which will submit pending commands if there are.
The other one is after converting frontend commands to backend command
buffer. Queue::SubmitImpl() will submit converted commands. However
usually queue submissions are expensive, so merge those two queue
submissions into one by not calling Tick() before converting frontend
commands, so pending commands and recorded commands can be submitted
together. After that, we call Tick() to resolve callbacks and perform
bookkeeping operations (deallocating memory for passed operations,
etc).

Bug: b/265151060
Change-Id: Ia171771bcc1061dc599a58aa6d213a645696fb75
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116929
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-01-18 14:40:07 +00:00
Peng Huang 429c2f93f4 Fix vulkan::Buffer::TransitionUsageAndGetResourceBarrier()
Do not transition if the buffer usage is already MapWrite

Change-Id: I16cf68501e19a5b60d6c6f28eaa539df691f14fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117240
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-01-17 23:40:41 +00:00
shrekshao e597e04e13 Validate if depth attachment is present when frag_depth is written
Bug: dawn:1636
Change-Id: I47aa4e5734b8e70e8c5a9171872a44a577d168d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116859
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-17 20:53:55 +00:00
Austin Eng cdec06a2aa Revert "Suppress vkUpdateDescriptorSets-None-03047"
This reverts commit afc3f9d4c7.

Reason for revert: crbug.com/dawn/1615 should be fixed now that
vulkan-deps has rolled into Chromium.

Original change's description:
> Suppress vkUpdateDescriptorSets-None-03047
>
> Bug: dawn:1615
> Change-Id: I40f745fe7f7736c9c5ece34fc9fb114d478c9118
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116926
> Commit-Queue: Austin Eng <enga@chromium.org>
> Reviewed-by: Zhaoming Jiang <zhaoming.jiang@intel.com>
> Auto-Submit: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>

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

Bug: dawn:1615
Change-Id: I5dbd7ae82a0c4f3b3b88ea70a9faac35507a0418
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117320
Kokoro: Austin Eng <enga@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Austin Eng <enga@google.com>
Commit-Queue: Austin Eng <enga@google.com>
2023-01-17 19:32:46 +00:00
Austin Eng 1177c970d6 Add Metal workaround to allocate stencil8 as combined depth-stencil
Stencil8 textures don't work correctly on some drivers. Workaround
by allocating a combined depth-stencil texture instead.

Suppress newly added test on Windows ANGLE

Bug: dawn:1389, dawn:1637
Change-Id: Iea03e8f3e5e7f663ffc7b344ab007a73836557cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116846
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-01-17 19:06:12 +00:00
Yan,Shaobo 9b6f01d603 Fix flipY logic in CopyTextureForBrowser()
CopyTextureForBrowser() handles flipY by flipping source texture then
applying copy op. But this is not correct. Instead
it should find the copy rect and apply flipY op in copy rect only,
which is the same as WebGPU GPUImageCopyExternalImage.flipY definition
(https://www.w3.org/TR/webgpu/#dom-gpuimagecopyexternalimage-flipy).

This CL fixed the issue and updated related end2end tests.

Bug: dawn:1635
Change-Id: I3ea7c9de44fb45224bc438486e0e92385446bfb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116924
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2023-01-17 09:29:20 +00:00
Corentin Wallez 16c7ea6bfc Expand VUID-vkUpdateDescriptorSets-None-03047 flake suppression
This isn't just failing on Windows Intel but also Windows Nvidia.

Bug: dawn:1617
Change-Id: I9cd492512df4118161deabb9cf3f97eee29c60d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116879
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2023-01-17 09:16:49 +00:00
Austin Eng afc3f9d4c7 Suppress vkUpdateDescriptorSets-None-03047
Bug: dawn:1615
Change-Id: I40f745fe7f7736c9c5ece34fc9fb114d478c9118
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116926
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Zhaoming Jiang <zhaoming.jiang@intel.com>
Auto-Submit: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-14 01:00:19 +00:00
Antonio Maiorano 1fd40c1d81 Improve readme for dawn.node
Fix paths, add note about coverage, and format.

Change-Id: I7ac228bf880d6416e89b2f7a3324f9edac5c7a74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117040
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-13 19:10:47 +00:00
Peng Huang f58ef99a15 Use std::move() for rvalues in SerialMap and SerialQueue
Change-Id: Iddaf8227cb76b823107997a740eb7563268ff859
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116925
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-13 18:30:21 +00:00
James Price dd54f74de1 tint/uniformity: Rework generation of diagnostics
Flip the diagnostics so that the trigger location is on the builtin
that requires uniformity.

We also now show the place at which control flow diverges regardless
of where it is in the function call stack.

Change-Id: Id739a137b9011c900649b74165a6600a95d87ca4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116691
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-13 17:15:32 +00:00
Ben Clayton a1eed91cb0 tint: Use TINT_UNLIKELY() on TINT_ASSERT() condition
Change-Id: I92c6cf4b52132b806822b9edb163838f474d7c3b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116876
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2023-01-13 14:46:21 +00:00
Ben Clayton 884f95258d tint/utils: Add TINT_LIKELY / TINT_UNLIKELY macros
Emits branch prediction hints.
Give unlikely hints about where we call TINT_ICE.

Change-Id: Ied5bc3d7c8b3a838e96e5a0a64156048f90411c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116875
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-01-12 22:52:57 +00:00
Ben Clayton 91d39a7639 tint/resolver: Reduce Hashmap fixed sizes for UA
Uniformity analysis can have very deep call stacks, and we're on the cusp of stack overflowing. Reducing these sizes helps avoid cache misses at the cost of more heap allocations.

Change-Id: I4685d1d888d062456c296d9dc25231a48d72e941
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116878
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-12 20:31:33 +00:00
Ben Clayton 42363a5b18 tint/transform: Skip SimplifyPointers if possible
Change-Id: Id937d82e9062cf7a4c54401121ed6d22e5d4fd73
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116870
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-12 18:29:07 +00:00
Ben Clayton 3d6c263446 tint/utils: Add Log2 and NextPowerOfTwo
Shamelessly adapted from dawn's implementations.

Change-Id: I77aff9bd1c852c14b0009295024973aa17c50d55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116873
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-12 18:23:28 +00:00
Ali Chraghi 2d94a0c075 Add missing Surface creation calls to get wayland surfaces working
Change-Id: I50e7b830769333dee4b865c3c0ab6e6016d81a9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116922
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-12 16:11:44 +00:00
Brandon Jones 1f9e50edd4 Add another const to arrays of strings in renamer.cc
These were triggering the "mutable constants" check on the
android binary size bot.

https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8792318173224229089/+/u/Trybot_Results/Mutable_Constants_Diff

Bug: dawn:286
Change-Id: I91d823edb14335cbb5139ef0e7723b2d360d1ebc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116801
Auto-Submit: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-12 11:44:40 +00:00
Corentin Wallez 961ad2358f DawnTest: try to more robustly handle device lost.
Deferred exepectations didn't handle device loss gracefully and would
crash, which meant all future tests were skipped. Instead of crashing,
skip the expectation, the test will fail anyway because the device was
lost.

Bug: None
Change-Id: If143f00a5ed9d2ddd5a923da7c771b1f40d80962
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-12 11:25:25 +00:00
Ben Clayton 7a41bf1e2f tint/transform: Skip Unshadow if possible
Change-Id: I73b7213aafe3ff25a5f6526e7002d2ec3dda57c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116871
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-12 10:36:27 +00:00
Ben Clayton b607bfbddf tint/utils: Manually inline HashmapBase::Scan()
Clang was doing a poor job inlining this very hot function and its lambda argument.

Change-Id: Id2005b2ad131a1a1802bc7fb66085395b659ade2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116867
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-12 08:17:46 +00:00
Ben Clayton 973a685ad3 tint/transform: Skip LocalizeStructArrayAssignment if possible
Change-Id: I148c576f97359923c0d6fd6ffe864ca84ccd5b6b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116869
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-12 08:16:46 +00:00
Takahiro 46e3e213b0 Fix Buffer mapState after destroyed in Wire
WebGPU specification described that Buffer mapState must be
"unmapped" after destroyed because Destroy() must internally
call Unmap().

But in the current Wire implementation the mapState won't be
"unmapped". The root issue is that Destroy() doesn't update
mMapState in Wire.

This commit fixes the problem by updating mMapState in
Destroy() in Wire.

bug: dawn:1634
Change-Id: I7398510f83ebacfbc6bb33fcc070c2eab10b9c24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116820
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
2023-01-12 02:07:48 +00:00
Austin Eng dc9c306a14 Remove suppressions for tests now passing on Mac Intel
Bug: dawn:704, dawn:791
Change-Id: I3d335c33caee943547798290026dffa7f9a90d83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116845
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-11 23:29:22 +00:00
Ben Clayton 6345562a98 resolver: Delay copy of TemplateState
Shows up in profiling, and doesn't always need to be done.

Change-Id: If8bf061563979d17dea4c48334dab4834770d921
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116865
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2023-01-11 22:16:08 +00:00
Ben Clayton e704336001 dawn/node: Avoid exception on teardown
If node is shutdown without first explicitly destroying the GPUDevice, the device's destructor will be called, which would automatically destroy the dawn device.

Before doing this, it would first reject the lost-device promise. With newer versions of node, attempting to construct new GC'd objects on NodeJS tear-down triggers a fatal error.

Work around this by adding a new state to promises, that allows promises to be destroyed without first being rejected or resolved, and without raising a 'Promise not resolved or rejected' fatal message.

Change-Id: I810d6894d384511cdb7989b9c6c5b707dd68d8c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116864
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-11 21:03:45 +00:00
Austin Eng 3c760b850c Remove supressions for disable_r8_rg8_mipmaps
This toggle no longer exists

Bug: none
Change-Id: I1ef99a760530286f1845ab0b55fa611f61df239d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116843
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Kokoro: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
2023-01-11 20:29:55 +00:00
Ben Clayton 58d1e89426 dawn/node: Avoid empty vector index
If a device lists no features, don't zero-index an empty std::vector.

Change-Id: I10d632f0c5d5a162abec180797ad11adee67fc6b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116863
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-11 20:05:37 +00:00
Ben Clayton 47a81fc126 tint/utils: Use a C-array instead of std::array
std::array unnecessarily zeros the memory, which shows up in profiles
Change-Id: I2a18ef4fb8ca46bc6fc87504858046d9b7d2fd45
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116866
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-11 20:00:55 +00:00
Corentin Wallez edca14171e DawnTest: Move the position of [selected] to be easier to spot.
The [selected] was on the second line of an adpater description in the
output of DawnTest which made it a bit difficult to find. Move it at the
end of the first line which is the adapter name.

Bug: None
Change-Id: I686b40588b03aac827c347510525f6c969b7180b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116860
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-11 15:10:05 +00:00
dan sinclair 7092786f31 Fixup return of HLSL sign to match WGSL.
The HLSL `sign` method returns an `int` result (scalar or vector). The
WGSL `sign` expects the result to be the same type as the argument. This
CL injects a cast to the correct type after the `sign` call in the HLSL
generated source.

Bug: tint:1795
Change-Id: I51fed24b5b8b752b6b27fdfb5dd47eb803902793
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116692
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-11 13:18:29 +00:00
Ben Clayton 54264d3037 tools/run-cts: Optimize coverage collection
Enable coverage collection when using the test server, which is substantially faster than running in separate, isolated processes.

Use clang's `__llvm_profile_*` APIs to reset the counters between each test case run.

Change-Id: I01f8d0c1b3f215f66cfa50ef0fd51f2522c2ea57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113880
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-10 21:55:43 +00:00
Ben Clayton c9c937cc3e dawn/node: Allow picking of the adapter by name
Add the "--adapter" flag to run-cts as a helper for setting this.

Make "--verbose" print the picked adapter.

Rename "dawn-backend" flag to just "backend" - this is already specific to the "gpu provider" (dawn).

Change-Id: Idc8d0eb3ccf5fa23325c06f0f9520aa9b528d9dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116295
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-10 19:15:42 +00:00
Corentin Wallez 0963142273 Add wgpu::Device::ValidateTextureDescriptor
Bug: chromium:1266549
Change-Id: Iaef63ca6f4e447450953dfb0633b43931d8c2552
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116294
Reviewed-by: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-01-10 15:17:26 +00:00
Ben Clayton e45bf9f3d6 dawn/node: Handle printf() erroring
printf() can return -1 on error. In this situation, don't adjust msg with a negative offset.

Fixes a spurious crash when emitting lots of text.

Change-Id: Id1e9402bbbe3dd49cf08e660dea0cf67c5369516
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116289
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-10 14:13:50 +00:00
senorblanco@chromium.org 477744b7b5 Tint/GLSL: fix null ptr deref in Texture1D -> 2D.
Bug: 1405676
Change-Id: If6edb0ba2b6c1ddd5d75421d234e168297e1b622
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116700
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-10 02:13:48 +00:00
Jiawei Shao ab00dd0725 Remove ShaderModuleValidationTest.FragmentOutputLocationExceedsMaxColorAttachments
This patch removes the test
ShaderModuleValidationTest.FragmentOutputLocationExceedsMaxColorAttachments
from dawn_unittests because now the emission of the validation errors about
the maximum value of fragment output location is delayed from
CreateShaderModule() to CreateRenderPipeline(), however this test expects the
error will still be reported in CreateShaderModule().

Previously this test can still pass because kMaxColorAttachments is declared as
an uint8_t, so it will be added as "\b" (ascii code is 8) in string stream when
constructing the shader, then we can still get a shader-creation error because
it is not an integer that is inside the bracket of the location() expression.

Bug: dawn:986
Change-Id: Iaf03f83b2c27e3d9e986f813b2086726b51a0aeb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116554
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-10 01:09:28 +00:00
Jiawei Shao f7beb85fd1 Count the line pos, offset and size of compilation message in UTF-16
This patch counts the line position, offset and size of the compilation
message in UTF-16 and saves them to WGPUCompilationMessage to align the
latest WebGPU SPEC.

Bug: dawn:1357
Change-Id: If8f4026bd5b4a64a078e100762b6d1f61da50053
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115640
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-10 00:03:24 +00:00
Arman Uguray 2dfd177009 spirv-reader: Apply image coord vector check on unwrapped type
When validating the image coordinate type of an identifier that may have
been hoisted into a 'var' declaration, spirv-reader correctly checked
the type of the unwrapped reference for scalars but not when the
coordinate type is a vector.

This change applies the vector type checks to the unwrapped type.
Introduced a vector coordinate variant of the
SpvParserHandleTest.ImageCoordinateCanBeHoistedConstant test which
demonstrates the issue and passes with the fix.

Fixed: tint:1712
Change-Id: I9d99a1996e5df71921d6f66d1af02fb5088f1f20
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116371
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2023-01-09 20:00:51 +00:00
dan sinclair 5e8ee8581d [ir] Handle some unexpected ast nodes.
This CL adds diagnostics for the ast nodes which would come before
override substitution. The struct member attributes are marked as ICE as
they should never be encountered. The Struct declaration is ignored as
we will get the `type::Struct` from the semantic usage.

Bug: tint:1718
Change-Id: I8c51787f1455d02e822f222f43a9606a844eed3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116549
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-08 01:31:30 +00:00
dan sinclair 97b98619e8 [ir] Convert tests to use disassembler.
This Cl updates the flow node tests to compare against a disassembled
output instead of explicit expect statements. This makes it easier to
see the structure of the IR and to determine any changes.

Bug: tint:1718
Change-Id: I5b8ab42ada4ba902e8937099c7058a39533f2010
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116548
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-08 01:29:03 +00:00
dan sinclair e3992f2408 [ir] Cleanup disassembler output
This CL expands the disassembler output and makes a bit more useful. The
case selector value is changed to an `ir::Constant` instead of the
`constant::Value` to make disassembly easier. The `BuilderImpl` is
updated to not fail in the face of missing implementation but continue
as best as possible.

Bug: tint:1718
Change-Id: I8b275a19bccbb02bb785d311778198bb0c9e0456
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116547
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-07 23:15:47 +00:00
dan sinclair a764437138 [ir] Allow branching arguments.
When branching to a different flow node, there is a need to pass
arguments to the branch. These arguments could be the value of the
return.

This extracts a `Branch` out to an object with a target and arguments
and then updates the IR to use the new Branch structure.

Bug: tint:1718
Change-Id: Ic8de8046f58056327a04c8afe3b597810c80ccdb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116546
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-07 23:13:35 +00:00
Stephen White 797cbf4f58 OpenGLES: implement 1D texture workaround.
OpenGLES doesn't support 1D textures, so use 2D textures of width x 1
as a workaround (requires dependent Tint change).

Bug: dawn:1301
Change-Id: I99dbccfae497ee86d6f9b9e1ca1608049971016d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114820
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-01-07 18:09:14 +00:00
Stephen White 1d04cf841c Enable the 1D -> 2D texture transform in GLSL writer.
Fix unit and WGSL test results.

Bug: dawn:1301
Change-Id: Idfe046bdb211c8db9724e02c2f9dfb12d04d5c2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-01-07 17:19:21 +00:00
Stephen White fb8a6dbb5d Implement a Texture1D -> Texture2D transform.
This is required for GLSL ES, which doesn't support Texture1D.

Bug: dawn:1301
Change-Id: Iba08d04a0bc23c278e65618550ea314ca0cbee1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114363
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-01-07 04:09:25 +00:00
Kai Ninomiya 9bb85fdaef Suppress VVL warning for empty descriptor set
Unsure whether this error is correct, there's an issue open on VVL to
figure that out. Suppress until that's resolved.

Bug: dawn:1627
Change-Id: I9663c1434f6eda48385ff66751432d22b2d8a3d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116544
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-06 23:51:19 +00:00
dan sinclair 4a62d91a9e [ir] Remove program in ir tests.
This Cl updates the IR tests which depend on a built IR to clear out the
program after the IR is generated. This will, hopefully, find accesses
into the old program AST in the sanitizer bots.

Bug: tint:1718
Change-Id: I8c83d8d6aa93d702dac6a1e8068ca8e0a00a7753
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116366
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-06 19:49:46 +00:00
dan sinclair 8bcb4e9e77 [ir] Remove ast pointers.
This CL removes the AST pointers from the IR nodes.

Bug: tint:1718
Change-Id: I818e1debc644b366c6e8378f448683b1b7d8fb00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116365
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-06 19:45:13 +00:00
dan sinclair 0258f276b5 Convert CaseSelector to IR.
This CL converts the case selectors over from ast CaseSelectors to IR
CaseSelectors. They work the same way in that a `nullptr` value signals
a `default` selector but they only store the resulting `constant::Value`
instead of the `ast::Expression`.

Bug: tint:1718
Change-Id: Ied62d661e03a7f8da4c1e1bdaccc04f21ab38111
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116364
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-06 17:58:40 +00:00
dan sinclair 19bc66a375 [ir] Cleanup some comments and un-needed code.
This CL cleans up a few comments for spelling and content. The EmitType
method is removed, types should not be emitted into the IR, they should
be cloned, so we should not need EmitType.

Bug: tint:1718
Change-Id: I7879e864e075837f756d47da422b2b129623d900
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116369
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-06 16:37:23 +00:00
Corentin Wallez 00208bd134 Fix CopyExternalTextureForBrowserTests overflow.
The call to Queue::WriteTexture was passing a size that was bigger than
the array of data being used. This caused an ASAN failure when running
with the wire, because the serialization of the command would memcpy
past the end of the data.

Bug: dawn:1625
Change-Id: I2a00f2e32e3d8f8ff66d85575d1908480861f153
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116288
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-06 14:28:24 +00:00
Jiawei Shao f43b92f6e0 Enable end2end tests that can pass on latest Intel bots
This patch enables all the dawn_end2end_tests that fail with old
Windows Intel driver but pass on the newer ones after the driver
of the bots being upgraded to 31.0.101.2111.

Bug: dawn:416, dawn:815, dawn:1070
Test: dawn_end2end_tests
Change-Id: I3022ff09a6c2be21f1c99fab0077743f84f83b34
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116133
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-06 10:10:07 +00:00
dan sinclair 529c3fd385 Add clone into constant/
This Cl adds the ability to clone a constant into a context provided.
This allows the IR to clone the constants out of the Program and into
the IR.

Bug: tint:1718
Change-Id: I78170cdc66b5824a1ab81000976a747b5bffee79
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116363
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-06 02:57:36 +00:00
James Price 128980f218 tint: Add support for workgroupUniformLoad
Accept any type in the intrinsics definition, and then manually
validate that there are no atomics in the type. Add manual E2E tests
for composite types.

Use the BuiltinPolyfill transform to implement it for all backends.

Update the uniformity analysis with special-case tags for the builtin.

Fixed: tint:1780
Change-Id: I95786dff4df70a0b16ed1c53b853b5d0ec6bc501
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114862
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: James Price <jrprice@google.com>
2023-01-06 02:25:06 +00:00
Shrek Shao 3b83e389fa Suppress FragmentInputIsSubsetOfVertexOutput tests for Adreno Pixel 4
Bug: chromium:1404849
Change-Id: I348363833e3ec39b12dab514bfa6e32381dda34f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116367
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-06 01:15:46 +00:00
Kai Ninomiya a3a68c3d0d Suppress VVL sync hazard for sampling + read-only depth/stencil
This should help unblock the roll of vulkan-deps into chromium, which is
currently failing dawn_end2end_tests and angle_end2end_tests.

Fixed: dawn:1626
Change-Id: I5c0313e93d0be01c794ce9c1ffe73f16c0dfc8df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116138
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-05 22:56:32 +00:00
dan sinclair f8abdc7aef Add ability to clone types.
This CL adds a `Clone` method into the type base classes. This allows
the IR to clone types provided by the program into the IR context.

Bug: tint:1718
Change-Id: Ieebf011dcf40bedc98bf5acebd3888acfde863bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116362
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-05 21:07:15 +00:00
Corentin Wallez 8e68a89cfb Vulkan: Clamp @builtin(frag_depth) with push constant values
Start using Tint's ClampFragDepth transform in the Vulkan backend when
needed in order to correctly clamp @builtin(frag_depth) on Vulkan. Do
this by always reserving 8 bytes of push constant space to contain the
f32 min and max values from the last viewport command.

Reenables relevant CTS tests that were suppressed on Vulkan.

Bug: dawn:1125, dawn:1576, dawn:1616
Change-Id: I38f4f6c3c51c99b5e591a780fea9859537529534
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105642
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-01-05 12:24:52 +00:00
Corentin Wallez edbebe3582 Remove the suppression for NV12SampleYUVtoRGB on Nvidia D3D12
Bug: dawn:733
Change-Id: Iaedd074e1fa6febab5cb87e20ee0c8255d69761d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116021
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-05 09:04:10 +00:00
Jiawei Shao 786d4b12dd Don't clear depth stencil textures when created as committed resource
The toggle D3D12ForceClearCopyableDepthStencilTextureOnCreation can be
disabled when the toggle D3D12Allocate2DTexturewithCopyDstAsCommittedResource
is enabled because with D3D12Allocate2DTexturewithCopyDstAsCommittedResource
all the depth stencil textures (can only be 2D textures) with CopyDst usage
have already been created with CreateCommittedResource() instead of
CreatePlacedResource(), thus the driver issue about creating depth stencil
texture on a dirty heap with CreatePlacedResource() won't be triggered.

Bug: dawn:1487, chromium:1237175
Change-Id: I872d4d95e6e05e1bcf9489b31a72e61f957de3e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116129
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-05 01:30:54 +00:00
Yuly Novikov 80f0a3a739 Suppress ColorStateTest.SparseAttachmentsDifferentColorMask on D3D12
Device lost on ASAN Intel and NVIDIA.

Bug: dawn:1625
Change-Id: I7435bf989fa36b4ece7a14e95de153e69a15b177
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116286
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
2023-01-05 00:10:53 +00:00
James Price 7ca2e99b64 Remove unused variable
This blocks the import into google3.

Change-Id: Ieb5db932553b5f9c8e44e1c334e497004c6bb778
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116361
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-01-04 21:29:39 +00:00
Brandon Jones 713cd86f78 Change External Texture Crop Parameters
Removes the ExternalTextureVisibleRect type in favor of the existing
visibleOrigin/visibleRect parameters.

Bug: dawn:1622
Change-Id: Ifa661392b5541543c1445ce3e1e8e5e9db881be4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116124
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2023-01-04 21:27:32 +00:00
Ben Clayton 8e2c3e14f9 tint/resolver: Adjust diagnostic source for member accessor error
And clean up sources in the validation_test.cc file.

Change-Id: If602c7c955c6264e7df98146c320e69aafe55654
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116282
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-04 20:07:23 +00:00
James Price 3a2573e93c DISABLE WireBufferMappingWriteTests.DestroyInsideMapWriteCallback
Fails with ASAN, should be fixed after at the same time as dawn:1619.

Bug: dawn:1619, dawn:1621
Change-Id: Ia1efbb5466b8e8fbb871c07dd6af53a530620935
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116360
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-04 19:23:48 +00:00
David Neto 8937ec4e72 spirv-reader: disable Clspv-related test
The grammar of the NonSemantic.ClspvReflection.1 instruction
set has changed but the corresponding feature in Clspv has not
yet landed.
Disable the Clspv-related test until upstream has settled.

Bug: tint:1789
Change-Id: I1cd9e9d15fc41338704e6e4b487cb6f099581aa0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116320
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-04 18:40:08 +00:00
Hans Wennborg 011e95a2ff Add missing include of type_traits
Recent libc++ versions no longer implicitly include <type_traits>
as part of <utility>, see https://reviews.llvm.org/D140426

Bug: chromium:1404923
Change-Id: Ic688b0ca05167ccae1db916ed964b77f53ff999f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116283
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-04 17:58:39 +00:00
James Price efdfc6bbca tint/gn: Use Unix diagnostic printer on macOS
Renames PrinterLinux to PrinterUnix and enables it for macOS in the GN
build. This allows the Tint EXE to produce colorized/emboldened
diagnostic messages on macOS.

We already do this in the CMake build, so this makes GN match.

Change-Id: I35a0d53de44c793870a5a050fdd14148aaf3d763
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116300
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-01-04 17:48:00 +00:00
Ben Clayton cf1f4658ae tint/resolver: Fix ICE on short-name type used as identifier.
Bug: chromium:1404922
Change-Id: I47a8a294ba62b034feba98566098bef2246a0c9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116281
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-01-04 17:20:57 +00:00
Corentin Wallez 1966ea9727 DISABLE WireBufferMappingReadTests.DestroyInsideMapReadCallback
It is failing under ASAN but should be fixed after at the same time as
issue dawn:1619 that makes mapping callbacks called only at the end of
the BufferBase method.

Bug: dawn:1619, dawn:1621
Change-Id: Idfdb6e36432a47eaef63b46e041f1404a2562f40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116284
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-01-04 16:58:20 +00:00
Ángel Eduardo García Hernández 0fa5fb16bd tint: fix clang-cl compilation
* Disabling warnings was using the MSVC codepath
* Required to disable a float comparison on lexer.cc for clang

Change-Id: Ie3123593ebba2bffe34bff490ff76d5bdbd7d40d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116240
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-04 12:35:39 +00:00
Ben Clayton f3f813eb0c tint: fix const eval short-circuiting with mixed runtime and constant expressions
For logical binary expressions that can be short-circuited, if the rhs
tree contained a mix of constant and runtime expressions, we would
erroneously mark the node as runtime, although some of its children were
resolved as kNotEvaluated. This would then fail during backend
generation.

This is a fork of 115820, addressing review comments, as amaiorano is OOO this week.

Bug: chromium:1403752
Bug: tint:1581
Change-Id: I18682c7fe1db092d280390881ff86b3c0db23e9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116020
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2023-01-04 12:30:47 +00:00
Ben Clayton be367b73ae Reduce shader complexity for external textures
Do more math on the CPU to avoid per-fragment ALU operations.
Use a mat3x2 instead of mat2x3 to avoid padding.

Fixed: dawn:1614
Change-Id: Ib0e0f7d44ed9aa16eaca712f6553214fad141feb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon1 Jones <brandon1.jones@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-04 12:29:56 +00:00
Corentin Wallez 7f45581f45 Revert "Skip flaky DrawIndirectTest.Uint32 on Win Intel Vulkan"
This reverts commit f6fd86c524.

Reason for revert: most likely fixed by a VVL roll, see issue dawn:1615

Original change's description:
> Skip flaky DrawIndirectTest.Uint32 on Win Intel Vulkan
>
> Bug: dawn:1620
> Change-Id: I1866630622d674fe24fbd355645dfb2b5a63280c
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115480
> Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Commit-Queue: Kai Ninomiya <kainino@chromium.org>

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

Bug: dawn:1620
Change-Id: I1060479ee4dae084197569599182e61da15128dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116081
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
2023-01-04 04:47:01 +00:00
dan sinclair afd7f2aa21 [ir] Add usage tracking to ir::Value.
This CL updates ir:Value to track the instructions which use a given
value. The instructions add their usage upon construction. This
necessitates making the values non-const in a lot of places as they get
changed by the instruction.

The `result` value is moved up to the base instruction class as it
should exist in all instructions.

Bug: tint:1718
Change-Id: Id7ab6e43d48caea502756d274dd6be2e1e4240f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116141
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-03 21:55:36 +00:00
Ben Clayton b70d610bae dawn/native: Hook tint ICE up to Dawn assertions
Scream and shout if we ICE in a debug build.

Fixed: tint:597
Change-Id: Ie349d314a2ddf518f54df81469e4e14aa16cacda
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-01-03 21:45:05 +00:00
dan sinclair 4cef4362b0 [ir] Add bitcast expression.
This CL adds the Bitcast expression into the IR.

Bug: tint:1718
Change-Id: Ic48bd54485e9b380c94f599e683c2fbba7505787
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116041
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-01-03 20:29:43 +00:00
dan sinclair cf58122c58 Minor cleanups from #114202.
This Cl adds a couple cleanups requested in 114202 as a followup.
Templates updated to have the EnableIf in the `template` block. The code
for `create` of a Splat or Composite is moved to a helper method.

Bug: tint:1718
Change-Id: Ib302d78633c6102cfbe17d63f0a4841ecf147472
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116100
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-01-03 20:25:37 +00:00
dan sinclair 3e449f2194 [ir] Add types to the ir::Value classes.
This CL updates the Value objects in the IR to store the corresponding
type::Type.

Bug: tint:1718
Change-Id: I58fb764bf438e0aca3bc4e7f59179643fee49b77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116040
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-01-03 20:25:13 +00:00
Yuly Novikov f6fd86c524 Skip flaky DrawIndirectTest.Uint32 on Win Intel Vulkan
Bug: dawn:1620
Change-Id: I1866630622d674fe24fbd355645dfb2b5a63280c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115480
Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2022-12-27 22:55:50 +00:00
Antonio Maiorano 659b5b7727 tint: add const eval matrix accessor unit tests
Bug: tint:1581
Change-Id: Icae0959cda95e028acee9663acfe698978881f93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115506
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-23 21:10:53 +00:00
Antonio Maiorano c73d673976 tint: add const eval vector accessor unit tests
Bug: tint:1581
Change-Id: I135c0cdc5d45c673aa156cd96ebad5c613545bd2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115504
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-23 21:09:10 +00:00
Antonio Maiorano b71898ea30 tint: add const eval array accessor unit tests
Bug: tint:1581
Change-Id: I0cbb16936bbc1c139e17cecd07007d418c6ee0fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115503
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-23 18:51:26 +00:00
Antonio Maiorano dfa92a9cb6 tint: Fix ProgramBuilder::WrapInFunction overload not being picked up
Before this change, the variadic function template version of
WrapInFunction would be selected when passing a utils::VectorRef<const
ast::Statement*>, even though an overload exists for that type. The
reason is that during type deduction, the compiler will select templates
over non-templates in its overload set. The only way around this was to
avoid type-deduction by explicitly casting the argument to
utils::VectorRef<const ast::Statement*>.

This CL adds a CanWrapInStatement metafunction that evaluates to true if
the arg type is one that could be passed to
ProgramBuilder::WrapInStatement. This is used to SFINAE in the variadic
args version of WrapInFunction.

Change-Id: I8aa3d69e2ce7324fd60b1b2a5906a51d51b549a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115502
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-23 17:56:56 +00:00
Antonio Maiorano 64c243e9e6 tint: add missing unit tests for const eval vector construction of AInt and
AFloat

Bug: tint:1581
Change-Id: Ic994fe50be6a73b215aabc8ec85fab9f31bcc8df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115500
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-22 22:08:48 +00:00
Antonio Maiorano 6b4622fb07 tint: add const eval array constructor tests
Bug: tint:1581
Change-Id: Ia6c4ba974b40cdff8dc28ddbd510189355ed27cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115400
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-22 16:27:43 +00:00
James Price 906fc9df20 tint/uniformity: Add a NameFor helper
Use it everywhere, and inline some simple uses for brevity.

Change-Id: I27727feedfb1eaa3e811241a420c3fbed404e5b1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115381
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-22 14:32:54 +00:00
James Price a84ebc3af9 tint: Add forward declaration for CastableBase
This fixes the google3 build, which compiles headers in isolation.

Change-Id: I3c9a91caa75c6da1d9dcc17bb6d2aeb5834c197e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115440
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-22 14:32:16 +00:00
Gregg Tavares 6609f9cfb9 Workaround Metal Validation Issue for copying 3D textures to a buffer.
The metal validation layer complains when copying from a 3D texture to
a buffer if the stride for the destination buffer is larger then 2048
bytes.

Bug: dawn:1430
Change-Id: I6ba4508d71610c35dfb0fab7d2bebc91d37504e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113426
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Gregg Tavares <gman@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
2022-12-22 01:30:22 +00:00
James Price 0244804193 tint/uniformity: Avoid string allocations for node tags
Use std::initializer_list<std::string_view> for the tags passed to
CreateNode, and only concatenate them if debug mode is enabled.

Change-Id: Ida3662c52d72ba71bae3f91766dca6aaca89ee50
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115380
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-12-22 00:51:18 +00:00
James Price 857b1580c7 tint/uniformity: Handle pointer uniformity
This change is a necessary to support workgroupUniformLoad in a
following patch. Otherwise, there is no change to the set of shaders
that are accepted or rejected by the analysis.

We now distinguish between uniformity requirements on the contents of
a pointer parameter versus the pointer value itself when generating
tags for function parameters.

Whilst processing an expression, if we see a sem::Load node we pass a
flag down through child expressions to indicate that we will be
loading from the result. When processing an identifier expression, we
can then select between adding an edge to the source of the
pointer/reference versus the contents of the root identifier that it
corresponds to.

Since the pointers passed to atomic builtins can be uniform, we
special-case them to capture the fact that their return value is
always considered non-uniform.

The arrayLength builtin no longer needs special-casing.

Added many tests to cover various cases that are now captured
differently in the graph. There are two cases that are disabled as
they require variable pointers to trigger the uniformity violation.

Bug: tint:1780
Change-Id: I03edb65f22a6ffb0e7daf8b2f590f5de898e6262
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114861
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-12-21 22:59:14 +00:00
Antonio Maiorano 1d77e2531c tint: add const eval of swizzle tests
Bug: tint:1581
Change-Id: I08d7279aed1a931072bd31735aa21fffdae2400f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115340
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-21 21:15:03 +00:00
Antonio Maiorano ffb322a096 tint: add bool member to const eval struct member access test
Bug: tint:1581
Change-Id: I65955745b9e4078368ba2b3797dd903e07238edd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115243
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-21 21:15:03 +00:00
Antonio Maiorano 309b10a8c5 tint: add const eval struct zero init tests
Bug: tint:1581
Change-Id: Id2562b288343229b1fc99f5ff78b6c3809532ddb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115242
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-21 21:15:03 +00:00
Antonio Maiorano 0890ecabda tint: add const eval zero init tests for scalars, vectors, matrices, and
arrays

Bug: tint:1581
Change-Id: Ib0024ddccd5107337e6711c6fa56b0efd68dde96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115241
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-21 21:15:03 +00:00
Antonio Maiorano 994b70feb9 tint: add AFloat and AInt const eval scalar constructor tests
Bug: tint:1581
Change-Id: I0cb190e3114f3fd1c68f4cb821399547830239a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115240
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-21 21:15:03 +00:00
Antonio Maiorano bc44620d68 tint: implement short-circuiting of const eval bitcast
Bug: tint:1581
Change-Id: I6058dee593bf97f9dee202a80ced7b2551da0ba9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115220
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2022-12-21 21:15:03 +00:00
Jiawei Shao f8277d0ae4 Add toggle to warn the dst-alpha issue on Intel GPUs
Bug: dawn:1579
Change-Id: Ifdf09aefcdd62be82bd874a6e185b18ab96cb29a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114920
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-12-21 02:22:53 +00:00
shrekshao 49a08b7668 Refix validation for command encoder pass encoding
According to latest spec, beginRenderPass/beginComputePass
don't throw validation error. Error still defers to
CommandEncoder::Finish()

Bug: dawn:1602
Change-Id: I5fd76f2c8951273a8dd82b02e20f076079354b60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115120
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2022-12-20 21:03:16 +00:00
James Price eb34a764a8 tint/uniformity: Fix handling of continuing block
Variables declared inside a loop block were not visible to the
continuing block. Special-case the continuing block by processing it
inside the loop-body block statement, instead of afterwards.

Change-Id: I05bc906bd98b24295dc91116b9ef8d8ef02c3af3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114860
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-20 20:12:51 +00:00
James Price efc9df4695 tint/uniformity: Fix issues with for-loops
Variables declared in for-loop initializers were not being tracked
properly across iterations as a check was wrongly determining them to
be declared inside the loop body.

Also fixes an issue where variables declared in for-loop initializers
were still considered to be in scope after loop exit.

Change-Id: I2ce3a519be45c8daba31bf00e8b2614f0bd6a2de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114364
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-12-20 19:08:56 +00:00
Antonio Maiorano 056618541f tint: const eval of bitcast operator
Bug: tint:1581
Change-Id: Ida43b34118282eeb99ae099c91a6465eb3040ca6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115080
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-12-20 18:34:06 +00:00
Antonio Maiorano ffa83ad1f7 tint: make utils::Bitcast not trigger gcc warning
When useing Bitcast to or from a class type, gcc warns even if the type
is trivially copyable. Fixed this by static_asserting that both types
are trivially copyable, and casting the pointers to std::byte*.

Change-Id: Ibb420f2dcdd35cfb187d74983fa8ab9b50d10c85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115180
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-20 17:13:39 +00:00
Austin Eng 5cc118bde7 Clear reference to MTLTexture on TextureView::DestroyImpl
Bug: dawn:1355
Change-Id: I834b02a05d50c39b1a8d272e2d437d7ce1f96fb5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115061
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-12-19 23:36:00 +00:00
Brandon Jones b38b3b0f8c Implement AlwaysResolveIntoZeroLevelAndLayer globally
Previously this toggle was implemented only for the Metal backend, but
a need for it was identified on Android as well. This change moves the
implementation to the backend-agnostic command encoder recording so that
it works for all backends. Fundamentally it's still doing the same
thing, however: Swapping resolve targets that point at a non-zero mip
level or layer with a temporary texture and then performing a copy once
the render pass has ended.

Bug: dawn:1569
Change-Id: I292860cc74f653b2880e727d2ef3a7dfa3f10b91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106040
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-19 19:46:12 +00:00
Takahiro 915e55a0d8 Add Buffer.GetMapState()
Bug: dawn:1521
Change-Id: I68962a4d6b17867cd17cfcb3a17910a2007764fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111924
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
2022-12-19 19:06:51 +00:00
Ben Clayton ce93a6b224 tint: Replace type::UniqueNode::Hash() virtual with field
Virtual methods are expensive to call, and hashes are frequently tested.
The hash must be immutable, so just calculate it once in the constructor and store it as an immutable field.

Change-Id: I9d29fb3fc074e57e7af91367768a47193baa40f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114780
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-12-19 17:07:29 +00:00
Takahiro ad541a7cdd Immediate Buffer.MapAsync() rejection if pending map in Wire
This immediate rejection has been implemented in Native but
hasn't been yet in Wire. This commit adds the implementation
to Wire.

Also the commit changes the MapAsync callback firing timing
if pending map buffer is unmapped or destroyed. With this
commit the callback will be fired immediately Unmap or
Destroy is called to match the WebGPU spec. Currently the
callback is fired when the client receives a response from
server but it mismatches the spec.

Change-Id: Ia48d62be31912fd0384e23271e9de516f9d71d6c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113607
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-12-17 04:24:05 +00:00
James Price 0fcc00e22a tint/uniformity: Fix debug graph output
The code that was ifdef'd out no longer compiled.

Change-Id: I6243cc6a3584c555505c4bee68ec02bbb96801c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113430
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-12-17 02:21:36 +00:00
Ben Clayton 2f9a98870e tint: Implement sem::Load
The resolver now wraps sem::Expression objects with a sem::Load object
anywhere that the load rule is invoked. sem::Expression provides an
`UnwrapLoad()` method that returns the inner expression (or
passthrough, if no load is present), which is analaguous to
Type::UnwrapRef().

The logic for alias analysis in `RegisterLoadIfNeeded` has been folded
into the new `Resolver::Load` method.

Fixed up many transforms and tests. The only difference in output is
for a single SPIR-V backend test, where some IDs have changed due to
slight re-ordering of when expressions are generated.

There may be further clean-ups possible (e.g. removing unnecessary
calls to `UnwrapRef`, and simplifying places in the SPIR-V writer or
transforms that deal with memory accesses), but these can be addressed
in future patches.

Fixed: tint:1654
Change-Id: I69adecfe9251faae46546b64d0cdc29eea26cd4e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99706
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-12-17 02:20:04 +00:00
Yuly Novikov 5a4f5dcf90 Skip dawn_end2end_tests failures on Win Intel Optiplex 7080 Vulkan
BindGroupTests.ArbitraryBindingNumbers/Vulkan_Intel_R_UHD_Graphics_630
QueryInternalShaderTests.TimestampComputeShader/Vulkan_Intel_R_UHD_Graphics_630

Bug: dawn:1615
Change-Id: I76d677157857dbc6ef7cb5ecbad6e37d2cc292e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114620
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-12-16 20:26:52 +00:00
Antonio Maiorano bf8a230c81 tint: const eval of ldexp builtin
Bug: tint:1581
Change-Id: Ib21717065041b65a637f4d73ce0088544b1fce0d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114321
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-16 18:37:19 +00:00
Austin Eng 04ad2a4c14 Add informational toggle that indirect baseVertex is broken on Mac Intel
Bug: dawn:966
Change-Id: I5f8183911eb04d4809c30cb7c1efdeca414f3329
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114662
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-16 18:10:06 +00:00
Austin Eng e48253f31e Add informational toggle that sample mask is broken on Mac Intel
Bug: dawn:1462
Change-Id: Ifec68914edb7d0f7eaf90e066491a0af3fe7b232
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-16 16:54:42 +00:00
Yunchao He 5082727e55 D3D12: Remove the 24K extra memory for texture corruption
2D array texture may corrupt on some Intel devices, making out-of-bound
texture access and memory information leak. It's a critical security
issue. Intel driver team suggested the 24K extra memory approach in
order to mitigate the security issue before.

However, the texture corruption issue (and even the correctness issue)
can be worked around via allocating a few extra layers. And patches
have already been merged in Dawn, with a lot tests for verification. The
24K extra memory for each texture is actually incorrect and unnecessary.
So this patch removes relevant code in Dawn.

This patch mainly reverts some code of this patch below:
https://dawn-review.googlesource.com/c/dawn/+/96220

Bug: dawn:1507
Change-Id: Ic3239115ad4c74bdee928577ccbb20f1e35d13c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2022-12-16 16:46:12 +00:00
Ben Clayton 7c3e9a6dd2 tint: Rework tint::Manager
Don't use dynamic casting in hashing and equality. These should be fast, and dynamic casting is expensive.

Add type::UniqueNode for things that need de-duplicating and bin the types on construction.

Replace some use of SFINAE with constexpr.

Also fixes a build failure for x86.

Bug: oss-fuzz:54184
Change-Id: Ic1b0708394f9f5703fc179a2c31ce18bd07e196c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114760
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-12-16 15:31:19 +00:00
Brandon Jones 183df9d24e Implement External Texture Crop Functionality
Adds to the External Texture shader transform to allow cropping. Tests
included.

Bug: chromium:1316671
Change-Id: Id0ec9acac22a0968ba6847d6ead9cf5084eaca88
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113281
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-16 05:41:06 +00:00
dan sinclair 02b466feb1 Move CreateComposite into ProgramBuilder.
This CL moves the CreateComposite helper into the ProgramBuilder.

Bug: tint:1718
Change-Id: I4aca7dc3d7192a7aa8b300f00529670aa9c09a27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114202
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-12-15 21:56:32 +00:00
dan sinclair 19ebcb2230 Convert ir::Constant over to use a constant::Value
This CL updaets the ir::Constant to store a constant::Value instead of the specific numbers
themselves.

Bug: tint:1718
Change-Id: I66b0a9643893b6079399daf61ee39ac5811e1eaf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114362
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-12-15 19:17:22 +00:00
David Neto dd1e4e39f2 Fix typo
Change-Id: I5b15e16c140dde600e83e4f48e2902963e948b46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114560
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-12-15 18:00:24 +00:00
Takahiro 5208edf37d Buffer.MapAsync pending map error non validation error consumed
Bug: dawn:1613
Change-Id: Ib1e5014d36c2c35d7ed9b946de4d21e046cf1282
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114280
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-12-15 16:44:18 +00:00
dan sinclair b53b8cf5be Rename constant::Constant to constant::Value.
This CL renames constant::Constant to constant::Value as it reads a bit
nicer.

Bug: tint:1718
Change-Id: I3489a271ebe229dabf98e7668bdaef4fec375534
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114361
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-12-15 16:25:31 +00:00
Yunchao He 69b7f4a61c Add more tests for texture corruption: msaa and depth stencil formats
2D array textures with non-color formats like depth/stencil formats
are always fine. Workaround is not needed.

Multisample textures are treated as array textures from the
perspective of texture memory layout on Intel Gen12 and each sample
acts like a layer. However, multisample textures are fine.
Workaround is not needed.

Bug: dawn:1507

Change-Id: I1e5cd6a4e46503f67e4c1ffe2133e2e8fb121016
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113740
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-12-15 00:52:53 +00:00
Brandon Jones 87a1724368 Improve draw-time bind group validation messages
Makes it clear that the index being reported by these messages is the
group index and not the binding number. This was a point of confusion
in on the bug.

Additionally, adds more information to the error message regarding
buffer sizes being too small for the current pipeline. Now includes the
pipeline name and buffer size as well as the minimum required size. Also
includes a note explaining that uniform buffer bindings must be a
multiple of 16. (This recently changed and cause several existing
samples to break for non-obvious reasons.)

The error message still does not contain the buffer or binding number,
which would be helpful. This is because we currently lack a way to look
up the binding index from the packed index that this error is generated
with.

Bug: dawn:1604
Change-Id: Ibb2b44bc9e1583ddef34d703e83bcf64ed7a3aa2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113602
Commit-Queue: Brandon Jones <bajones@chromium.org>
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-14 23:44:11 +00:00
Ben Clayton ea1cc79cb8 tint/castable: Add Maybe() MaybeAnyOf()
Moves hashcode bloom-filter type logic to helpers instead of inlining
this stuff. Minor code cleanup.

Change-Id: Id6816dd18445d1d1200a9d49f05cb803095b3d89
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114341
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-12-14 22:38:43 +00:00
dan sinclair 5addefb148 Rename Constant::As to Constant::ValueAs.
This CL updates Constant::As to be Constant::ValueAs. Now that Constant
inherits from CastableBase, there is already an As method on
CastableBase. This makes the override inside Constant confusing and
potentially incorrect.

Bug: tint:1718
Change-Id: I4f73971801e95225a99a5a993124c04194d0d7d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114360
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Dan Sinclair <dsinclair@chromium.org>
2022-12-14 20:46:32 +00:00
Ben Clayton 35842190ef tint/castable: Reformat comments (grow width)
Tint used to use 80-character columns, and now uses 100.
Use the extra space

Change-Id: I493a2195094b23ecc70091b906b12cf742deac7c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114340
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2022-12-14 20:27:31 +00:00
dan sinclair 93c0ef2b33 Reduce default vec size in composite.
This CL decreases the default vector size in Composite from 8 to 4.
There will, probably, be a lot more vectors then arrays and structs so
this should reduce the used memory slightly.

Change-Id: I0a47780736192b43189cd211d34744a4f8028b97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114200
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-12-14 19:29:10 +00:00
dan sinclair 9268561678 Remove ImplResult.
The ImplResult type is the same as ConstEval::Result after recent
changes. This CL replaces all usages and removes ImplResult.

Bug: tint:1718
Change-Id: If424f3d00f953d97a339de8ae18c94083f3346bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114162
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-14 19:23:48 +00:00
dan sinclair 8626c9ee87 Move constants into constant namespace.
This CL moves the constants into the constant namespace.

Bug: tint:1718
Change-Id: Id8f98ca6c16085136c06d98bbd8b755b36cb2409
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114161
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-12-14 19:22:19 +00:00
dan sinclair 0890380d10 Split concrete constant classes into own files.
This Cl splits the concrete constant implementations out of the
const_eval.cc file and into individual files. The classes are left in
the resolver namespace and will have a namespace update in a followup
CL.

Bug: tint:1718
Change-Id: I54539b6aa06f09aff39a1b1331d89f67a3594791
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114160
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-14 18:13:37 +00:00
dan sinclair 7efe4860c9 Move helper methods inside Scalar.
This CL moves ValueOf and IsPositiveZero into the Scalar class which was
the only usage.

Bug: tint:1718
Change-Id: I2c99831ac30d4d3f0b3bfe9ad25a85186bba0f1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114123
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-12-14 16:20:09 +00:00
dan sinclair 5225fcc689 Remove ImplConstant.
The content of ImplConstant has been removed and can be replaced by the
constant::Constant base class.

Bug: tint:1718
Change-Id: I611f03d43335bf3b5629a8bc44d74318c7f69a58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114122
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-14 16:18:29 +00:00
dan sinclair d586d91478 Extract constant convert methods.
This CL pulls the convert methods out into standalone methods inside the
resolver and de-couples from the constants.

Bug: tint:1718
Change-Id: Id566704687b2d74e05eae860477552f88f6a06b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114120
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-12-14 14:07:07 +00:00
dan sinclair 2e737daaae Rename Element to Shader in ConstEval.
The const-eval Element is renamed to Scalar to better represent what is
stored.

Bug: tint:1718
Change-Id: I882a8d955f805bc04cea6794fdeaeba0ff2f2ae8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114101
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-14 13:43:51 +00:00
Ben Clayton 0335c7d65d tint: Add matrix short names
Fixed: tint:1786
Change-Id: Ifa3acb2fc1792b392ccb4555bde840f5038eef2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2022-12-14 11:55:58 +00:00
Ben Clayton 167a7da051 tint: Add TypeInfo as a field instead of a virtual
Removes the overhead of a virtual function call, at the expense of a larger object.

Change-Id: I81d783d4a69b16a69143d4b313f8d90d5df88a33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114080
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-12-14 11:22:23 +00:00
Ben Clayton 188ed1793a tint/resolver: Correctly validate f16 usage
There was limited validation for this. Validate all ways to use a f16.

Change-Id: Ibdcde1f304e704790da3db379c79fcc0844cad67
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-12-14 11:09:47 +00:00
Loko Kung eaeded4971 Enables maxColorAttachmentBytesPerSample in Dawn node.
Bug: dawn:1522
Change-Id: Iaccbffbc8ac641d407491bdd8ef0b0f2c9cba309
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113901
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-12-14 05:46:48 +00:00
Loko Kung 5646acbd71 Refactors RenderPassLoadOpTests to adhere to new limit.
Bug: dawn:1522
Change-Id: I856bad3d2930d276f1b8b281a7692d38dc82cf21
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113900
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-14 03:06:10 +00:00
Ben Clayton fbb339ff97 tint: Add sem::Load node
This change adds the node, but this is (currently) not generated or used.

Bug: tint:1654
Change-Id: Id38e531bf811833cf576085805cb00f444ea5451
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99581
Commit-Queue: James Price <jrprice@google.com>
Kokoro: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-12-14 01:50:52 +00:00
Antonio Maiorano bed9c98a07 tint: const eval of fract
Bug: tint:1581
Change-Id: I14207080b14e45e7520f50230c85cd902f25dc71
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113943
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-12-13 23:59:45 +00:00