Commit Graph

6278 Commits

Author SHA1 Message Date
Stephen White 628289e17d GLSL: implement abs() on unsigned arguments.
It's a no-op.

Bug: tint:1458
Change-Id: Ib97c409fd806da1c97ac867f21ef42b8a18c178c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82364
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-03-02 14:36:52 +00:00
Stephen White b4c338ff37 GLSL: swizzle out the dimension on cube arrays.
Note: ES doesn't support cube arrays, so this fixes the tests but does
not cause them to pass.

Bug: tint:1461
Change-Id: Ia2b1ffacab83dae58ac1b50eb04457da270d73e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82363
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-02 14:33:13 +00:00
Stephen White 6c2115ee91 GLSL: fix boolean "not" operator on vectors.
GLSL uses not() for vectors, and ! for scalars.

Bug: tint:1444
Change-Id: I7fa9bdf0b546224737f9cda18428dea7051fe9e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82362
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-03-02 14:15:52 +00:00
Stephen White e4e409f2ae GLSL: remove spurious semicolons.
textureQueryLevels() and textureSamples() were being emitted with a
spurious semicolon.

Bug: tint:1222
Change-Id: I56c561fcaac510b76a27a850f5be522ab7f98307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82361
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-03-02 14:14:02 +00:00
Stephen White 66abf3ed14 GLSL: don't emit structs w/runtime-sized arrays.
In GLSL, runtime-sized arrays are only valid in interface blocks, not
in structs. The existing code was attempting to avoid emitting structs
containing runtime-sized arrays but was confused by type aliases in
the AST resulting in arrays being missed.

The fix is to do the work on the semantic types instead, where type
aliases have been resolved.

Bug: tint:1339
Change-Id: I8c305ee9bddd75f975dd13f1d19d623d71410693
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82360
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-03-02 14:09:22 +00:00
Stephen White 93f686617e GLSL: fix textureGather() and textureGatherOffset() with depth textures.
Unlike other texture functions in GLSL, textureGather() and
textureGatherOffset() do not expect the refZ value to be appended to
the texture coordinates. It is passed as a regular argument. So append
refZ to coordinates by default, and pass as a regular parameter only
for the gather functions.

Bug: tint:1459
Change-Id: Iad1255be3de5915aeff4adb9054479b9e92c45cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82340
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-02 14:07:02 +00:00
Stephen White 17601930e4 GLSL: fix textureSampleLevel() on depth textures.
Multiple bugs here:

1) Like texture(), GLSL's textureLod() on depth textures returns a
   scalar, and does not need to be swizzled. So set glsl_ret_width to
   1 in that case.
2) Like texture(), GLSL's textureLod() always requires a Dref
   parameter, so append a zero if not present.
3) GLSL's "lod" parameter to textureLod() is always a float, unlike
   WGSL's textureSampleLevel() which is an i32 for depth textures,
   so cast it.

Along the way, I discovered that textureLod() is not supported on
samplerCubeShadow or sampler2DArrayShadow (even on Desktop GL). So some
tests will never pass. Logged as https://crbug.com/dawn/1313

Bug: tint:1456
Change-Id: If67d8d288704142278d7a4e52b46e8010776f381
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-03-02 14:01:00 +00:00
Shaobo a24acf2fbc Validate destination texture states for CopyTextureForBrowser
Current implmentation of ValidateCopyTextureForBrowser has a bug
to verify destination texture states.
This CL fix the simple bug and add noop copy in unittest to catch this
issue.

Bug: dawn:1306
Change-Id: I193105ced89db5092873d604c7dbf43d7ea4fba0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/82101
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-03-02 02:44:01 +00:00
Loko Kung 44f039d3c2 Adds new chained struct for device creation to specify cache options.
- Adds isolation key option, DawnNative support, and relevant unit tests.

Bug: dawn:549
Change-Id: I16344581c7956ce8576c0a4c14655fbdb4e15a54
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81920
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-03-01 22:59:40 +00:00
Stephen White 4acf466ff9 GLSL: fix countOneBits().
This change essentially relands 10c554ecf4,
aka https://dawn-review.googlesource.com/c/tint/+/82140.

(Somehow, I managed to revert most of that in the subsequent CL for
reverseBits. I suspect a bad upstream and/or rebase.)

Bug: tint:1430
Change-Id: Iba2688294dcd7d3008ee9da78957a7a464ca1c0f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-03-01 14:25:42 +00:00
Stephen White bee5fa6881 GLSL: implement pack/unpack builtins.
Bug: tint:1428
Change-Id: Ic1db31feb6c6da4a98f6a37b40c77be887662825
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82200
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 21:19:02 +00:00
Stephen White 59f1e8d06c GLSL: special-case BinaryOp::kModulo for floating point.
The '%' operator in GLSL is integer-only. Use the full OpFRem
expression: (a - b * trunc(a / b)).

Bug: tint:1270
Change-Id: I0a969983bef132e004ce456d4a738488e400a61b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68760
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 21:15:02 +00:00
Stephen White 9b152e655f GLSL: implement fma().
Bug: tint:1448
Change-Id: I7e331a2eabd507a4babce756fc79d68b0bf7d7be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82145
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 20:03:11 +00:00
Stephen White 7028077a6a GLSL: implement inverseSqrt() and update test expectations.
Bug: tint:1447
Change-Id: I521d021a9177c75badd52ad39ce4db6def48b6ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82144
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 18:23:17 +00:00
Stephen White 2a02b68453 GLSL: implement fract() builtin function.
Bug: tint:1446
Change-Id: Icb06bb560956372a689db33c758b3d5ad8c27225
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82143
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 18:19:47 +00:00
Stephen White ba4d6ab01d GLSL: implement derivative instructions.
While Desktop GLSL supports the Coarse and Fine flavours, GLSL ES does
not. For now, emit dFdx/dFdy in all cases for ES, but excluding the
Coarse and Fine flavours via validation is also an option.

Bug: tint:1445
Change-Id: Iaac589f72043b5547e9141a6e870c1fd49631f6f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82142
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 18:08:13 +00:00
Stephen White 3b68fcb544 GLSL: implement reverseBits().
Bug: tint:1431
Change-Id: I816ce26e98705f459e2fbc652d06d6fc97bab7fb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82141
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 17:43:37 +00:00
Stephen White 10c554ecf4 GLSL: implement countOneBits().
Bug: tint:1430
Change-Id: I1aa886d1f68e50f0ce6fd5b55d87722742ca5f69
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82140
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-28 17:41:47 +00:00
Ben Clayton 2e6269acb0 Use the new Switch() inferred types
Change-Id: I48ecd18957101631caa27480e7b1937a10791118
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81106
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-25 23:02:22 +00:00
Ben Clayton f33f1b41ff castable: Make Switch() smarter about return types
Infer the return type by finding the common type across all cases.
Types that derive from CastableBase will automatically infer to
the common base class.

Change-Id: I2112ca1abae34e55396685e9ebf2da12f8a6e3fc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80320
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-02-25 20:24:42 +00:00
Brandon Jones 6661b28d1e Delete Single-Plane External Texture Transform
The multiplanar external texture transform has been integrated into
Dawn, which means we have no use for the single plane transform - so it
should be deleted.

Bug: dawn:1082
Change-Id: Id8977d03839b76c90ae6e70400d048c13fbe85f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80120
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-02-25 20:14:52 +00:00
Ben Clayton dbf75bc217 benchmarks: Fix path to benchmark files
Bug: tint:1378
Bug: tint:1418
Change-Id: I601d344c0fe5598b5ccc50dc1fc4cecf5a8f5357
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82000
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-25 19:18:23 +00:00
Yang Gu 6a9f9bd1ff Skip the check of maxFragmentCombinedOutputResources for Mesa llvmpipe driver
The Mesa Gallium llvmpipe driver is a software rasterizer that uses LLVM
to do runtime code generation. It seems to put incorrect value for
maxFragmentCombinedOutputResources, like we see on desktop GPUs.

Some relative values are as below.
vkLimits.maxFragmentCombinedOutputResources: 8
kMaxColorAttachments: 8
baseLimits.v1.maxStorageTexturesPerShaderStage: 4
baseLimits.v1.maxStorageBuffersPerShaderStage: 8

This CL will skip the check of this limit on llvmpipe, like we did for
desktop GPUs.

BUG=dawn:1311
Change-Id: I1698f6e26dd62b56f3819980fa2dcc986c9c5ba3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81941
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Hao Li <hao.x.li@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-25 18:30:47 +00:00
Jiawei Shao ec3e4b0510 Fix use-after-free issue in Create*PipelineAsyncTasks::Run()
This patch fixes a use-after-free issue in Create*PipelineAsyncTasks
that when pipeline->Initialize() returns error, the pipeline object
will be deleted, while we still attempt to call its member function
after it is deleted.

BUG=dawn:1310
TEST=dawn_unittests

Change-Id: I57d5ca98d6c97b14df1d7c3bf2941c9cc87adeff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81800
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-25 16:28:39 +00:00
Jiawei Shao a84791a955 Ensure non-renderable formats don't support multisampling
This patch removes the support of multisampling on the below 4
formats as they are not renderable according to the discussions at
https://github.com/gpuweb/gpuweb/issues/2465.
- R8Snorm
- RG8Snorm
- RGBA8Snorm
- RG11B10Ufloat

BUG=chromium:1299154, dawn:1244
TEST=dawn_unittests

Change-Id: I3837f2aee322a71c90772322dc01fae410f03e57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81801
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-24 17:46:46 +00:00
Shaobo 6084407b21 Change texture state validation in CopyTextureForBrowser() to report meaningful errors
CopyTextureForBrowser() will support all uploading paths for WebGPU
CopyExternalImageToTexture(). The validation checks for texture states
should report accurate errors to meet CopyExternalImageToTexture() validate
rules.

Bug: dawn:1306
Change-Id: Ie3b25ec82246d53e6c82968b5dc2f8a253c560c1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81240
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-02-24 02:26:26 +00:00
Ben Clayton fe08ba4677 builtins: Add insertBits
CTS tests: https://github.com/gpuweb/cts/pull/1012

Bug: tint:1371
Change-Id: Idd55c0bc9dad1dffb558d0bc57d744f65e9041b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81701
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-02-23 21:18:09 +00:00
Ben Clayton d868e860e0 builtins: Add extractBits
CTS tests: https://github.com/gpuweb/cts/pull/1005

Bug: tint:1371
Change-Id: I228c7b2a27c6fbac0653c416fac603a6fb4bff85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81640
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-02-23 21:18:09 +00:00
Ben Clayton 8169693136 builtins: Add firstLeadingBit
Currently polyfilled for all backends.
HLSL should be able to map this to 'firstbithigh', but there might need
to be some special case handling for 0 (undocumented behavior). For now
just polyfill.

CTS tests: https://github.com/gpuweb/cts/pull/1004

Bug: tint:1367
Bug: tint:1449
Change-Id: I9c9a08ea93d1c4a602e0ab763e95e2eea336fb0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81503
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-23 18:20:30 +00:00
Li Hao 7abcadfce6 Add toggle to disable the tick->ns conversion of timestamp query
Although the error rate of timestamp tick->ns conversion is very small
(3e-5), some profiling scenarios, such as CPU/GPU timestamp calibration
on Windows, require absolutely accurate timestamps.

Add new toggle to resolve timestamps to ticks for those cases where zero
error is required.

Add an end2end test for GPU timestamp calibration on D3D12 backend.

Disable timestamp period calculation on Device when the
DisableTimestampQueryConversion is enabled.

Bug: dawn:1305
Change-Id: I31ee6b4c1686d5dd2ac29ccb0bd398e650481c26
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81023
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-23 17:50:35 +00:00
Antonio Maiorano 2680d1f846 Fix VS2022 build error
VS2022 fails with "error C7631: 'info': variable with internal linkage
declared but not defined" because Iguana's type info was not defined.
Moved globals out of internal linkage to fix it.

Change-Id: Ieb24ea04d4328971ada87bf39b7a0b1c2329e45c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-02-23 15:02:30 +00:00
Ben Clayton df3630c194 builtins: Add firstTrailingBit
Currently polyfilled for all backends.
HLSL should be able to map this to 'firstbitlow', but there might need
to be some special case handling for 0 (undocumented behavior). For now
just polyfill.

CTS tests: https://github.com/gpuweb/cts/pull/1003

Bug: tint:1367
Bug: tint:1449
Change-Id: I8125b32687196678906e5a9d056b4f2efd885073
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81502
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-23 14:32:14 +00:00
Ben Clayton f8672d8c35 builtins: Add countTrailingZeros
Requires polyfilling for all but the MSL backend.

CTS tests: https://github.com/gpuweb/cts/pull/1002

Bug: tint:1367
Change-Id: I0cf56b74c01f30436f9ad00595a554a4042587e4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81501
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2022-02-22 23:16:39 +00:00
Ben Clayton 27aa57ccac builtins: Add countLeadingZeros
Requires polyfilling for all but the MSL backend.

CTS tests: https://github.com/gpuweb/cts/pull/1001

Bug: tint:1367
Change-Id: I75097de945909e3242ede9001124d8821bc832bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-22 23:13:39 +00:00
Ben Clayton 1fcb2a7a24 tools: Update post-shuffle paths for builtin-gen
Bug: tint:1418
Change-Id: Ic1560bf7a0aa99ecbe554b985dc07f1b055fab64
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81500
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-02-22 20:24:59 +00:00
Ryan Harrison 16d5739b73 Update fuzzer build path that was missed in the repo shuffle
BUG=tint:1418

Change-Id: Ie30d9859845b74b36775b56e0dd41ff731a63528
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81580
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-02-22 17:45:19 +00:00
Ryan Harrison b3e6d37055 tint->dawn: Shuffle tint repo layout
BUG=tint:1418

Change-Id: Iee47f1846be63bbd829067b3d818d2603647d4e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80481
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
2022-02-21 17:56:32 +00:00
Ryan Harrison dbc13af287 tint->dawn: Shuffle source tree in preperation of merging repos
docs/    -> docs/tint/
fuzzers/ -> src/tint/fuzzers/
samples/ -> src/tint/cmd/
src/     -> src/tint/
test/    -> test/tint/

BUG=tint:1418,tint:1433

Change-Id: Id2aa79f989aef3245b80ef4aa37a27ff16cd700b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-02-21 15:19:07 +00:00
Jiawei Shao 68d44a7006 Add validations on the format of a resolve target
This patch adds the validations on the format of a resolve target
according to the latest updates in WebGPU SPEC. WebGPU SPEC only
supports the below texture formats being used as the resolve target
of a render pass encoder:
- R8Unorm
- RG8Unorm
- RGBA8Unorm
- RGBA8UnormSrgb
- BGRA8Unorm
- BGRA8UnormSrgb
- R16Float
- RG16Float
- RGBA16Float
- RGB10A2Unorm

BUG=dawn:1244
TEST=dawn_unittests

Change-Id: I16f9c3984f4ffb4641f4f43ecdb3cc76be6a562a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81080
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-02-19 02:53:32 +00:00
Brandon Jones 6e8c473fa5 Updating names of attachment clear values
Renames multiple attachment clear values to match their new names in the
spec, deprecating the old ones.
 - GPURenderPassColorAttachment.clearColor -> clearValue
 - GPURenderPassDepthStencilAttachment.clearDepth -> depthClearValue
 - GPURenderPassDepthStencilAttachment.clearStencil -> stencilClearValue

Additionally, the old names are marked as deprecated with appropriate
warnings if they are used during the deprecation period.

Bug: dawn:1269
Change-Id: I6649184d65578118942c1f51a41f350719665272
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80941
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-02-19 00:44:12 +00:00
Ben Clayton 38f1e9c75c resolver: Optimize type dispatch with Switch()
Bug: tint:1383
Change-Id: Ia02c7ddd3e46d36134f5430e4f22df04993b2158
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81104
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
2022-02-18 22:06:33 +00:00
Ben Clayton 473b6087ac Simplify traits, add CastableCommonBase & IsCastable
Use `static constexpr bool` instead of `std::integral_constant` for `IsTypeOrDerived`. This is often cleaner to use.

Add `IsCastable`, a helper for determining if all the template types derive from `CastableBase`.

Add `CastableCommonBase`, some template magic for determinine the most derived, common base type for all castable types.

Change-Id: Ia3d33548424750f8260f518ecd63d39949e4a826
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81105
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-02-18 22:05:53 +00:00
Ben Clayton 911944cc8d resolver: Error when calling shadowed functions
The fix involves unifying the dependency logic of DependencyScanner, which also cleans up the code quite a bit.

Also:
* Correctly resolve parameter type before declaring the parameter variable.
* Fix bonkers typos in utils::Lookup.

Fixed: tint:1442
Change-Id: I77b548e148b461f87ec10e8272c398f6fee297bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81102
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-18 21:57:53 +00:00
Ben Clayton d29d3d5740 reader/wgsl: Support unicode identifiers
Bug: tint:1437
Change-Id: Ie00ccb3e93d207111e55117dfc989f79b76164bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80844
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-18 20:39:43 +00:00
Ben Clayton 1c6c6b19ab Put tint::debugger::Break() behind a build flag
Breaking isn't always desirable, as there are many tests that intentionally trigger ICEs, which are caught by a EXPECT_DEATH().

On Linux the break also performs IO, which will likely cause problems in Chromium's sandboxed environment.

Change-Id: Ic2e1f5d13c9e986c066eaf364ffa5759c7299f6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81103
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-18 18:56:43 +00:00
David Neto 27605e505b spirv-reader: Ignore Restrict, RestrictPointer decorations
They have no effect in graphics APIs.

Fixes: tint:1440
Change-Id: I80a4b2f5875fbabbd53fd1ebd085ba146401ca71
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80980
Auto-Submit: David Neto <dneto@google.com>
Kokoro: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-18 10:32:19 +00:00
Ben Clayton 6f5316ba46 diagnostic: don't squiggle for unicode lines
If the line contains non-ascii characters, then we cannot assume that a single utf8 code unit represents a single glyph, so don't attempt to draw squiggles.

Bug: tint:1437
Change-Id: Ibd911200b03297f3e1b059ad7cc53fcba59e7714
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80846
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-18 10:26:39 +00:00
Yan,Shaobo 893889b0bb CopyTextureForBrowser(): Validate src/dst texture state
The validation of CopyTextureForBrwoser() fails to valid src and dst
texture state. And a bug has been caught by cts
webgpu:api,validation,queue,copyToTexture,CopyExternalImageToTexture:destination_texture,state:*
after changing CopyExternalImageToTexture() to use CopyTextureForBroswer()
to upload CPU resource.

The CL fix this.

Bug: dawn:1306
Change-Id: Ie4cfd174dc9f54f6cf2099226c4e1cc00ed1d446
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80900
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-02-18 06:26:11 +00:00
James Price 7161ae55c2 DecomposeStridedMatrix: Avoid reserved keyword
The `mat` token is a reserved keyword in WGSL, so don't try to create
identifiers that using it.

Bug: tint:1438
Change-Id: If3840aff35ab0ea937df776cd95920dd55157d9f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80960
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-02-17 20:43:19 +00:00
Ben Clayton 67f5c715a9 Add src/text
Implements a basic decoder for utf8 and codepoint tables for XID_Start and XID_Continue.

The first steps to supporting unicode identifiers.

Bug: tint:1437
Change-Id: I7371d1e63d664f3a3c34929221c7c6d043beb45d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80842
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-17 20:21:19 +00:00
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