Commit Graph

6278 Commits

Author SHA1 Message Date
Brandon Jones df70004c52 Add Validation For External Texture Bind Group Layout Mismatch
Adds validation to ensure that external texture binding entries match
the bind group layout. This should fix an issue found by the fuzzer.

Bug: dawn:1082
Bug: chromium:1296935
Change-Id: I1cc542ed9105dbe29d775e01e52475a7d6c8d393
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80460
Reviewed-by: Loko Kung <lokokung@google.com>
Auto-Submit: Brandon1 Jones <brandon1.jones@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-17 19:20:31 +00:00
Li Hao a73050795e Fix QueryInternalShaderTests
1. The left cases will be not checked if the first value is 0 in Check
function.
2. All timestamps are the same value at initialization.
3. Update 83.33 to 83.333 which is closer to the actual period on Intel.

Bug: dawn:1250
Change-Id: I7378cf45453682a3d364b6930072ccc229085f0c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80901
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-17 16:12:41 +00:00
Ryan Harrison 555e94e7e3 Fix legacy non-inclusive language issues
Explicitly filters out problematic files from presubmit with issues
that are not under our control, i.e. URLs.

BUG=tint:1433

Change-Id: I34a449c825edc39f934cbe9afa3436f7514f2808
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80860
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-02-17 15:03:19 +00:00
Ben Clayton c9735450c0 Remove stdout spam
Change-Id: Iaca6434003a0f10f5b35cce39cf48548f22f9114
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80843
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-17 14:40:58 +00:00
Jiawei Shao ab1a2b7407 Add validation on format when creating a multisampled texture
This patch adds the validation on the texture format when we create
a texture with sample count > 1 according to the latest updates in
WebGPU SPEC.

Below formats can't be used to create a multisampled texture:
- R32Uint, R32Sint, RG32Uint, RG32Sint, RG32Float, RGBA32Uint,
  RGBA32Uint, RGBA32Sint, RGBA32Float
- All compressed formats
- RGB9E5UFloat

BUG=dawn:1244
TEST=dawn_unittests

Change-Id: I71743281ce12158be4b1904732934fad95f39cee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80240
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-02-17 00:48:26 +00:00
James Price afb02e8ec7 glsl: Add missing cstdint include for uint32_t
Change-Id: I0d5a8b5e844871028cae874b962b55b1af16fc54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80880
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-02-17 00:03:10 +00:00
Christopher Cameron be72f76c23 Expand GetFormatEquivalentToIOSurfaceFormat
Add support for IOSurface formats for:
- RGBA16Float
- RG16Float
- R16Float
- RGB10A2Unorm

Bug: chromium:1241369
Change-Id: I8d3ed2c7575fe651406cb470383f3d4d23fb7aeb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80820
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2022-02-16 20:38:50 +00:00
Austin Eng 15bc24eeb8 Don't try to load libvulkan on Mac
Only SwiftShader would be available on Mac.

Bug: chromium:1297154
Change-Id: I943a39dfdde4215ba0ea880bf08294f37f08ee42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80720
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-16 17:32:20 +00:00
Stephen White 4a15605be7 GLSL: fix Select op with a bool vector condition.
The fix is in the mix().

Bug: tint:1429
Change-Id: Id128ead6b124cd364f45a860ad991977be94be5b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-15 20:00:27 +00:00
James Price 0fe8d27903 Roll Tint and update WGSL syntax for overrides
The syntax for pipeline-overridable constants has changed in
WGSL. Since this feature is still hidden behind the
disallow-unsafe-APIs flag in Dawn, we removed support for the old
syntax in Tint. This commit rolls Tint forward to get that change, and
updates the WGSL syntax in affected tests at the same time.

Bug: tint:1403
Change-Id: I1d081d9dea0c1de9def5cd123020700df3419f35
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80500
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2022-02-15 18:36:10 +00:00
Austin Eng 7a8006033a Add additional guards in counter set feature checks
- Don't use for..in since some crashes show that NSFastEnumeration
   in those loops is doing something wrong.
 - Check that the receiver actually supports the selector before
   calling it. Crashes indicate an unrecognized selector is being
   used.
 - Add a ref to MTLCounterSet to be sure it is not somehow freed
   between when it is stored, and when we use it as the receiver for
   [MTLCounterSet counters].

Bug: dawn:1102
Change-Id: I882045ba09547df62a98a862e6e64c5a7d656e80
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80461
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-15 18:18:26 +00:00
Stephen White 5f6a185d02 GLSL: implement textureNumLayers(), and update expectations.
Bug: tint:1426
Change-Id: I609a34be458c14deef866ab66d7b57b8ee6316f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80580
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-15 17:58:07 +00:00
Stephen White ee38740991 GLSL: implement bitwise & and | on boolean types.
Bug: tint:1427
Change-Id: Ide2b89ac5f61237d0d39c1210dadaf9587c5db97
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80360
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Stephen White <senorblanco@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-15 17:52:37 +00:00
Antonio Maiorano ce982d8a06 HoistToDeclBefore: hoist to reference if expression is a reference type
Don't lose reference-ness of expression. This is necessary for
assignments via the hoisted variable, for example.

Bug: tint:1300
Change-Id: I8e633f20e50541bb70becc5069019f795ec11e01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-15 17:04:47 +00:00
James Price d0ec88ce61 Add support for override keyword and @id attribute
This replaces the @override keyword that was previously used for
pipeline-overridable constants.

Support for pipeline-overridable constants in Dawn is hidden behind
the "disallow-unsafe-APIs" toggle, so we can make this change directly
instead of deprecating and continuing to support the old syntax.

Fixed: tint:1403
Change-Id: I9b2957a1e33b12772bfe449c0f3a31d929f8aa8b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80480
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-02-15 16:36:57 +00:00
Li Hao 3a60f96079 Reset root descriptor table for samplers when descriptor heaps are changed
When shader-visible heap switch happens, we re-populate all bindgroups
and change the descriptor heaps, which need to reset root descriptor
tables, but for the samplers which are cached in
mBoundRootSamplerTables and not changed, they won't be reset, which make
shaders cannot access the sampler heaps.

Bug: dawn:1255

Change-Id: Icc142206121af9daf8b9352b4c639f7d7ef8f1d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2022-02-15 02:05:06 +00:00
Brandon Jones fe994f74ff More verbose BindGroupLayout error messages
Begins including the expected BindGroupLayout in validation messages
where a BindGroup descriptor does not match the BindGroupLayout. This
is especially helpful in cases where the BindGroupLayout was implicitly
created by the pipeline.

Bug: dawn:1258
Change-Id: Icbf27b4a2ac9b4dc1716feed47e3e63cf99929a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80380
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-02-14 19:06:55 +00:00
Ben Clayton f95f11417e resolver: Use Switch() for type-dispatch
Bug: tint:1383
Change-Id: I9efbe6b3e7c0314a76f65b5e8969f1f20bcecf93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79771
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-14 10:05:16 +00:00
Stephen White 6f9ac3524a GLSL: fix isNormal.
(I know it's deprecated, I'm just being a completist.)

Bug: tint:1222
Change-Id: Ie7716d2f5dd2d2bd2245ba2b0fe7ed8705574de0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80141
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-11 14:35:14 +00:00
Stephen White 723f999ac2 GLSL: fix frexp and modf builtins.
These still had vestiges of HLSL.

Bug: tint:1222
Change-Id: I5f93f75e7384db641f0c5421dca24a3e8f2b716e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-11 13:41:23 +00:00
Ben Clayton 6688b0a3c7 resolver: Enable support of out of order declarations
Allow module-scope declarations to be made in any order.

Bug: tint:1266
Change-Id: Ib2607b6c33fad7c83e2c36f85b0a965eac922ec5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79769
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-11 12:59:08 +00:00
Stephen White a52abab38c Nuke SPIRV-Cross.
Change-Id: I1fc58d50ba3999e3a9b6f4e30a0799be301893de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79481
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-11 00:45:51 +00:00
Stephen White 96b72c262c OpenGL: use Tint for GLSL generation.
Change-Id: Ibced679fa6568f1eb33707f0157d03505e6f8a1c
Bug: dawn:1263
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/67540
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-10 22:17:41 +00:00
Brandon Jones 31f60e3a40 Remove accidental unused Transform Manager
Removes an unused tint::Transform::Manager that was accidentally merged
as part of commit "Integrate Multiplanar External Texture Transform".

Bug: dawn:1082
Change-Id: I55b5eec8b17f27df22658a90912dec4d6d583cbb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80100
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-02-10 21:56:51 +00:00
Austin Eng e710706858 Remove old src/tests/BUILD.gn
Bug: dawn:1275
Change-Id: I1da086fb291551b0a437411b13285a097557e7de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80060
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-10 19:41:24 +00:00
Brandon Jones cff04b4d3f Integrate Multiplanar External Texture Transform
Introduces the majority of the logic associated with enabling
multiplanar external textures. Removes most backend logic associated
with external textures in favor of expanding them into their components
in the frontend. Includes a basic e2e test demonstrating multiplanar
YUV-to-RGB conversion.

Bug: dawn:1082
Change-Id: Ib5c042e5639b1a8efe2954680abc346c8c6c76d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78248
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-02-10 19:31:13 +00:00
Antonio Maiorano 0bb04c2057 Split back out two transforms previously combined into PromoteSideEffectsToDeclTest
That is, bring back both VarForDynamicIndex and
PromoteInitializersToConstVar. This is not a complete revert, though:
*  VarForDynamicIndex no longer depends on ForLoopToLoop
* Both can cope with hoisting from "else if"
* More unit tests were added in the interim

Delete PromoteSideEffectsToDecl for now. This may be brought back to
handle ensuring order of evaluation.

Bug: tint:1300
Change-Id: I8bbae46377ec4603cc02c1eb3f0661a8461a19fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-10 18:50:38 +00:00
Stephen White 0b3dfef469 GLSL: call renamer transform from GLSL transform.
This significantly simplifies the calling code from Dawn.
It does require moving the SingleEntryPoint transform above the
renamer, since we need to call SEP with the original name. That is
probably also an optimization, since we do the subsequent transforms
with a culled AST.

Bug: tint:1268
Change-Id: I1f48ec0238ea76310742c60b119311747dd3dbac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80020
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-10 16:22:28 +00:00
Jiawei Shao 47f051984b D3D12: Only set root parameters for dynamic storage buffers when needed
This patch skips setting the items for dynamic storage buffer lengths
in root signatures when there is no dynamic storage buffer in the
pipeline layout so that we can avoid adding a root constant with
Num32BitValues == 0 in the root signature.

BUG=dawn:1262

Change-Id: I7d698425c94092299aefaf8cb6ef465745c8d194
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79742
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-02-10 00:05:01 +00:00
Ben Clayton 8bbdda7e89 transform: Update MultiplanarExternalTexture to support OOO-decls
MultiplanarExternalTexture cannot deal with out-of-order declarations.
Re-work things so that it can.

Bug: tint:1266
Change-Id: Ie2c8237be4f6ddb91120cbeb25f3c186b572ba59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79768
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-09 23:55:51 +00:00
Ben Clayton 8ec32a6ec9 writers: Use the new sem::Module::DependencyOrderedDeclarations
As the resolver currently enforces in-order declarations, this does not
change the declaration order from iterating over the
ast::Module::GlobalDeclarations.

The MSL backend has been changed to use the
sem::Module::DependencyOrderedDeclarations list instead of looping over
different declaration types separately.

Bug: tint:1266
Change-Id: I698d612032285311017bfceab3c42adae1928a0e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79767
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-09 23:55:51 +00:00
Ben Clayton a52be6c9ec Add sem::Module
Holds `DependencyOrderedDeclarations()`, which will hold the
sorted dependency-graph ordered list of global declarations.

Bug: tint:1266
Change-Id: I9840fae8689abd214973ea4785f71c3ae2587bbc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79766
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-09 23:55:51 +00:00
Ben Clayton 597fc4cdbe resolver: Replace ICEs with proper errors
If you attempted to:
 * Use a function as a type
 * Use a variable as a type
 * Use a variable as a call target

You would get an ICE. Replace these with proper error diagnostics.

Change-Id: Ibbe4cd1b59b1aadd451aa0445ad137859aa071eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79765
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-09 22:23:17 +00:00
Ben Clayton 88d1a433aa Castable: Have Switch() support nullptr objects.
Change-Id: I7635b01707e80c2d2e0b79148e07874f2fa2b5ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79764
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-09 21:37:57 +00:00
Corentin Wallez 82ca6096ac Mark 1D textures as safe.
Fixed: dawn:814
Change-Id: I216ebdb68cfb1634cfad8b44de998c2f1a87edaf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79320
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-02-09 18:40:51 +00:00
Antonio Maiorano dba215cd16 Add sem::Expression::HasSideEffects()
Will be used to implement order of execution.

Bug: tint:1300
Change-Id: I027295e482da7a3f9d7ca930b5303e8f89d7fe09
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79824
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-09 18:30:27 +00:00
Stephen White 35cc663130 GLSL: implement desktop GLSL support.
Introduce a glsl::Version, to allow the client to specify ES or
Desktop, as well as the desired GLSL major and minor version.

Bug: tint:1422

Change-Id: I4116bc2da40ae6a553dc2522d042dda1464a0c05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79700
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-09 17:44:17 +00:00
Corentin Wallez 9fc28cf3b6 Metal: Fix leak of MTLVertexDescriptor when using vertex pulling
Bug: dawn:1175
Change-Id: I1fd833fef830de4165a397e07c3ddaae0d7bdca8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79762
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-09 15:56:32 +00:00
Austin Eng 189b0cec37 tint->dawn: Move src/dawn_tests -> src/dawn/tests
Bug: dawn:1275
Change-Id: I79f2aeb0c54a74dd5becd90c46792705a28e87da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-09 14:54:31 +00:00
Austin Eng 7fd6b996f4 tint->dawn: Add proxy groups and temp targets for Dawn tests
Needed so that Chromium can reference the temp groups and
targets while we move Dawn's test build targets.

Bug: dawn:1275
Change-Id: Ia26769adfb3714e78ebd058ffcec50f3ccfa1a05
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79821
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-08 22:15:50 +00:00
Antonio Maiorano 85f7df55eb CloneContext: fix InsertAfter and InsertBack not working if done while cloning a node in a vector
Also make tests more idiomatic by removing diamonds in the Node
hierarchy.

Bug: tint:1300
Change-Id: I681f4251bd8d9bdef169dcdf5de345792c927436
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79680
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-07 21:43:06 +00:00
Brandon Jones 0fee4c180a Deprecate endPass(), replace with end()
Method was renamed in https://github.com/gpuweb/gpuweb/pull/2560

Bug: dawn:1286
Change-Id: I02a5da3f6ff56868c4d8f45a17433b6c5adf5c22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79480
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-02-07 19:48:39 +00:00
Stephen White bf0180bcee GLSL: only emit default precision qualifier for frag shader.
Other shader types don't need this.
Also fix code style of member var.

Bug: tint:1360
Change-Id: Ic3600ec7c6da9b85b57655fabbf1f2e44b0ea7d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79640
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-07 18:49:46 +00:00
Corentin Wallez a9a80ef386 Guard for [MTLDevice counterSets] being null.
Bug: dawn:1102
Change-Id: I1c8fffba65cba0b04ef72018013f027f0a814f90
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79361
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-02-07 16:12:00 +00:00
Corentin Wallez 31680a7ec0 Add validation of the max binding number.
Fixed: dawn:1283
Change-Id: I5efd0d5c92bd6c1a4cdfe91079a12a9f98ddfd61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79260
Reviewed-by: Brandon Jones <bajones@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-02-07 12:02:57 +00:00
Antonio Maiorano 2d87beb200 Add native visualizers for MSVC
Currently contains a subset of ast nodes to make it easier to debug.

Bug: tint:1331
Change-Id: I27afe3c57aa752bdf823120e31585100c8adbe36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79460
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-07 10:07:25 +00:00
Austin Eng 377ead9d44 Fix version check for timestamp queries - Mac 11.0+ AMD
Bug: dawn:545
Change-Id: I7cb48813e0a582a6b7314c6fa726800b146ea6be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79243
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-05 03:30:05 +00:00
Stephen White 6d770093bd GLSL: fix arrayLength().
Bug: tint:1222
Change-Id: I6f9576908a41f3b37036ef7afe10cb74a99cd63f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79440
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-05 00:20:54 +00:00
Stephen White deec53332f GLSL: fix barriers.
Bug: tint:1416
Change-Id: I138932cc0d702289684c4db80b4640df43b41833
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-05 00:15:34 +00:00
Stephen White 46647f1c13 GLSL: put std430 packing on all buffer variables.
This is not 100% correct (the exceptions for mat2 and friends are not
implemented yet), but gets more tests passing in Dawn.

Bug: tint:1415
Change-Id: Ia11c63a5236f35e724431a65ddb6ef3c598775d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-04 23:09:23 +00:00
Antonio Maiorano c6d967b4dd Add debugger::Break() to break into debugger if attached, and call when an ICE occurs
Helpful for debugging.

Bug: tint:1331
Change-Id: Ia2b58626ff7fb92194b419805eb4f48ad419092d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79242
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-04 22:25:45 +00:00
Ben Clayton 3d5b38447a Castable: Optimize Switch() (part 2)
Use the TypeInfo already obtained from the object instead of calling As<T>() again, which would trigger another virtual call.

Bug: tint:1383
Change-Id: I0394ea049589b0f7f72c80509ac8e9536196f368
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79302
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 21:00:13 +00:00
Ben Clayton 7b77855a87 tint->dawn Add src/dawn/CMakeLists.txt
Promote up some build rules from the root CMakeLists.txt file that are
specific to Dawn.

Bug: dawn:1275
Change-Id: I11e9261ac595f6d71742b20d54dc658a5fa7e996
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79105
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:59:15 +00:00
Ben Clayton 3fbe98e657 Castable: Optimize Switch()
Use a bloom-filter-style early rejection to eliminate whole blocks of
case statements from the switch type checks. Much like IsAnyOf(), the
list of types considered are recursively tested as a whole and
then binary-chopped if there's a potential match, until we test the
individual switch case types.

Bug: tint:1383
Change-Id: I5b30f19ea070e8352bf6b9363f133da906013182
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78544
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-04 18:58:33 +00:00
Ben Clayton c6ccd539e8 tint->dawn: Move src/fuzzers/dawn -> src/dawn/fuzzers
This has already been moved once, but with more consideration, there's far less fuzzer-related stuff to put in the same root directory here.

Bug: dawn:1275
Change-Id: Ic4bb556d9a9f104293cca3316cae84b66a6362b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79104
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:48:05 +00:00
Ben Clayton a6750751c7 tint->dawn: Move examples -> samples/dawn
Bug: dawn:1275
Change-Id: I4824aaabc2c2b55a609a6e1370959394b93463b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79103
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:35:55 +00:00
Ben Clayton 9fb7a5146a tint->dawn: Move src/include -> include
Also simplify the target names.

Bug: dawn:1275
Change-Id: I2929b70897f64903b91b693b48c2e8dd7c11d07b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79102
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:18:18 +00:00
Corentin Wallez b3c99ddfae writer/msl: Output constant 0 lod for 1d texture builtins
The MSL headers have annotations that requires that the lod for 1D
textures is a constexpr with value 0. This affects .get_width() and
.read().

Bug: dawn:814

Change-Id: Ic21d32067061afe67a16fbbeee222ab695b53066
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79301
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-02-04 17:55:43 +00:00
Ben Clayton 35940f9b83 gn: Trim target prefixes from src/dawn targets
Removes stuttering.

Bug: dawn:1275
Change-Id: Ie32929e0b0ca579d7eef13a43fd2d1c648140276
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79101
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 17:15:16 +00:00
Ben Clayton 818001d32e tint->dawn: Move src/dawn_native -> src/dawn/native
Bug: dawn:1275
Change-Id: Ic60a00107a015bc677ff929c492f1085ffc38482
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79083
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-04 17:07:46 +00:00
Stephen White a924ffe70c GLSL: fix sample_index, sample_mask and bitcasts
In GLSL, gl_SampleID and gl_SampleMask[In] require the
GL_OES_sample_variables extension, so output:

"#extension GL_OES_sample_variables : require"

in the header if those builtins is used.

Note that extensions must be inserted before the default precision
declaration, but helpers must be inserted after it, so we set a flag
and emit extensions, then the precision declaration, then helpers.

Further fixes:
- use gl_SampleMaskIn for input builtins, gl_SampleMask for output,
  necessitating the addition of a storage class to GLSLBuiltinToString()
- fix the handling of gl_SampleMaskIn: it's array<i32> in GLSL, not
  array<u32> as in SPIR-V
- centralize conversions for GLSL builtins used as input variables in
  FromGLSLBuiltin()
- implement bitcasts on assignment to GLSL builtin output variables,
  centralized in ToGLSLBuiltin()
- update the extension handling in the GLSL writer to check for both
  sample_index and sample_mask.
- call UnwrapRef() in GLSL's EmitBitcast(). In the test case, we were
  not recognizing the argument as a uint, yielding float() instead of
  uintBitsToFloat().

Bug: tint:1408, tint:1412, tint:1414

Change-Id: Ie01541eb6e7cdf4e21347341f988bff916346797
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78920
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-04 16:41:33 +00:00
Ben Clayton 009d129103 reader/spirv: Decompose arrays with strides
Transform any SPIR-V that has an array with a custom stride:

  @stride(S) array<T, N>

into:

  struct strided_arr {
    @size(S) er : T;
  };
  array<strided_arr, N>

Also remove any @stride decorations that match the default array stride.

Bug: tint:1394
Bug: tint:1381
Change-Id: I8be8f3a76c5335fdb2bc5183388366091dbc7642
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78781
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 15:39:34 +00:00
Ben Clayton de857e1c58 Add tint::Switch()
A type dispatch helper with replaces chains of:

  if (auto* a = obj->As<A>()) {
    ...
  } else if (auto* b = obj->As<B>()) {
    ...
  } else {
    ...
  }

with:

  Switch(obj,
    [&](A* a) { ... },
    [&](B* b) { ... },
    [&](Default) { ... });

This new helper provides greater opportunities for optimizations, avoids
scoping issues with if-else blocks, and is slightly cleaner (IMO).

Bug: tint:1383
Change-Id: Ice469a03342ef57cbcf65f69753e4b528ac50137
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78543
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 15:38:23 +00:00
Ben Clayton b2c4d7a244 tint->dawn: Move src/dawn_platform -> src/dawn/platform
Bug: dawn:1275
Change-Id: I043c5e6d84e199fe2e753ac43181b125882439bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79082
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00
Ben Clayton 20cbe6d9e8 tint->dawn: Move src/dawn_wire -> src/dawn/wire
Bug: dawn:1275
Change-Id: I56535bf4d387c4bd423140705ea70812be073eac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79081
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00
Ben Clayton 7d5badd9f4 gn: Trim target prefix from static and shared libraries
If the target name matches the package directory.
Reduces stuttering in target names.

Change-Id: I6cf01ac22c4998f4b862135b13b8503bdd92bdd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00
Ben Clayton 902ad1f9b2 tint->dawn: Move src/dawn_node -> src/dawn/node
Bug: dawn:1275
Change-Id: I206287da7728788646929e696c756b43d53cf272
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79063
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00
Ben Clayton 1e657a6328 tint->dawn: Move src/utils -> src/dawn/utils
Also remove stuttering from the target names by dropping the 'dawn_' prefix.

Bug: dawn:1275
Change-Id: I3263f1236f71bf23795b4b12670ad3535822a537
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79062
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00
Ben Clayton d9ab69a9c1 tint->dawn: Move src/common -> src/dawn/common
Also remove stuttering from the target names by dropping the 'dawn_' prefix.

Bug: dawn:1275
Change-Id: Iac79f9927010b8e5edeb7e0949092b34431d54dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79061
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00
Ben Clayton fa0d64b76d inspector: Implement a custom StageVariable copy constructor
The fields `has_location_decoration` and `location_decoration` are references to `has_location_attribute` and `location_attribute`, respectively, which act as an alias for a field-rename.

The default copy-constructor was copying across the reference (pointer) to the source StageVariable, instead of making a reference to the target's fields. This is causing Bad Things™ to happen in downstream projects.

Credit to dneto@ for identifying the issue, and for making this fix (which I've stolen for this CL).

Change-Id: Id0570e4e389f28980fa5aea29ad63b5100373dc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79200
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 08:55:23 +00:00
Corentin Wallez 42e648c1cf Implement creating and using 1D texture views.
- Adds a test to sample a 1D texture.
 - Adds a test writing to a 1D texture as a storage texture.
 - Reworks some of the StorageTextureTests helper code to allow passing
   custom sizes (since 1D textures must have height=1).
 - Deletes some dead code leftover from readonly storage textures.
 - Adds validation tests for 1D texture view creation.

Bug: dawn:814

Change-Id: I279856569f4fc6c9a7a5023a42bfa50d444158ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79106
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-02-04 08:34:54 +00:00
Stephen White d9b32c3178 GLSL: fix textureLoad() and textureStore(), depth textures, and more.
The CombineSamplers transform was incorrectly flagging StorageTexture
(which in GLSL ends up as image2D) as needing to be combined with a
sampler, or at least renamed. This is incorrect: StorageTexture never
has an associated sampler, so don't try to pair it up and just output
it as image* in GLSL.

In GLSL, textureLoad (aka texelFetch) of depth textures is not allowed.
The fix is to bind the depth texture as the corresponding f32 texture
instead (e.g., texture_depth_2d -> texture_2d<f32>,
texture_depth_cube -> texture_cube<f32>, etc). This requires changing
both the uniform globals and function parameter types. We're now going
to receive a vec4 instead of a float from texelFetch, so add a ".x"
member accessor to retrieve the first component. (Note that we don't
do this inside a CallStatement since this gives the CloneContext
indigestion, and CallStatement is going to ignore the result of the
call anyway.)

We were failing to find the dummy samplers that Dawn creates for the
calls that actually do require a dummy sampler, since the old Inspector
implementation of GetSamplerTextureUses() does not find them. The fix
is to implement a new Inspector call to return the texture/sampler
pairs the Resolver found during resolution. This will include the
dummy sampler as a null variable pointer.

In order to identify the placeholder sampler, we pass in a BindingPair
to represent it. When we discover a null sampler in the variable pair,
we return the passed-in placeholder binding point to the caller (Dawn).
(Dawn will use a group of kMaxBindGroups, to ensure that it never
collides with an existing sampler.)

Bug: tint:1298
Change-Id: I82e142c2b4318608c27a9fa9521c27f15a6214cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78820
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-03 22:39:13 +00:00
Brandon Jones a20ce6f5a9 Deprecate read only depth/stencil Load/StoreOp
In https://github.com/gpuweb/gpuweb/pull/2387 the spec was updated to
require that when depthReadOnly or stencilReadOnly is set the associated
load and store ops must be omitted. This change deprecates setting them
to `Load` and `Store` respectively, while adding an `Undefined` value
which the enums default to.

Bug: dawn:1281
Change-Id: I36474ba67bfb080da8c713d5bb88b8522e4630f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-02-03 17:59:04 +00:00
Ben Clayton 8250f2b850 resolver: Correctly validate 'break' inside 'continuing'
We haven't been correctly checking the esoteric set of rules around breaks in continuing statements.

Bug: chromium:1288919
Change-Id: Ica6a0e71d06d9b204c359fea5f778db2383e6fa1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78860
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-03 00:12:52 +00:00
Ben Clayton b85e692aa7 Rename 'intrinsic' to 'builtin'
This matches the term used in the WGSL spec.

Change-Id: I4603332b828450c126ef806f1064ed54f372013f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78787
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-02 23:07:11 +00:00
Ben Clayton a996ffbd1f Rename 'decoration' to 'attribute'
This matches (mostly) the term used in the WGSL spec.

Change-Id: Ie148a1ca8498698e91fdbb60e1aeb0d509b80630
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78786
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-02 23:07:11 +00:00
Brandon Jones 012840b752 Create 1x1 Dummy Texture For Single-Plane External Textures
Creates a 1x1x1 dummy texture that will be bound, but unused to shaders
that use external textures. It is expected that a special texture type
will be introduced and used in the future to optimize backends that
allow null bindings.

Bug: dawn:1082
Change-Id: I0c49f58f6a725290ec9b73b09578c0f85e5b38d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78940
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-02-02 21:11:42 +00:00
Austin Eng 2fbc170827 Add runtime search paths to Instance descriptor
So that Chrome can configure Dawn to load SwiftShader from
the bundled/module directory. The shared libraries and ICD
are packaged in a separate directory while dawn::native is
linked statically into the Chrome executable.

Change the Vulkan backend to use these paths for loading
Vulkan.

Bug: chromium:1266550
Change-Id: I40468b481881f6c249694c1c61137bc0c9b8fe76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78840
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-02 21:00:52 +00:00
Stephen White d4d7153bad GLSL: fix shadow samplers, and textures generally.
1) Append "Shadow" to samplers representing depth textures.
2) Sampling a depth texture returns f32, not vec4<f32>
3) Sampling a depth texture requires a Dref parameter, so we must
   generate one if none is provided.
4) GLSL requires Dref to be appended to the texture coordinates vector,
   *unless* it's a samplerCubeArrayShadow, since this would require vec5.
   In that case, it's passed as a separate parameter.
5) GLSL's textureGather() with a depth sampler always requires a refZ
   parameter, so provide zero to emulate WGSL's compare-less textureGather().
6) texelFetch() does not support depth textures, so this will have to be
   validated out.
7) textureOffset() does not support sampler2DArrayShadow in GLES, so this will
   have to be validated out.

Bug: tint:1298
Change-Id: Idaebe89cac6c1ec97c50a361b1d3aa3b84fb6c12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78760
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-02 15:25:42 +00:00
Ben Clayton b68e8aa658 Optimize tint::IsAnyOf<>() for many types
Split IsAnyOf() into log(n) stages, where each stage performs a hashcode
check.

Previously there was a single hash test across the bitwise-or of all the
types being considered. If this passed, then each type would be tested
with Is<T>() individually. With this change, the list of types will be
recursively split into two, which each block hash-code checked. This is
repeated until we reach fewer than 4 types to check, where the test
decays to using Is<T>() for each type.

Also renamed `combined_hashcode` to `full_hashcode`, and used the term
CombinedHash for new helpers that bitwise-or the hashes from a number
of types.

Bug: tint:1383
Change-Id: Id056b9f7a9792430bd75ce554cb5fe73221ca4c7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78580
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2022-02-02 14:38:32 +00:00
Antonio Maiorano e1699caf81 Fix PromoteSideEffectsToDeclTest converting for loop to loop with nested hoisted lets
When converting a for-loop to a loop, we were not cloning the for-loop's
body, but rather the statements within it. This worked fine, except if
we also hoisted a variable to a let within that body, which requires the
body to be cloned for the 'insert before' to work. This change clones
the for-loop body, which fixes the problem, but introduces a block in
the destination AST, which is ugly, but not incorrect.

Bug: tint:1300
Change-Id: I478244d87f8cf58837102004242ba1c835e21710
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78821
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-02 14:33:32 +00:00
Ben Clayton 0123832cc0 BUILD: Remove temporary fuzzer alias
This was used to allow Dawn to roll into Chromium.

The usage of this build rule has been removed:
https://chromium-review.googlesource.com/c/chromium/src/+/3427755

So this can now be deleted.

Bug: dawn:1275
Change-Id: If080cf3b576b51b2522699ae2063419bcaeba7c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78804
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-02 09:40:12 +00:00
Ben Clayton b80e2f3b6e intrinsics: Remove ignore()
This has been deprecated since M97.

Fixed: tint:1214
Change-Id: I970898f2ae8baf1916e2f8d43230d8b724641730
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78785
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-01 17:21:52 +00:00
Ben Clayton e1159c7180 diagnostic: Use shared_ptr for owned Source::Files
It's too easy to copy diagnostics around and lose track of Source::File
ownership. Ideally we'd place the shared_ptr on the Source, but Sources
are copied _very_ frequently, and we'd lose a huge amount of
performance. Typically, Source::Files are owned externally. The only
time we really need to hold a shared_ptr to these is when a Source::File
is generated by an ICE, as the File points to the C++ source file that
raised the error.

Bug: chromium:1292829
Bug: tint:1383
Change-Id: I2706de8775bc3366115865b5a94785c0b2fefaae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78782
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-01 17:16:01 +00:00
Ben Clayton 7d37677a03 dawn_native/metal: Round workgroup memory size to 16 bytes
The documentation for setThreadgroupMemoryLength states:
  length - The size of the threadgroup memory, in bytes. Must be a multiple of 16 bytes.

This is the likely cause of a number of CTS flakes for 'webgpu:shader,execution,zero_init:compute,zero_init:storageClass="workgroup";*'

Bug: dawn:1277
Change-Id: Ib8c271fccacac6e68cdf0ddb5c6b5a41756173b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78801
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-01 16:53:21 +00:00
Ben Clayton 1a4185b742 Move src/fuzzers to src/fuzzers/dawn
As part of the tint -> dawn merge.

Bug: tint:1275
Change-Id: I0ebb8afe9971c21ca90f90f246edcfde01d5f4bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78800
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-01 16:45:12 +00:00
Corentin Wallez 38b188ce61 Support 1D texture copies.
- WriteBuffer to 1D textures
 - copyBufferToTexture to 1D textures
 - copyTextureToBuffer from 1D textures
 - copyTextureToTexture with 1D textures

Test coverage will be provided by the CTS. At the time this
commit is up for review, the validation tests have been change
to test 1D texture copies comprehensively, except for copies
between 1D textures and textures of other dimensions.

Bug: dawn:814
Change-Id: I91a278d9c113a06a108fecb124aa21fea5e691b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64544
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-02-01 15:32:32 +00:00
Corentin Wallez 777654e6b9 QueryHelper: improve the precision of the tick->ns conversion.
Previously the conversion lost precision because of the repeated
float additions and rounding of float to uint. It is reworked to operate
using only integers, giving a better precision (3e-5 instead of 2e-3)
for all periods between 1ns and 2^16ns (which all GPUs seem to fall in
to).

The QueryHelper test is reworked to test multiple periods to provide
better certainty that the maths in the conversion is correct.

Bug: dawn:1250
Change-Id: I43703bb3a40c4e362d78126e3bf0d830690bc1d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77780
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-02-01 12:05:22 +00:00
Corentin Wallez 9dfcc20750 D3D12: Unify both buffer<->texture copy paths.
The two paths were duplicated with extremely similar code.
Unifying them will help implement the buffer<->1D texture
copies by having a single place to change.

Bug: dawn:814
Change-Id: Id574bf62fc85e5e72ab54ba5066e52ff37000e87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78723
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-02-01 11:04:53 +00:00
Ben Clayton 5416d9ba2a reader/spirv: Always run the cleanup transforms
The SPIR-V cleanup transforms were only being run if the
DecomposeStridedMatrix transform needed to be run - despite
the RemoveUnreachableStatements transform needing to be run, always.

Change-Id: I5dc28a79200ab67c96fb793980412a5632e26026
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78780
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-01 09:09:12 +00:00
Ben Clayton f67b6373a6 Move src/benchmark to src/bench
The current directory and namespace collides quite spectacularly with
the google benchmark include directory and namespace.
This becomes very hard to work around when there's a .cc file in src/
that wants to include "benchmark/benchmark.h", as MSVC appears to
resolve this to the relative path, while GCC and Clang resolve to the
compiler specified include directory.

Bug: tint:1383
Change-Id: Icc8891718d1d8a1b55c2ac4b2bb1487e8d09e629
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78740
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-01-31 19:49:00 +00:00
Corentin Wallez 9c2e07cff9 Use C++17 message-less static_assert where applicable.
Bug: dawn:824
Change-Id: I01dda88caaf613092541b62ea1b8d92768d405e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78724
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-31 16:40:31 +00:00
Corentin Wallez 3e80ae68ee Disable a couple SpvParserCFGTests preventing google3 roll
SPIRV-Tools was updated to fix a typo (preceeded->preceded) and the
string matching of these tests started failing.

Bug: tint:1406
Change-Id: If7affbf2e34e4f8d3e929c38ecdec7e3a624ee19
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78722
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-31 13:03:34 +00:00
Corentin Wallez abd099c063 Add a defaulted ExternalTextureBase destructor.
Without this, users of ExternalTextureBase will try to instantiate the
default destructor, which will cause a call to ~Ref<BufferBase> which
will fail when Buffer.h isn't included.

Fixes the roll of Dawn in google3.

Bug: None
Change-Id: Ib88d4338033468779f416973e5808910eb4ef110
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78721
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-31 12:20:04 +00:00
Dawn Autoroller a6222d2c5b Roll Tint from 3cdb8e3c3e to 0b39270e01 (8 revisions)
Also contains a fix for src/dawn_native/CompilationMessages.cpp, where
the tint::Source structure has changed in a breaking way.

https://dawn.googlesource.com/tint.git/+log/3cdb8e3c3e0a..0b39270e01ce

Bug: None
Change-Id: If801fa85200316012916b24324fd39d275d1fd2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78720
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-31 07:35:21 +00:00
Yuly Novikov d21a970f76 Update SYNC-HAZARD-WRITE_AFTER_READ skip
VK_PIPELINE_STAGE_2_NONE_KHR
was renamed to
VK_PIPELINE_STAGE_2_NONE
in https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/3705

Removing the comma in the end of string will make it catch both cases.

Bug: chromium:1292106
Change-Id: Idca97cc6b2d53476b7d108595e329e7c287d086f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78640
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-01-29 01:05:08 +00:00
Stephen White 0b39270e01 GLSL: move entry point handling to CanonicalizeEntryPointIO transform.
Move builtin_to_string() and builtin_type() to
the CanonicalizeEntryPointIO transform. Use the former to
rename entry point IO variables to the gl_ names, and the latter
to cast values to the correct type.

Change-Id: Iddfad574ddd660ff1bfd89a399a001b967b6b67e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78380
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-28 22:36:58 +00:00
Yunchao He 1365885386 Remove UnsafeAPI toggle for readonly depth/stencil attachment
Readonly depth/stencil attachment has already been supported on
D3D12, Metal and Vulkan. Its implement on GL and GLES will be
at post V1 via WebGPU-compat.

Bug: dawn:485
Change-Id: I1c13232f405b10b36f66c1c452449a864ca8fedc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78441
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2022-01-28 19:44:58 +00:00
Ben Clayton 3fe1bd3715 transform: Fix CalculateArrayLength for arrays
The transform was not correctly inserting the intrinsic call after array element types.

Fixed: chromium:1290107
Change-Id: I7199d1846cb98305d789cf0bc362eb5872d9b917
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78542
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2022-01-28 16:49:46 +00:00
Ben Clayton c28f5926be transform: Fix `TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM`
In recent optimizations, this got broken: when enabled the input program was printed over and over again, instead of the current transformed program.

Change-Id: I0c5acaf40a88ac759d0114f85febc052d577a698
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-01-28 16:49:46 +00:00
Ben Clayton 26c31f6b2c Shuffle 'docs' directories
As part of the tint -> dawn merge.

Bug: dawn:1275
Change-Id: Ice0c9d2f03f6d7e96471cf8398aecd16273c833f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-27 18:33:47 +00:00
Brandon Jones 9f1579469d Initialize External Texture's Internal Params Buffer
Initializes a uniform buffer on ExternalTexture objects that holds data
used by in shaders. Includes modifications to some Mock tests, which
should be using mock external texture objects instead of real ones.

Bug: dawn:1082
Change-Id: I34c02eadaf38aebf22630ac99098e0637ca1279c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78240
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-01-27 18:05:28 +00:00
Ben Clayton df9900c43e Optimize Source by removing a std::string
The `std::string file_path` carried around by every Source was very expensive for heap allocations.
Push this into the Source::File.

Bug: tint:1383
Change-Id: Id9e3bdef1cf24aea5f3c83f348c05f5cf8ef4bbb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78321
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2022-01-27 17:36:27 +00:00
James Price 792897422d Remove the "image" storage class
This doesn't exist in WGSL, and we don't have a supported path to
implement this in MSL.

This was preventing "image" from being used as an identifier.

Change-Id: I724e46c866a4dd488f45fbc1215ef23a67355a78
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78280
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-27 15:55:16 +00:00
Ben Clayton 3cdb8e3c3e reader/wgsl: Optimize tokens by using string_view
Each Token was making a copy of the `val_str_`, despite the token being a slice on the original source.

Bug: tint:1383
Change-Id: I17b2da8f986ba105853aa47afe21bcc75f140f8e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-27 14:48:46 +00:00
Brandon Jones 913e158429 Update arg names for GPUComputePassEncoder.dispatch()
Slightly silly, since it has no effect on API use, but it is nice to
keep the arg names in sync with the spec.

Bug: dawn:1270
Change-Id: I1f8cfabefb3a721691c092815cbb66c959980b5e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78245
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-27 09:40:02 +00:00
Loko Kung a52dc04ee3 Adds validation tests for new device.Tick behavior based on internal and API calls.
Bug: dawn:628
Change-Id: I4de0a32fd18dc620637777754304df4634bbac66
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77720
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-01-26 19:37:16 +00:00
Stephen White e2f35ba8e0 GLSL: clean up GLSL output whitespace generation.
More line() and less std::endl.
More automated indents and less manual spacing.
Put a single newline after every struct and function declaration.

Note that this does touch every test result, but only affects whitespace.

Change-Id: I7506b9029b79b91fb335911dba44369b36f09bbe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-26 16:48:55 +00:00
Stephen White b1d2b84f7d GLSL: fix clip space mismatch in gl_Position.
OpenGL clips against [-w, w], while WebGPU uses [0, w]. The fix is to
modify gl_Position.z on output to match GLSL semantics. (This is the
same code used by SPIRV-Cross under the fixup_clipspace option.)

Bug: tint:1401
Change-Id: I1b1511352eee11cd9b095cd809aa8e1263c6cf4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78261
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-26 14:45:55 +00:00
Zhaoming Jiang 3d3e1757c4 Reland "Recording timing info in trace events when D3D12 queue submit"
This is a reland of 8e9fbbe7ca

Add a toggle RecordDetailedTimingInTraceEvents. When this toggle is
enabled, record detailed timing information in trace events right
before calling ExecuteCommandLists on a D3D12 command queue, and the
information includes system time, CPU timestamp, GPU timestamp, and
their frequency. All Windows APIs used here are supported since Windows
2000.

Original change's description:
> Recording timing info in trace events when D3D12 queue submit
>
> Add a toggle RecordDetailedTimingInTraceEvents. When this toggle is
> enabled, record detailed timing information in trace events right
> before calling ExecuteCommandLists on a D3D12 command queue, and the
> information includes system time, CPU timestamp, GPU timestamp, and
> their frequency.
>
> Bug: dawn:1264
> Change-Id: Ie06d3f2b7eb25c641ee00476334bd276227c3678
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77381
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>

Bug: dawn:1264
Change-Id: I3f81a76726f88fc0e9d817bfe452a050583399e8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78252
Reviewed-by: Yuly Novikov <ynovikov@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-01-26 13:34:51 +00:00
Jiawei Shao 04584a567e Skip two tests that fail on Win11 with backend validation == full
BUG=dawn:1273, dawn:1255

Change-Id: I78f3dc3a3cfb6a3cedd03c1644e31abf71306dd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78180
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-01-26 07:37:54 +00:00
Shaobo 5875ad7064 Implement platform-independent isNaNCustom for VertexFormatTest
Wgsl removes inNaN from spec (https://github.com/gpuweb/gpuweb/pull/2311)
and VertexFormatTest needs to cover NaN input. So we implement a
platform-independent isNaNCustom based on the rules in IEEE 754-1985.

Bug: dawn:1268
Change-Id: I53aef428c72d34381efc6b3ba0250685fc685965
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-01-26 00:22:40 +00:00
Stephen White 520bccf8d8 GLSL: implement builtin kNumWorkgroups.
Bug: tint:1400
Change-Id: I5f2523d41f73abe55e57b8931833124c2ebaf00d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78260
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 22:47:05 +00:00
Yuly Novikov c64159ca25 Revert "Recording timing info in trace events when D3D12 queue submit"
This reverts commit 8e9fbbe7ca.

Reason for revert: crashes on Win7

Original change's description:
> Recording timing info in trace events when D3D12 queue submit
>
> Add a toggle RecordDetailedTimingInTraceEvents. When this toggle is
> enabled, record detailed timing information in trace events right
> before calling ExecuteCommandLists on a D3D12 command queue, and the
> information includes system time, CPU timestamp, GPU timestamp, and
> their frequency.
>
> Bug: dawn:1264
> Change-Id: Ie06d3f2b7eb25c641ee00476334bd276227c3678
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77381
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>

TBR=cwallez@chromium.org,kainino@chromium.org,enga@chromium.org,zhaoming.jiang@intel.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I7884e1c9cb580237bfa65790e12879a075720b18
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1264, chromium:1290964
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78250
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@google.com>
2022-01-25 22:13:03 +00:00
Stephen White ca4cfb9d6f GLSL: implement interpolation qualifiers.
Bug: tint:1399 tint:451
Change-Id: Idf02a98d2c51ab4d93847fc24a9d5a447ce3aaa3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78222
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 21:39:05 +00:00
Ben Clayton 800b8e3175 optimizations: Implement transform::ShouldRun()
This change adds an override for Transform::ShouldRun() for many of the transforms that can trivially detect whether running would be a no-op or not. Most programs do not require all the transforms to be run, and by skipping those that are not needed, significant performance wins can be had.

This change also removes Transform::Requires() and Program::HasTransformApplied(). This makes little sense now that transforms can be skipped, and the usefulness of this information has been severely reduced since the introduction of transforms that need to be run more than once.
Instread, just document on the transform class what the expectations are.

Issue: tint:1383
Change-Id: I1a6f27cc4ba61ca1475a4ba912c465db619f76c7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77121
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-25 21:36:04 +00:00
Ben Clayton 12d54d746e transform: Make methods const, add ShouldRun()
Transforms are supposed to be immutable, operating on the DataMaps provided for input and output, so make the methods const.

Add a ShouldRun() method which the Manager can use to skip over transforms that do not need to be run.

Change-Id: I320ac964577e94ac988748d8aca85bd43ee8d3b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-25 20:53:25 +00:00
Ben Clayton 4a3503a610 dawn_native: Use 'auto' to handle change of tint type
tint::Source::FileContent::lines has changed from a vector of std::string to std::string_view.
The dawn usage of the field works with both types without changes, so juse use `auto` to let tint roll.

Change-Id: I0d8309a13e94da7e3558bd32d0d98a4f27a1a4bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77943
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-25 20:34:10 +00:00
Stephen White c8c0e2ea38 GLSL: standardize layout() formatting (whitespace change).
Change-Id: Id0c879c597e02da32350b2ee4878991fe78c470f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78221
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 20:06:05 +00:00
Stephen White 8e01c45e54 GLSL: add location layout qualifier before in/out variables.
Bug: tint:1398
Change-Id: I89c985d01d539ed166661ee5e858247cde4702b3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78080
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 19:44:14 +00:00
Stephen White fc792989e1 GLSL: implement image format qualifiers for storage textures.
Bug: tint:1397
Change-Id: Ifd6870b3e7cba151c361bd21f9d3d42642ff6c26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78060
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Stephen White <senorblanco@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 19:20:04 +00:00
Brandon Jones 37b3df4337 Modify External Texture Interface For BiPlanar Formats
Changes dawn.json entry for ExternalTexture to take a secondary plane
and adds wgpu::PredefinedColorSpace. Includes validation tests.

Bug: dawn:1082
Change-Id: I76475e4a1bce6f25c728ac0251ff582ef6369cd1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76282
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-01-25 18:09:00 +00:00
Stephen White 0999cb0371 Add missing @interpolate(flat) to validation test.
(Note that I've added the decoration to all types, integer or not.
This should make no difference for the purpose of this test.)

Bug: dawn:1271
Change-Id: I77a4c3ac25ad360ea59352499d97148c068ceda1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78204
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 17:17:52 +00:00
Brandon Jones b9d1540b31 Make use of std::string_view when parsing
There may very well be more places it can be used, but this updates
the easiest to identify cases that could be switched over with minimal
restructuring.

Change-Id: I5100f398731cc4e031c82548ac826d713d0a4cda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76640
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-25 17:15:37 +00:00
Ben Clayton a9ca8cb4ab wgsl: Replace use of [[attribute]] with @attribute
Bug: tint:1382
Change-Id: I58ad2c88fde1e7c96f2ae8257e6df924b94b61db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77660
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-25 16:29:04 +00:00
Yang Gu 3b46eb9d7b Replace 'elseif' with 'else if' in end2end tests
Bug: tint:1289
Change-Id: Icc93f4d6136238b6942f6ca7daae5ce494e2f0e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78160
Commit-Queue: yang gu <yang.gu@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-25 09:03:10 +00:00
jchen10 8e7b513f95 Refactor vulkan image wrapping tests on CROS
This implements the test "backend" for DmaBuf.

Bug: chromium:996470
Change-Id: I9a4b8c7d345669e26c1349b87101c6f076e1f613
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76820
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2022-01-25 08:08:09 +00:00
Zhaoming Jiang fd3505ba43 Validate texture usage is non-zero in createTexture
Validate that texture usage is not 0 (None) when creating buffer.

Bug: dawn:1266
Change-Id: I1bbb766319b8680d1303f214632708f5234bd9d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77760
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-01-25 02:54:23 +00:00
Zhaoming Jiang 8e9fbbe7ca Recording timing info in trace events when D3D12 queue submit
Add a toggle RecordDetailedTimingInTraceEvents. When this toggle is
enabled, record detailed timing information in trace events right
before calling ExecuteCommandLists on a D3D12 command queue, and the
information includes system time, CPU timestamp, GPU timestamp, and
their frequency.

Bug: dawn:1264
Change-Id: Ie06d3f2b7eb25c641ee00476334bd276227c3678
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77381
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-01-25 01:40:44 +00:00
jchen10 778cf04126 Suppress some cases in ComputeDispatchTests
These cases fail on D3D12 with the full validation layer turned on.

Bug: dawn:1262
Change-Id: I7778f081fcb1b69d85e58bbe7fcce47205d7ec12
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2022-01-25 01:25:54 +00:00
James Price 1c02eb8cb0 validation: Require interpolate(flat) for integers
This was made a warning in M97, and can now become a hard error.

Fixed: tint:1224
Change-Id: Ied72f6e28b3dc64a6ab832e0eac53f62ce045d40
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77700
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-01-25 01:01:39 +00:00
Stephen White d5560400a3 Run all of the backends in the test runner.
Essentially, this adds GLSL to the list of backends to run.

Bug: tint:1358
Change-Id: I5075df32d935a3e08733daadbe5ac9dc1e13f03c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77220
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 00:35:20 +00:00
Stephen White 2190481ad9 GLSL: avoid collisions on existing vars for binding 0/0.
Bug: tint:1396
Change-Id: I870c3dd7772b1fdf9bf7adfdb34798a9eb170163
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78020
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-24 22:51:49 +00:00
Ben Clayton 6c0df44211 Castable: Optimizations using bloomfilters
Calculate a hashcode for each TypeInfo, use these hashcodes to quickly
eliminate full base class walks for As() and Is(). Use the hashcodes to
optimize IsAnyOf() calls where the result is false.

Benchmarks:

A: base.bench
B: new.bench

Test name                             | Δ (A → B)    | % (A → B)
--------------------------------------+--------------+-----------
ParseWGSL/"particles.wgsl"            | -78.84µs     | -3.2%
GenerateWGSL/"particles.wgsl"         | -11.264µs    | -5.8%
GenerateGLSL/"particles.wgsl"         | -2.610127ms  | -7.2%
GenerateMSL/"simple_compute.wgsl"     | -41.187µs    | -7.2%
GenerateMSL/"particles.wgsl"          | -818.689µs   | -7.2%
GenerateGLSL/"simple_compute.wgsl"    | -48.362µs    | -7.4%
GenerateGLSL/"simple_vertex.wgsl"     | -49.992µs    | -7.7%
GenerateSPIRV/"simple_compute.wgsl"   | -42.869µs    | -7.8%
GenerateSPIRV/"particles.wgsl"        | -835.423µs   | -7.9%
GenerateSPIRV/"simple_fragment.wgsl"  | -33.868µs    | -8.1%
GenerateGLSL/"simple_fragment.wgsl"   | -51.368µs    | -8.2%
GenerateSPIRV/"simple_vertex.wgsl"    | -39.096µs    | -8.3%
GenerateHLSL/"particles.wgsl"         | -1.437747ms  | -8.3%
GenerateMSL/"simple_vertex.wgsl"      | -57.232µs    | -8.5%
GenerateHLSL/"simple_compute.wgsl"    | -85.981µs    | -8.9%
GenerateHLSL/"simple_fragment.wgsl"   | -73.095µs    | -9.2%
GenerateMSL/"simple_fragment.wgsl"    | -61.257µs    | -9.3%
GenerateHLSL/"simple_vertex.wgsl"     | -76.661µs    | -9.4%

Change-Id: Idb03bf871b08274b5b52ef55e41450ed3448a60f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76960
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2022-01-24 21:07:20 +00:00
Stephen White f9b8b6104d GLSL: implement CombineSamplers transform (string version).
This transform converts all separate texture/sampler references
in a program into combined texture/samplers. This is required for GLSL,
which does not support separate texture/samplers.

As input, the transform requires a map from the unique sampler/texture
pairs previously gathered by the Resolver to strings, which will be
used as the names of the newly-generated combined samplers. Note that
binding points are unused by GLSL, and so are set to (0, 0) with
collision detection disabled.

All function signatures containing textures or samplers are rewritten,
as well as function calls and texture intrinsic calls. For texture
intrinsic calls, a placeholder sampler is used to satisfy the subsequent
Resolver pass (GLSL texture intrinsics do not require a separate sampler,
but WGSL intrinsics do). The placeholder is also used if the shader
contains only texture references (e.g., textureLoad).

Bug: tint:1366

Change-Id: Iff8407d28fdc2a8adac5cb655707a08c8553c389
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77080
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-24 17:17:22 +00:00
Antonio Maiorano 4183a574b0 PromoteSideEffectsToDecl: add decomposing 'else if's to 'if { else }'
Just as we do with for loops that need decomposing to loops, we must
also decompose 'else if's to 'else { if }' so that we can insert decls
above the condition.

Bug: tint:1300
Change-Id: Ia16f1cf351964817587d353e58a02d9ae6f8386c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77500
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-24 15:18:59 +00:00
Antonio Maiorano 8db439d848 Add PromoteSideEffectsToDecl transform
Fold both PromoteInitializersToConstVar and VarForDynamicIndex into this
new transform, with a config to enable either type of transformation.
This is almost a no-op change, except that VarForDynamicIndex required
ForLoopToLoop, while this tranformation in PromoteInitializersToConstVar
converts for-loops only as needed, so it doesn't do so when the
expression is in the for-loop initializer.

This transform will be extended to handle ensuring order of execution of
expressions.

Bug: tint:1300
Change-Id: I4d00984346a2c92b2d8563b459898f8f737589fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77140
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-01-24 15:14:39 +00:00
Ben Clayton 2a31b8c1bc MSVC 2017 build fixes
Add missing include, and fix return type of tint::utils::UniqueVector::empy().

Fixed: tint:1395
Change-Id: I413eabb882b39d959dedcc4175cd7f5cc82e6838
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77840
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-01-24 14:09:09 +00:00
Yan Shaobo 25fe51a2ae Suppress D3D12 Debug Layer warning D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_NOT_SET
In the end2end test BufferZeroInitTests.PaddingInitialized, the case use
drawIndex to access OOB vertexBuffer to see whether the padding part has
been set to zero. The case use
'renderPass.SetVertexBuffer(0, vertexBuffer, vertexBufferOffset)' to set
the vertexBuffer.

But when the vertexBufferOffset == vertexBufferSize, this SetVertexBuffer
won't create any vertex buffer view on D3D12 backend. And it turns out
input slot 0 has nothing.

This warning has been reported by win11 full debug layer. But this
behaviour is allowed by WebGPU.

So this CL suppress the warning
D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_NOT_SET in D3D12 adapter.

Bug: dawn:1255
Change-Id: I0dcf816b284cf7d7013f633186d010bae8fa6523
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77640
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-01-24 10:04:24 +00:00
Ben Clayton ba1a8f8d05 optimization: BlockAllocator: Actually allocate in blocks
Instead of hitting the heap for each and every call to Create()

Significantly improves performance for heavy loads. Slight performance
loss for lighter loads.

A: base.bench
B: new.bench

Test name                             | Δ (A → B)    | % (A → B)
--------------------------------------+--------------+-----------
GenerateSPIRV/"simple_fragment.wgsl"  | 27.021µs     | +6.4%
GenerateMSL/"simple_compute.wgsl"     | 35.592µs     | +6.1%
GenerateMSL/"simple_vertex.wgsl"      | 37.64µs      | +5.5%
GenerateHLSL/"simple_fragment.wgsl"   | 42.145µs     | +5.2%
GenerateGLSL/"simple_fragment.wgsl"   | 31.506µs     | +4.9%
GenerateHLSL/"simple_vertex.wgsl"     | 38.843µs     | +4.7%
GenerateMSL/"simple_fragment.wgsl"    | 29.977µs     | +4.5%
GenerateSPIRV/"simple_vertex.wgsl"    | 19.882µs     | +4.2%
GenerateGLSL/"simple_vertex.wgsl"     | 24.702µs     | +3.7%
GenerateSPIRV/"simple_compute.wgsl"   | 17.652µs     | +3.2%
GenerateHLSL/"simple_compute.wgsl"    | 26.826µs     | +2.7%
GenerateGLSL/"simple_compute.wgsl"    | 11.952µs     | +1.8%
ParseWGSL/"particles.wgsl"            | -104.83µs    | -4.2%
GenerateMSL/"particles.wgsl"          | -1.079243ms  | -9.4%
GenerateSPIRV/"particles.wgsl"        | -1.012483ms  | -9.4%
GenerateGLSL/"particles.wgsl"         | -3.522106ms  | -9.5%
GenerateHLSL/"particles.wgsl"         | -1.849666ms  | -10.6%

Issue: tint:1383
Change-Id: Ib691328538c597c06a75dfba392c99d2afbd5442
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76961
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-22 20:32:38 +00:00
Zhaoming Jiang e67adac441 Validate buffer usage is non-zero in createBuffer
Validate that buffer usage is not 0 (None) when creating buffer.

Bug: dawn:1266
Change-Id: I690582aca91fb505c7b8c7b79c9530e71b958ebc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77642
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-01-22 05:57:25 +00:00
Loko Kung 4f37ae7f3e Loosens validation for APITick.
- Validation no longer produces an error if the device is destroyed. Instead it just no-ops now.
- Internal Ticks are still validated the same as before.
- Necessary because Chromium may call Tick after device.destroy() which causes noisy validation errors that can break tests.
- Removes the current tests for this bahavior with new follow up tests in child CL.

Bug: dawn:628
Change-Id: Idc676490c7dcf1edd104b5dfd0e9fa5c023089ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77200
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-01-22 01:40:28 +00:00
Brandon Jones d90a4f50a1 Remove External Texture Format Member Validation
Removes validation of the format member of an external texture
descriptor. Replaces it with format information inferred from the passed
texture.

Bug: dawn:1082
Change-Id: I333c3659859501eff48a532aa4701f25a33124c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77480
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-01-21 23:38:08 +00:00
Ben Clayton 73ced33dfb test/benchmark: Add more shaders to the corpus
Kindly donated by Brandon Jones and Austin Eng.
Tint has been used to convert all the deprecated attributes to the new style. In doing so, comments have been stripped. These are not massively important for the benchmarking.

Bindings have also been adjusted to be sequential and unique so that the MSL backend doesn't have to deal with binding remapping.

Existing benchmark files that used an underscore '_' have been renamed to use a dash '-' instead, to match the new files.

Change-Id: If5fb507b981f107ed570f6eedb55b232448f67aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77443
Reviewed-by: Brandon Jones <bajones@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-21 22:38:16 +00:00
Ben Clayton a2f4134c56 Formatting fix in template.
The headers get swapped by clang-format

Change-Id: I8a95d5789413d6e18ad4bfd545e1a2021eae3d72
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77444
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-21 21:26:39 +00:00
Stephen White 671d9703f0 GLSL samples: add empty entry point if needed.
If a WGSL test contains no entry points, add an empty one.
In that case, do not pass its name to the generator, so we
generate code for all functions, so they aren't culled for
reachability.

Add new test results for formerly empty tests.

Bug: tint:1376
Change-Id: Ibf371b943fb273d44712dfcc9dc1b7bb4ab071db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-21 18:40:18 +00:00
Jiawei Shao 3619a2b017 Add validation on blend factors and blend operations
This patch adds validations on blend factors and blend
operations according to the latest WebGPU SPEC:
If component.operation is "min" or "max":
component.srcFactor and component.dstFactor must both
be "one".

BUG=dawn:1257
TEST=dawn_unittests

Change-Id: Id17c06044900eb0fa8d2ebab6fd3132f9deb157a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76480
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-01-21 02:05:47 +00:00
James Price 533a1bae68 validation: Fix array storage class validation
We weren't recursing into array element types, which meant that we
weren't validating nested arrays or buffers whose top-level store-type
was an array.

Change-Id: Ib897b36e0b5c3de3dc67c4f60805411c014cd914
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77561
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-20 22:11:07 +00:00
James Price f6e5cc03bf Deprecate the @stride attribute
Update validation error for invalid uniform array element alignment.

Update tests to either remove the @stride attribute or use a different
element type.

Bug: tint:1381
Change-Id: I50b52cd78a34d9cd162fa5f2171a5fd35dcf3b79
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77560
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-20 22:11:07 +00:00
Ben Clayton 198417097f Clang format the entire tint codebase
Change-Id: I8e6ae93d0d4449e38cd32672e714ef07e1075d75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77441
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-20 20:40:18 +00:00
jchen10 0d415ff26c D3D12: Ignore the debug warning for vertex buffer out-of-bounds
This adds D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_TOO_SMALL to
the filter list of debug layer warning messages.

BUG=dawn:1261

Change-Id: Ifd0fdf9eb8314a1b2a4f9cd7d248daf0a92a6c17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76920
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2022-01-20 07:23:28 +00:00
Ben Clayton 01e4b6fc18 wgsl: Replace [[decoration]] with @decoration
Deprecate the old syntax. Migrate everything to the new syntax.

Bug: tint:1382
Change-Id: Ide12b2e927b17dc93b9714c7049090864cc568d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77260
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-19 22:46:57 +00:00
James Price 8f1d5224ee cmake: Link diagnostic sources into tint_utils_io
Splits these sources out into a separate library target to make sure
that it is only built once.

Many of these symbols are used by tint_utils_io, and building with
shared libraries enabled fails if they are not present.

Change-Id: I501d302b2502b22357f5691f012cd56ebcfde478
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75600
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-01-19 21:40:20 +00:00
James Price b28c5ad3c6 msl: Fix non-struct runtime-sized array codegen
When these are used inside a function, we were not unwrapping the
array from the struct that we wrapped it in.

Fixed: tint:1385
Change-Id: Ide7bbd802394bf09819265be48d978ec9346adfe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77180
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-01-19 19:36:17 +00:00
James Price 6b1e5f552b wgsl: Do not require a semicolon after a struct
Don't generate them either, which generated a lot of test churn.

Fixed: tint:1380
Change-Id: I0a7cfdd2ef0ffe8e7fda111fbc57997b36b949e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77165
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 18:11:17 +00:00
Austin Eng 017f9cc855 Default dawn_use_swiftshader to true
SwiftShader is required to implement WebGPU fallback adapters.

Perf tests are skipped for CPU adapters since they easily timeout
for intensive benchmarks.

Bug: chromium:1266550
Change-Id: Ib6e91da1128baae1770c797a69cf9ad605ea324d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76421
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-19 17:32:56 +00:00
James Price 5085438423 inspector: Add support for non-struct buffers
Use the sem::Type size instead of the sem::Struct size.

Some binding numbers in MSL expected outputs changed since these
buffers were previously not being reported in the resource list that
the Tint exe uses to automatically remap bindings.

Bug: tint:1372
Change-Id: I14479ddc5129d91b91449cc2d68ee37bd99d2f7e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76220
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price ae8c65620e glsl: Wrap non-struct buffer types in structs
Use the AddSpirvBlockDecoration transform to do this.

Add expected results for all of the new E2E tests. The arrayLength()
tests all fail as this is not yet implemented for the GLSL
backend. The other tests all pass except two that assign whole structs
to buffers, which is also a pre-existing issue.

Bug: tint:1372
Change-Id: I230197b43a5561e619866419d642ffc1ed085aac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76164
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price 51e55b244e transform: Handle arrayLength for non-struct buffers
These two transforms previously assumed that the argument to
arrayLength had the form `&struct_var.array_member`. We now also need
to handle the case where it is just `&array_var`.

Bug: tint:1372
Change-Id: I173a84bd32c324445573a295b281a51e291c2ae2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76163
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price 7395e29e70 Allow non-struct buffer store types
For SPIR-V, wrap non-struct types in structs in the
AddSpirvBlockDecoration transform.

For MSL, wrap runtime-sized arrays in structs in the
ModuleScopeVarToEntryPointParam transform.

Bug: tint:1372
Change-Id: Icced5d77b4538e816aa9fab57a634a9f4c52fdab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76162
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
Ben Clayton c3cec4d901 inspector: Re-add inspector::SamplerTexturePair
The tint -> dawn roll is failing as dawn is using tint::inspector::SamplerTexturePair.
We need to land this change, fix dawn, then revert this change.

Bug: tint:1366
Change-Id: I3a3849ddd9416a06d0be394e295603de59594ead
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-18 23:51:56 +00:00
Austin Eng aa9475e973 Add WGPUDawnEncoderInternalUsageDescriptor
This descriptor, when chained on WGPUCommandEncoderDescriptor makes
internal usages visible to validation.

This CL is to help implement WebGPU Swiftshader support in Chrome.

Bug: chromium:1266550
Change-Id: I7253fe45003e9ad5ac4d8ddd2d4782989e9b5c27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76440
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-18 21:54:25 +00:00
Austin Eng d0530a6e03 Use ErrorLog instead of InfoLog in InstanceBase::ConsumedError
Printing to stdout actually impacts Web Tests results which
makes managing expectations difficult, especially if logs
change.

Change InfoLog to ErrorLog:
 1) because this is ConsumedError, after all
 2) until we figure out if we can make Web Tests ignore stdout

Bug: chromium:1266550
Change-Id: I05f47f8b6d7a8e11568c5ee87eabab0cfd7c02d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76680
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-18 19:40:35 +00:00
Ben Clayton be2362b18c benchmarks: Add a basic set of benchmarks
Add google benchmark to the DEPs.

Implement a basic set of benchmarks for each of the writers and the WGSL parser.

Add build rules for CMake. GN build rules TODO.

Add a simple go tool (ported from Marl) to diff two benchmarks. Less
noisy than the one provided by google benchmark.

Bug: tint:1378
Change-Id: I73cf92c5d9fd2d3bfac8f264864fd774afbd5d01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-01-18 18:58:16 +00:00
Antonio Maiorano e232e35723 Factor out structure layout print function
Simplifies Resolver::ValidateStorageClassLayout and would allow us to
use this function for displaying structure layout in a language server,
for example.

Bug: tint:1348
Change-Id: I9d83329f0a168e5d8c094b3282d07cd1ab321dca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76080
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-01-14 21:57:22 +00:00
Stephen White 65112dc77c Move SamplerTexturePair from inspector to sem.
The plan is to reuse this datatype for the combine-samplers transform.

Bug: tint:1366
Change-Id: Icd2f4bd45b662f32fe9803e3485f1a54a2c42265
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-14 20:08:42 +00:00
Yunchao He 0fe647b817 Add d3d12-render-pass toggle in readonly depth/stencil attachment test
Bug: dawn:485
Change-Id: I569a98d59b05fafbc4f594bfe9106d26258964d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76504
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2022-01-14 18:53:40 +00:00
Ben Clayton e5919ac115 validation: Error on obviously infinite loops
Most of this change is fixing up the numerious tests that violated this rule.

Fixed: tint:1365
Issue: tint:1374
Change-Id: I38da27c7367277fe60857208170fec017e80bd25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 17:16:32 +00:00
Ben Clayton 8dd9a56f91 inspector: Remove DEPRECATED texel format APIs.
Dawn has been updated to use the new APIs.

Bug: tint:1361
Change-Id: I0eb501132b896385b21648bad8466342569317bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76520
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 14:26:32 +00:00
Ben Clayton 51e37c6f91 Fixes for bugs around unreachable code
Remove the ICE check for expression behaviors always being either `{Next}` or `{Next, Discard}`. Unreachable code may be result in something else.

Add the RemoveUnreachableStatements transform to the SPIR-V writer sanitizer transform list. The writer cannot correctly handle unreachable statements.

Bug: tint:1369
Bug: chromium:1285622
Change-Id: I9fa54c6d2096b1ee633dd551b628c7dd3ba64fb5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 10:16:24 +00:00
Loko Kung 15e3592fd5 Guards explicit device.destroy() until tested.
Bug: dawn:628
Change-Id: Ib6a6be0e5467d3cdd6432834d6f9d5c2000b18be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76340
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-01-13 23:47:20 +00:00
Brandon Jones 4abe2a0b53 Add TRACEs to backend shader module creation
Specifically ensuring that Tint's generator is individually traced so
that we can better see how much time is going into Tint's transforms
vs the backend's compiler.

Change-Id: I9903cdca137d652ee400e94f0570eeeb17779207
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76260
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-01-13 21:43:26 +00:00
Corentin Wallez 3148b49730 Start introducing a "backend" for vulkan image wrapping tests
Bug: dawn:221

Change-Id: I8077d6a873bbd4f4ed549b386014e10020ffc725
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75424
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-13 13:11:17 +00:00
Corentin Wallez 22bd21ef74 Add support for creating 1D textures.
However there are a lot more things to implement for full support:

 - Copies from/to buffers.
 - Copies from/to other textures.
 - WriteTexture
 - Lazy initialization (if needed)
 - Anything using views and 1D textures in shaders

So they are currently marked as unsafe API.

Bug: dawn:814
Change-Id: I3f1aac87bd5bc27f710d58e525938c1226d093d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64542
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-01-13 10:53:36 +00:00
Austin Eng a78192741e Implement upstream RequestAdapter
Bug: dawn:160
Change-Id: Ifbce6f71fdf43a749c332bd691b63119929e0128
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75640
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-12 23:08:35 +00:00
James Price db2f5fcf10 resolver: Reject non-storage runtime-sized arrays
There were several cases where we were not rejecting these which were
leading to ICEs or bad codegen.

Fixed: tint:1248
Change-Id: I7cdf3b74d92b81b1067ad908af423ea0b5442328
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76161
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-01-12 20:51:36 +00:00
James Price 13c79bef23 validation: Reject var<function> at module-scope
Fixed: tint:1368
Change-Id: I15fd0d2cbd9600500213e3140e9ac4500d179eb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-01-12 20:51:36 +00:00
Yunchao He b765c59c7d Implement readonly depth/stencil attachment on Metal
Bug: dawn:485
Change-Id: Ifb119361d8c383c43b4fad51f6a1f6b12ccea434
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76040
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2022-01-12 19:21:35 +00:00
Corentin Wallez ec9cf2a85c Rename namespace dawn_native to dawn::native.
But keep a namespace alias to avoid breaking project that depend on the
previous namespace name while they get updated.

Done with through the following steps:

 - git grep -l dawn_native:: | xargs sed -i "" "s/dawn_native::/dawn::native::/g"
 - git grep -l "namespace dawn_native" | xargs sed -i "" "s/namespace dawn_native/namespace dawn::native/g"
 - git cl format
 - Manual fixups in generator/templates (and the addition of
   namespace_case in dawn_json_generator.py).
 - The addition of the namespace alias in DawnNative.h

Bug: dawn:824
Change-Id: I676cc4e3ced2e0e4bab32a0d66d7eaf9537e3f09
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75982
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-01-12 09:17:35 +00:00
Sunny Sachanandani 0114ade92a d3d12: Acquire/release keyed mutex around ExecuteCommandLists
D3D keyed mutex cannot be acquired recursively and therefore external
D3D textures cannot be concurrently read within Dawn (e.g. multiple
imports of the same video frame) or across Dawn and GL (e.g. both WebGPU
and WebGL importing a video frame).

Within Dawn, we can scope keyed mutex acquire/release to command list
submission so that Chromium can always guarantee that Dawn doesn't hold
access to any resources after running Dawn wire commands. We also check
that keyed mutexes aren't recursively acquired in Dawn by keeping track
of the acquire count per resource.

This solves the multiple acquire problem within Dawn and provides a path
for concurrent read access across Dawn and GL once the GL decoders are
changed so that they also don't hold access to resources after switching
contexts.

Bug: chromium:1241533
Change-Id: If88fd4a4f798b972836a134809e4fed8832ec89c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75644
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-12 00:28:37 +00:00
Corentin Wallez 5d846ab503 Rename namespace dawn_wire to dawn::wire.
But keep a namespace alias to avoid breaking project that depend on the
previous namespace name while they get updated.

Bug: dawn:824
Change-Id: I1e99c4d0d2acf7644a225a88d07806d1a64478e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75540
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-11 09:57:33 +00:00
Corentin Wallez f07477a1ce Remove deprecated DawnNative Adapter getters.
Bug: dawn:824
Change-Id: I4e73598ccd8eb5ce85c8a0ed86629daef4b575c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75584
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-11 09:30:34 +00:00
Corentin Wallez 8bf8587eb3 Rename namespace dawn_platform to dawn::platform.
But keep a namespace alias to avoid breaking project that depend on the
previous namespace name while they get updated.

Some TraceEvent.h macro were using "platform" as an argument name so
that was renamed to "platformObj" to avoid conflicting with ::platform::

Bug: dawn:824
Change-Id: Iaf14853f02b0d9fcf866ce87788f87a3fdf8f364
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75541
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-11 02:10:53 +00:00
Sunny Sachanandani e53bfc561c d3d12: Use fixed key for keyed mutex acquire and release
Chromium has switched to using a fixed key (0) for quite some time.
Using a fixed key enables future work needed for concurrent access of
external textures both inside Dawn (e.g. importing a video frame twice)
or across Dawn and GL. We want to try scoping the Acquire/Release calls
to command list submission, but with a non-fixed key concurrent access
for the same resource becomes ambiguous.

Bug: chromium:1241533
Change-Id: Ia8ff473b8c9c731c411a3fd59d69213f2d903e61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75642
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-11 01:36:54 +00:00
Jiawei Shao 9acdbcba85 Vulkan: Add StoreOp to the computation of the key of RenderPassCache
This patch adds StoreOp to the computation of key of RenderPassCache,
which was missed in the last CL that fixes a failure of end2end test
on Windows Intel Vulkan drivers.

BUG=dawn:1151

Change-Id: Iec03d70303c89906154db5256fd8691cc018a91a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75860
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-01-11 00:19:54 +00:00
Ben Clayton 6fad9e9745 dawn_node: Add support for diffing against expectations file
Adds the command line flags:
*  `--output <path>` which will write the current test results to the given file
* `--expect <path>` will compare the current run against the given expectations file

Bug: dawn:1123
Change-Id: Ie1bfa4e0c0698a95922e350387f8493b7a6ac68b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75980
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-01-10 20:57:37 +00:00
Stephen White 3e354fd524 Resolver: collect unique texture/samplers pairs.
GLSL does not support separate textures and samplers, so they must be
replaced with combined samplers. This is the first stage of that change,
where we collect the unique texture/sampler pairs. Within a function,
texture and sampler must be either a global variable or a function
parameter. At the entry point level, all references must resolve to global
variables, so by recursing the call graph we can determine all of the
global pairs required.

This information will be used by an upcoming transform to modify the AST
to be GLSL-compliant: modifying function signatures, call sites, removing
separate globals and adding combined globals. It will also eventually
replace the pair-gathering currently performed by
Inspector::GetSamplerTextureUses().

Bug: tint:1366
Change-Id: I89451b195649da26e45641ea2f6955683ae9fc66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75960
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-10 20:46:35 +00:00
Ben Clayton d1efb5d48c reader/wgsl: Replace std::result_of with std::invoke_result
With C++17, std::result_of has been deprecated and superceeded with std::invoke_result.
std::result_of triggers a compiler warning about use of a deprecated feature, which is causing the ossfuzz builds to fail

Issue: oss-fuzz:43441
Change-Id: Ie4ed670dd5b25b9059d5feb8056e37a22dad3cbf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75981
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-10 20:44:25 +00:00
Corentin Wallez 5bab76a64d run-cts: Hint to use --isolate on POST failures.
Bug: dawn:1123
Change-Id: Ifac813410b7ec36e48282875c5915a5d8cf89282
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75904
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-10 16:36:02 +00:00
Corentin Wallez 0275a4c83b Roll third_party/gpuweb/ 67edc187f..0aadaca4c (519 commits)
- Adds supports for the ETC2 and ASTC extensions.
 - Adds support for all texture formats supported by the spec.
 - Removes pipeline statistic queries.
 - Removes support for depthClamping since it has been reworked in a
   depthClipControl extension that Dawn doesn't implement yet.
 - Removes GPUCommandBuffer.getExecutionTime.
 - Adds support for GPUCommandBuffer.clearBuffer.
 - Removes writeTimestamp inside passes and adds TODO to add support for
   timestampWrites.

67edc187f5...0aadaca4c5

$ git log 67edc187f..0aadaca4c --date=short --no-merges --format='%ad %ae %s'
2022-01-07 dneto Clarify fract (#2485)
2022-01-07 dneto Clarify fract (#2485)
2022-01-07 dneto Clarify fract (#2485)
2022-01-06 dneto Behaviors: Ban obviously infinite loops (#2430)
2022-01-06 dneto Fix declaration-and-scope section for out-of-order decls (#2479)
2022-01-06 dneto Behaviors: Ban obviously infinite loops (#2430)
2022-01-06 dneto Fix declaration-and-scope section for out-of-order decls (#2479)
2022-01-06 dneto Behaviors: Ban obviously infinite loops (#2430)
2022-01-06 dneto Fix declaration-and-scope section for out-of-order decls (#2479)
2022-01-06 dneto Move Limits section to under "WGSL Program" (#2480)
2022-01-06 dneto Move Limits section to under "WGSL Program" (#2480)
2022-01-06 dneto Move Limits section to under "WGSL Program" (#2480)
2022-01-05 dneto [editorial] Rename "built-in variable" -> "built-in value" (#2476)
2022-01-05 dneto [editorial] Rename "built-in variable" -> "built-in value" (#2476)
2022-01-05 dneto [editorial] Rename "built-in variable" -> "built-in value" (#2476)
2022-01-05 dneto Only define image format names usable for storage textures (#2475)
2022-01-05 dneto Only define image format names usable for storage textures (#2475)
2022-01-05 dneto Only define image format names usable for storage textures (#2475)
2022-01-04 dneto Remove 'read','read_write','write' as keywords, image formats as keywords (#2474)
2022-01-04 dneto Remove 'read','read_write','write' as keywords, image formats as keywords (#2474)
2022-01-04 dneto Remove 'read','read_write','write' as keywords, image formats as keywords (#2474)
2022-01-04 jrprice [editorial] wgsl: left shifts are logical (#2472)
2022-01-04 jrprice [editorial] wgsl: left shifts are logical (#2472)
2022-01-04 jrprice [editorial] wgsl: left shifts are logical (#2472)
2022-01-04 dneto Deploying to gh-pages from @ gpuweb/gpuweb@7371fbf6d3 🚀
2021-12-30 kvarkus Texture format caps for MSAA and resolve (#2463)
2021-12-30 kvarkus Texture format caps for MSAA and resolve (#2463)
2021-12-30 kvarkus Texture format caps for MSAA and resolve (#2463)
2021-12-30 kainino Fully describe validation of render attachments (#2458)
2021-12-30 kainino Fully describe validation of render attachments (#2458)
2021-12-30 kainino Fully describe validation of render attachments (#2458)
2021-12-29 kainino Rework encoder state and mixins (#2452)
2021-12-29 kainino Rework encoder state and mixins (#2452)
2021-12-29 kainino Rework encoder state and mixins (#2452)
2021-12-29 kainino1 Deploying to gh-pages from @ gpuweb/gpuweb@68fe77316d 🚀
2021-12-29 mehmetoguzderin Fix examples classes, globals, and previews (#2412)
2021-12-29 mehmetoguzderin Fix examples classes, globals, and previews (#2412)
2021-12-29 mehmetoguzderin Fix examples classes, globals, and previews (#2412)
2021-12-28 kainino Clarify that attachments may not alias (#2454)
2021-12-28 kainino Clarify that attachments may not alias (#2454)
2021-12-28 kainino Clarify that attachments may not alias (#2454)
2021-12-28 shaobo.yan Add source image orientation to copyExternalImageToTexture (#2376)
2021-12-28 shaobo.yan Add source image orientation to copyExternalImageToTexture (#2376)
2021-12-28 shaobo.yan Add source image orientation to copyExternalImageToTexture (#2376)
2021-12-28 kainino1 Deploying to gh-pages from @ gpuweb/gpuweb@e7224b9949 🚀
2021-12-24 kainino Restore the box around algorithm divs (#2453)
2021-12-24 kainino Restore the box around algorithm divs (#2453)
2021-12-24 kainino Restore the box around algorithm divs (#2453)
2021-12-24 kainino Define GPUTextureViewDimension values (#2455)
2021-12-24 kainino Define GPUTextureViewDimension values (#2455)
(...)
2021-10-14 dneto Deploying to gh-pages from @ gpuweb/gpuweb@6f239ffda6 🚀
2021-10-14 lokokung Add ETC2 and ASTC texture formats and feature name documentation (#2180)
2021-10-14 lokokung Add ETC2 and ASTC texture formats and feature name documentation (#2180)
2021-10-14 lokokung Add ETC2 and ASTC texture formats and feature name documentation (#2180)
2021-10-14 kvark Deploying to gh-pages from @ gpuweb/gpuweb@ab71f65a80 🚀
2021-10-13 dneto describe builtin functions as prototypes (#2178)
2021-10-13 dneto describe builtin functions as prototypes (#2178)
2021-10-13 dneto describe builtin functions as prototypes (#2178)
2021-10-13 dneto Integral pipeline IO must be specified interpolate(flat) (#2183)
2021-10-13 dneto Integral pipeline IO must be specified interpolate(flat) (#2183)
2021-10-13 dneto Integral pipeline IO must be specified interpolate(flat) (#2183)
2021-10-12 mehmetoguzderin Fix render by closing table (#2177)
2021-10-12 mehmetoguzderin Fix render by closing table (#2177)
2021-10-12 mehmetoguzderin Fix render by closing table (#2177)
2021-10-12 mehmetoguzderin Allow syntactic navigation and styling (#2143)
2021-10-12 mehmetoguzderin Allow syntactic navigation and styling (#2143)
2021-10-12 mehmetoguzderin Allow syntactic navigation and styling (#2143)
2021-10-12 dneto Deploying to gh-pages from @ gpuweb/gpuweb@59d839d767 🚀
2021-10-06 dneto wgsl: remove ignore, add phony-assignment (#2127)
2021-10-06 dneto wgsl: remove ignore, add phony-assignment (#2127)
2021-10-06 dneto wgsl: remove ignore, add phony-assignment (#2127)
2021-10-06 dneto wgsl: editorial cleanup: memory vs. storage (#2155)
2021-10-06 dneto wgsl: editorial cleanup: memory vs. storage (#2155)
2021-10-06 dneto wgsl: editorial cleanup: memory vs. storage (#2155)
2021-10-06 mehmetoguzderin Make hex exponent suffix optional for floats (#2164)
2021-10-06 mehmetoguzderin Make hex exponent suffix optional for floats (#2164)
2021-10-06 mehmetoguzderin Make hex exponent suffix optional for floats (#2164)
2021-10-06 dneto wgsl: Add limits section, and "spurious" failure (#1997)
2021-10-06 dneto wgsl: Add limits section, and "spurious" failure (#1997)
2021-10-06 dneto wgsl: Add limits section, and "spurious" failure (#1997)
2021-10-06 alanbaker Clarify memory locations accessed when writing a vector component (#2152)
2021-10-06 alanbaker Clarify memory locations accessed when writing a vector component (#2152)
2021-10-06 alanbaker Clarify memory locations accessed when writing a vector component (#2152)
2021-10-04 jrprice Fix inequality symbol in compute shader grid bound (#2153)
2021-10-04 jrprice Fix inequality symbol in compute shader grid bound (#2153)
2021-10-04 jrprice Fix inequality symbol in compute shader grid bound (#2153)
2021-10-04 jimb Fix some misplaced characters in the `select` description. (#2154)
2021-10-04 jimb Fix some misplaced characters in the `select` description. (#2154)
2021-10-04 jimb Fix some misplaced characters in the `select` description. (#2154)
2021-09-29 dneto wgsl: Function call statement may call non-void functions (#2148)
2021-09-29 dneto wgsl: Function call statement may call non-void functions (#2148)
2021-09-29 bclayton wgsl: Update README.md (#2150)
2021-09-29 dneto wgsl: Function call statement may call non-void functions (#2148)
2021-09-29 dneto Deploying to gh-pages from @ gpuweb/gpuweb@7e87583853 🚀
2021-09-28 kainino Remove no-op minBindingSize text (#2141)
2021-09-28 kainino Remove no-op minBindingSize text (#2141)
2021-09-28 kainino Remove no-op minBindingSize text (#2141)
2021-09-28 kainino Clarify copies into -srgb formats (#2146)
2021-09-28 kainino Clarify copies into -srgb formats (#2146)
2021-09-28 kainino Clarify copies into -srgb formats (#2146)

Created with:
  roll-dep third_party/gpuweb

Fixed: dawn:1130
Bug: dawn:1123
Change-Id: I9a9539696fbd0a4d15a7e3369959ac97b262d9d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75902
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-10 15:26:31 +00:00
Corentin Wallez 6d9ee4254b dawn_node: handle literals on typdef'd interface members
Bug: dawn:1123
Change-Id: Ie7f388a0322b195937aa76ab30b1513ca642b572
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75901
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-10 15:23:21 +00:00
Corentin Wallez 4fe5d65446 dawn_node: Allow Include and Mixins to come out of order in idlgen
Bug: dawn:1123
Change-Id: I120e6234e194f46954e3c7e75a3a8cc667df9611
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75900
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-10 15:23:01 +00:00
Corentin Wallez 0d2c6c6215 dawn_node: Return undefined for "void" methods instead of null
Bug: dawn:1123
Change-Id: I38a5b160c12485ea23b34a6b3c8cdf44baee2ada
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75903
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-10 14:30:14 +00:00
Corentin Wallez 03b3594f79 Add C overload for dawn_native::Adapter::GetProperties
This helps Chromium move to using this method and stop using
dawn_native::AdapterType/BackendType.

Bug: dawn:824
Change-Id: I9e16edd271d3406bc45e3b9fd472bd94bbf53b30
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75583
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-01-07 17:30:48 +00:00
Ben Clayton 8b4d03d302 tint: Remove deprecated texel formats.
Issue: tint:1361
Change-Id: Id49ad89c439443ea30cc8693a10a23af52eb9ebf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75542
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-07 11:10:18 +00:00
James Price 72ba3039eb dawn_node: Fix default adapter selection
The Null adapter was always being used when no backend override was
specified, instead of the platform's default adapter.

Change-Id: I3d8ae62aacda1309a141c3ca39d6e03252fc5e94
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75700
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-07 09:19:08 +00:00
Shaobo Yan c40f04b85b Support *-srgb format as dst formats in CopyTextureForBrowser
Dawn allows texture-to-texture copy happens between the textures that
formats only have diff on srgb-ness.

CopyTextureForBrowser could align on this rule to achieve copying to
*-srgb dst texture and keep the bytes the same as copying to non-srgb
formats.

This CL add support for *-srgb textures as dst textures and using an
extra gamma decoding step for this.

Bug: dawn:1195
Change-Id: I665dbca473aa84b9d87b7a35c4f90ce1897ade7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74580
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-01-07 03:05:27 +00:00
Jiawei Shao e009ad7edd Vulkan: Compare storeOp when comparing the key of RenderPassCache
This patch adds the missing comparisons on the storeOp when comparing
the key of RenderPassCache as now we support more than one storeOp
(Store and Discard).

With this patch the following end2end test will pass on Windows Intel
Vulkan drivers:
- TextureZeroInitTest.IndependentDepthStencilLoadAfterDiscard

BUG=dawn:1151
TEST=dawn_end2end_tests

Change-Id: I44d6f3e589341bba761503b1a06c388db92d1295
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75482
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-01-07 00:02:57 +00:00
Austin Eng 3ac7b9ce79 Change uint32_t -> size_t in *Enumerate functions
Follows https://github.com/webgpu-native/webgpu-headers/pull/142

Bug: dawn:160
Change-Id: Ic8aa5868bf1a68ae5ff80ce6e5fc0e8d687c34bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75481
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-06 22:11:28 +00:00
Ben Clayton e4e7485854 transform: Fix PromoteInitializersToConstVar handling of for-loops
PromoteInitializersToConstVar was erroring on for loops that contained array or structure constructor expressions.

Added lots more tests.

Fixed: tint:1364
Change-Id: I033eaad94756ea496fc8bc5f03f39c6dba4e3a88
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75580
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 21:32:41 +00:00
Ben Clayton 4d245d9a36 ast: Remove unsupported texel formats
Fixed: tint:1361
Change-Id: Idcf98713d9a380e56811bea6419913714d602103
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75582
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 18:37:01 +00:00
Ben Clayton 3cbb136b8a Re-allow dynamic indexing of 'let' arrays and matrices
Spec change: https://github.com/gpuweb/gpuweb/pull/2427
Reverses: tint:867

This reverts and fixes commits:
 b6fdcc54df
 10442eff7d

Added a bunch of end-to-end tests.

Fixed: tint:1352
Change-Id: I34968243bbec1cab838c8ba50a6f027146bbfd06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75401
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 18:11:01 +00:00
Ben Clayton 294ce9394f ast: Rename ImageFormat to TexelFormat
This is what its called in the spec.

Issue: tint:1361
Change-Id: I512c4224191fd2bbf04522da2093872f79ee02a6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75581
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 17:20:22 +00:00
Ben Clayton 6165cca1a6 reader/wgsl: Remove texel format names as keywords
These were removed in https://github.com/gpuweb/gpuweb/pull/2474.
`read`, `write` and `read_write` were already excluded as keywords.

Fixed: tint:1359
Change-Id: I5424f780f4bd67bb336320a22dd2097ed03b4bd6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75360
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-01-06 12:16:11 +00:00
Corentin Wallez 7f8fa04edc Use C++17 nested namespaces instead of manually nesting them.
This was done with these two commands and a couple manual fixups for
namespaces that had more than one space in the comment in the closing
brace, as well as vulkan_platform.h

git grep -l "namespace .* { namespace " | xargs sed -i "" "s/namespace \(.*\) { namespace /namespace \1::/"
git grep -l "}}  // namespace" | xargs sed -i "" "s%}}  // namespace%}  // namespace%"

Bug: dawn:824
Change-Id: I6f448b820c12fc1004ea5270bf8e1f466b0c0aab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75400
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:22:17 +00:00
Corentin Wallez 5984d8d1a8 Use C++17 structured binding in more places.
Bug: dawn:824
Change-Id: Ie39d4f622bfb3dcc3a74b03d594efcea7139a9dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75069
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:17:57 +00:00
Corentin Wallez 1c49d1b43b Use C++17 structure bindings instead of some std::tie
Not all std::tie can be replaced because structured binding introduces
references names and cannot bind member variables.

Bug: dawn:824
Change-Id: Ie2b45834aac72fb063d4aaea5949a53457bc73c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75068
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:14:17 +00:00
Corentin Wallez a4357a7619 Add Window at the end of SurfaceDescriptorFromXlib.
Bug: dawn:1246
Change-Id: I1917056e9bb2bde0997c072ab76963e9dd079bb3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75420
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:10:00 +00:00
Corentin Wallez 31f12242da dawn_wire::server: Simplify ForwardToServer usage with C++17
This uses template parameter type deduction to pass the member function
pointer and then extract the types that compose it. Which means that the
member function pointer only needs to be written once.

The order of arguments of the Server::On*Callback methods is changed to
put the userdata first. This helps make template type deduction simpler.

Bug: dawn:824
Change-Id: I4e2bc33dfd52a11620dea51b40508eca6c878d72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75071
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:09:49 +00:00
Corentin Wallez 2994d2e7b9 Use C++17 [[nodiscard]] and [[fallthrough]] attributes
Bug: dawn:824
Change-Id: Ied4f2eb736e0c3488a79e4872e7ffa3eb2fdaac5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75063
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:02:38 +00:00
Corentin Wallez 3f011e6807 SlabAllocator: Remove note about C++17
We can't use aligned_alloc because it is only available starting from
macOS 10.15 and above. Now that we have C++17 the only thing blocking
use from using aligned_alloc is the macOS version, so note that.

Bug: dawn:824

Change-Id: Icb3bc22047193c189932dea4d10073dabb0cf32a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75065
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:02:28 +00:00
Yan cf0e4fceb3 Support T2T copies between formats that have only difference on srgb-ness
In previous T2T copy, Dawn requires textures have the same formats. But
Vulkan/Metal/D3D12 have ability to copy between "compatible" formats textures.

Metal has the most restrict rules without setting interpreter flags when creating
textures. It defines "compatible" texture formats to the formats that only have
difference on srgb-ness.

This CL follow Metal's rule and release the validations for T2T copies. It supports
T2T copy between "compatible" texture format textures.

Bug: dawn:1204
Change-Id: I50bf04ea15e8026530b3a5bdb5725f56aa192d85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74301
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-01-06 09:01:58 +00:00
Corentin Wallez fa2fde1432 Use C++17 non-const string.data() in WindowsUtils
Bug: dawn:824
Change-Id: I9a7880bc38b15864364505f9f9399e440c048e7a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75064
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:01:48 +00:00
Ben Clayton c00cc43e53 reader/spirv: Optimize FindUnusedDerivedName()
Store the last search id suffix so that we don't research the same suffixes over and over again.

Bug: oss-fuzz:38098
Bug: oss-fuzz:38606
Bug: oss-fuzz:39300
Bug: oss-fuzz:40339
Change-Id: I295147d91bb9f805170c49114267033bbb781e4d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75427
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:42:50 +00:00
Ben Clayton 1c4f8de30b reader/spirv: Optimize MakeNullValue()
Constructing a null vector, matrix or array does not need to provide an explicit list of null elements. `T()` is a more efficient and readable equivalent.

Fuzzers like to generate enormous pathological composite types, which has been triggering OOM failures.

Bug: oss-fuzz:38095
Bug: oss-fuzz:39235
Bug: oss-fuzz:39246
Bug: oss-fuzz:39874
Change-Id: I910bb04bdd0e80532c09fc038be895ec37d3d380
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75426
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:24:22 +00:00
Ben Clayton 4a143a40a3 reader/spirv: Prevent nullptrs being passed to ast::CallExpression.
nullptrs are caused by errors. Detect and return before passing nullptrs to places they shouldn't go.

Also: Rename 'params' to 'args'. These are arguments, not parameters.

Bug: oss-fuzz:38074
Fixed: tint:1355
Change-Id: I77f97b4a8e5dab21802b300ba3eedad767ac2ad5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75425
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:11:41 +00:00
Ben Clayton 5c99ed046a intrinsics: Add degrees() and radians()
Fixed: tint:1329
Change-Id: I5fb927268fc9cb8047a2b365d26e813a8546605a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75423
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:11:00 +00:00
Brandon Jones cef2d17385 Prevent negative error message ranges
If an error message was reported from Tint that had a end line/position
that occurred before the start line/position then the range would have
a negative length, causing the unsigned length to underflow into a very
large value. Also, specifically, if the start line was non-zero but the
end line was zero (indicating no line, and the value ranges are
constructed with by default) the for loop that adds the line offsets
would underflow and cause it to read off the end of the line list.

Clamping the end of the range to always be less than or equal to the
start of the range avoids both of these problems.

Bug: dawn:1245
Change-Id: I780a1f5acc228297cbbea86f33679d00e9153b4c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75260
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-05 18:27:36 +00:00
Corentin Wallez 7c8bc94bee CMake: enable C++17
Bug: dawn:824
Change-Id: Ia8ac55d406a2b0b9c71f12b523058fa97aabf408
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75040
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-05 09:26:46 +00:00
Li Hao 538d8d5d1c Implement depth24unorm-stencil8 and depth32float-stencil8 formats
- Add format implementation on D3D12, Metal and Vulkan
- Add more formats in depth/stencil copy, sampling and load op tests and
  refactor them to test with parameters.

BUG=dawn:690

Change-Id: I829d1eea3ce35ffb39417ea23fb8afba6d542769
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/73180
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2022-01-05 01:31:16 +00:00
David Neto 4beeaea9da spirv-reader: support OpImageDrefGather
Also, issue an error when a gather or dref-gather operation
is used with a Bias or Grad image operand.

Fixed: tint:1336
Change-Id: Ife11d2f52a1a2d1b75e26269373db5cc4b3440bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74801
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2022-01-04 22:00:59 +00:00
David Neto 5791197e80 fix spirv-reader test: add Block decoration
Fixes a SPIR-V validation error.

Change-Id: I51bf887d1e2b55760e5512648074ae349a90a15e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74802
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-04 20:23:19 +00:00
Ben Clayton 1372222215 wgsl: Replace 'elseif' with 'else if'
Bug: tint:1289
Change-Id: I72432391e60cf5ff173aa51a6d4a2bc8ef58fbf2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75240
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-04 20:06:49 +00:00
David Neto 622bc9732a Add -DDAWN_USE_X11=OFF for dawn.node build
Otherwise we gain a default dependency on X11, when on Linux.

Change-Id: Ief52603758f5808a47dde64b04b4f10d27e4c93a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74880
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-04 19:39:06 +00:00
Corentin Wallez 3343e3b29f Add missing space in a toggle description
Change-Id: Ic233a75cba31923d9fe320634ca6b2ea45432ceb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/73020
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-01-04 17:29:15 +00:00
Corentin Wallez e19e8356c1 Preliminary fixes for upgrading the MSVC toolchain
Fixes / suppresses a couple warnings raised by the updated MSVC and
silences all C++17 deprecation warnings since we can only fix them after
we update to use C++17.

Bug: dawn:824
Change-Id: I047985f26244ed3a42c73740617aee15546ca9dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75072
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-01-04 16:32:06 +00:00
David Neto 7d88368c56 spirv-reader: support OpImageGather
Bug: tint:1336
Change-Id: I771b09e7568f1f022a316f2ba0bc72c03f735aa1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74800
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-04 15:46:39 +00:00
Corentin Wallez f09a23a3f7 Fix MSVC narrowing warnings in newer MSVC versions.
Bug: dawn:824
Change-Id: I4be68ab47e5aa846583240c1024e286d7ec2e115
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75073
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-04 15:31:24 +00:00
Ben Clayton 76ff65f694 dawn_node: Error if the specified backend is not found
Defaulting to the 0'th adapter can silently use the Null adapter, which is no fun for anyone.

Bug tint:1354

Change-Id: I14e2379175cb90a48753bd81d096391d15d2dc22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75070
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-04 14:36:25 +00:00
Corentin Wallez 09c49b34d9 Fix -Wunreachable-code-return with newer clang version.
When the emit_continuing lambda always returns true, clang is able to
detect it and finds that some code is unreachable.

This commit changes places that use the lambdas directly to instead use
the stored emit_continuing_ member.

Bud: dawn:824
Change-Id: Idfd804a6ec53ac793e8988dce79991c659fbbc36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75060
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-04 10:18:39 +00:00
David Neto 680900a9ca Fix dawn.node compilation
Fix the use of DawnTogglesDeviceDescriptor.
The dawn.node GPUAdaptor binindg code is already in the wgpu namespace
so use DawnTogglesDeviceDescriptor directly instead of prefixing
it with wgpu::

Bug: dawn:160
Change-Id: I01ab76983aabe150df5769764735d90e4f1e73bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74840
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-30 20:16:33 +00:00
David Neto 7913982f87 wgsl reader: Allow 0X as a hex prefix for ints and floats
Fixed: tint:1353
Change-Id: I8252cc9d055657e361c4bceadcc59f7703f98c23
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74380
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-23 22:25:21 +00:00
Jiawei Shao 67a22dee01 Add a missing space in the error message of SetIndexBuffer
BUG=dawn:887

Change-Id: I108377328ce735a2daaca9512ded6b35e0bfaa14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74460
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-23 09:50:36 +00:00
fujunwei f001ef5505 Make the templates of webgpu_absl_format flexible
Move the manually parts to src/dawn_native/webgpu_absl_format.cpp/h.
Rename the template webgpu_absl_format.cpp/h to api_absl_format.cpp.h .

BUG=dawn:1201, dawn:563
Change-Id: Ibbeea43227f4fcf7f1d6b1d0bc3927226e79e6c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74300
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Junwei Fu <junwei.fu@intel.com>
2021-12-23 05:16:04 +00:00
Austin Eng dc518772c6 Update tests to use wgpu::DeviceDescriptor
Bug: dawn:160
Change-Id: I2fce45c5cc6f9e95054ad5fa42acfeb42ad787c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72062
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-22 19:04:33 +00:00
Austin Eng 2f218e2b21 Implement upstream RequestDevice, add native-only CreateDevice
This CL implements RequestDevice and also has changes for
Dawn to internally use wgpu::FeatureName enums, instead of
strings. Some of the string handling is kept for now to
support the deprecated creation path. GetFeatureInfo is added
to the instance to get a name and description of the feature,
for reporting in about://gpu.

Dawn device toggles are now passed in an extension struct off
of the device descriptor. This is only supported in dawn_native,
and not dawn_wire, for now, since dawn_wire doesn't have a way
to serialize lists of null-terminated const char*.

To enable the client to check whether the toggle descriptor is
supported, a `dawn-native` feature is added which is supported
all the time with dawn_native, but not supported with dawn_wire.

Feature `dawn-native` also enables a synchronous version of
CreateDevice for convenience.

Bug: dawn:160
Change-Id: Ifc195e7ea808c6c319021528ef4b36bd65583bff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72020
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-22 19:02:23 +00:00
Corentin Wallez 7628489cf6 Reland "Bump maxUniformBindingSize to 2^16 from 2^14"
This is a reland of 1a57ee9d4e

Original change's description:
> Bump maxUniformBindingSize to 2^16 from 2^14
>
> This was upped in https://github.com/gpuweb/gpuweb/pull/2159
>
> Bug: dawn:1173
> Change-Id: I98d46b9b5a339280d21ddcb2ab039ce7ebce4ec3
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71608
> Commit-Queue: Brandon Jones <bajones@chromium.org>
> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Brandon Jones <bajones@chromium.org>

Bug: dawn:1173
Change-Id: Id86c6432e792a44bb231ae7778df1d38f4084f5b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/74302
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-22 16:18:36 +00:00
Antonio Maiorano 9943de6813 Fix FXC compile errors on modulo by zero
Just like for divide, FXC fails with the exact same error when
performing a modulo on a value that FXC determines to be zero. We
address it in the same way as we do for divide.

This also fixes a couple of the vk-gl-cts tests for which I manually
generated expectation files for.

Bug: tint:1083
Change-Id: Ia388bf002112afded542adb791d37e88e35a77ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74220
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-22 15:02:09 +00:00
Stephen White cc4d97b6e3 GLSL: use "Offset" forms of texture intrinsics when appropriate.
Also ensure correct paramter ordering: bias is always after offset.

Bug: tint:1351

Change-Id: I41ee66b86cd9d912f3857e5377b660c50d035c6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-12-21 16:53:36 +00:00
Antonio Maiorano 821f9bb525 Fix FXC compile errors on divide by zero
FXC fails to compile when it determines that the rhs of an integral
division is zero with "error X4010: Unsigned integer divide by zero".

bclayton's fix (https://dawn-review.googlesource.com/c/tint/+/60500)
addressed cases for division by an integer constant 0. This CL adds the
missing support for division by integral vectors with 0 components.

FXC also fails on division by integral expressions that it can fold to
0. To handle these cases, we now emit a runtime check for 0 and replace
by 1. In the cases I've tested, FXC seems able to optimize these checks
away.

Bug: tint:1083
Change-Id: I02f08e9077882f03c1e42b62dacb742a48fa48ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-21 14:48:26 +00:00
Yunchao He b9467591a4 Implement readonly depth/stencil without sample from it
This change add a couple end2end tests when readonly depth/stencil
attahcment is enabled in render pass and the pipeline doesn't
sample from the depth/stencil attachment. The pipeline only do
depth/stencil test.

This situation may not be useful in real world applications. But
it is possible that developers do it in this way. And it impacts
the implementation on some backend like Vulkan.

Bug: dawn:485
Change-Id: I8a81330659295cd4a2f00591b6ead719538babd9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71441
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2021-12-21 04:02:22 +00:00
Brandon Jones 67a2d57e3f Temporarily avoid error message formatting failure
For unknown reasons formatting of a error context message fails in
RenderEncoderBase::APISetBindGroup fails if the bind group is printed
as a string in the message. This despite the exact same code working as
intended in ComputePassEncoder::APISetBindGroup. Replacing it with a
static "[BindGroup]" to allow the rest of the message to format
correctly until the reason for the failure can be determined.

Bug: dawn:1190
Change-Id: I31105acff4d08849a34e406c6b8e85fab28f17b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/73280
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2021-12-21 00:07:01 +00:00
David Neto 66e7569e15 spirv-writer: Fix termination of basic blocks
There are a few places where a branch or return is created,
conditionally on whether a terminator was the last thing seen.
The goal is to generate a SPIR-V basic block terminator exactly
when needed, and to avoid generating a branch or return immediately
after a prior terminator.

Previously, the decision was based on the last thing seen in the AST.
But we should instead check the emitted SPIR-V instead.

This fixes cases such as a break or return inside an else-if.
That's because an if/elseif is actually a selection inside a selection.
Looking at the AST only works when trying to terminate the *inside*
selection.  In the outer recursive call, the last AST node is
no longer a terminator, and we would skip generating the branch
to the merge block.

Fixed: tint:1315
Change-Id: I6b886ce85d1d681f2063997e469e0c1b4e5973a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73480
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-12-20 16:46:55 +00:00
Yan 36e86ee778 Remove AlphaOp
CopyTextureForBrowserOptions deprecated AlphaOp after supporting
color space conversion. AlphaMode for src and dst is the replacement.

Bug: dawn:1140
Change-Id: Id507bd7525d74be8a12d212b92cc22f0c7bc94b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/73141
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2021-12-17 03:49:48 +00:00
David Neto 188b1fb8f5 spir-reader: fix tests: struct with BuiltIns must have Block
Fixes https://github.com/dneto0/spirv-samples/issues/2

Change-Id: Ie3ab62f31ba7e3d7c8d4dd56f8dc9a87046e1b92
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73241
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-16 22:07:51 +00:00
David Neto 11d9a08287 spirv-reader: remove test with invalid SPIR-V
SPIR-V validation fails when an object has multiple ArrayStride
decorations. Remove the SPIR-V reader tests that did this.

Change-Id: Iaac0f0f0c9230ccbc7dde5414d6aaf6f0e972534
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73240
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-16 21:50:51 +00:00
Austin Eng f6519cc4e5 Test requestAdapter and requestDevice on the wire
Bug: dawn:689
Change-Id: I032cfcba755be241126dfa8447a38625d7183334
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71523
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-15 23:06:17 +00:00
Austin Eng 07e766728a dawn_wire: Implement requestAdapter and requestDevice
This implements requestAdapter and requestDevice by
forwarding commands the the server and relaying back
replies. After an adapter or device is created,
limits/properties/features are queried and also sent
back to the client.

Bug: dawn:689
Change-Id: Ie0c2984b8ebb661efb0c284a14ae8b74ae4af2ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-15 21:52:17 +00:00
James Price d4f8c39f52 Remove [[block]] attribute from all shaders
This has been removed from WGSL and is now deprecated in Tint.

Bug: tint:1324
Change-Id: Ic187ce3c5ce0723db6f3ca6483e9f5e73ce27acc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72880
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-15 13:13:26 +00:00
fujunwei 16ae3b8b95 Make the templates of mocking api flexible
Rename mock_webgpu to mock_api and define the function "GetProcTableAndDevice" to "GetProcTable" for removing the special arguments "WGPUDevice* device" that can be got with "GetNewDevice()".

BUG=dawn:1201

Change-Id: I4fc47e4497ba4b6d280cc8af8605f1d93f43497e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72761
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Junwei Fu <junwei.fu@intel.com>
2021-12-15 04:35:26 +00:00
Yan 5204053954 Support "length" in dawn.json could be a integer
Struct member defined in dawn.json could have a 'length' attribute
defines the length of the member if it is an array.

In previous, the 'length' could only be 'strlen' or other variable
which has 'uint32_t' types. It cannot support constant length.

CopyTextureForBrowserOptions transfers conversion parameters and
conversion matrix with a constant length. This CL adds this ability
to meet such requirements.

Bug: dawn:1140
Change-Id: I6eeabbc55cc3853fe15e33bdd44060b16f6096bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72580
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2021-12-15 04:08:56 +00:00
Austin Eng 18416ecdf9 dawn_node: Fix wgpu::ErrorFilter::None
This enum value was removed.

Bug: dawn:1206
Change-Id: Ifebceb01e817a29daec6629434d4dd792f343f74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72940
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-12-15 00:29:46 +00:00
Austin Eng 89ddadcd1e Add feature queries to dawn_native/dawn_wire
This is so we can implement the adapter/device APIs fully
on dawn_wire.

Bug: dawn:689
Change-Id: I47f68157d081f359f871e0efe0d974dfe53de7d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71521
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-15 00:12:30 +00:00
Austin Eng 5397f9f9d0 Add basic or stub implementations of upstream instance/adapter APIs
Adds upstream instance/adapter APIs. In dawn_native, the basic APIs
to get limits and properties are implemented, but requestAdapter and
requestDevice are not. In dawn_wire, nothing is implemented, but the
stub definitions are put in place, as well the mechanism to inject
WGPUInstance into the wire.

There is a lifetime concern with WGPUInstance and WGPUAdapter on the
wire in that we need to ensure that the client cannot free the
instance or adapter while they are in use. In the near term, this is
not a problem because Chromium will always hold ownership of the
instance and adapters outside of the wire - i.e. it won't inject and
then release ownership.

Bug: dawn:160, dawn:689
Change-Id: Id904272983f23babc9177bc163d78c4fa1044da0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71520
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-14 23:22:46 +00:00
Austin Eng 0e6f443359 Remove dawn_native::DeviceDescriptor typedef
Bug: dawn:160, dawn:689
Change-Id: I9ec5f2056ac70c4150e6555291045690ee295403
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70582
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-14 22:35:35 +00:00
David Neto 9360046a86 spirv-reader: Use GenerateExpressionWithLoadIfNeeded more
* Rename GenerateNonReferenceExpression to
  GenerateExpressionWithLoadIfNeeded.
  This version takes an ast::Expression
* Add a variant that takes a sem::Expression, because the sem
  expression already knows the resolved type, and so we can save
  a lookup.
* Replace most uses of GenerateExpression ... GenerateLoadIfNeeded
  with a call to one of the above.

This is a non-functional change.
Followup to the fix in tint:1343.

Bug: tint:1343
Change-Id: If19a1bc7670edd2badc1533861d8b42f0825c7b8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72720
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-14 22:15:39 +00:00
David Neto 5ad482744d spirv-writer: Generate load if needed for continue block conditional exit
Fixed: tint:1343
Change-Id: Ic105e407c572f1c309da8f21908a16c08b081f7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72641
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-14 15:16:11 +00:00
Li Hao 4682ae0034 Get counterSets and counters using Objective-C style
Bug=dawn:1102

Change-Id: I656938f180ac3436a40ba8720e54618c8921504b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72760
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-14 08:41:26 +00:00
Yan 483bead0e2 CopyTextureForBrowser: Support display p3 to Srgb color space conversion
This CL add color space conversion bases for CopyTextureForBrowser.
Theoretically, it could support any color space conversion. But
test cases only cover (Srgb, DisplayP3) to (Srgb).
It could be expanded to more color spaces conversions.

Bug: dawn:1140
Change-Id: I332e6d1f7cf2424fd5f5af83c71fa45c98d2d8ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2021-12-14 04:51:45 +00:00
Antonio Maiorano 9b9132c715 Fix OOB access while dumping struct layout for invalid storage class layout
A one letter typo would lead to invalid memory access in the very
specific case of outputting the layout for a struct within a struct with
field alignment padding, and the inner struct has more members than the
outer.

Bug: tint:1344
Bug: oss-fuzz:72642
Change-Id: I749e3fb172e78a20ece68b40be1a0a57dc5746f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72642
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-13 23:36:38 +00:00
David Neto f885941100 Add cstddef for definition of size_t
Change-Id: Ic92072a680951145f4925a2ac640f74a8f8b4335
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72640
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-13 21:14:48 +00:00
David Neto 6d67dad7fe spirv-reader: Ignore duplicate decorations
Vulkan allows them, but WGSL does not.

A duplicate decoration is purely redundant.
A parameterized decoratio with different parameterization is
an inconsistency and a semantic error, at least for currently defined
SPIR-V decorations.

So for each target, only take the first decoration of each kind.

Fixed: tint:1337
Change-Id: I6ed5c39cf2e213c695cb8217ed1b97814da3db56
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72500
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-12-13 17:54:21 +00:00
Antonio Maiorano d733fdb85c HLSL: work around FXC failures when dynamically indexing arrays in structs
FXC fails to compile code that assigns to dynamically-indexed fixed-size
arrays in structs on internal shader variables with:

error X3500: array reference cannot be used as an l-value; not natively
addressable

This CL detects this case, and transforms such assignments into copying
out the array to a local variable, assigning to that local, and then
copying the array back.

Also manually regenerate SKIPs for HLSL/FXC after this change, which
fixes 30 tests. Also exposes some "compilation aborted unexpectedly" now
that  "array reference cannot be used as an l-value" has been fixed. For
tests that fail for both DXC and FXC, updating SKIPs to the DXC one to
help distinguish actual FXC bugs from valid errors.

Bug: tint:998
Bug: tint:1206
Change-Id: I09204d8d81ab27d1c257538ad702414ccc386543
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71620
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-13 15:55:11 +00:00
Corentin Wallez 88d5e07d73 Roll GN
Also fix a gn check failure with the new GN.

Bug: None
Change-Id: I0686dd5de7fc5804fbbe79f19db413cc67fa0aae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72484
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
2021-12-13 15:24:55 +00:00
jchen10 ffb0024a89 Support NV12 via ExternalImageDescriptorDmaBuf on CROS
On Intel platforms, all planes in fact have same dma-buf, so the
DISJOINT bit shouldn't be used to create the vkimage.
For multi-planar formats, VkImageDrmFormatModifierListCreateInfoEXT
has to be used instead of
VkImageDrmFormatModifierExplicitCreateInfoEXT.

Bug: chromium:1258986
Change-Id: I25306a438e7ba9fd981848e63068e486bbddf11d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68961
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2021-12-13 02:38:44 +00:00
David Neto 5923803f7e Document that ast::Variable::type can be null
Change-Id: I7a29c1de49cbd082a5c3e0fc4bdcdead9dd2c956
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70340
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-10 21:51:05 +00:00
Corentin Wallez 3b7e75865c Vulkan: make PNextChainBuilder require pNext==nullptr
This will hopefully help catch issues early when people forget to set
pNext before creating the PNextChainBuilder.

Bug: dawn:1223
Change-Id: Ic6b9704aeaa20731e4f7de4d1ac0207d4110c720
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71762
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-10 15:48:19 +00:00
Austin Eng 6ad6278bc5 Enable dynamic storage buffers
Validation is implemented with CTS tests added in
https://github.com/gpuweb/cts/pull/850

Fixed: dawn:429
Change-Id: Iee570c712f81fbafc158c0ceec89a28011a3fed8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71960
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-10 01:50:08 +00:00
David Neto 9c179a601c wgsl-reader: hex prefix only is an error
These are errors:

    let a = 0x;
    let b = -0x;

Fixes: tint:1338
Change-Id: I9d26ad66e32deb954550c0ecfbda0a9005bcd380
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72380
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-09 22:35:44 +00:00
Yunchao He 0e922b5995 Add validations for depth/stencil aspect requirement for DepthStencilState
In RenderPipelineDescriptor.DepthStencilState, if depth test or depth
write is enabled, the texture format must have depth aspect. Likewise,
if stencil test or stencil write is enabled, the texture format must
have stencil aspect.

Bug: dawn:1226

Change-Id: I9d7efb25675ff2c90704fa45703fb542bab6f1f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72101
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2021-12-09 22:02:14 +00:00
Yunchao He 15fec68a4f Implement readonly depth/stencil attachment on Vulkan
It requires to revise quite a few flags in order to implement
readonly depth/stencil attachment on Vulkan. For example:
  - VkAccessFlags,
  - VkPipelineStageFlags,
  - VkImageUsageFlags,
  - and the most important: VkImageLayout.

These revised flags need to be applied to many Vulkan objects.
For examples:
  - VkImageMemoryBarriers,
  - IMAGE_LAYOUT revisions in descriptor set (bindings),
    render pass, and subpass,
  - and loadOp/storeOp revisions in render pass and subpass.

This change also does some workarounds in order to make Vulkan
validation layers happy. For example:
  - use DEPTH_STENCIL_READ_ONLY image layout for binding a
    depth/stencil texture,
  - add DEPTH_STENCIL_ATTACHMENT_BIT image usage for binding a
    depth/stencil texture.

Note that STORE_OP_STORE is used for depth/stencil's storeOp for
readonly attachment. It leads to Vulkan validation error. This
change igores that error and let it proceeds and it works well.

Bug: dawn:485
Change-Id: Ie247c9cbffbd837984b0933a905632ab5ad8862d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70280
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2021-12-09 21:32:28 +00:00
Austin Eng 63f65465f5 Add a build target for a webgpu_dawn library
This library binds directly to dawn_native and implements
webgpu.h. It may be built as a single library so it can
be easily used in other projects.

Bug: dawn:1220
Change-Id: I73be8c6455922fa526efd1600446cc46b07e82ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53887
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-09 20:03:48 +00:00
James Price 1461b032aa glsl: Don't emit structs with runtime-sized arrays
The GLSL emitted for these was invalid, and we don't need these
structs since they're only used as the store types of buffers, which
are handled elsewhere.

Change-Id: I17c15e408b5c36e9b895e5950528a6d02d1802a6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72381
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-09 18:54:35 +00:00
Ben Clayton 4e6e113816 reader/spirv: Allow leading underscore in identifiers
Bug: tint:1292
Change-Id: I738c981f503545075115101a3ead30941a19d95a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72320
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-12-09 16:55:04 +00:00
David Neto 01e4b54497 null character on input is an error
Fixes: tint:1311
Change-Id: Id80adc2c14c6d2cd5ee884e081d1d84f021e6620
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72200
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-09 15:57:30 +00:00
James Price 170a50353c reader/wgsl: Deprecate the [[block]] attribute
Bug: tint:1324
Change-Id: Ic8e9cd4a2e924498397659b5d23d6ac6d602588d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72088
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-12-09 15:45:03 +00:00
James Price 3530c6bf06 reader/spirv: Do not generate block attributes
These are no longer necessary and will soon be deprecated and removed.

Bug: tint:1324
Change-Id: I3fa076e7ce5eb36466d24c80fd1c83658c28c5ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72086
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-09 15:45:03 +00:00
James Price ebdfa5d303 transform: Do not generate block attributes
These are no longer necessary, and the attribute will soon be
deprecated and removed.

Bug: tint:1324
Change-Id: Ia3cdd4e9d9bd7bca45d734a06466993199b3e838
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72085
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-09 15:45:03 +00:00
James Price 7c0693d9fe Remove {ast,sem}::Struct::IsBlockDecorated()
No code should rely on the presence of the block attribute, which will
soon be deprecated and removed.

Bug: tint:1324
Change-Id: I868d5e795e66a93bdf99b94389c07dec98cb0ec2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72084
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-09 15:45:03 +00:00
James Price c7c80c053d glsl: Always emit structures
Skipping those that are block-decorated is not correct, as
block-decorated structures can also have non-buffer usages. This is
even clearer now that WGSL has removed the block attribute.

Bug: tint:1324
Change-Id: I6484766a5c541d39e2dc08beb3ae7b889759a3fb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72083
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-12-09 15:45:03 +00:00
James Price 3a4443a681 spirv: Add block decorations with a transform
Any struct which is used as the store type of a buffer variable needs
to have a block decoration. If that struct is nested inside an array
or another struct, we wrap it inside another struct first.

This removes the SPIR-V backend's reliance on the [[block]] attribute,
which will soon be deprecated and removed.

Bug: tint:1324
Change-Id: Ib6ad54f24a3e4a090da9faeed699f266abcb66ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72082
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-12-09 15:45:03 +00:00
James Price ac8975f291 validation: Remove requirement for block attribute
Replace all validation rules that rely on the block attribute with the
new rules based on fixed-footprint types.

Bug: tint:1324
Change-Id: I02656537bee66e6e1af95875e503a37bf23d4a6b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72081
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-12-09 15:45:03 +00:00
Ben Clayton 81b3948649 resolver: Implement element inference of vecN and matNxM
Fixed: tint:1334
Change-Id: Idc94d49ecd41e37354bb93138348e3af3e733932
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72143
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-09 14:37:37 +00:00
James Price 0fe30b52a5 single_entry_point: Retain applied transforms
This transform does not use the top-level ctx.Clone() method, so we
need to manually copy the applied transforms over to the destination
program.

This fixes the GLSL backend, where this transform was dropping the
applied transforms and breaking a required transform dependency later
in the chain.

Change-Id: I3db688fe35dfbe67468b9941f739cb2ecf3a843b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-12-09 09:18:44 +00:00
Jiawei Shao b6d80e027d dawn_wire: Rename Write{Buffer|Texture}Internal to Write{Buffer|Texture}
BUG=chromium:1266727

Change-Id: I3cad4c7b6b09ef4475ff030a5d239f544dc1cdef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72066
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-12-09 02:42:47 +00:00
Antonio Maiorano a8c202b8e7 HLSL: work around FXC failures when dynamically indexing matrices
This fixes errors like "error X3500: array reference cannot be used as
an l-value; not natively addressable". Note that FXC treats matrices
like arrays. We still get this error for dynamically indexed arrays in
structs.

Also improved HLSL assign tests, and add missing ones for vector
indexing.

Manually removed 20 e2e skip hlsl SKIP files that are now passing with
this change.

Bug: tint:1333
Change-Id: If23881a667857a4d4ec6881e72666af0a666ef10
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71982
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-08 23:03:33 +00:00
Loko Kung 79f62081c0 Fixes bad mem-read in Vulkan's ~DescriptorSetAllocator.
Bug was a result of an external BGL reference that lingered after device was destroyed leading to a bad read on the device's FencedDeleter when the BGL reference was finally released. Fix just makes sure that the previous code path runs during the device destruction instead of afterwards.

- Removes passthrough call in BGL to the allocator and instead has the device keep track of the allocator directly so that the list can be used to both deallocate bind groups and bind group layouts at the end.
- Makes the allocator an ObjectBase so that we can have an explicit copy of the device since getting it from the layout can be dangerous now that the allocator may outlive the layout.

Bug: chromium:1276928
Change-Id: Ibca5e3c313fc0c0980ecaaa9ad2c871e204ac153
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71860
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2021-12-08 20:27:14 +00:00
Ben Clayton 3703522d41 Implement textureGather, textureGatherCompare
All writers implemented, along with resolving and validation.

TODO: SPIR-V Reader.

Bug: tint:1330
Change-Id: I8ba2f6023749474f80efb8a5422ac187e6c73a69
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71820
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2021-12-08 19:54:08 +00:00
Brandon Jones 370e6bd734 Validate stripIndexFormat at draw time.
Updates validation logic to match the recent changes in
https://github.com/gpuweb/gpuweb/pull/2385 that allows stripIndexFormat
to be undefined at pipeline creation time, even for strip topologies.
Non indexed draw calls are valid with such pipelines. Indexed draw calls
fail validation at draw time.

Bug: dawn:1224
Change-Id: I28ff78eac726d46f99a099ffb2338b5da81a4a88
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-12-08 17:24:37 +00:00
fujunwei ed33e05db1 Move EnumClassBitmasks from wgpu to dawn namespace
The EnumClassBitmasks is used by dawn/api_cpp.h that needs to be common.
Define a macro to export the operators from dawn to other various namespace.

BUG=dawn:1201
Change-Id: I20badd54e844fead6ecf12546a2c9e0afa2fd83f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Junwei Fu <junwei.fu@intel.com>
2021-12-08 05:46:17 +00:00
Zhaoming Jiang 53137bd57d Remove wgpu::ErrorFilter::None
Remove wgpu::ErrorFilter::None from Dawn as it is removed from the
specification.

Bug: dawn:1206
Change-Id: If8ec2722cf1b2bad380011f191f296f0e591646d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71607
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2021-12-08 02:42:17 +00:00
Antonio Maiorano b2bbb14bd4 Add TINT_SYMBOL_STORE_DEBUG_NAME option to help debugging the AST
If TINT_SYMBOL_STORE_DEBUG_NAME is 1, Symbol instances store a
`debug_name_` member initialized with the name of the identifier they
represent. This member is not exposed, but is useful for debugging
purposes.

Bug: tint:1331
Change-Id: Ia98e266aefc1ca26bbf30c6ece73d9eac8afdbd7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-12-07 14:43:17 +00:00
Antonio Maiorano cf3880201b Make HLSL validation run with same flags as Dawn
FXC is buggy, and I recently landed changes in Dawn to run with "/O0"
rather than /"O2" because of these bugs. Let's make sure Tint end-to-end
tests do the same. Also do the same when running against DXC.

Bug: dawn:1203
Change-Id: I1a30f16dee8306bd645d87b3ccb0cc87691c5972
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71800
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-07 14:40:47 +00:00
Corentin Wallez 0766ce6ed1 Vulkan: Load procs for VK_KHR_get_memory_requirements2
Bug: dawn:1223
Change-Id: I14f6bfd66ac35a2d80b70fd121bd3be5e9670352
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71761
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-07 09:32:08 +00:00
Corentin Wallez 87ef49c461 Require semicolon after DAWN_TEST_PARAM_STRUCT
Bug: None
Change-Id: I6b9fb69c6d02abb2a210f10d91b02c5b77b48cdc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71760
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-07 09:29:46 +00:00
Jiawei Shao 6a886b47de Align offset to 4 bytes in writeTexture on depth stencil textures
This patch fixes a bug in the allocation of internal staging buffer
for Queue::WriteTexture() that we must ensure the buffer offset to
be 4 bytes when calling Queue::WriteTexture() on depth stencil
textures as is restricted by Vulkan SPEC.

BUG=dawn:1213
TEST=dawn_end2end_tests

Change-Id: Ia2d073ef12d48baff42fca97005c1185c9560f1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71605
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-12-07 01:33:36 +00:00
Loko Kung 4539a48355 Revert "Bump maxUniformBindingSize to 2^16 from 2^14"
This reverts commit 1a57ee9d4e.

Reason for revert: Swiftshader does not support 2^16 at the moment, and this is causing all Swiftshader tests to be skipped silently.

Original change's description:
> Bump maxUniformBindingSize to 2^16 from 2^14
>
> This was upped in https://github.com/gpuweb/gpuweb/pull/2159
>
> Bug: dawn:1173
> Change-Id: I98d46b9b5a339280d21ddcb2ab039ce7ebce4ec3
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71608
> Commit-Queue: Brandon Jones <bajones@chromium.org>
> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Brandon Jones <bajones@chromium.org>

TBR=cwallez@chromium.org,enga@chromium.org,bajones@chromium.org,bajones@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Ib7d6023adac3f99b8e7238035eed2a16f2ced6d0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1173
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71840
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2021-12-06 23:06:09 +00:00
Austin Eng 58c655b6b3 Complete per-backend AdapterDiscoveryOptions
D3D12, OpenGL, and OpenGLES have their own backend-specific
AdapterDiscoveryOptions. Add the same for Vulkan and Metal so we can
selectively discover just Vulkan or Metal adapters.

The Vulkan options include a boolean forceSwiftShader to force
Dawn to discover only SwiftShader on the Vulkan backend.

Also, refactor D3D12's DiscoverDefaultAdapters to simply call
DiscoverAdapters to match the other backends.

Bug: chromium:1266550
Change-Id: I137f94b40084b2d0ddeda39b6b7ef20f033d8a4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/69522
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2021-12-06 20:58:56 +00:00
Austin Eng 652293f14c Support multiple Vulkan instances in the Vulkan backend
This will allow the Vulkan backend connection to be initialized, and
then selectively discover adapters on just one of the instances.
This is needed so that discovery of the fallback WebGPU adapter can
avoid initializing any adapters other than SwiftShader.

Bug: chromium:1266550
Change-Id: Ia8b31c0239da89a41aa89f1c09a66e9e56e10d95
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/69980
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-06 19:31:12 +00:00
Corentin Wallez 1a57ee9d4e Bump maxUniformBindingSize to 2^16 from 2^14
This was upped in https://github.com/gpuweb/gpuweb/pull/2159

Bug: dawn:1173
Change-Id: I98d46b9b5a339280d21ddcb2ab039ce7ebce4ec3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71608
Commit-Queue: Brandon Jones <bajones@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
2021-12-06 16:17:21 +00:00
Ben Clayton 9c7b39f365 msl: Explicity validate against MSL 1.2
Fixed: tint:1327
Change-Id: I7d2e182f60c42894410500f393a1235d37efe5e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71680
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-12-06 13:02:36 +00:00
Kai Ninomiya 5db89fbd38 Fix typo in DmaBuf tests
Caused roll failure starting here:
https://chromium-review.googlesource.com/c/chromium/src/+/3314932/

Bug: None
Change-Id: I8f348a4fea243364fefc01f902add33abff66d1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71700
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-04 01:51:49 +00:00
Ben Clayton 05eedd81b0 writer/msl: Only use [[invariant]] on MSL 2.1+
This is not supported on older versions.
This behavior was agreed by the WGSL core group:
https://github.com/gpuweb/gpuweb/issues/893#issuecomment-745537465

Bug: tint:1327
Change-Id: I1a0459068c438e625ae9d99fe4a044a96f2db57e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71684
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-03 21:58:53 +00:00
Ben Clayton cc05d89820 writer/msl: Replace use of 'auto' with actual return type
Fixes MSL 1.2 error:
'auto' return without trailing return type; deduced return types are a C++14 extension

Bug: tint:1327
Change-Id: I5956aadf6b28b605b07c9681716ac4b3e31d804a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71683
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-03 21:50:23 +00:00
Ben Clayton c830130bb8 resolver: Fixes for bitcasts
Fix dependency graph traversal for bitcasts. These were not being traversed, leading to an ICE if the bitcast type was an alias, as the symbol was not resolved for later use by the resolver.

Add missing validation for bitcasts. We were permitting any bitcast that wasn't a being cast to a pointer type, when the spec only allows:
 * numeric_scalar to numeric_scalar
 * vecN<numeric_scalar> to vecN<numeric_scalar>

Add lots of tests.

Fixed: chromium:1276320
Change-Id: I9e5487ec7649ac543f73fc878e7e282bf932d8cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71681
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-12-03 21:29:13 +00:00
Ben Clayton b9e8a0b87d writer/spirv: Add tests for automatic OpReturnValue
As requested at:
https://dawn-review.googlesource.com/c/tint/+/71604/5/src/writer/spirv/builder_if_test.cc#476

Bug: tint:1302
Change-Id: I661f877beb44f999e17f2769b4aa46b22180bbb9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71682
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-12-03 19:19:33 +00:00
Ben Clayton ea3eee9885 resolver: Migrate validation to behavior analysis
Migrate some of the validation logic over to use the results of behavior
analysis.

The most significant changes are:
* Unreachable-statements now consider merge-points of control flow. For
  example, if all branches of a if-statement or switch-statement either
  return or discard, the next statement will be considered unreachable.
* Unreachable statements are no longer an error, but a warning. See
  https://github.com/gpuweb/gpuweb/issues/2378.
* Statements that follow a loops that does not break, or have a
  conditional will now be considered unreachable.
* Unreachable statements produced by the SPIR-V reader are now removed
  using the new RemoveUnreachableStatements transform.

Some other new changes include additional validation for the continuing
block for for-loops, to match the rules of a loop continuing block.
The new cases this validation is testing for are not expressible in
WGSL, but some transforms may produce complex continuing statements that
might violate these rules. All the writers are able to decay these
complex for-loop continuing statements to regular loops.

Bug: tint:1302
Change-Id: I0d8a48c73d5d5c30a1cddf92cc3383a692a58e61
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-12-03 17:51:48 +00:00
Ben Clayton c270322884 writer/spirv: Fix trailing emission of OpReturn
writer::spirv::Function attempted to append a trailing OpReturn if the
function does not end with a terminating instruction. This wasn't
considering functions that have a non-void return type.

This has now been moved to spirv::Builder::GenerateFunction(),
where we can actually examine the function return type, and generate a
zero-expression to return if we need to.

Note: this was masked by WGSL validation that required all functions to
end with a return statement.

Bug: tint:1302
Change-Id: Iddfeda25a956622c318b8235dc6fc093a2a5c26d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71604
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-12-03 17:51:48 +00:00
Corentin Wallez c6d3a840da Replace reinterpret_cast with FromAPI/ToAPI where possible
This brings more type safety to the code and is marginally more
readable.

Bug: None
Change-Id: I0330a8a8e95cd9b8b531af266acd8fdc50c50460
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71606
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-12-03 16:47:18 +00:00
Ben Clayton 3298625760 resolver: Implement Behavior Analysis
This change implements the behavior analysis for expressions and
statements as described in:
https://www.w3.org/TR/WGSL/#behaviors

This CL makes no changes to the validation rules. This will be done as a
followup change.

Bug: tint:1302
Change-Id: If0a251a7982ea15ff5d93b54a5cc5ed03ba60608
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68408
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-12-03 15:49:34 +00:00
Ben Clayton bf39c8fb19 sem: Replace SwitchCaseBlockStatement with CaseStatement
The SwitchCaseBlockStatement was bound to the BlockStatement of an ast::CaseStatement, but we had nothing that mapped to the actual ast::CaseStatement.
sem::CaseStatement replaces sem::SwitchCaseBlockStatement, and has a Block() accessor, providing a superset of the old behavior.

With this, we can now easily validate the `fallthrough` rules directly, instead of scanning the switch case. This keeps the validation more tigtly coupled to the ast / sem nodes.

Change-Id: I0f22eba37bb164b9e071a6166c7a41fc1a5ac532
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71460
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-12-03 15:23:52 +00:00
Ben Clayton 8e39ffd512 sem: Add constructor field to sem::Variable
Produces a direct SEM -> SEM pointer, reducing AST <-> SEM hopping.

Change-Id: I233b4c47d4e55b5f2c6e14ed08699a302b8fb64d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71321
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-12-03 11:42:43 +00:00
Brandon Jones d3105bfa47 Implement GPUCommandEncoder::ClearBuffer
Implements ClearBuffer for all backends.

Bug: dawn:1170
Change-Id: Ifc687d55727821c4fc134bf95020794c9d325025
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68642
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-12-02 21:43:49 +00:00
Corentin Wallez 959f1da637 Roll Vulkan headers to 1.2.201
Also delete vulkan.hpp that we don't use, and vulkan_fuchsia_extras that
have since then been upstreamed.

Also updates the fuchsia external import code to use the non-temp
extension.

Bug: dawn:221

Change-Id: I23e1bfedc5a18731be1e58d0bae1bddf6b0f45fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71601
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-12-02 20:27:58 +00:00
Brian Sheedy 75f0f29507 Fix test suppression macros
Changes several DAWN_TEST_UNSUPPORTED_IF macros that were erroneously
used to DAWN_SUPPRESS_TEST_IF.

Bug: dawn:1216, dawn:1217

Change-Id: Iaa0d7eb1b3aad8c0b11ff395cebaff0f15631beb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71524
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-12-02 20:25:58 +00:00
Austin Eng 2d0007ca8f Don't connect to backends that aren't needed
Change backend connection in Instance.cpp to store a bitset of
backends that have been connected. This lets us only connect to a
single backend if AdapterDiscoveryOptions are passed explicitly,
and track which connections have/have not been made. Later, we can
connect to the rest of the backends if more are requested.

This is part of some improvements to the existing code so we can
selectively discover adapters and control discovery of the
high-performance, low-power, and fallback WebGPU adapters.

Bug: chromium:1266550
Change-Id: Iceb0d3f71751f5aac6218996ace3cf89deda8a29
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/69521
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-12-02 18:12:57 +00:00
Brandon Jones f71784fc2b Transform texture_externals used in a user-defined function
Adds functionality and tests for performing the multiplanar external
texture transform on texture_external parameters in user-defined
functions.

Bug: dawn:1082
Change-Id: I15f23e639a6cd24ed3428055420908f05b69c0c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-12-02 15:21:31 +00:00
Ben Clayton abf4f17b8e utils: Add copy constructor to EnumSet
Some versions of clang warn as error without this:

error: definition of implicit copy constructor for 'EnumSet<tint::ast::PipelineStage>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
Change-Id: I02cee0b1f7b70d74f29da0067e888b50acf27ee1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71600
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-12-02 13:00:32 +00:00
Zhaoming Jiang 3a036ab698 Validate that storage texture views have a single miplevel
Validate the storage texture views have a miplevel of 1 when creating
bind group. This validation is added in
https://github.com/gpuweb/gpuweb/pull/2285.
Also fix a bug in unittest BindGroupValidationTest.TextureBindingType.

Bug: dawn:1212
Change-Id: If32400ed1e4f3049b8b8979e6e6133bada36b45c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71380
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2021-12-02 05:38:30 +00:00
Li Hao c871df0b19 Validate depth/stencil texture formats in image copies
- Update block size of depth/stencil formats in TextureUtils.h
- Allow to copy depth aspect for Depth32FloatStencil8 and disallow it
for Depth24UnormStencil8 in copyTextureToBuffer()
- Add Depth24UnormStencil8, Depth32FloatStencil8 and other depth/stencil
  formats in CopyCommandsValidationTests.

Bug=dawn:690

Change-Id: I3f645b838b8a8cdafe0880bbd1e4e8d17d994510
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-12-02 02:06:40 +00:00
Brian Sheedy b17ecc3835 Suppress GTX 1660 failures
Suppresses several failures in Dawn's C++ tests that were found on
Windows machines with GTX 1660s.

Bug: dawn:1216, dawn:1217

Change-Id: I1b9feddd742837d0f91118803103eecbaa9effc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71560
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-12-02 01:28:26 +00:00
Loko Kung 25e41622c8 Adds testing infrastructure in DawnTest for error testing.
Bug: dawn:628
Change-Id: I80ef132a3ff0998d30a25cc5024e86905d859fb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71240
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-12-01 22:25:00 +00:00
Loko Kung 1d47bac0fc Moves remaining logic in BindGroup dtor into Destroy.
Bug: dawn:628
Change-Id: I2e6a403c89e450efc952c91a2d497b99aa60c298
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71244
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-12-01 19:32:00 +00:00
Loko Kung 6331f959c1 Refactors Destroy to be upward calls instead of overriding.
- Fixes all class and implementations to call upwards when necessary.
- Makes DestroyImpl full virtual at ApiObjectBase.
- Fixes mock classes to call default DestroyImpl upwards on mock calls.
- Adds back D3D12 optimization for buffer destruction.

Bug: dawn:628, dawn:1189
Change-Id: Id2c2c6483dc7ed93daf8e4648af26ac1307e3d90
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71243
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-12-01 18:54:40 +00:00
Loko Kung 2494c9be8f Expose device.destroy upwards and add end2end tests
Bug: dawn:628
Change-Id: I0820d6855ac928c25f5720a2ccf0f21ae3f88d79
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68120
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-12-01 17:55:30 +00:00
Brandon Jones e7efad0325 Copy from a zeroed-out buffer to clear in D3D12
When setting a buffer to zero now uses copies from a previously
allocated, zeroed out buffer to perform the clear rather than making new
allocations every time.

Bug: dawn:1160
Change-Id: I0c8e7e56b2afcb5961723e352d8bbdf276f4557c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70760
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-12-01 16:17:20 +00:00
Ben Clayton 62394b2492 utils: Add more methods to EnumSet
Add assignment operators and methods for adding, removing and operators for performing set arithmatic.

Change-Id: I13d30734354f503180f75480866b54034f647c2a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71320
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-12-01 16:17:00 +00:00
Austin Eng dcf5743395 Use Tint HLSL options to pass dynamic storage buffer sizes
Dynamic storage buffer sizes are loaded from a uniform buffer
which is bound to a set of root constants in the D3D12 root
signature.

Bug: dawn:429
Change-Id: I3bf0d9bbdb7a5b0a8c0f624f18081c6bf8d45fca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68960
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-11-30 23:54:39 +00:00
Loko Kung f89824595d Suppress flaky order-dependent BufferZeroInitTest.PaddingInitialized.
- Only suppressing for Linux/Vulkan/Nvidia platforms for now as those are the reproducable ones. The issue could be larger though.

Bug: dawn:1214
Change-Id: I56f29fdef912b0857b33bb81d391a82702750b47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71360
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2021-11-30 23:42:49 +00:00
Ben Clayton 77e2c6f0b2 sem: Add Behavior to Statement and Expression
Nothing currently does the analysis to calculate these.

Change-Id: Ia2103102fbf36109f357aebf32cdfda24d6d8155
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68407
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2021-11-30 13:25:12 +00:00
jchen10 ba276a4f55 Bug fixes for VulkanImageWrappingTestsDmaBuf
VulkanImageWrappingTestsOpaqueFD already has the same fixes, but
sadly didn't get applied to VulkanImageWrappingTestsDmaBuf.
DawnTest::Setup() and TearDown() are missing so the device isn't
initialized.
The expected values in CopyTextureToBufferSrcSync are wrong.

Bug: dawn:1210
Change-Id: I3810a626d840573ab7c1fa75ba7ca239e7288c3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71245
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2021-11-30 12:40:59 +00:00
Austin Eng 6e83e6284e Disabling inlining of counterSet checks
To help debug a suspect crash in these functions.

Also, change some of the counter checks to use more
Objective-C style checks instead of std::find.

Bug: dawn:1102
Change-Id: I693d1f2489116200b2c0608ca60bc3eb8ddb8571
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71242
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Hao Li <hao.x.li@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-11-30 04:16:18 +00:00
Li Hao 66467a4d8f Add Depth16Unorm texture format in utils/TextureUtils.h
The Depth16Unorm format has been implemented at
https://dawn-review.googlesource.com/c/dawn/+/62420, we can add it to
kAllTextureFormats and kDepthFormats in utils/TextureUtils.h.

Bug=dawn:570

Change-Id: I5abf845341debc1d6881c639bc400c40b14fc3bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70900
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-11-30 03:36:49 +00:00
Austin Eng 633d40bd0f Revert "Add a guard for MTLDevice.counterSets being null."
This reverts commit 610f184fd9.

Reason for revert: Crashes still happen even with this guard.
Testing shows that counterSets being null does not cause crashes.

Original change's description:
> Add a guard for MTLDevice.counterSets being null.
>
> This is a tentative fix for a segfault that's happening on
> metal::Adapter initialization on some systems.
>
> Bug: dawn:1102
> Change-Id: Iff31e46420e60cd76ecbbfa92bd5b5906ca89cf4
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/69340
> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Austin Eng <enga@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>

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

Bug: dawn:1102
Change-Id: Ia7d7428acee552a107425c774ba15e97bf170e38
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71241
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-11-30 01:07:38 +00:00
Austin Eng e5b361d8ef Add D3D12 root constants to hold dynamic storage buffer sizes
All of these root constants are set when a bind group holding
dynamic storage buffers is applied. This could be improved by
using reflection data to only set constants that are needed
in the shader. This will require adding a way to store the
reflection information in the blob cache.

Bug: dawn:429
Change-Id: I3afce6b781ec5a82d5d0bafb6720d368b82c1b00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68600
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-11-29 23:02:49 +00:00
shrekshao 23d877caa2 Add undef Bool for xlib_with_undefs.h
Add undef Bool for xlib_with_undefs.h
Also fix a link in perf_tests/README.md

Change-Id: I83718b2014b6fe2bdfbd82b248d358abbd463abb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65223
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-11-29 20:55:49 +00:00
Loko Kung 349062fb72 Fixes Dawn to use custom Vulkan loader on Linux systems.
- Adds system utility to get the module directory for dawn native.
- Updates Vulkan backend to use the module directory to find loader.
- Test ran on NVIDIA GTX 1660 here: https://chromium-swarm.appspot.com/task?id=576d77991add7c10.

Bug: dawn:1191
Change-Id: I7c577008b5252ac94f38c8cdb56f7e8d8a0aa956
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70860
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-11-29 18:18:58 +00:00
Ben Clayton 8c30d752a0 resolver: Refactor Statement handling
Break up Resolver::Statement() into multiple resolver functions.
Move simple statement validation out to resolver_validation.cc

Change-Id: Ifa29433af0a9afa39a66ac3e4f7ca376351adfbf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71102
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-26 16:26:42 +00:00
Ben Clayton 0ea236f755 resolver: Forbid module-scope declarations from aliasing a builtin
Fixed: tint:1318
Change-Id: Ifcb1aced6885bebcf3eb883f39bfbd0871dae7b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70663
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-11-26 09:56:19 +00:00
Antonio Maiorano e2528e9297 Reland "HLSL: force FXC to never unroll loops"
Now that I've landed this change to Dawn to disable FXC optimizations:
https://dawn-review.googlesource.com/c/dawn/+/70700,, we can reland this
change. The Tint-into-Dawn roll was failing because FXC would miscompile
certain loops into infinite loops when not unrolled.

Also reland
test/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.hlsl

Bug: tint:1112
Bug: dawn:1203
Change-Id: I641d68864b833e0fbe3b117d397b89ae96482536
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-25 18:44:50 +00:00
Ben Clayton 91785d277b resolver: Fix bug in dep graph SortGlobals()
If we encounter a global twice, the stack vector was not popped, which could trigger false cyclic-dependency errors. Because the cyclic dependency did not actually exist, later logic could break, expecting to find a global->global edge which did not exist.

Fixed: chromium:1273451
Change-Id: I9d99f1aeeaea042d9ed847a878c4717803122240
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70980
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-11-25 18:07:57 +00:00
Ben Clayton e0a560c8da transform: Don't consider type-ctor/casts as having side-effects
RemovePhonies was transforming:

_ = f32(1)
_ = vec2<f32>(1.0, 2.0)

into:

f32(1)
vec2<f32>(1.0, 2.0)

Which the resolver gets grumpy about, as these are expressions, not statements.

Fixed: chromium:1273230
Change-Id: Ie85d3cee705fa3f792db686c021d76331e241f17
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70960
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-11-25 16:10:28 +00:00
Antonio Maiorano db6aa8a4ad Add "fxc_optimizations" toggle set to false by default
FXC sometimes miscompiles code when optimizing (/O2), and there is no
discernable workaround. This change sets the optimization level to /O0
when compiling shaders with FXC.

Also, no longer default to enabling EmitHLSLDebugSymbols in Debug
builds, which disabled optimizations (/Od). This confused me a few
times, and is not necessary since we can set this toggle via command
line.

Bug: dawn:1203
Bug: tint:1175
Bug: tint:1112
Change-Id: Ide9e6ecd45adeca951b8836dee91a8367eca3769
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70700
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-25 13:24:50 +00:00
Li Hao a329997e27 Add features of depth24unorm-stencil8 and depth32float-stencil8 texture formats
The depth240unorm-stencil8 and depth32float-stencil8 are optional
features. Enable them and add validation tests for texture creation
and texture view creation.

They are unimplmented on backends, skip their end2end tests.

TODO: add validtion for copy commands.

BUG=dawn:690

Change-Id: I980631d2f3fa6397a6125221a76980a15c8cb2f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68220
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-11-25 01:11:57 +00:00
Loko Kung 596e07f768 Suppresses SwapChainTests.ResizingWindowAndSwapChain for Linux/Vulkan/Nvidia.
See successful run here: https://chromium-swarm.appspot.com/task?id=576d23443b829010

Bug: dawn: 1191, dawn:1205
Change-Id: I45acffcd2b23d7aaf0634b89f1c63e5e7f4437b4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70880
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-11-25 01:11:27 +00:00
Antonio Maiorano 13712ba4f3 Fix dumping of FXC compile flags
The logic was incorrect, printing "D3DCOMPILE_OPTIMIZATION_LEVEL2" for
levels 0, 2, and 3.

Bug: dawn:1162
Change-Id: I6ab7d9d3d22556b6602c778bddd99e5f2274b02b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70705
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-11-24 20:05:57 +00:00
Shrek Shao 2ec09921cc Add include RenderPipeline.h in DeviceMock.h
To unblock g3 dawn roll.

Change-Id: I92ea111dc4c65d4b2ff0c44e7f17799026afd96c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70800
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-11-24 19:55:07 +00:00
Loko Kung f008bb3b7e Update Vulkan's shader module destruction to remove cache for cleanup.
- Turns internal cache into a pointer so that we can deallocate it earlier for the destroy.

Bug: dawn:628
Change-Id: I69fd1e4be5ed5d8b7a28efebd9c2852bab3224b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70182
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2021-11-24 19:46:17 +00:00
Austin Eng 9756030d4e fuzzer: Implement BuildImpl for msl/hlsl Options structs
The default implementation of this was generating random data for
the underlying pointers of std::unordered_map, leading to crashes
when the map was accessed. This CL populates the map in a
structured manner with pseudo-random data.

Bug: chromium:1273001
Change-Id: Ic20ecab85bedba2a59587ebe4a5016be6e53e6f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70701
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-11-24 16:22:18 +00:00
Ryan Harrison 1c1b9762ce Add tests for fuzzers::RandomGenerator
BUG=tint:1019

Change-Id: Ia462080877a97348c5589bfa71231a832a7ebfd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70081
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-11-24 14:55:05 +00:00