Commit Graph

8203 Commits

Author SHA1 Message Date
dan sinclair f6fcf0a3ef [ir] Add conditions to if and switch nodes.
This CL updates the if and switch nodes to store the condition value in
a register. The EmitExpression is updated to return a Register and the
builder updated to emit the expressions for the if, break-if, while,
and switch expressions.

Bug: tint:1718
Change-Id: Ie710812c74e8b9423a4aa997db451d9cdf304feb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110784
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-23 02:09:43 +00:00
Jiawei Shao 806c58324c Wire: Make validation error prior to OOM if mappedAtCreation == false
This patch updates the validations about CreateBuffer() with dawn_wire
to match the latest WebGPU SPEC.

According to the SPEC, the validations in CreateBuffer() should be
executed in the below order:
1. If mappedAtCreation == true, return nullptr and a RangeError will be
   generated in Chromium.
2. Validate BufferDescriptor and check if there is OOM at device timeline
3. Check if there is OOM at content timeline

Bug: dawn:1586
Change-Id: I97ff5f82a42208442ddf6e46e66381c3b3680450
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109040
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-11-23 02:06:11 +00:00
dan sinclair a8bc296259 [spirv-reader] Emit break-if as needed.
This CL updates the SPIRV-Reader to emit `break-if` nodes instead of
`if-break` statements.

Bug: tint:1724
Change-Id: I8cd568f5e90a950acc5a42a470345273a5f1e6bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111103
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-23 01:51:24 +00:00
dan sinclair a5b73a0fde [ir] Implement EmitLiteral.
This CL fills in the EmitLiteral method. Each literal is emitted as the
appropriate type of register. The literal is not added to the current
flow block as it is not yet used.

Bug: tint:1718
Change-Id: Ic6a576bcc08dc6ea251b60d1d079929ac4d97981
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110783
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-23 00:34:48 +00:00
Ben Clayton 329dfd7cbd tint: Implement const-eval of modf
Bug: tint:1581
Change-Id: I53151ebf43601cd6afcdd2ec91d0ff9c4e650ef3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111241
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-23 00:05:05 +00:00
Antonio Maiorano 92d858ac3c tint: const eval of length builtin
Bug: tint:1581
Change-Id: Ie6dc9da6b48c606af03da023c835ec36a99dd362
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110981
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-11-23 00:00:45 +00:00
James Price 89f15fc57e dawn/node: Fix shared library build
dawn.node now uses tint::Initialize() and tint::Shutdown(), and so
needs to link against libtint.

Fixed: tint:1765
Change-Id: I03e575b4709c43a6052ed3ca635376251c3323c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111080
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-22 23:25:16 +00:00
Loko Kung 2e1b359087 Add wire serialized command buffer padding.
Pads serialized wire command buffers to 8 bytes so that we don't have
misaligned write/reads which can cause SIGILL depending on platform and
compilation mode, i.e. -c dbg in google3 builds.

- Adds helpers for aligning sizeof calls.
- Adds constant for wire padding (8u).
- Modifies BufferConsumer to allocate according to padding. This
  guarantees that when we [de]serialize stuff, the padding should be
  equal on both sides.
- Modifies extra byte serialization code (adding CommandExtension
  struct). This makes it clearer that each extension needs to be
  padded independently. Otherwise, before in wire/client/Buffer.cpp,
  since the read/write handle sizes were being passed as a sum, but
  read out separately from the BufferConsumer, we corrupt our pointers.
- Adds some simple unit tests.

Bug: dawn:1334
Change-Id: Id80e7c01a34b9f01c3f02b3e6c04c3bb3ad0eff9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110501
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-22 23:19:43 +00:00
Austin Eng c982cd45c4 Use TINT_REFLECT for OverrideId
Adds tint_public_config to Dawn's internal config so Tint headers
can be included.

Fixed: dawn:1594
Change-Id: I4068fd95b6eae3138fbcc04f29f054c7cffdcf12
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111260
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
2022-11-22 22:23:55 +00:00
shrekshao f9c6633006 Update inter stage variable subsetting validation and add tests
Sync up with current WebGPU spec to allow FS input being a
subset of VS output instead of requiring a strict match.
This patch involves changing the validation and adding tests,
together with using the TruncateInterstageVariables for hlsl
generator to workaround the extra limit for D3D12 backend.

Bug: dawn:1493
Change-Id: I2d4ba7f43dbe57f17ecd5c5d659f4ca93bb682a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109460
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-22 21:36:27 +00:00
shrekshao 7f760cb25c Tint truncate interstage variable transform
Add a transform to truncate unused user interstage variables by
adding a new truncated shader io struct wrapper of the original
one, with a truncate function to do the assignments called
at the return statement.

This transform is meant to be run after CanonicalizeEntryPointIO,
and will only be run under hlsl/generator_impl.cc to workaround
the extra register limitation for interstage variables on D3D FXC.

Bug: dawn:1493
Change-Id: I69081189ad7d4b76f2371fcc079f67dced2e9944
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104620
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2022-11-22 21:30:10 +00:00
dan sinclair 840bf6fc6d [ir] Add a Register class.
This CL adds a class to store register information for the IR. The
register can hold various types of data depending on if it's a f32, i32,
temporary, etc register.

Bug: tint:1718
Change-Id: I025af70f2b145c9697f1d7f996d0e98022eea829
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110782
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-22 20:43:49 +00:00
dan sinclair 2664229fd5 Cleanup some grammar.
This CL updates some grammar in break-if error messages.

Change-Id: I15ab6b98fd1b12dd4e6db16a28f0e311e9fee453
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111102
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-22 20:13:11 +00:00
Ben Clayton 6559903234 tint/resolver: Split constant checking to utility
And add basic support for builtins returning structures.

Bug tint:1581

Change-Id: I67f987339b9a344e1915c69c9991803f0665305d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111242
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-22 19:53:21 +00:00
Antonio Maiorano d6d30f4256 tint: const eval of dot builtin
Bug: tint:1581
Change-Id: Ie7768f8bf254509c1795207de0a1d8b07a317555
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110984
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-22 15:02:55 +00:00
Ben Clayton b2e6b7b865 tint/resolver: Consistently use ConstEval::Result
Fixed: tint:1661
Change-Id: I527b5e2d03abeb53b177a1c69952953864ec0913
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111240
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-11-22 14:14:38 +00:00
Austin Eng 8a68537de2 Check buffer state is not destroyed before internally calling unmap
Calling UnmapInternal would set the state to Unmapped, allowing the
buffer to be mapped again even though it is destroyed.

Bug: chromium:1388920
Change-Id: Ibb4da332bafd44a0d4900c8ea5bfbd674bbc35e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111121
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-11-22 13:34:06 +00:00
dan sinclair e02377c2b3 [ir] Testing updates.
This CL renames the `Build` method in the test helper to be
`CreateBuilder` to maek the intention clearer. A second,
`CreateEmptyBuilder` is provided to allow for easier testing of
expressions.

The `current_flow_block` and `builder` are moved to public so they can
be used/updated during testing.

Bug: tint:1718
Change-Id: I663d4c7a3c76e6bf5396ca05f54fe634d35d0d56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110781
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-22 13:15:08 +00:00
dan sinclair 51ecf65d43 [ir] Stub remaining AST walk structure.
This CL adds commented out blocks for the various switches required to
walk the AST.

Bug: tint:1718
Change-Id: I70e7c4d0168621bf97006a782f2942df1173c393
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110780
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-22 10:17:30 +00:00
Loko Kung edbeeee285 Fix cache default on condition.
- Messed up the conditon in previous change so it required both the
  enable flag to be on and the disable to be off, but then we can't
  deprecate the enable flag in Chromium.

Bug: dawn:549
Change-Id: I1c730939104aafaef48182238fa32ed7fa6a1e16
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110983
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-11-22 03:38:51 +00:00
Loko Kung aa527ba348 Adds toggle to disable blob cache.
- The disable toggle will supercede the enable one once Chromium side
  deprecates usage of the enable one.

Bug: dawn:549
Change-Id: I5c5bd60161917fe2654cfce55a6f29e8a7e79962
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110728
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 21:46:18 +00:00
dan sinclair a32b6b4a0f [spirv-reader] Remove `forced` param from `MakeBranchDetailed`.
The `forced` parameter is always false, remove it.

Change-Id: I9aa16dfc6a51516f6b6e619a3c8ce982a25ba4c4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111101
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-21 21:39:42 +00:00
Ben Clayton 81ce4b6237 tint/transform: Include diagnostics in TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM
Change-Id: Id3e7e0cce464e8b1db00c2adab8db350eee0168c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111041
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-21 19:13:43 +00:00
Ben Clayton 87bccb74d8 tint/transform: Handle arrays of complex override lengths
Update CreateASTTypeFor() to handle a potential edge-case described in tint:1764.

We haven't seen this issue happen in production, nor can I find a way to trigger this with the tint executable, but try to handle this before we encounter a nasty bug.

Fixed: tint:1764
Change-Id: I496932955a6fdcbe26eacef8dcd04988f92545a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111040
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 19:05:24 +00:00
dan sinclair efe9c49819 Add const-eval for `degrees` and `radians`
This CL adds const-eval for `degrees` and `radians`.

Bug: tint:1581
Change-Id: I7f00e2b1e5ab7c8e895680a6b75b9531dac31f5a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110601
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-21 18:00:01 +00:00
Ben Clayton 619f9bd639 tint/transform: Fix ICE when combining polyfills
There's a reason the overload of `ctx.Replace()` that takes a pointer to the replacement is deprecated - it doesn't play well when used as part of another replacement.
Switch to using the callback overload of Replace() to fix bad transform output.

Bug: tint:1386647
Change-Id: I94292eeb65d24d7b2446b16b8b4ad13bdd27965a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111000
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 17:11:05 +00:00
Antonio Maiorano f5eec817de tint: enable smoothstep error tests for f32 and f16
...now that we correctly fail on inf/nan. Also fold separate error test
functions into SmoothstepCases.

Also fixed atanh, acos, acosh, and asin tests to properly test error
cases for all float types, not just abstract float.

Bug: tint:1581
Bug: tint:1747
Change-Id: I63bd57d36beab4cc7dde501183052aa688e2efdb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110727
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-21 15:29:54 +00:00
Antonio Maiorano 1eaeb310a7 tint: fail on creation of a non-finite constant
This is a catch-all that handles all cases where an operation can result
in non-finite values, such as from calls to std::cosh and std::sinh.

Bug: tint:1581
Bug: tint:1747
Change-Id: Ibb55466fea01b263c98d598459c788fd22cf5bb7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110726
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 15:29:54 +00:00
Antonio Maiorano 72551392e8 tint: remove ConstEval::current_source member and pass down source through function calls
Bug: tint:1581
Bug: tint:1751
Change-Id: I4dea92d4b67d39559ce65f45144215e56b6a3e9a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110724
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 15:29:54 +00:00
Antonio Maiorano 893316014a tint: emit an error for float conversions that are not representable
For example, a large f32 value converted to f16 now fails, instead of
resulting in +/-inf.

Bug: tint:1581
Bug: tint:1747
Change-Id: I30fd8c61ecc328206e8f73b626af8046dad4b0b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110723
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 15:29:54 +00:00
Ben Clayton 8bc64636cf tools/run-cts: Append --data flag to node
This will be required to use the new data-caching functionality provided by:
https://github.com/gpuweb/cts/pull/1985

Also propagate `--verbose` down, if passed to the frontend.

Change-Id: Ic436e8ed754296cec859c45bd4db703634c31ab1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109764
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-21 13:03:05 +00:00
James Price fcac2f8304 tint: Strip aliases that reference unused overrides
The SingleEntryPoint transform currently does not strip away any
unused type declarations, which was leading to broken code when an
alias referenced an override that was removed. We can detect this
scenario and remove such aliases, until we have a better mechanism for
detecting all unused aliases.

Fixed: tint:1763
Change-Id: I319ff30b5e52d7dd54596cc99a2201a708c502f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110725
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-21 12:49:15 +00:00
Jason Erb 5008af273c Replace CMAKE_SOURCE_DIR with PROJECT_SOURCE_DIR
Bug: 1596
Change-Id: I62285bb912e79323b7bb3fcdaea9ff64b1a4a1b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110172
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-21 11:40:38 +00:00
Austin Eng b097bf2e34 Switch one more debug message UNREACHABLE to ASSERT(false)
Bug: chromium:1375131
Change-Id: I9150ef25ea3278d97f785f6ffbcc8d45ab79fd6a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110703
Auto-Submit: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2022-11-18 19:29:02 +00:00
Ben Clayton 542db5ce06 tint: Fix TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM
The #if disabled code wasn't compiling as a variable was renamed

Change-Id: I2ce7210d18d52036dd99f729a44e21c6137f84a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110520
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2022-11-18 12:11:33 +00:00
Ben Clayton 0d2aedf097 Run ./tools/format
Change-Id: I4a9f375f5c383d02917c2ade4c83c3d4fc458165
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110102
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-18 11:57:37 +00:00
Ben Clayton 543dd18d3c tint: Remove textureSampleLevel(texture_external)
Fixed: tint:1671
Change-Id: Iafed8d3ddbc99b80bbe70d3fc3847ac7a25c5e37
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110101
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-18 11:17:41 +00:00
Antonio Maiorano aedda6a500 tint: remove all inf/nan input cases for const-eval builtin tests
Bug: tint:1581
Bug: tint:1747
Change-Id: I26dec12c6abbb29f1128c3b3205fd2beb0058bd2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110702
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-11-18 05:45:17 +00:00
Antonio Maiorano aff1656a76 tint/spriv-reader: emit error on non-finite literal
Bug: tint:1581
Bug: tint:1747
Change-Id: I2855c8e277e74ecf1465b81c4545b99fef2a321b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110701
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-11-18 05:45:17 +00:00
Antonio Maiorano 0da91e06c5 tint: make const eval of binary ops on concrete values fail on NaN/Inf
With this CL, binary ops add, subtract, multiply, and divide of concrete
values will now produce an error if the result is inf/NaN, as it was
doing with abstract values. This also affects the cross builtin, which
is written in terms of subtract and multiply.

Bug: tint:1581
Bug: tint:1747
Change-Id: Ib1d0d8deddc82c67ab53729a6011937636fcc1a5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110163
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-18 05:45:17 +00:00
Loko Kung e956a04daf Suppress MaxLimitTests.MaxBufferBindingSize on Linux/Vulkan/Nvidia.
- The test was failing on the google3 TAP bots.
- Also adjusts the size so that it is the aligned min given the limit,
  not just the aligned limit since that can be larger than the limit.

Bug: dawn:1217
Change-Id: I02a68d14d61099dc5c1a2450cbaadc2320f5b8a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110760
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-11-18 00:46:38 +00:00
Jiawei Shao c2646135e1 D3D12: Allocate 2D textures with CopyDst as committed resources on Intel GPUs
This patch adds a workaround on Intel Gen9.5 and Gen11 GPUs to always
allocate 2D textures with CopyDst as committed resources instead of
placed resources to mitigate a driver bug about CreatePlacedResource().

Bug: chromium:1237175
Test: dawn_end2end_tests
Change-Id: I64ab9c083c8835fb2971660eed51252fecac416c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100641
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-17 23:03:34 +00:00
Loko Kung a88b90a69d Remove ListNode from any LinkedList in dtor.
- Issue found in LinkedListTests when running against ASAN since the
  LinkedList was being destroyed after the Nodes, thereby triggering
  a RemoveFromList on the root node, but the other nodes were never
  removed from the list and are dangling pointers.

Change-Id: I136abbc5d73c35142990c9fe4669e5fc6d5ef644
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110500
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Loko Kung <lokokung@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 22:35:24 +00:00
James Price 9e15952e2d tint: Fix set of overrides in the shader interface
Since overrides can be used to size workgroup arrays and also as
initializers to module-scope variables, we cannot just consider
overrides that are directly referenced in the shader functions.

This change makes the Resolver track references to overrides whilst
resolving array types and module-scope variable declarations, so that
they are included in the set of overrides reported by the Inspector in
these scenarios.

Fixed: tint:1762
Change-Id: If7501abf3ddcb87a87134ddd578aa4904d204de6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110460
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 22:23:46 +00:00
Brendon Tiszka e32457fa11 Revert "Add assertions to ServerInlineMemoryTransferService to catch corrupted states while fuzzing with DawnWireServerFuzzer and tests."
This reverts commit f3666c45f3.

Reason for revert: Did not realize these assertions could knowingly be reached after this fix for crbug.com/1340654

Original change's description:
> Add assertions to ServerInlineMemoryTransferService to catch corrupted states while fuzzing with DawnWireServerFuzzer and tests.
>
> Bug: chromium:1340654,chromium:1374495,chromium:1376477
> Change-Id: Icfb008a1cd6dbd8af32f3aedc90ef29e29a0465b
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106041
> Commit-Queue: Brendon Tiszka <tiszka@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>

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

Bug: chromium:1340654,chromium:1374495
Change-Id: I5bff56e32266721ec418a545ad72c1065c73d526
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109461
Commit-Queue: Brendon Tiszka <tiszka@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-17 22:08:23 +00:00
Ben Clayton 83cef52eb7 tint/resolver: Error when quantizeToF16 value is unrepresentable
...as a F16, for const-eval.

Fixed: tint:1744
Change-Id: I5eff05c6bc4727cbdfefb546602f3ee194d22612
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108640
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-17 21:34:27 +00:00
Austin Eng f6181d0365 Change UNREACHABLE to ASSERT(false) in OnDebugUtilsCallback
In cases that a debug message does happen, we shouldn't use
unreachable as it will make the compiler use a false assumption.
Instead, only ASSERT(false) which crashes in debug, and does
nothing in release builds.

Bug: chromium:1375131
Change-Id: I7733151c241ee875ac40969ce22f037351141e89
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110600
Auto-Submit: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-11-17 20:54:14 +00:00
Ben Clayton c2e2013c2d tint/resolver: Fix DBZ with explicit strides of invalid arrays
Fixed: tint:1693
Change-Id: Ieafc8659daade26c5ce4fab583d3bc03d35c2a2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110580
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 19:59:19 +00:00
Ben Clayton e412c8d8c6 Remove tint::Source::data_view
It's just a view on another field. It doesn't add anything.

Change-Id: I52c1939c455d48c067c9c31938be87671328d263
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110560
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 19:16:24 +00:00
dan sinclair 6a4c918cbf [ir] Sketch out tree walk
This CL adds the sketch of how to walk the IR tree in order to rebuild
the format of the original control flow.

Bug: tint:1718
Change-Id: Id9376d51907ea2a60f32506a152928b3a82d14ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110481
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-17 19:15:07 +00:00
dan sinclair 5fbce71eea Change some kNone to kUnknown.
Missed a couple kNone settings in the Tint executable when attempting
to determine the output format. This CL updates the to be kUnknown.

Change-Id: Ia0c4293fe69711cf1de878255bd18c6eeec4bffe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110502
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 18:42:39 +00:00
James Price 4d65fc91bb tint: Implement pointer alias analysis
Track reads and writes to pointer parameters for each function in the
Resolver, as well as accesses to module-scope variables. At function
call sites, check the root identifiers of each pointer argument to
determine if problematic aliasing occurs.

The MSL backend passes pointers to sub-objects to functions when
handling workgroup storage variables, which triggers the alias
analysis. Add a validation override for this scenario.

Bug: tint:1675

Change-Id: I81a40d1309df65521cc5ad39764d6a09a260f51e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110167
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-11-17 17:27:27 +00:00
dan sinclair d6f9a8a253 Enable some disabled test.
This CL enables some of the @const disabled test now that the
methods are implemented.

Bug: tint:1581
Change-Id: I2cc0aa33188e439a661e2e7c265c6414881c92a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110169
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-17 13:19:16 +00:00
Antonio Maiorano 46682e7e6b tint: remove redundant insertBits tests
Meant to remove this in
https://dawn-review.googlesource.com/c/dawn/+/110482

Bug: tint:1581
Bug: chromium:53440
Change-Id: I38a51873b93c2bfbf6ea20456a7992422ead6208
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110446
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 12:41:15 +00:00
Antonio Maiorano 8fbfacfd43 tint: fix insertBits edge case
If count is highest and offset is non-zero, or vice-versa, we'd overflow
the count + offset > bit-width check. This CL fixes this case.

Also folded in error tests into extractBits and insertBits.

Bug: tint:1581
Bug: chromium:53440
Change-Id: Id1e9e737b8076e8075da5992a41d18b6b7c8afd4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110482
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-17 00:35:49 +00:00
dan sinclair 32c28cbc90 Add const-eval for `smoothstep`
This CL adds const-eval for `smoothstep`.

Bug: tint:1581
Change-Id: I78aa5c4a39882f29ff78e37313e6c44708719095
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110176
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-16 23:02:39 +00:00
dan sinclair 19e5042ade Add const-eval for `round`
This CL adds const-eval for `round`.

Bug: tint:1581
Change-Id: I16ebb2010969debb8de50479235d9d9f5433c0a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110175
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-16 22:52:08 +00:00
dan sinclair c214cbe98b Add a `none` format.
This CL adds a `none` format to the tint command in order to allow
skipping the emission of the resulting program. This adds a `unknown`
format to take the place of the original `none`.

Change-Id: Ib25e933857c0acb26e3cf0e04ed8a5d1cca1e633
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110480
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-16 22:29:12 +00:00
Antonio Maiorano 4d89ce1a68 tint/number: add Checked* overloads for f32 and f16
Also add missing unit tests for CheckedMul of floats.

Bug: tint:1581
Bug: tint:1747
Change-Id: I5d0d5d2b010803d6fd65f6feddc619cf1d071fe2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110170
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-11-16 21:51:31 +00:00
Ben Clayton 6be02b607f tint: Fix stability of intrinsic_table.inl
Use a StableSort() to ensure the output is the same between different
versions of golang.

Change-Id: Ic81688d189ce62816ba0aefddcef607b76415a5d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110361
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2022-11-16 21:30:13 +00:00
dan sinclair 2d90dedea4 Add const-eval for `sqrt`
This CL adds const-eval for `sqrt`.

Bug: tint:1581
Change-Id: I0d109e6439feaf07edb7db4d6a50274c1c4efcae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110174
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-16 21:15:49 +00:00
dan sinclair 92af2b5693 Add const-eval for `trunc`
This CL adds const-eval for `trunc`.

Bug: tint:1581
Change-Id: If58f79ea70fe490746e30ed118d847c61edd8023
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110173
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-16 20:07:31 +00:00
dan sinclair c6d46994af [ir] Add framework to dump IR to text
This CL adds the framework and `tint` option to write the IR to stdout
as text for debug purposes.

Bug: tint:1718
Change-Id: I05bd83635800fbfe3b65d968a84b30931ec1bdb6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110171
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-16 14:36:30 +00:00
Ben Clayton fad31fe74a dawn: fix 'control reaches end of non-void function' warning
Change-Id: I8820df29d84df9151f7992677ca7e926d14ecb08
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107240
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-11-16 14:21:03 +00:00
dan sinclair acce83d109 Add const-eval for `min` and `max`
This CL adds const-eval for `min` and `max`.

Bug: tint:1581
Change-Id: Ica68ba312f21767c46d57d83570ddc72ee857231
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110166
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-15 18:39:38 +00:00
Jiawei Shao 6924d6e903 Remove unused function declarations
Bug: dawn:1516
Change-Id: I7a62a80f3377c3b0675520d0eb71caa18c546bfa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110260
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-11-15 16:11:36 +00:00
Jiawei Shao f7e113d47e Add test to reproduce Intel driver issues with CreatePlacedResource()
This patch adds a test to dawn_end2end_tests to reproduce a driver
issue about creating textures with CreatePlacedResource() on Intel
D3D12 drivers.

Bug: chromium:1237175
Test: dawn_end2end_tests
Change-Id: I26fe6c9b827d8a05cfe2336405e43c549e52ea50
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100567
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-15 01:56:06 +00:00
David Neto 7f06aa06ac spirv-reader: support NumWorkgroups
Fixed: tint:1065
Change-Id: Id2a8af247e7da79933703e634478f1dec25f9145
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2022-11-15 01:32:17 +00:00
dan sinclair 267f1748c8 Remove infrastructure for fallthrough
This Cl removes the internal infrastructor and backend code
generation for the fallthrough statement.

Bug: tint:1644
Change-Id: I2a1de7d527865e5a7221074f4e0fb106599f4c57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109005
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-15 00:30:33 +00:00
dan sinclair bf586f6dfd Remove fallthrough from WGSL parser.
This CL removes the `fallthrough` parsing from the WGSL parser. The
`fallthrough` token is left so we can generate a nicer error message
in the case `fallthrough` is used.

Bug: tint:1644
Change-Id: Ifb23d78d1219cba9c64b80c9b098a248bc68e5c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109001
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-15 00:20:24 +00:00
dan sinclair d8a986beae Remove fallthrough support from SPIRV-Reader.
This CL removes support for fallthrough from the SPIRV-Reader.

Bug: tint:1644
Change-Id: I80b63d627960a82ba90de83af407c539b0442080
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109004
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-11-15 00:19:05 +00:00
David Neto 3c32758a0e spirv-reader: Support texture and sampler args to user-defined functions
Fixed: tint:1039
Change-Id: If0cb28679cc73f54025c2c142bdc32852bf4ae28
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109820
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2022-11-14 23:15:51 +00:00
Antonio Maiorano 1db8831be4 tint: fold error cases into regular case in const eval binary op unit tests
This is the same as was done for const eval builtin tests, allowing the
error cases to be defined in the same place as we define the positive
cases.

Also got rid fo the 'overflow' flag, which was used to skip abstract
cases in the unit test. Instead, I modified the tests to only add
overflow cases if not abstract.

This change will make it easier to update tests when we make Inf/NaN
failures for concrete float operations.

Bug: tint:1581
Bug: tint:1747
Change-Id: I7e5d8f9b24ca486aaa03a3b1bd07ccedb09411c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110043
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-14 21:20:05 +00:00
David Neto 208fc35471 spirv-reader: refactor getting handle type
Rename ParserImpl::GetTypeForHandleMemObjDecl to
ParserImpl::GetHandleTypeForSpirvHandle

More importantly, it now returns the texture or sampler type rather
than the pointer type to the texture or sampler.

Most usages only wanted the store type.

Change-Id: I875e11d97e6d3ecb10fdb3317b860c05fc5fe406
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109760
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2022-11-14 21:13:30 +00:00
James Price 8cd34f8425 tint: Fix DemoteToHelper for atomicCmpXchgWeak
We cannot explicitly name the result type of this builtin, so we have
to redeclare it manually.

Fixed: oss-fuzz:53347, oss-fuzz:53343
Change-Id: I23816b8b35eb20ae91472143ab30668b573d65bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110160
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
2022-11-14 20:30:38 +00:00
Li Hao fbd00b44ee Fix non-inclusive language in toggle name
Use 'Mock' instead of non-inclusive language 'Dummy' in toggle
MetalUseDummyBlitEncoderForWriteTimestamp to pass PRESUBMIT.py check.

Bug: dawn:1250
Change-Id: I47dff4adec08d4d076b5ae5b4e0a521b235d5868
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110060
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-11-14 16:57:22 +00:00
Ben Clayton 10fae7ac79 tint: Rename `frexp().sig` to `frexp().fract`
Fixed: tint:1757
Change-Id: Iacce6ab0f08f89abbe5831e6f2285a0c964e74d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110100
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-11-14 15:29:29 +00:00
Ben Clayton 1ef277db0e tint: Skip e2e test validation for known-good
Cache the hash of the test output, and only re-validate if the output changes.
This speeds up incremental end-to-end testing.

Change-Id: I44bc1eff62320df1e80524e8481d1c012fb67f42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109761
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-11-14 13:58:36 +00:00
Wang Qing 09dd5635e4 loongarch: Fix ASSERT() breakpoint support.
Bug: dawn:1506
Change-Id: I79aa5fe75477280570bfced0ee60aac5c18fab6f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109900
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-11-14 13:07:30 +00:00
Ben Clayton c33d10ae79 tint/resolver: Fix bad pointer deref (UAF)
Passing a dereferenced value from Hashmap::Find() directly into Hashmap::Add() is a potential cause of UAF, as the insertion may reallocate the map, invalidating the input reference.

I'll try to think of ways to make this foot-gun harder to do, but this CL fixes the immediate bug found by fuzzers.

Bug: chromium:1383755
Change-Id: I4f8b2fcb0745b008a47ef9947c330afb9ac4e78f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110020
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-13 18:26:25 +00:00
Antonio Maiorano 7338848589 dawn: ouput DXBC literals as hex when dump_shaders is enabled
The DXBC asm listing attempts to be helpful when display literals by
making them human readable,but when it displays values as floats, they
will only have a precision of 6.

For example, 0x09909909 ends up getting displayed as 0.000000 because as
a float, this value is 3.48106525683e-33. FXC has an option to output
literals as hex values, so let's use that.

Change-Id: I2b3017bd834eac89248fe01cae85ba1bb4033e59
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109582
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-11 19:33:31 +00:00
Ryan Harrison 4e0eac148d Manual Roll third_party/vulkan-deps/ a7a3fb393..c29c532c9 (71 commits)
https://chromium.googlesource.com/vulkan-deps/+log/a7a3fb39310c..c29c532c92db

$ git log a7a3fb393..c29c532c9 --date=short --no-merges --format='%ad %ae %s'
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from 096b2903118c to f276f028ee79 (1 revision)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from 45b81b398ab4 to 096b2903118c (2 revisions)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from 983b408199f2 to 45b81b398ab4 (3 revisions)
2022-11-10 chromium-autoroll Roll Vulkan-Headers from f97f29836cb9 to 29c0457cc167 (1 revision)
2022-11-10 chromium-autoroll Roll Vulkan-Tools from e8234991418c to 3a729c0a9d58 (1 revision)
2022-11-10 chromium-autoroll Roll SPIRV-Tools from aae7d4132571 to 68e8327f2932 (2 revisions)
2022-11-10 chromium-autoroll Roll Vulkan-Loader from 1b40be299b02 to 0df63661a5fa (1 revision)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from e7380d60c9a6 to 983b408199f2 (8 revisions)
2022-11-10 chromium-autoroll Roll Vulkan-Headers from 689821914113 to f97f29836cb9 (1 revision)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from afd4e9d82d92 to e7380d60c9a6 (3 revisions)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from fc9da6832a2b to afd4e9d82d92 (1 revision)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from 1059ee93ebff to fc9da6832a2b (1 revision)
2022-11-10 chromium-autoroll Roll Vulkan-ValidationLayers from 065b8cbc41cb to 1059ee93ebff (1 revision)
2022-11-09 chromium-autoroll Roll Vulkan-Loader from 7e61110364b4 to 1b40be299b02 (2 revisions)
2022-11-09 chromium-autoroll Roll SPIRV-Tools from 525bc38062ab to aae7d4132571 (1 revision)
2022-11-09 chromium-autoroll Roll Vulkan-Loader from 5b054b4333fd to 7e61110364b4 (1 revision)
2022-11-09 chromium-autoroll Roll Vulkan-ValidationLayers from f162411346bb to 065b8cbc41cb (1 revision)
2022-11-09 chromium-autoroll Roll Vulkan-Tools from 6e5bd86b76c0 to e8234991418c (1 revision)
2022-11-09 chromium-autoroll Roll Vulkan-ValidationLayers from 8a253a6c5b7a to f162411346bb (1 revision)
2022-11-09 chromium-autoroll Roll Vulkan-ValidationLayers from e09172e79c0b to 8a253a6c5b7a (1 revision)
2022-11-08 chromium-autoroll Roll Vulkan-Loader from 6442b72aea02 to 5b054b4333fd (1 revision)
2022-11-08 chromium-autoroll Roll glslang from f4cba22d0824 to 2b2523fb951f (1 revision)
2022-11-08 chromium-autoroll Roll Vulkan-ValidationLayers from 212ea587c100 to e09172e79c0b (1 revision)
2022-11-08 chromium-autoroll Roll Vulkan-Headers from ef96d229cb3d to 689821914113 (1 revision)
2022-11-08 chromium-autoroll Roll SPIRV-Tools from 54d4e77fa559 to 525bc38062ab (1 revision)
2022-11-08 chromium-autoroll Roll glslang from 5e08deae050c to f4cba22d0824 (1 revision)
2022-11-08 chromium-autoroll Roll Vulkan-Headers from 1661f3e962f5 to ef96d229cb3d (3 revisions)
2022-11-08 chromium-autoroll Roll Vulkan-ValidationLayers from 2dbf684715c2 to 212ea587c100 (2 revisions)
2022-11-08 chromium-autoroll Roll SPIRV-Tools from a5e766b2b47c to 54d4e77fa559 (1 revision)
2022-11-08 chromium-autoroll Roll Vulkan-ValidationLayers from bcf3a2bd93f2 to 2dbf684715c2 (1 revision)
2022-11-08 chromium-autoroll Roll SPIRV-Cross from abc31207bffb to edd66a2fc9e9 (1 revision)
2022-11-08 chromium-autoroll Roll Vulkan-ValidationLayers from 8382dbcaeb7c to bcf3a2bd93f2 (3 revisions)
2022-11-08 chromium-autoroll Roll Vulkan-ValidationLayers from b5cbd4242593 to 8382dbcaeb7c (2 revisions)
2022-11-08 chromium-autoroll Roll Vulkan-Headers from 91388ba10409 to 1661f3e962f5 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-Loader from 6b0551428e57 to 6442b72aea02 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-ValidationLayers from 2632b3362f77 to b5cbd4242593 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-ValidationLayers from 8a1cdac2bde1 to 2632b3362f77 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-ValidationLayers from 94c32cc2541c to 8a1cdac2bde1 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-Loader from 8ff839bda370 to 6b0551428e57 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-Headers from 52b7c620a540 to 91388ba10409 (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-ValidationLayers from 62eb78a06365 to 94c32cc2541c (1 revision)
2022-11-07 chromium-autoroll Roll Vulkan-ValidationLayers from 8debb3bd2948 to 62eb78a06365 (2 revisions)
2022-11-07 chromium-autoroll Roll SPIRV-Tools from d35a78db57e6 to a5e766b2b47c (1 revision)
2022-11-05 chromium-autoroll Roll Vulkan-ValidationLayers from 226b595aeec0 to 8debb3bd2948 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-Loader from 256a5e3b6d6f to 8ff839bda370 (1 revision)
2022-11-04 chromium-autoroll Roll SPIRV-Tools from c8e1588cfa3f to d35a78db57e6 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-ValidationLayers from 37e77914ef0d to 226b595aeec0 (7 revisions)
2022-11-04 chromium-autoroll Roll SPIRV-Headers from 747031e10dea to 47f2465ee3e7 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-Loader from 1bc3a2fa8ec1 to 256a5e3b6d6f (8 revisions)
2022-11-04 chromium-autoroll Roll Vulkan-ValidationLayers from a566d5b79346 to 37e77914ef0d (2 revisions)
2022-11-04 chromium-autoroll Roll Vulkan-Loader from 374dbe9df7bd to 1bc3a2fa8ec1 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-Headers from ff03306bf986 to 52b7c620a540 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-ValidationLayers from e108987ee76c to a566d5b79346 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-ValidationLayers from 9a31edfa80d5 to e108987ee76c (7 revisions)
2022-11-04 chromium-autoroll Roll Vulkan-Headers from d4c221772cb2 to ff03306bf986 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-ValidationLayers from a38db2b8b172 to 9a31edfa80d5 (1 revision)
2022-11-04 chromium-autoroll Roll Vulkan-ValidationLayers from d5bc5ca269e5 to a38db2b8b172 (1 revision)
2022-11-03 chromium-autoroll Roll glslang from 8da649505887 to 5e08deae050c (1 revision)
2022-11-03 chromium-autoroll Roll Vulkan-Tools from 0bb32875d2e6 to 6e5bd86b76c0 (1 revision)
2022-11-03 chromium-autoroll Roll Vulkan-Loader from da810336e761 to 374dbe9df7bd (1 revision)
2022-11-03 chromium-autoroll Roll SPIRV-Headers from 85a1ed200d50 to 747031e10dea (1 revision)
2022-11-03 chromium-autoroll Roll Vulkan-ValidationLayers from 823f8beb4f70 to d5bc5ca269e5 (2 revisions)
2022-11-03 chromium-autoroll Roll Vulkan-Headers from e12a8f8cde40 to d4c221772cb2 (1 revision)
2022-11-03 chromium-autoroll Roll Vulkan-ValidationLayers from 6d377701f393 to 823f8beb4f70 (1 revision)
2022-11-03 chromium-autoroll Roll Vulkan-Loader from 4f4b32cf7545 to da810336e761 (1 revision)
2022-11-02 chromium-autoroll Roll Vulkan-ValidationLayers from 18a0e59294d1 to 6d377701f393 (2 revisions)
2022-11-02 chromium-autoroll Roll Vulkan-Tools from 292e6ed02141 to 0bb32875d2e6 (1 revision)
2022-11-02 chromium-autoroll Roll Vulkan-Loader from 3f29209dd65d to 4f4b32cf7545 (1 revision)
2022-11-02 chromium-autoroll Roll SPIRV-Tools from a52de681dd17 to c8e1588cfa3f (1 revision)
2022-11-02 chromium-autoroll Roll glslang from 1a8869e4d1be to 8da649505887 (1 revision)
2022-11-02 chromium-autoroll Roll SPIRV-Cross from 744279ec78ff to abc31207bffb (1 revision)

Created with:
  roll-dep third_party/vulkan-deps

Change-Id: I24e8219f2226c6ee76a44bc00bb17b30b7a50d32
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109740
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-11-10 22:21:16 +00:00
David Neto 183b8eb19c spirv-reader: func decl with handle or ptr-to-handle
Support function declarations where formal parameters
are textures, samplers, or pointers to them.

Still need to update call sites.

Bug: tint:1039

Change-Id: I5bb3ca73190b2e27c28205e78aa433108efec252
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109540
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-10 20:52:31 +00:00
dan sinclair b77332edd2 Add const-eval for `tan` and `tanh`
This CL adds const-eval for `tan` and `tanh`.

Bug: tint:1581
Change-Id: I3d3506a6e7462bba1557cb88065d696ddc21b0f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109562
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-10 15:55:00 +00:00
dan sinclair 02d4ea06b9 Add const-eval for `cos` and `cosh`
This CL adds const-eval for `cos` and `cosh`.

Bug: tint:1581
Change-Id: I8df8f979a7b351288cadccda88940fdb5a20d18f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109561
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-10 15:52:41 +00:00
dan sinclair b7868ff3ee Add const-eval for `sin` and `sinh`
This CL adds const-eval for `sin` and `sinh`.

Bug: tint:1581
Change-Id: I96345378c826e2c49ffae688b5185764019967d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109560
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-10 14:20:36 +00:00
dan sinclair e2fd5e09c6 Implement const-eval for `acosh`
This CL adds const-eval for the `acosh` test case. The generation of
`f16` values into test files is also fixed because `acosh` requires the
value to be `>= 1.0`

Bug: tint:1581
Change-Id: Iba2ca4d9d114034845475679346f042c8c66e571
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109341
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-10 02:39:08 +00:00
Ben Clayton 46ee63933c tint/transform: Implement div / mod polyfill
Prevents UB for divide-by-zero and integer overflow when dividing

Fixed: tint:1349
Change-Id: Ieef66d27d7aec3011628ced076b2bccc7770a8af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108925
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-09 22:04:11 +00:00
Ben Clayton 9418152d08 tint/resolver: Move from STL to tint::utils containers
Change-Id: I883168a1a84457138de85decb921c5c430c32bd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108702
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-09 20:55:33 +00:00
Ben Clayton 55a8eace75 tint/resolver: Forbid workgroup pointer parameters
Fixed: tint:1721
Change-Id: I80a2cfc753f928facc165e1c8cd8c5af6c497550
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108701
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-09 20:11:43 +00:00
dan sinclair 5ac2a365d9 Add const-eval for pack and unpack of 2x16float.
This CL adds const-eval for pack and unpack of 2x16 float values.

Bug: tint:1581
Change-Id: I59a1925148124e628c3771ca96d309fad045f27d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109280
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-09 20:04:37 +00:00
dan sinclair 00d0fd5e84 Update f16 to have from_bits
This CL adds a `from_bits` method to the f16 number to allow converting
a uint16_t representation to a f16.

Bug: tint:1581
Change-Id: I80882e74a88411963f0e30423a72cfca40370af1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109201
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
2022-11-09 20:03:09 +00:00
James Price 744d0eb4aa tint: Use "demote-to-helper" semantics for discard
Discard statements no longer affect the behavior or uniformity
analysis. Update the resolver, validator, and several tests to reflect
this.

Some E2E tests were removed as they had loops that are now considered
to be infinite.

Use the DemoteToHelper transform to emulate the correct semantics on
platforms where discard is (or may) terminate the invocation in a
manner that would affect derivative operations.

We no longer need the UnwindDiscardFunctions transform for HLSL, which
already implements the correct semantics. However, we still run the
DemoteToHelper transform for the HLSL backend due to issues with FXC's
handling of discard statements (see crbug.com/tint/1118).

Fixed: tint:1723
Change-Id: Ib49ff187919ae81c4af8675e1b66acd57e2ff7d2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109003
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-11-09 19:58:59 +00:00
James Price 78ae4c243b tint: Fix phony assignments in DemoteToHelper
We just need to skip these.

Bug: tint:1723
Change-Id: I311fe0432ecf1f69936eaf08eb57123a6a738175
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109340
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-09 18:27:12 +00:00
James Price 97519c2cd3 tint: Allow captured pointers as function args
The updated WGSL validation rule now requires that the memory view of
the argument matches its root identifier.

This allows for code like this:
   let p = &v;
   foo(p);

Fixed: tint:1754, tint:1734
Change-Id: I3239ec84e1c06398a6ce5bebb1e0b28986764bc6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109221
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-11-09 16:47:19 +00:00
James Price 6251598ad2 tint: Add DemoteToHelper transform
This transform implements demote-to-helper semantics for discard
statements, by setting a global flag and masking any writes to
host-visible memory.

Bug: tint:1723
Change-Id: I619c5661c6ffcc6978aa4f7635b0d680d83de3dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109002
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-11-09 15:40:06 +00:00
James Price a7cd3aeff0 tint: Rename SourceVariable() to RootIdentifier()
This is now a well-defined term in the WGSL spec, so we should use it.

Change-Id: Icc46a77f0a465afbfd39cdaec84e506b143c8c0c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109220
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
2022-11-09 12:16:56 +00:00
Zhaoming Jiang 4f3f45c00f Tint/transform: Fix insertBits polyfill for HLSL
This CL fix insertBits polyfill to handle with the left-shifting
behavior in HLSL, i.e. `(1u << 32u) == (1u << 0u) == 1u` where we want
the result to be `0u`.

Fixed: tint:1743
Change-Id: Ibb82abe4ab2f76dbb0fa06057fb19f15f961d969
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108166
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-09 01:54:08 +00:00
Antonio Maiorano e4270d111b Fix dawn_native MSVC x86 build
Bug: dawn:1590
Change-Id: I4559a664fde1ee0ebcf7eae44a752d1977a63e24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109200
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-11-08 23:24:52 +00:00
Antonio Maiorano a70e365313 tint: fix extractBits edge case
If count is highest and offset is non-zero, or vice-versa, we'd overflow
the count + offset > bit-width check. This CL fixes this case.

Bug: tint:1581
Bug: chromium:1381810
Change-Id: I6ee60ec1a13230fca6f4bb6407cd33bcc6730eb7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109162
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-08 18:27:08 +00:00
Jiawei Shao e052683e3f Remove two unused function declarations in wire::client::Device
Bug: dawn:1586
Change-Id: Ic3a7bdedc62ff6765a559f94a7ad379741687fed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109080
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-08 15:11:31 +00:00
Antonio Maiorano c36417343f tint: const eval of cross
Bug: tint:1581
Change-Id: I63ebb7de3a7d719f2c149715295492f561311579
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108544
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-08 11:42:07 +00:00
David Neto eb949c87ee spirv-reader: use spirv.hpp11
In preparation for SPIRV-Tools change where its internals
use the C++11 headers.

This patch works with SPIRV-Tools using the old C header
and using the C++11 header.

This patch includes some complex machinery inside "three_sided_patch"
namespaces that can be removed after third_party/vulkan-deps/spirv-tools has
fully transitioned into using the C++11 headers.

Change-Id: I36f358fe3edcc5e613625708017fb8d7919c40c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108780
Reviewed-by: Alan Baker <alanbaker@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-08 00:17:56 +00:00
dan sinclair 1bdaded736 Implemement const-eval for some unpack routines.
This CL adds const-eval for unpack2x16snorm, unpack2x16unorm,
unpack4x8snorm and unpack4x8unorm.

Bug: tint:1581
Change-Id: Ieda938b797dfe3f8d8046101d12b99da69ad68f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108864
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-07 22:28:01 +00:00
dan sinclair ec4b650adb Remove fallthrough from fuzzer AST mutation.
This CL removes the logic to handle fallthrough in the AST fuzzer.

Bug: tint:1644
Change-Id: Ie636e2377bed8acfd7a644d2af6827efaf37a60e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-07 20:56:04 +00:00
Ben Clayton ba200e87c5 tint: Bump stack size for MSVC + debug build
Bug: tint:1749
Change-Id: Ic7a87a769ade9c459914ac745b449b4383812753
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108923
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-11-07 17:24:10 +00:00
dan sinclair 5071a54af4 Make reserved words an error.
This CL moves reserved words from a deprecation to an error.

Bug: tint:1463
Change-Id: I5c66baa15dc748215877c8152171c690495bc0c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108861
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-07 16:15:55 +00:00
dan sinclair 2d706a0436 Implemement const-eval for some pack routines.
This CL adds const-eval for pack2x16snorm, pack2x16unorm,
pack4x8snorm and pack4x8unorm.

Bug: tint:1581
Change-Id: I58d8f02da32a6a173ca54ee5110ca7be39e2c52f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108466
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-07 14:32:16 +00:00
dan sinclair 3b2b5484e2 Remove module-scope let deprecation.
This CL moves module-scope let from a deprecation to an error.

Change-Id: Iffecbb667cf79515234b6510ce7c5bbbb6e673bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108862
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-07 14:20:33 +00:00
Antonio Maiorano c027f33cfd tint: Fix gdb and lldb pretty printers for recently updated Hashset and Hashmap
Change-Id: If9aae44b6e58d3ba3be3463306f626ce8c23d4d0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108723
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2022-11-07 14:00:53 +00:00
Ben Clayton ca98b1b1b9 tint/resolver: Resolve dependencies of parameter attributes
Fixed: chromium:1381883
Change-Id: If93840977407e349ab8d3ea5a2f51b9e03c7d0e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-07 13:15:21 +00:00
dan sinclair 6f799d676d Change default acos test value.
This Cl changes the default acos test value so it equals `cos(.25)`
instead of `cos(.5)`. The `.5` result was slightly different on
various machines.

Bug: tint:1581
Change-Id: I768141ae87a63b2c35ec4d61eb030edad77e11e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108863
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-07 12:06:18 +00:00
dan sinclair f218af0461 Remove the `@stage` attribute
This CL removes the `@stage` attribute.

Bug: tint:1503
Change-Id: I1e31e96056a053f0c1e92b4bfc3c63c3592e9765
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108860
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-07 11:34:34 +00:00
Austin Eng 270c044100 Metal: Implement begin/end access synchronization with MTLSharedEvent
Bug: b/252731382
Change-Id: Ie2bf978c10dcb7b2c03a2c7ff81ddd8b9b77ac20
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106760
Reviewed-by: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-11-04 22:06:20 +00:00
Ben Clayton b6903295a8 tint/resolver: Support error cases with const-eval builtin tests
Also:

Print unrepresentable numbers with higher precision - otherwise values can round, and diagnostics can be very confusing.
Improve diagnostic distinction between `( )` `[ ]` interval ranges.

Change-Id: I9269fbf1738f0bce5f2ddb5a387687543fd5d0bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108700
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-04 19:18:55 +00:00
Austin Eng dc819c939b dawn::wire validate that the generation must be strictly increasing
Bug: chromium:1379634
Change-Id: Iaa067a30ac5992adfb5aac168104163a62f8bf9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108549
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-04 15:29:23 +00:00
Antonio Maiorano 6fcc4f3a54 tint: const eval of reverseBits
Bug: tint:1581
Change-Id: I3dd1ea2c774f9fc0dff87b71f25375a469c3d05e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108300
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-04 13:48:26 +00:00
Li Hao 23a35c8a26 Add more tests in white_box/D3D12GPUTimestampCalibrationTests.cpp
Add more coverage for timestamp query on D3D12 backend to make sure
timestamps are converted correctly:
- All timestamp queries inside and outside passes
- The 'disable_timestamp_query_conversion' toggle disabled and enabled

Bug: dawn:1250

Change-Id: Ibdc6b35faed7cc1e1a8b60df4a5032914b411bc1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108022
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-04 08:43:57 +00:00
Loko Kung a4314fabb4 Minor build/include fixes for google3 roll.
Change-Id: I2f9ba7f98acdf9441d80d3a1169b36bee44a2e0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108545
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-04 01:44:43 +00:00
Takahiro e8cd0beb74 GPUBuffer.unmap() shouldn't validate buffer state
WebGPU specification was updated that GPUBuffer.unmap()
shouldn't validate buffer state.

https://github.com/gpuweb/gpuweb/pull/3368

This commit reflects it to the Dawn implementation.

Bug: dawn:1528
Change-Id: Ie66f68214bd6896a4d674ed00addc3ffb539c235
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106264
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
2022-11-04 00:08:27 +00:00
dan sinclair 16b4cf87d0 Template cmake for generated files.
This CL adds a cmake function to make it easier to integrate
files generated from the intrinsics file.

Change-Id: If2a593fad9703075ea91a29f72d482b34cc9dc1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108462
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-03 21:10:40 +00:00
dan sinclair 6590cc4fd9 Add missing benchmark test.
There is a benchmark test for builtin_value which was not added
into the benchmark code. This cl adds the missing test.

Change-Id: I6fc0eee0a50cad31f516024125be11e434df0ac0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108461
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-03 19:37:49 +00:00
Ben Clayton 8fa6c25b78 tint: Add Initialize() / Shutdown() public APIs
Have Initialize() bind the Program printer - which is helpful for debugging.
Call these from dawn/node.

This allows dawn/node to print programs when things go wrong.

Change-Id: I32d8805381d2939e82dc6ea383b9860fbb5fb69e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107684
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-11-03 19:16:26 +00:00
Ben Clayton 02f04d914d tint/transform: Polyfill bit-shift with RHS modulo
Fixed: tint:1453
Fixed: tint:1543
Change-Id: Idb5af752d7a3bb9e181cc47430ad4ddfb707873d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108440
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-11-03 19:15:17 +00:00
dan sinclair 91e27f25f9 Add const-eval for `floor`.
This Cl adds const-eval for the `floor` builtin.

Bug: tint:1581
Change-Id: I992eba3aa6c66707e923907a4bb912c2f6f8d290
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108343
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-03 17:10:49 +00:00
dan sinclair 11cecc1e4f Revert "Add CMake build option to generate intrinsic files."
This reverts commit c22b8b9dc8.

Reason for revert: Cost not worth benefit.

Original change's description:
> Add CMake build option to generate intrinsic files.
>
> This Cl adds an option to cmake to generate the intrinsic files
> as part of the buid.
>
> Change-Id: I785fbaa57b6d3b3ecd16e36b2f2baaa5da3cc9d9
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108000
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@chromium.org>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>

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

Change-Id: Idc57ea21d9d9152703e0a6d99fa518e8da079092
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108460
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-03 16:28:51 +00:00
dan sinclair abd6a7d9d4 Add const-eval for `ceil`
This CL adds const-eval for the `ceil` builtin

Bug: tint:1581
Change-Id: I32957d17000df1a8a59ce37f49b6177d1087406c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108342
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-03 15:59:23 +00:00
Dan Sinclair 465df13196 Revert "This CL updates the cmake files to use go run directly."
This reverts commit a950d4539e.

Reason for revert: Ran into issues integrating into all the required build environments.

Original change's description:
> This CL updates the cmake files to use go run directly.
>
> Instead of using the tools/run script this CL updates CMake
> to directly invoke go run. This should work around issues
> with multiple writers of the gen binary and fixup windows issues.
>
> Change-Id: Ie27f45a1d132e9ec100cad709bb92da8558b4fb3
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108045
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I10e7796d4f11661f2055c08202c84e56355ec397
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-03 15:09:03 +00:00
dan sinclair 9cbc7e1e54 Implement const-eval for `acos`
This CL adds const-eval for the `acos` builtin.

Bug: tint:1581
Change-Id: I01c0f48e73eedf87cf9c912715487f8eea44f64e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108341
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-03 14:49:23 +00:00
dan sinclair b3518d8b4d Implement const eval of `abs`
This CL adds const-eval for the `abs` builtin.

Bug: tint:1581
Change-Id: I6ee25c07620990f72a6962441aec62ae7665653e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108340
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-03 14:47:18 +00:00
Dan Sinclair 5ae03c266a Revert "Scaffolding for generation of intrinsics files."
This reverts commit 6c5db2afa6.

Reason for revert: Ran into issues integrating into all the required build environments.

Original change's description:
> Scaffolding for generation of intrinsics files.
>
> This CL sets up the basis for the intrinsic file generation. All of
> the GN and CMake pieces are setup, but they aren't hooked into the
> main build yet. That will be a followup which just enables the
> generation in order to allow easy reverting.
>
> Change-Id: Iccac59377076ed6ac66eeaf0be965be2f49bc738
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107981
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Reviewed-by: Ryan Harrison <rharrison@chromium.org>

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

Change-Id: If289cd2769faea6466bcae68c3c58cf416b3567a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108421
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-03 14:25:37 +00:00
Antonio Maiorano 11f0c52bfb tint: const eval of extractBits
Bug: tint:1581
Change-Id: I56e9b7de9aef803eaf6304c122f40e5a0c4dce67
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108203
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-11-03 13:03:08 +00:00
dan sinclair 58eca19f33 Add const-eval for `all`.
This CL adds const-eval for the `all` builtin.

Bug: tint:1581
Change-Id: Ib1d857ba24114c61e1a90b30dd66d063edfa136d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107464
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-03 12:07:49 +00:00
Ben Clayton aa4b64f4c8 tint/utils: Optimise HashmapBase::Scan()
Avoid an integer modulo for each scan iteration.

Change-Id: Ie80af4620b39769db622b4ab175b5639cf9ade8e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108260
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-11-03 11:44:15 +00:00
jchen10 61d6d21091 Byte counting WriteBuffer/Texture to submit
Only tag to submit when the total size is larger than the threshold,
so that we can make as few submits as possible meanwhile avoiding OOM.

Bug: chromium:1258986
Change-Id: I7190e1bb942bfaffc5cd424ce4743173735b25e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106418
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2022-11-03 09:58:59 +00:00
Yan,Shaobo e8dd681f19 Provide origin info for ExternalTexture
Current ExternalTexture visible related info only contains width and height.

But not all the visible rect started at (0, 0). This CL add visibleOrigin to contain origin info and record (width, height) in
visibleSize

Bug: chromium:1361363
Change-Id: I3d8931e490c97740f152653383f07d0a2d984dd3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108024
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-11-03 09:03:01 +00:00
Ben Clayton c6b381495d tint/transform: Refactor transforms
Replace the ShouldRun() method with Apply() which will do the
transformation if it needs to be done, otherwise returns
'SkipTransform'.

This reduces a bunch of duplicated scanning between the old ShouldRun()
and Transform().

This change also adjusts code style to make the transforms more
consistent.

Change-Id: I9a6b10cb8b4ed62676b12ef30fb7764d363386c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107681
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-11-03 08:41:19 +00:00
Antonio Maiorano 336f3536e5 tint: const eval of insertBits
Bug: tint:1581
Change-Id: Id89530eb90d3c75bd1f99dd67a78cad1c923c6f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107924
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-11-02 20:40:23 +00:00
Ben Clayton e372511e1b tint/utils: Rework Hashmap / Hashset
Previously Hashmap used to internally use a Hashset which held entries
of key-value pairs. This was cute, but meant that a Hashset held mutable
entries, which was a bag-of-bugs waiting to happen (change the entry to
hash as something different and you're now in an entirely broken state).

Pull the complex bits of Hashset out to HashmapBase, and have both
derive from that. I've opted for inheritance over composition here to
reduce the amount of structure chasing you'd have to do without
debugger pretty-printers.

Change-Id: I99e72244b69206a994edabfefd0e28d5d74d08d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108240
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-02 19:46:49 +00:00
Ben Clayton 9535f72209 tint/validator: Hint 'var' instead of 'const'
Involves expanding the source range of a variable declaration so we can point at something that can include the 'const'.

Fixed: tint:1740
Change-Id: Ie8f784de34a1792002aaa708c1b77053be54f1b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-02 18:14:59 +00:00
James Price fd9c3fe4bc tint/uniforimty: Remove short-circuit special-case
Now that expressions can only ever have the `Next` behavior,
short-circuiting operators will always reconverge.

Change-Id: Ib9fe4c774191b8a304fa7f7a6eafdfa6c6e6f18a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108202
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-11-02 18:01:31 +00:00
Ben Clayton c81f9dce07 tint: Implement const-eval of quantizeToF16
Bug: tint:1581
Change-Id: I5cf9806bde7875282d3b67731dbb88666523f598
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108142
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-02 17:29:48 +00:00
Dan Sinclair 749abeaafb Revert "Add GN build option to build using generated files."
This reverts commit 7cd8db1155.

Reason for revert: Breaking the Skia roll.

Original change's description:
> Add GN build option to build using generated files.
>
> This CL hooks the generated files into the GN build
> behind a `tint_build_use_generator` flag.
>
> Change-Id: I4926b2c9c1a349f26be8a1f8a4508e1e31dab813
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108041
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@chromium.org>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com,bclayton@chromium.org,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I3b920791bc2b6d22d9cbeb1310a2e89fbd1e8cd1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108205
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-02 17:07:25 +00:00
dan sinclair a950d4539e This CL updates the cmake files to use go run directly.
Instead of using the tools/run script this CL updates CMake
to directly invoke go run. This should work around issues
with multiple writers of the gen binary and fixup windows issues.

Change-Id: Ie27f45a1d132e9ec100cad709bb92da8558b4fb3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108045
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-02 14:53:57 +00:00
Ben Clayton bdd5bbe0c5 tint/transform/utils: HoistToDeclBefore polish
A new HoistToDeclBefore::InsertBefore() overload that takes a statement
builder. Required for supporting multiple clones.

Remove Apply() - it was API smell that wasn't needed.

Spring-clean the implementation

Change-Id: If448d2e1945ad6d988d1bdb30487d89efced2f0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104043
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-02 13:45:49 +00:00
Ben Clayton 2d63e321fd tint: Add callback overloads to CloneContext::Insert*
Change-Id: I2fc0b93d3ea3ba0d9d64fe575364f188db564b8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104041
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-11-02 13:40:41 +00:00
Ben Clayton b5c213b995 tint/resolver: Fix failures with no error
Invalid values to @binding(), @group() and @location() would fail resolving without an error diagnostic. This later triggers and ICE.

Refactor duplicate @location resolving in 4 places to a single method.

Canonicalize the diagnostic messages for attributes.

Remove a bunch of TODOs

Bug: chromium:1380212
Bug: tint:1633
Change-Id: Id2cc6ba4b807f12f350a2a31ef87fa0f185b64c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108144
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-11-02 07:49:23 +00:00
Zhaoming Jiang 6ab5d3c151 Tint/transform: make AddBlockAttribute always do wrapping if possible
This CL make transform AddBlockAttribute always try to wrap types used
by buffer variables into a struct, in order to generate valid GLSL code
for assigning one buffer struct variable to another buffer struct
variable.

Fixed: tint:1735
Change-Id: I009d8a9ca7ecea1dc0ad6164275c964a18acb33f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108023
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-11-02 02:25:38 +00:00
Ben Clayton 2bea9055f4 tint: Implement runtime quantizeToF16()
Fixed: tint:991
Fixed: tint:1741
Change-Id: I55dbabce6d28adf5abb710dc1e3e879c5aaa6be5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-02 00:09:50 +00:00
James Price 35da054624 tint/cmake: Fix test source paths
Change-Id: I69aec703de0ab96175b5ea79f3d0ae4f5ccb9227
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108201
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2022-11-01 21:51:14 +00:00
dan sinclair ed0649dec4 [IR] Fix setting of if merge target
When emitting the if true/false blocks we attempt to set the merge
target if the start block hasn't branched. This isn't right, as if the
block branched to other control flow, then that isn't the end of the
flow chain for that branch. We have to look at the current branch
target, and, if it exists, branch that to the if merge block.

Bug: tint:1718
Change-Id: Ifcafc4dd12c805efbee9d1dbcbc42c6add8f06a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107861
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-01 18:17:21 +00:00
dan sinclair 9261261da8 [IR] Add ability to dump IR graph to dot
This CL adds the ability to dump an IR graph to a dot file. The
`--dump-ir-graph` option is added to the main tint command. The IR code
is moved behind a TINT_BUILD_IR flag in order to allow the GN build to
continue to build the tint program.

Bug: tint:1718
Change-Id: I0953fe2a59a34c21bb6cd288cb90e9d0298af793
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107860
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-01 18:15:50 +00:00
dan sinclair 1c755b68e6 [IR] Add support for `for` statements
This CL adds the ability to convert a for statement into a loop control
flow node.

Bug: tint:1718
Change-Id: Ibd55ae3b202518d3362267eaa1f507dce6a9fe56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107804
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-11-01 17:11:25 +00:00
dan sinclair 0dce067e28 [IR] Add support for `while` statements.
This CL adds `while` statement support into the IR builder, converting
them into loop flow nodes.

Bug: tint:1718
Change-Id: I6dbaa24a0082463281dc933f02805169836fedd6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107803
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-01 17:09:39 +00:00
dan sinclair 7cd8db1155 Add GN build option to build using generated files.
This CL hooks the generated files into the GN build
behind a `tint_build_use_generator` flag.

Change-Id: I4926b2c9c1a349f26be8a1f8a4508e1e31dab813
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108041
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-01 17:03:48 +00:00
dan sinclair 50c29f6d38 [IR] Add support for `fallthrough`.
This CL adds `fallthrough` support to the IR building. Fallthrough is
deprecated but needs to be supported until removed from Tint.

Bug: tint:1718
Change-Id: I52ce4cc9953384a450ad09422b2ba38943284a42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107802
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-01 17:03:05 +00:00
dan sinclair c22b8b9dc8 Add CMake build option to generate intrinsic files.
This Cl adds an option to cmake to generate the intrinsic files
as part of the buid.

Change-Id: I785fbaa57b6d3b3ecd16e36b2f2baaa5da3cc9d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-01 17:02:31 +00:00
Ben Clayton c02feff258 tint/cmd: Add `--rename-all` flag
Renames all symbols

Add a test for tint:1725

Bug: tint:1725
Change-Id: Idac45c677d15361d76510068ad756e2f9bffacb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106880
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-11-01 16:12:23 +00:00
dan sinclair d336733c83 [IR] Add switch control flow node.
This CL updates the IR builder to create control flow nodes for
a switch statement and the contained case statements.

Bug: tint:1718
Change-Id: I05b73db11ab14676cc123f436ae5912b1dbee0d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107801
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-11-01 14:34:08 +00:00
dan sinclair b9ed75cf2f [IR] Track inbound branches to flow nodes.
This CL updates the flow node to track the nodes which are inbound
to the current target. This allows to fix an issue with a loop,
after a continuing with a break, properly eliminating dead code.

This also allows always providing the merge target for an if, it
just knows if it's disconnected by having zero inbound branches.

Bug: tint:1718
Change-Id: Ia9b9dbc734bf1e9cd0c829093c0cb1e470efb32e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107800
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-01 14:22:10 +00:00
dan sinclair 6c5db2afa6 Scaffolding for generation of intrinsics files.
This CL sets up the basis for the intrinsic file generation. All of
the GN and CMake pieces are setup, but they aren't hooked into the
main build yet. That will be a followup which just enables the
generation in order to allow easy reverting.

Change-Id: Iccac59377076ed6ac66eeaf0be965be2f49bc738
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107981
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-11-01 13:15:36 +00:00
dan sinclair 5c5f47afbf Fixup shadow variable.
This CL fixes up a shadow variable which causes compilation issues
on OSX.

Change-Id: I750423630cc2882d176c5ef304e1e0b4bef133a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108040
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2022-11-01 11:40:08 +00:00
Li Hao dec01f1fd5 Add timestamp period calculation for timestamp-query-inside-passes
Timestamp period is also needed by the timestamp-query-inside-passes
feature, which is enabled separately from the timestamp-query feature.

Bug: dawn:1193
Change-Id: I8a1f87f8d7931261b87608306820daefc4c3dc55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107880
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-01 00:58:31 +00:00
Ben Clayton 3f24fdc447 tint/fuzzers: Don't run the inspector on invalid programs
docs/tint/arch.md states that:
> The input `Program` to the inspector must be valid (pass validation).

So it should not be assumed that the inspector can handle invalid programs.

Bug: chromium:1378999
Change-Id: I780f59ba1117f5eadb461a55947c8e36761ab25f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107688
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-11-01 00:23:14 +00:00
Antonio Maiorano a3175f28f6 tint: const eval of firstTrailingBit
Bug: tint:1581
Change-Id: I4a9cb113780439849aec10cd0fc8e2f6d2ab55cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107881
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-31 22:57:14 +00:00
Antonio Maiorano 1abe52dc1c tint: const eval of firstLeadingBit
Bug: tint:1581
Change-Id: I33c87ced173938bcd16e00debdd5c6682b4a9426
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107763
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-31 20:34:36 +00:00
Antonio Maiorano 76c21c070b tint: const eval of countOneBits
Bug: tint:1581
Change-Id: I156cbd162010d28ec25b410220638e810fc34c98
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107701
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-31 18:44:15 +00:00
Ben Clayton 68ed8d92d3 tools/gen: Add flags for explicit output
`-o` will emit the files to the given root output directory
`--verbose` will print what's going on, to help with debugging

Omitting these flags will behave as before.

Also consolidate the utils package into fileutils. These were two packages with near identical functionality.

Change-Id: I855dd4b57807fb9239a52e7f357842d4ba2517ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107687
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-31 18:28:22 +00:00
Ben Clayton 6dbb463f1d tint/writers: Polyfill integer clamp()
...to `min(max(e, low), high)` as defined by the WGSL spec.

Fixed: tint:1479
Fixed: tint:1539
Change-Id: I39406d5256a155a781e44bd9d6081ce7a9bf5a68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107640
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-10-31 17:54:49 +00:00
Ben Clayton be83128031 tint/transform: Don't hoist textures / samplers
in the PromoteSideEffectsToDecl transform

Fixed: tint:1739
Change-Id: Iaa5a6e086708a6bba601c59962042650829795f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107683
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-31 17:33:35 +00:00
Ben Clayton 22c4850b06 tint/resolver: Allow array sizes to be unnamed override-expressions
I got the rules around this wrong. This should be allowed, but the array types cannot compare equal if they are unnamed override-expressions.

Fixed tint:1737

Change-Id: I83dc49703eed015e9c183e804474886da5dad7b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107685
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-31 17:26:10 +00:00
James Price cc85ed6dd1 tint: Function calls do not affect control flow uniformity
We now use the MergeReturn transform for SPIR-V, which is the only
backend that requires special handling to meet these function call
reconvergence requirements.

Fixed: tint:1627, tint:1726
Change-Id: I25f848f4b9ff0fd301b8a27a220bb09cdb2867ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107364
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-31 16:33:11 +00:00
James Price 3e1bc0a6da tint: Use MergeReturn transform in SPIR-V backend
Bug: tint:1627
Change-Id: I5a3639543b076e6f666bfcca8c61b22db7f2630e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107363
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-31 15:41:41 +00:00
Ben Clayton 8e8e38d129 tint/cmd: Expose multiplaner_external_texture transform
As a command line flag, enabling end-to-end testing of this transform.

This currently generates the binding points for the plane textures and parameters by looking for free binding points.

Bug: tint:1739
Change-Id: Id2b36a075b4fd2f7c71435b15f3edc3ba68f0339
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107682
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@google.com>
2022-10-31 15:00:45 +00:00
Ben Clayton 116a5e050a tint: regenerate intrinsic_table.inl
Change-Id: I201bcd6a7459d8f817bc4f808f5a0787319ecc77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107686
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-31 14:54:08 +00:00
James Price 5de8b436fa tint: Add MergeReturn transform
Add a transform that merges return statements into a single return
statement at the end of the function.

Bug: tint:1627
Change-Id: I971cc298fd9814634c82b49a07e15c5c0f3da404
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-10-31 14:49:03 +00:00
Corentin Wallez 363a995068 ShaderModuleVk: Add a renamer to make other transforms safe.
Without this other Tint transforms may end up calling user code instead
of builtins (for example for the min() used in robustness).

This commit does the following changes:
 - Changes ShaderModuleVk to return a CompiledSpirv object instead of
   just a Spirv Blob so that a remappedEntryPoint can be stored in the
   cache alongside the SPIR-V.
 - Inlines the logic and simplifies TransformedConcurrentShaderModuleCache
   slightly (by introducing a struct instead of std::pair, and adding a
   conversion method to ModuleAndSpirv).
 - Adds the Renamer transform to ShaderModuleVk and adapt the code to
   use the remappedEntryPoint where needed (pipeline creation and
   post-compilation reflection).
 - Adds a test where the min() used by the robustness transform is
   overriden to return a constant 0.
 - Moves the Renamer transform to be just after the SingleEntryPoint
   transform in D3D12 and Metal as well so as to make the test pass.

Fixed: dawn:1583
Bug: dawn:1585 dawn:1587

Change-Id: Ia9de38d391a7901ed04b097f4a8d439759f7556e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107020
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-31 11:17:50 +00:00
dan sinclair 8a523d7d8e Add const-eval for `any`.
This CL adds const-eval for the `any` builtin.

Bug: tint:1581
Change-Id: I32d8946b3cd5c6d210b75104fa37c4d1ef6a6f84
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107542
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-29 16:21:24 +00:00
Antonio Maiorano 7494e10f91 tint: const eval of countTrailingZeros
Bug: tint:1581
Change-Id: I2967ea1d6f3f297c03795bddd0e26abcccd57184
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107700
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-29 14:02:38 +00:00
Antonio Maiorano 2be5167e3e tint: const eval of countLeadingZeros
Bug: tint:1581
Change-Id: Ib7ae9f36dad64c1eed3ce223af47e92aa0a663f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107661
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-29 14:02:38 +00:00
jchen10 5722f2878d Remove the future serial
This adds 'HasScheduledCommands()', with which Dawn no longer needs the
future serial to tick and track the async tasks.

Bug: dawn:1413
Change-Id: Ide9ba69b796a46fa8bb70b002f4e2aeb1622bffd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98720
Kokoro: Kokoro <noreply+kokoro@google.com>
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-10-29 03:28:20 +00:00
Ben Clayton 46de10299f tint/transform/builtin_polyfill: Don't polyfill @const builtins
We don't want to replace builtins that are constant-expression
evaluated, as the replacement cannot be used as a constant expression.

Fixed: tint:1667
Change-Id: I554d9884fc41890247ee64b47a70621be5fcdbe5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107680
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-28 20:46:07 +00:00
Antonio Maiorano 2048d4f6ef tint: fix identity initializer of vec from vec of abstract not remaining abstract
For "vec3(vec3<T>) -> vec3<T>", this CL makes T also include abstract
int and float (all scalars).

Bug: tint:1731
Change-Id: I776c7ba6872c3d680982dbec6b0970389e720611
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-28 15:58:38 +00:00
Yan,Shaobo c303bdf705 Fix HandleAssertionFailure in ValidateCopyTextureForBrowser
The assert failure is caused by the validation orders. Current
validation order cannot ensure "destination" is valid when it is
passed to "ValidateTextureToTextureCopyCommonRestrictions".

This CL seperate "ValidateCopyForBrowserCommonRestrictions" to
"ValidateCopyForBrowserDestination" and "ValidateCopyForBrowserOptions".
Correcting the order and adding more comments.

Bug: chromium:1379001
Change-Id: I9bdbd773659827d0056cd7c37e78ac02ce22451c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107560
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-10-28 15:35:28 +00:00
dan sinclair c395660ee6 Add const-eval for `sign`.
This CL adds const-eval for the `sign` builtin.

Bug: tint:1581
Change-Id: I5d9bfd3f3f742bcba69fbb0d7f47dc57ce18e134
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107460
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-10-28 14:56:50 +00:00
dan sinclair fd1b5a893d Set specific test value for asin test cases.
The value of 1 for the `asin` is providing a slightly different result on OSX
compared to the Windows and Linux results. This CL updates the test case to use
asin(0.479425538604) = 0.5

Bug: tint:1581
Change-Id: Ibf7a921d1476c0d24da696eb6cc2b491c1ca1516
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107541
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-10-28 12:31:08 +00:00
Li Hao 74f6bc7e40 Move timestamp query inside compute/render passes to new feature
Feature::TimestampQuery is used for timestamp query in command encoder
and compute/render descriptor to match WebGPU SPEC.

Add a new feature timestamp-query-inside-passes for writeTimestamp API
on compute pass and render pass.

Split timestamp query tests in dawn_end2end_tests and dawn_unit_tests.

Bug: dawn:1193, dawn:1250
Change-Id: I8dd66c1d40939877e37ec2b979a573cc4812c21f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106500
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2022-10-28 04:51:16 +00:00
Antonio Maiorano e366dcf747 tint: show template param when printing initializer overloads with no params
Bug: tint:1732
Change-Id: Ide1d961730638a5c062cc0a8e072c5fb0f0fd9dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-28 02:39:35 +00:00
dan sinclair 71111f8e0d Fixup dispatch call for step and saturate.
The incorrect dispatch call was used for step and saturate. It
included the int and uint aspects when not needed.

Bug: tint:1581
Change-Id: Ibb80a7869eaa674d38bdae69929c9e91011918f8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107463
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-28 02:37:49 +00:00
Jiawei Shao 036a24b047 Disable workaround for T2T copy issue on Intel GPUs on latest driver
This patch disables the workaround for the T2T copy issue on Intel
GPUs on the latest Intel D3D driver 31.0.101.2114 as the driver bug
has been fixed in that driver.

Bug: chromium:1161355
Test: dawn_end2end_tests
Change-Id: I5a1d01e2da519a133aacfac695e180b72715fac6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107181
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-28 02:24:00 +00:00
dan sinclair eee8d88210 Start adding IR.
This CL starts adding the basics for an IR for Tint. The IR is
a lower level representation then the AST with several of the
restrictions removed. For example, the IR is mutable, is a DAG
instead of a tree, and removes a number of WGSL constructs to
simplify transforms.

Bug: tint:1718
Change-Id: I6a16ac3116cee31410896c3a0424af7b41f958c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105800
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-28 01:22:58 +00:00
Antonio Maiorano 14b5fb6f17 tint: add pretty printers for gdb and lldb
Currently supports pretty printing of:
- tint::Utils::Vector, VectorRef, and Slice
- tint::Utils::Hashset, Hashmap

Change-Id: Ifbf2547b0f87d7fde8d9ff0dd458aa35c5fd57f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106720
Reviewed-by: dan sinclair <dsinclair@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-27 20:17:45 +00:00
dan sinclair c3cbc35650 Add negative number parsing into `@test_value`
This CL updates the intrinsics lexer to allow negative values for int
and float numerics. This allows doing `@test_value(-2)` in the def file.

Change-Id: I2cad9b25a2932057ce9bc51dec6c32231e06f0a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107440
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-27 18:44:50 +00:00
dan sinclair 91ed6f7289 Add const-eval for `saturate`.
This CL adds const-eval for the `saturate` builtin.

Bug: tint:1581
Change-Id: I3729ea5b381b04b73bbe1bc8e03e5ce65c27e082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107362
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-27 16:41:44 +00:00
dan sinclair c98ad87368 Add const-eval for `step`.
This CL adds const-eval for the `step` builtin.

Bug: tint:1581
Change-Id: Idbf773fb88892a8a5e620bcfe8b779dee148f746
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107281
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-27 15:32:45 +00:00
dan sinclair 59d9c89ff7 Add const-eval for `asin` and `asinh`.
This CL adds const-eval for the `asin` and `asinh` operators.

Bug: tint:1581
Change-Id: I18b2eeb4fb85b8979012b48551eefa773d1b980e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106980
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-27 15:10:20 +00:00
Ben Clayton a92f4259d5 tint/writer/msl: Move packed_vector hacks to transform
Attempting to paper over all the MSL standard library holes for packed_vector in the MSL writer added complexity to the writer, produced messy output, and didn't actually catch all the cases where casts were needed.

Add a new PackedVec3 transform that applies the packed_vector -> vec casts in a smarter, more precise way.

Fixed: tint:1534
Change-Id: I73ce7e5a62fbc9cb04e1093133070f5fb8965dce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107340
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-27 14:36:49 +00:00
dan sinclair 81ecd739b0 Protect sem::MemberAccessorExpression constructor.
This CL moves the constructor for a sem::MemberAccessorExpression to
protected to make it clear that only Swizzle and StructMemberAccess
classes can be created.

Change-Id: I85eef6c6f41c4c36192d88b84150f15205f1bf22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107361
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-26 21:54:06 +00:00
Ben Clayton 2e376a9bb0 tint/intrinsics: Allow mixing of signed / unsigned integer arguments
Fixed: tint:1733
Change-Id: Id83c5c5a59df062320a9a9fde087a34b85fbaa2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107160
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-26 18:47:02 +00:00
Ben Clayton 13f089095f tint/intrinsics: Texture queries now return unsigned integer / vectors
To match the spec.

Also add a bunch of missing texture test cases to
src/tint/ast/builtin_texture_helper_test.cc. Fix all the tests that were
broken because these were not being exercised.

Fixed: tint:1526
Change-Id: I207b51d307bbdc054b595e0e0e0fd3330607e171
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106681
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-26 18:36:44 +00:00
Corentin Wallez 0143ec57ba Reland "tint::transform::VertexPulling: require SingleEntryPoint"
This is a reland of commit 63463c2f77

Original change's description:
> tint::transform::VertexPulling: require SingleEntryPoint
>
> This change the vertex pulling transform to look for the single vertex
> entry point in the module, instead of taking the entry point name in the
> config. This is necessary because the renamer needs to run before
> VertexPulling so that builtins like min() don't end up referring to the
> input WGSL. Putting the renamer before VertexPulling makes the config
> entry point name no longer match.
>
> Bug: dawn:1583
> Change-Id: I4c96eb83518e0d6fe8ce23b37e238f4a890eeb2f
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107080
> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>

Bug: dawn:1583
Change-Id: Ida4ac03003dff95c26d7b2bff82f4717c90c9691
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107320
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-26 17:02:16 +00:00
Dan Sinclair 45844e3df4 Revert "tint::transform::VertexPulling: require SingleEntryPoint"
This reverts commit 63463c2f77.

Reason for revert: Breaks the kokoro build

Original change's description:
> tint::transform::VertexPulling: require SingleEntryPoint
>
> This change the vertex pulling transform to look for the single vertex
> entry point in the module, instead of taking the entry point name in the
> config. This is necessary because the renamer needs to run before
> VertexPulling so that builtins like min() don't end up referring to the
> input WGSL. Putting the renamer before VertexPulling makes the config
> entry point name no longer match.
>
> Bug: dawn:1583
> Change-Id: I4c96eb83518e0d6fe8ce23b37e238f4a890eeb2f
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107080
> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>

TBR=cwallez@chromium.org,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I26f521213db6ce80cdccad20cbaa6a1c0d37b2c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1583
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107280
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-10-26 16:01:33 +00:00
dan sinclair b3b027d3cd Update lexer to not include `-` in numbers.
This CL removes the parsing of a `-` in front of numerics when lexed.
This will cause the number to become a UnaryOperator negation then the
number instead of a negative number.

Bug: tint:1679, tint:1141, tint:1570
Change-Id: I217c0ffcbe5be934c8d56bd83141b47ade83bc60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106463
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-26 15:20:47 +00:00
Corentin Wallez 63463c2f77 tint::transform::VertexPulling: require SingleEntryPoint
This change the vertex pulling transform to look for the single vertex
entry point in the module, instead of taking the entry point name in the
config. This is necessary because the renamer needs to run before
VertexPulling so that builtins like min() don't end up referring to the
input WGSL. Putting the renamer before VertexPulling makes the config
entry point name no longer match.

Bug: dawn:1583
Change-Id: I4c96eb83518e0d6fe8ce23b37e238f4a890eeb2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-26 12:47:30 +00:00
Zhaoming Jiang 4faf3581b8 Tint/builder/spirv: Fix atomicCompareExchangeWeak wrong return
This CL fix the spv code generated for atomicCompareExchangeWeak,
specifically the emulated `exchanged` field of the returned struct.
It should be true if and only if the `old_value`, i.e. the return value
of spv `OpAtomicCompareExchange`, equals to the comparator, rather than
equals to new value.

Fixed: tint:1663
Change-Id: I1cb0de6bb6b90ae681f5053b8bdd6f6b247146f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107180
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-10-26 08:23:25 +00:00
Yan,Shaobo b4d8c8012b Reland "Add CopyExternalTextureForBrowser()"
This is a reland of commit f392c38b67

The new added structure ImageCopyExternalTexture used in dawn only. Adding
tags : ["dawn"] to fix compile error.

Original change's description:
> Add CopyExternalTextureForBrowser()
>
> This API accept ExternalTexture object as copy source and a dawn 2D texture
> as destination. It has similar functions as CopyTextureForBrowser().
> The API is used to support cases that source images are multi-planar format
> and want to do conversion and uploading to a dawn 2D texture.
>
> Bug: chromium:1361363
> Change-Id: Ie390acfb95b47d417f4a8faa2d1e19163d549154
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105880
> Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

Bug: chromium:1361363
Change-Id: I213c3dc7fe81ccc35050592e491995d0d5425f6e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106883
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-10-26 00:58:46 +00:00
Antonio Maiorano 0640c81073 tint: make uniformity analysis failures warnings again
Bug: tint:1728
Change-Id: I7684a49567d2e5c2c49f3c5b1d45a9fe543abbc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-26 00:27:38 +00:00
Antonio Maiorano ee42e05101 tint: enable unit test now that const eval of shift left has landed
Bug: tint:1713
Change-Id: Iaea50c6b833230331d98784f98ef4b1108422039
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107142
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-25 23:37:07 +00:00
Antonio Maiorano 25fdff1ff8 Unrevert "tint: rhs of left shift is always u32 or vector of u32"
Was failing e2e tests. Bug fixed in a parent commit.

Bug: tint:1713
Change-Id: I5cf20e6fd21e6358bb418f2ede7f4a7e0a61f138
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107141
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-25 23:37:07 +00:00
Antonio Maiorano e0f78f924c tint: always pass in earliest evaluation stage to intrinsic table lookup
This fixes cases where input args of different type are mixed between
constant and runtime evaluated. We initially did this only for builtins
(https://dawn-review.googlesource.com/c/dawn/+/104545) to fix cases like
`select`, but we also need this for binary operators like shift
left/right that also take args of differing types. For consistency, this
change also includes passing in the earliest evaluation stage when
looking up unary ops and initializer/conversions.

Bug: tint:1713
Change-Id: I196c67acfe767aa01aa45298d75cfc4d345d08ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107140
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-25 23:37:07 +00:00
dan sinclair 4c8401f33c Add const-eval for `atanh`.
This CL adds const-eval for the `atanh` operator.

Bug: tint:1581
Change-Id: I7d8989a348ad1d8ca463dae90233fd82d6faf2d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106849
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-25 18:03:56 +00:00
Corentin Wallez 19c761ffe5 Fix a typo in a BindGroup compatibility error message
Bug: None
Change-Id: I3e58b07d7cff57dde1dd6305c362f8d8e07fc8e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106680
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-10-25 18:02:08 +00:00
Ben Clayton 5af4d88753 tint/resolver: Validate @size only on creation-fixed footprint member types.
Fixed: tint:1623
Change-Id: Id553dfe57effb4084a16fd6e6b02ad0cef85f836
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106224
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 17:58:42 +00:00
Ben Clayton bd5bd247f0 tint/resolver: Limit scope depth / if-chains.
DXC will bail if these get too deeply nested (~256).
This is also a risk for stack-overflows, so apply a limit agreed by the
WGSL working group.

Fixed: tint:1518
Change-Id: Idacdba85b36b27a0a89a3a7958fd4c6cce7dc84d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105964
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-10-25 16:53:06 +00:00
dan sinclair 0423c3ccd0 Use ConcatIntoIf in const-eval builtin tests.
This CL updates atan2 and atan to use the ConcatIntoIf helper
instead of doing the case concatention.

Bug: tint:1581
Change-Id: I4ea3153aefcab18db88ab81dd499b9f9e37e7906
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106846
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-10-25 14:47:31 +00:00
Ben Clayton f17497cb6d tint/sem: Add tests for IsConstructable
Change-Id: Id0eb03f2f8fd1053b62d3238214fc982f02a960f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106223
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-25 13:27:49 +00:00
Ben Clayton 95dd428c75 tint/intrinsics.def: Add @test_value() annotation
Specifies the value to use for argument values when generating end-to-end tests.

Use this to provide a legal value for atanh().

Change-Id: I008050c856f9d687ab918c68e90678c4e74f3a1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106887
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 13:08:45 +00:00
Ben Clayton 14281033e5 dawn: Fix OpenGL context creation for Nvidia / Linux
Change 104120 enabled `EGL_EXT_create_context_robustness` to ensure that robustness is enabled for OpenGL.

Despite listing `EGL_EXT_create_context_robustness` in the extension list, Nvidia linux drivers will error with `EGL_BAD_ATTRIBUTE` when `EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT` is specified when requesting an OpenGL context (ES works fine!)

EGL promoted this extension to core in EGL 1.5, and requesting `EGL_CONTEXT_OPENGL_ROBUST_ACCESS` keeps Nvidia happy - so use this instead.

Note: We already require EGL 1.5 for EGLImage.
Change-Id: I6012773aef0d53b1d147228f40e0348865e98107
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106884
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-25 13:03:36 +00:00
Ben Clayton 80b2312493 tint/sem: Add Type::Flags()
Use a utils::EnumSet to hold type flags.
This scales better than adding a virtual method for each flag.

Change IsConstructable() from virtual to inline method.

Also remove sem::MemoryLayout. This was some cruft from something
removed a long time ago.

Change-Id: Ib3371946d7f4b07692255641425ccf621dc3e2f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106220
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 10:05:18 +00:00
Ben Clayton 434edc2a12 tint/resolver: Allow shadowing of builtins
Fixed: tint:1610
Change-Id: Ie7a391dae2f47db84d084c89a18ec35115bdd667
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106882
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-25 08:44:20 +00:00
Ben Clayton da5424b617 tint: Allow signed / unsigned texture builtin params
Bug: tint:1526
Change-Id: I301a9ba6e94b162a1ffb436be3e3212b723b7401
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106682
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-24 23:58:53 +00:00
Ben Clayton d96f7c22ed dawn/node: Fix missing validation errors
Derived interfaces were not exposing their base interface's attributes / methods / constants.

By fixing this, we now correctly expose the `message` property on interfaces deriving from `GPUError`.

Change-Id: I2f8cb4145b589a7b148495ad36f1ae00e388a99e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106881
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-24 22:59:44 +00:00
dan sinclair 20500b8e3a Add const-eval for `atan`.
This CL adds const-eval for the `atan` operator.

Bug: tint:1581
Change-Id: I3d9b417e86af010dc2f18c4e0424ddf971d55984
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106844
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 21:57:27 +00:00
Antonio Maiorano 087c355e08 Revert "tint: rhs of left shift is always u32 or vector of u32"
This reverts commit cc9ae5cae3.

Reason for revert: Kokoro failed on this CL

Original change's description:
> tint: rhs of left shift is always u32 or vector of u32
>
> Implements recent spec change:
> https://github.com/gpuweb/gpuweb/pull/3516
>
> Bug: tint:1713
> Change-Id: I678e3c15ec8ab010dca43fc814cf0bc79486f4b6
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106721
> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,amaiorano@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I9d2337b77e2853c9e26300d0bfdbfba744c54c48
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: tint:1713
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106847
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-24 20:30:12 +00:00
dan sinclair a3325fa94d Traverse function return attributes.
The dependency graph needs to traverse function return attributes
as they can contain expressions now.

Bug: chromium:1377630
Change-Id: I338aa7ff1105baed93871ec44ca02285fabf407d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106845
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-24 19:43:28 +00:00
Antonio Maiorano cc9ae5cae3 tint: rhs of left shift is always u32 or vector of u32
Implements recent spec change:
https://github.com/gpuweb/gpuweb/pull/3516

Bug: tint:1713
Change-Id: I678e3c15ec8ab010dca43fc814cf0bc79486f4b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106721
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 18:30:11 +00:00
dan sinclair 3a1b799585 Review feeback from 106420
Change-Id: I9c1ec7f26b0fda25bcedc86fec66d174fe81ed5f
Bug: tint:1633, tint:1451
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106843
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 17:49:20 +00:00
dan sinclair a7014a969e Rename primary_expression.
This CL updates the name of primary_expression to match spec.

Bug: tint:1633
Change-Id: Iba0f681a47f80f80913a5ce3efb6f753201b072c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106581
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-24 14:41:44 +00:00
dan sinclair f4baf2713c Revert "Add CopyExternalTextureForBrowser()"
This reverts commit f392c38b67.

Reason for revert: Breaking the roll into Chromium, and breaks the CMake build of Dawn. https://chromium-review.googlesource.com/c/chromium/src/+/3974728

Original change's description:
> Add CopyExternalTextureForBrowser()
>
> This API accept ExternalTexture object as copy source and a dawn 2D texture
> as destination. It has similar functions as CopyTextureForBrowser().
> The API is used to support cases that source images are multi-planar format
> and want to do conversion and uploading to a dawn 2D texture.
>
> Bug: chromium:1361363
> Change-Id: Ie390acfb95b47d417f4a8faa2d1e19163d549154
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105880
> Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

TBR=cwallez@chromium.org,shaobo.yan@intel.com,enga@chromium.org,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I3f057b1e5fe3bb0e41063eb402d2c269c27aaedf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1361363
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106842
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-24 14:24:29 +00:00
Yan,Shaobo f392c38b67 Add CopyExternalTextureForBrowser()
This API accept ExternalTexture object as copy source and a dawn 2D texture
as destination. It has similar functions as CopyTextureForBrowser().
The API is used to support cases that source images are multi-planar format
and want to do conversion and uploading to a dawn 2D texture.

Bug: chromium:1361363
Change-Id: Ie390acfb95b47d417f4a8faa2d1e19163d549154
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105880
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-10-24 06:03:22 +00:00
Yan,Shaobo 96a0bd5bdf Add visibleRect to ExternalTextureDescriptor
Add visibleRect in ExternalTextureDescriptor to create ExternalTexture.
This helps ExternalTexture present the content correctly if needed.

Bug: chromium:1361363
Change-Id: I54b1912305080943babd7558ef40bca8528c932c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106181
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-24 04:19:43 +00:00
dan sinclair b8b0c21918 Add break-if support.
This CL adds support for `break-if` to Tint.

Bug: tint:1633, tint:1451
Change-Id: I30dfd62a3e09255624ff76ebe0cdd3a3c7cf9c5f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106420
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
2022-10-20 22:45:50 +00:00
Antonio Maiorano b69c6066c4 tint: Fix uniformity ICE during error reporting wrt non-uniform pointer parameters
Added support for reporting when pointer parameters point to non-uniform
values. Also add support for binary expressions results that may be
non-uniform.

Bug: chromium:1374534
Change-Id: Ia51557e3a984c69a39f2878c964bf07085599809
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106560
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-20 17:15:34 +00:00
dan sinclair 481b2ed959 Fix issue resolving address of numeric.
This CL fixes up a clusterfuzz issue where the address of a
numeric was take in a case selector leading to a nullptr.

Bug: chromium:1376865
Change-Id: I3b78a17e1c47263e18d2d272ff28c2cc8be79a0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106540
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-20 14:56:45 +00:00
dan sinclair 882b38a2f5 Update fallthrough deprecation notice.
The `default` case selector has been implemented in Tint. This CL
updates the deprecation notice with that fact along with some more
information on replacements.

Bug: tint:1644
Change-Id: I883b4465d11d9696d46523d11e66c9a2dc2777ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106460
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-20 14:03:04 +00:00
dan sinclair 6e77b47ed9 Update internals to initializer instead of constructor.
This CL catches up the internals (along with a few error messages) to
say `initializer` instead of `constructor.

Bug: tint:1600
Change-Id: I8e56572c310d77da1130380bdd32b334f27c8e46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106462
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-20 13:38:28 +00:00
dan sinclair fdd2ff1145 Add tests to show correct handling of mixed && and ||.
This CL adds tests to verify the new parser handles the mixing of && and
|| correctly.

Bug: tint:1599
Change-Id: I1a73d041a00118ed649522ae07fc1489021c4b41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106461
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-19 20:28:34 +00:00
Antonio Maiorano 1c94938726 tint: implement updated spec rules for shift left of concrete values
Rules for shift left of concrete values are now split between signed and
unsigned. Shifting unsigned values no longer fails with "sign change"
errors. Furthermore, shifting unsigned values must only shift out 0s.

See https://github.com/gpuweb/gpuweb/pull/3539.

Bug: tint:1701
Bug: tint:1717
Change-Id: Iba2799f4b02cdc77cc58a6c7c104aaa408f0f0f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106381
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-19 17:46:12 +00:00
Antonio Maiorano 3fa6887679 tint: use struct instead of tuple for test cases
googletest doesn't print test parameters properly when they are a tuple
of variants.

Change-Id: I070697bb0118282dd4841df23c936e0171934628
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-19 17:20:58 +00:00
dan sinclair f148f0891b [WGSL] Allow default as a case selector
This CL updates the WGSL parser to parse `default` as a case selector
value.

Bug: tint:1633
Change-Id: I57661d25924e36bec5c03f96399c557fb7bbf760
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106382
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-19 15:55:02 +00:00
Yunchao He d27151d333 D3D12 Intel: Improve the workaround for array texture corruption issue
This change adds more tests to exercise the code of the workaround for
array texture corruption issue. Because texture memory layout and tile
alignment vary accordingly if array textures have mipmaps, and/or
different dimensions, etc.

It also does some slight changes in the workaround itself for array
textures with non-32-or-16-bit-wise formats.

Bug: dawn: 949, dawn: 1507
Change-Id: I22e87830ba59f2a2814e6786aa9a1a55a15c95cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105241
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2022-10-19 15:19:13 +00:00
Jiawei Shao f30e8dbe31 Set colorAttachment.clearColor to NAN in CHelloTriangle.cpp
This patch sets the deprecated member colorAttachment.clearColor to
NAN in CHelloTriangle.cpp to eliminate a warning when running the
demo.

Bug: dawn:1269
Change-Id: I274198d1cafbc2dc15dcf6e59d26b58a62134c5a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-10-19 13:28:56 +00:00
dan sinclair d32fbe07e7 Store expressions in switch case statements.
This CL moves switch case statements to store Expression instead
of an IntLiteralExpression. The SEM is updated to store the
materialized constant instead of accessing the expression value
directly.

Bug: tint:1633
Change-Id: Id79dabb806be1049f775299732bc1c7b1bf0c05f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106300
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-19 00:43:41 +00:00
Ben Clayton 00aa7ef462 tint/reader/wgsl: Better diagnostics for missing parentheses
This change required removing the `&&` splitting for `a & b && c` which never valid WGSL (right now).

Fixed: tint:1658
Change-Id: Ideb9f1aa9cf9b9b1054a6fc65860106dc072a9dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105820
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-18 23:57:25 +00:00
Antonio Maiorano b6e1bc7d5d tint: Fix C++ UB when shifting abstract 0 left by >= 64
In WGSL, we can shift left abstracts by >= 64, as long as the result is
representable in the data type we choose for it. When shifting 0, we can
shift by any positive u32 value (result is always 0), but in C++, it's
UB to shift by more than the bit width of the data type, so we need to
handle this. This bug was caught by ClusterFuzz.

Bug: chromium:1372963
Change-Id: I638ca190b93538908ca6472f3735627ea8531c5a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106266
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-18 20:17:55 +00:00
Brendon Tiszka f3666c45f3 Add assertions to ServerInlineMemoryTransferService to catch corrupted states while fuzzing with DawnWireServerFuzzer and tests.
Bug: chromium:1340654,chromium:1374495
Change-Id: Icfb008a1cd6dbd8af32f3aedc90ef29e29a0465b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106041
Commit-Queue: Brendon Tiszka <tiszka@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-18 15:15:02 +00:00
Antonio Maiorano 79195ca42a tint/uniformity: implement analysis for full and partial assignments
As per https://github.com/gpuweb/gpuweb/pull/3298

Bug: tint:1703
Change-Id: I88eb40764473fdae52962b36df1b4a1c929603f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105000
Reviewed-by: Alan Baker <alanbaker@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-17 21:47:38 +00:00
dan sinclair 33a090f90f Remove unused SwitchStatement method.
The SwitchStatement has an IsDefault method which checks if the
condition is nullptr. The method is never called, and default
cases are tracked in the CaseStatement class, so it's questionable
what IsDefault even means here.

Change-Id: I96e97fbbf4823df3e92d2440fa6a9541a5ba337f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106280
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-17 21:45:34 +00:00
Antonio Maiorano 29fb8f8eef tint: optimize compile time for const_eval_*_test files
The reason for slow compile times is because the very large variants of
builder::Value<T>s combined with the many std::visits over these
variants result in many combinatorial instantiations of the visit
callbacks.

To address this, I added a polymorphic base class ValueBase to Value<T>,
and replaced most of the std::visit-based compile time code with runtime
virtual calls. For the two heaviest users of std::visit over the large
variants, compiles times dropped more than half (clang-10, debug):

const_eval_binary_op_test.cc: 19.079s to 7.736s
const_eval_unary_op_test.cc: 10.021s to 4.789s

Bug: tint:1711
Change-Id: Iba05e6ae1004ef0814250e2a8ea50aa2b26b85f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105782
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-17 16:11:02 +00:00
dan sinclair 3fd42ae042 Convert the location attribute to expressions.
This CL updates the @location attribute to use expressions instead of
integers.

Bug: tint:1633
Change-Id: If4dfca6d39e5134bb173209414ad8d2528c8095d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106121
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-17 15:21:48 +00:00
dan sinclair 155165cd52 Convert the id attribute to expressions.
This CL updates the @id attribute to use expressions instead of
integers.

Bug: tint:1633
Change-Id: I3db9ab39f10a7f50f8d1e418ec508d4e709a24ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106120
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-17 14:35:43 +00:00
Ben Clayton f50ad7f63d tint/resolver: Make member attribute diagnostics consistent
Standardize how we refer to @size, @align and @offset.

Change-Id: I14d462a7e96e35e6c3d6dc5a11cc09f9a95eca15
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106200
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-17 14:18:07 +00:00
Ben Clayton df3a0462ad tint/sem: Remove 'sem_' prefix from array / struct tests
This is cruft left over from file name collisions between ast / sem,
which has been resolved by splitting the build targets.

Change-Id: I0d65ffe97fed7095b37cc91a506dd05a20cda76a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106222
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-17 13:24:38 +00:00
Ben Clayton c574151e72 tint: Remove junk from copyright header
Change-Id: Ib38cc4b7b9783cce8efcb3d0d00ff4603ad7c928
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106221
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-17 13:18:25 +00:00
Ben Clayton cd4b6c1479 tint/sem: Add missing 'const' to static const char*
Change-Id: I01791122a2f33128909d0eaf4837bc32c86a653e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106160
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-10-17 12:39:55 +00:00
Austin Eng a4c148fe03 Unsuppress Metal Intel TextureViewSamplingTests
Passing now on our infra, starting in MacOS 10.13.
Chromium has also dropped support for 10.12.

Bug: dawn:39
Change-Id: Ied22c00ffdcfa7c2ae4f122af8721defc2bbc5aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106020
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
2022-10-17 09:25:20 +00:00
Ben Clayton 4e0689b665 tint/sem: Move variable decls to CompoundStatement
Variables can be declared in more than just BlockStatement.
For example, for-loops can declare a variable.

Change this to be a map instead of a vector. This helps with lookups.

Change-Id: Ic9429425af70e9535c21cc0875b875f145724266
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104040
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-17 09:14:16 +00:00
Zhaoming Jiang 9fc7a77609 Always validate DXC version and forbid DXC older than 1.4
This CL add a `Backend::IsDXCAvailable` method that check not only the
DXC binary is available but also its version is no older than a given
minimum version, and use this function to replace all previous
`PlatformFunctions::IsDXCAvailable` to ensure that we always check the
DXC version. By giving the minimum version 1.4, this CL also forbid
using DXC older than 1.4.

Issue: tint:1719
Change-Id: I6ab0a3791ac734c4e8b13570c55194573f111e61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105900
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-17 08:39:06 +00:00
Ben Clayton 99084a411d tint/resolver: fix diagnostic source for test
As spotted in https://dawn-review.googlesource.com/c/dawn/+/105640/comment/c79d61a2_ec2d879f.

Change-Id: I1fda26d9050bd2a8f43e94ebcba32440f2f748f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105940
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-15 01:03:13 +00:00
dan sinclair 72ac53e5fa Convert binding and group attributes to expressions.
This CL updates the @group and @binding attributes to use
expressions instead of integers.

Bug: tint:1633
Change-Id: I91068874c104d5b84390f1617cb96265dda6e1e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105801
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-14 18:39:04 +00:00
dan sinclair 308c55d9e0 Convert `size` attribute to expressions.
This CL updates the size attribute to parse expressions.

Bug: tint:1633
Change-Id: Ia12650848e7041faa53013d195f4313b8d3e9969
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103320
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-14 18:27:35 +00:00
Corentin Wallez 2a7966e519 Expose DepthClipControl on D3D12
It is always available.

Bug: dawn:1178
Change-Id: Id49064002ed4ebc10ee85113d0db854d7fcf84a5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105962
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-14 16:02:17 +00:00
Jiawei Shao 7171fa9550 Fix shaders in ShaderRobustnessPerf
This patch fixes the shaders used in ShaderRobustnessPerf tests by
replacing the deprecated "let" with "const".

Bug: dawn:594
Test: dawn_perf_tests
Change-Id: Ife3d03f40404963193fd79c05649334f52154f1a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105921
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-14 15:51:49 +00:00
Ben Clayton d9222f44c9 tint/resolver: Validate discard is only used by fragment shaders
Fixed: tint:1373
Change-Id: Ieb2a808982d8fa8b199e57d4df44f29390fa6e74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105961
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-10-14 13:44:54 +00:00
Ben Clayton 1a567780d9 tint/writer: Check extensions are supported
If they're not supported by the backend, print an error that includes the line that enables the extension

Fixed: tint:1678
Change-Id: I3732bfba92a8f96c9e5613c5da6f0e197352508f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105760
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-14 13:38:27 +00:00
Ben Clayton aecf1a2ab5 tint/inspector: Fix GetOverrideDefaultValues()
Override values no longer need to be a literal.
Use the constant value to infer the initializer value.

Bug: chromium:1362256
Change-Id: Ie0eef49291c568fef2197dfa91fcb5f3e3197d65
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105960
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-14 12:09:59 +00:00
Austin Eng 545d8629ef Remove test suppressions for crbug.com/dawn/838
No longer failing on our test infrastructure.

Bug: dawn:838
Change-Id: I70168d89fb56218e2bc9b20c7fbe95b791cbdeb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105781
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Auto-Submit: Austin Eng <enga@chromium.org>
2022-10-13 22:34:38 +00:00
Antonio Maiorano 723da2aac5 tint: split up const eval unit tests into multiple files
The single file was taking too long to compile, and was becoming
difficult to work in.

Bug: tint:1711
Change-Id: Ibaaa5dd72aef02cdffe80156848d010ff84c9553
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105740
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-13 19:27:30 +00:00
Ben Clayton c84d06e860 tint/resolver: Improve errors for expr eval-stages
Raise the error on the inner-most expression that violates the required evaluation stage.

Fixed: tint:1655
Change-Id: I82186e72ed6efa1cd6d4456c04446da18e9f1850
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105640
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-13 17:23:06 +00:00
Ben Clayton 559a248233 tint/resolver: Allow texture 'offset' to be const-expr
This allows the value to be declared in a `const` expression, and to use arithmetic.

Fixed: tint:1636
Change-Id: Ie641a9d4183429c79c91605cd4df78f569be3579
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-13 17:06:29 +00:00
dan sinclair d5139b4463 [msl] Handle packed conversions in shift expressions.
Similar to the handling of packed values in the arithmetic operators
the shift operators need to cast to the unpacked type before doing the
as_type casts.

Bug: tint:1542
Change-Id: I4289c45ab0a067ce122f61675fe5e251a83b6f8b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-13 15:28:51 +00:00
Antonio Maiorano 840e42477d tint: update natvis
Change-Id: Icf31f70c3c6bf09611938847a8fb537d3fdad7c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105660
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-13 14:43:11 +00:00
Ben Clayton f10a57908a tint: Use `const-expression` and `override-expression` terms
Fixed: tint:1601
Change-Id: I72827df7c83dbb8f5dc69a8803fbe955b1a2421d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105622
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-13 13:47:39 +00:00
Ben Clayton 92264f8bb2 tint/resolver: Fix NPE in CollectTextureSamplerPairs()
Fixed: tint:1715
Change-Id: Ie46d1348e44c4719ef318e7d18393713148338d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105620
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-13 13:45:35 +00:00
Ben Clayton 4fe330fff4 tint: s/analysing/analyzing
Tint uses american spelling.

Change-Id: Ibd3b425cb217db5b43f20cc64c6f3876233ec16e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105621
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-13 13:33:25 +00:00
David Neto 6988e894d2 spirv-reader: track access mode for ptr/ref
Fixed: tint:1041 tint:1103
Change-Id: Ief5f3da73c65700fe904e76683b9b25f4eca2169
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104900
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-10-12 21:32:19 +00:00
David Neto cc0c67bce8 spirv-reader: Support GLSL.std.450 FindSMsb
Fixed: tint:1058
Change-Id: Ifdc2ee9c54d18e1efe6b908991e8eb1b8c6a6de4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104903
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-12 20:42:26 +00:00
Corentin Wallez 042711b2b1 Remove redundant file in tint/BUILD.gn
Change-Id: I457d765aa58319b9b2a60253463e4fef04981492
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105561
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-12 20:24:25 +00:00
Ben Clayton ba384f0383 tint/transform: Fix array materialization when indexing with override
Fixed: tint:1697
Change-Id: I6de9ea520e8e8fcba281c8cf68ad77021eb3dd22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104825
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-12 19:18:25 +00:00
Ben Clayton d6daefc379 wgsl: Print abstract-floats with full precision.
Change-Id: Ie95547f065b896983b90ffd5455538fdd843b81a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104824
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-12 19:13:38 +00:00
David Neto 2b8c9d7c2a spirv-reader: Support GLSL.std.450 FindUMsb
Fixed: tint:1059
Change-Id: I7bd7ae4b83036fce3ba5979b33d17d274e26bd69
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104902
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-10-12 18:59:01 +00:00
Ben Clayton d2e0db3af2 tint: Rename kInvalid to kUndefined for enums
This is a more neutral term for an unassigned enum value.

Change-Id: Ic69d912472f26fd8a2c8348281b27edfcc145eab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105480
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-12 18:49:15 +00:00
Ben Clayton 78c839be97 tint/resolver: Ensure that total workgroup size fits in u32
This is below the 256x256x64 limits as defined by the WebGPU spec:
https://gpuweb.github.io/gpuweb/#limits

Fixed: tint:1692
Change-Id: I3608eb41094fbc7c77a40ea32f0f7418c31e0a05
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105401
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-12 17:03:57 +00:00
Ben Clayton fafeb9a327 tint/reader/wgsl: Improve errors when parsing access controls
If the access control doesn't parse, then generate an error message that includes the list of possible values, and a suggestion if there was a close match.

Change-Id: I12fdbe0f73762b51e670b5b1b0f087f3a9157339
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105330
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-12 11:17:56 +00:00
Ben Clayton bccd87c37a tint/ast: Generate access.[h|cc]
Emits all the enum info from the single-source-of-truth `intrinsics.def` file

Change-Id: Ib9170a2337597d4d81983c446d50582b518c6d71
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105329
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-12 09:42:00 +00:00
Jiawei Shao 75a8574b29 Validate effective storage or read-only storage buffer size be multiple of 4
This patch adds a validation that the effective buffer size must be a multiple
of 4 when the binding type is storage or read-only storage to match the latest
WebGPU SPEC.

This patch also fixes some typos in BindGroupValidationTests.

Bug: dawn:1542
Test: dawn_unittest
Change-Id: I30234bcf718be0d82d4a09b9980127a98ebe8172
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105101
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-10-12 00:55:37 +00:00
Ben Clayton a44e3d8bea tint: include T type in converter overload diagnostics
Fixed: tint:1710
Change-Id: Iac66b5bb9e1b8f38f46e01b1d6aee0e5284eb157
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105262
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-11 23:46:55 +00:00
Ben Clayton c889500f6e tint/reader/wgsl: Improve errors when parsing interpolation modes
If the interpolation mode doesn't parse, then generate an error message that includes the list of possible values, and a suggestion if there was a close match.

Change-Id: I4ee52389e94c834b9d5d9b8d1e76f453a1acd4d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105328
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-11 22:04:29 +00:00
David Neto 542d27d874 spirv-reader: support GLSL.std.450 instruction FindILsb
Fixed: tint:1057
Change-Id: Iacaefb9d634b60745f163061424090b041fccc68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104901
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-10-11 21:47:41 +00:00
Antonio Maiorano 2ad747dedd tint: Fix const eval unary tests
I broke this in a recent CL:
https://dawn-review.googlesource.com/c/dawn/+/104424

Bug: tint:1709
Change-Id: I930a57bae723e18708d4f746ed66d24378518df4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105461
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-11 21:29:28 +00:00
Ben Clayton 75bc93c0df tint: Fix const eval of type conversions
These were quite spectacularly broken.

Also:
* Fix the definition of 'scalar' in `intrinsics.def`. This was in part why conversions were broken, as abstracts were materialized before reaching the converter builtin when they shouldn't have been.
* Implement `ScalarArgsFrom()` helper in `const_eval_test.cc`. This is used by the new conversion tests, and also implements part of the suggestion to improve tint:1709.

Fixed: tint:1707
Bug: tint:1709
Change-Id: Iab962b671305e868f92710912d2ed07e3338c680
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105261
Commit-Queue: 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-10-11 20:36:48 +00:00
Ben Clayton feb447d9dc tint/resolver: Formatting
Change-Id: I9580a9bad5b1f281d14ee1c1fba38c18d9cff610
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105402
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-10-11 20:01:52 +00:00
Ben Clayton f9ed9d3a63 tint/ast: Generate interpolate_attribute.[h|cc]
Emits all the enum info from the single-source-of-truth `intrinsics.def` file

Change-Id: Ie9deba9e64927945133027cf243777944119ea41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105327
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-11 19:49:17 +00:00
Ben Clayton c1af0f5005 tint/reader/wgsl: Improve errors when parsing address spaces
If the address space doesn't parse, then generate an error message that includes the list of possible values, and a suggestion if there was a close match.

Change-Id: Id55bedfdabd693b211ce69b6dcd01b28b61f3a12
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105326
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-11 19:47:33 +00:00
Ben Clayton 9af5b406ba tint/reader/wgsl: Improve errors when parsing texel formats
If the texel format doesn't parse, then generate an error message that includes the list of possible values, and a suggestion if there was a close match.

Change-Id: I206aa712d9c9a4f47da099d5f98e12e42f36d42e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105325
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-11 19:40:44 +00:00
Ben Clayton ecd7f7ee7f tint/reader/wgsl: Improve errors when parsing extensions
If the extension name doesn't parse, then generate an error message that includes the list of possible values, and a suggestion if there was a close match.

Change-Id: I0eb2a682ca5a0717bb31d2716824663924ccd8f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105324
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-11 19:34:19 +00:00
Ben Clayton 760eee9e92 tint/reader/wgsl: Improve errors when parsing builtin
If the builtin doesn't parse, then generate an error message that includes the list of possible values, and a suggestion if there was a close match.

Fixed: tint:1629
Change-Id: I8f575a2ffcef2af308b9566ae7832702e76085ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105323
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-11 19:32:19 +00:00
Ben Clayton b7aef033fa tint/templates: Generate enum string arrays
This will be useful for emitting possible enum values when an enum fails to parse.

Bug: tint:1629
Change-Id: I0be177a2bc27962580f4465ec18fdc5f2e930a99
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105322
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-10-11 19:29:11 +00:00
Ben Clayton 3e0984afe0 tint/program_builder.h: Remove stale comment
Change-Id: Ifb8eb10e9fdc5ff46329285716b8460dc71d9d85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104661
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-11 19:27:53 +00:00
Ben Clayton db368f1b9c tools/tint/intrinsic: Sort enum values lexicographically
Reorders the output of the CanonicalizeEntryPointIO transform, but
otherwise is a no-op.

This will help with diagnostics that print the enum values.

Bug: tint:1629
Change-Id: Iff517d88836d2a8cd42ce3cfde6363c1973df0dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105321
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-11 18:26:18 +00:00
Ben Clayton ae832a2c6a tint/reader/wgsl: Minor cleanups
Change-Id: I3fccb7f5c31c27da5118d9ec6ed86d4a9c3157ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105400
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-10-11 18:21:42 +00:00
Ben Clayton d04c54e178 tint/utils: Add Levenshtein Distance() function
Will be used to make a suggestion when enums fail to parse.

Bug: tint:1629
Change-Id: Ia2754f86641f752539fa541ddb6b90b4e200f07c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105320
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-11 17:53:07 +00:00
Ben Clayton 3c34d83088 tint/ast: Add missing 'const' on pointer member
Change-Id: I8572e3b3f1b26ba79b1306e23f3447cc739108a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104660
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-11 16:31:52 +00:00
Ben Clayton ab2fa8be87 tint: Fix vector equality operator
Change-Id: Ic8e66016beb8fd6a3046beaccbb9c07acbd765d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105260
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-10-11 15:31:46 +00:00
Corentin Wallez 8d3d4f6fd1 tint/inspector: Reflect whether @builtin(frag_depth) is used.
This will be used by Dawn between other factors to decide whether to use
the ClampFragDepth transform.

Bug: dawn:1125
Change-Id: I53be846d9c3ebb9b2d424f40fc87db89c843c81b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105220
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-11 09:52:59 +00:00
Corentin Wallez 98a7cd11af Add a ClampFragDepth transform.
Add clamping of the @builtin(frag_depth) output of fragment shaders using
two push constantsprovided by the outside environment. For example the
following code:

  @fragment fn main() -> @builtin(frag_depth) f32 {
      return 0.0;
  }

Is transformed to:

  enable chromium_experimental_push_constant;

  struct FragDepthClampArgs {
    min : f32,
    max : f32,
  }

  var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;

  fn clamp_frag_depth(v : f32) -> f32 {
    return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
  }

  @fragment
  fn main() -> @builtin(frag_depth) f32 {
    return clamp_frag_depth(0.0);
  }

Fixed: tint:1620
Change-Id: Id403c4813fb2698aa87630abc30d26f02d53634a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104980
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-11 09:52:25 +00:00
Zhaoming Jiang 5cbb32d764 Tint/tranfsorm/test: Refactor and add exhaustive test for Std140
This CL refactor unittests in std140_test.cc, and add exhaustive
parameterized unittests in std140_exhaustive_test.cc. In std140_test.cc,
only test Std140 transform result for `mat2x2<f32>` for matrix used as
array element type and `mat3x2<f32>` otherwise, and keep the source and
expected programs as plain WGSL code to ensure the readablity. In
std140_exhaustive_test.cc, all matrix shape and different constant index
are tested using parameterized WGSL code, at the cost of readablity.
This CL prepares for supporting f16 in Std140 transform by allowing
testing all shape of f16 matrix as well by simply adding parameters.

Bug: tint:1473, tint:1502
Change-Id: Ib2ef5bd806ee61eab04d73a415ba62c2191e2a7e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104282
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-10-11 07:55:00 +00:00
David Neto 112d761448 spirv-reader: Track storage class for pointer/ref values
Fixed: tint:1041 tint:1648
Change-Id: I28c6677e0ef3f96902f4f9ced030c2280a17c247
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104762
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-10 17:15:18 +00:00
Ben Clayton c8f1075310 tint: Disable tint_concurrency_fuzzer for win+asan
This combination uses a suspiciously high amount of memory, triggering the fuzzer limits of 2560MB.

Tint doesn't really have any OS specific code paths, so we should still have good coverage with ASAN builds for other OSes.

Fixed: chromium:1357188
Change-Id: I4c7001f7e194ff46b2e8da635ddccdb04d60b838
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105140
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-10 11:38:49 +00:00
Ben Clayton cc636273da tint: Validate no f16 sampled textures
Bug: chromium:1370417
Change-Id: Id78178ab61cd882ff8fcbbe96aa8123de512f9aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105120
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-10 11:37:57 +00:00
Corentin Wallez 174b6bd5d9 Make GetBindGroupLayout error for indices past the last defined BGL.
Fixed: dawn:1565
Change-Id: I8a482623fcbd68648c451499ce769b871cf89c0a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104820
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-10-07 22:02:20 +00:00
Brandon Jones b68cd1a212 Split Vulkan command buffers to work around bug
There's a bug in some Qualcomm devices where using a depth/stencil
texture as a render attachment and then sampling it in a compute pass
causes a crash. This only happens, however, if the two passes occur as
part of the same Vulkan command buffer.

To work around the issue, this change splits the Vulkan command buffer
while recording any time it identifies that the problematic scenario may
occur.

Bug: dawn:1564
Change-Id: Ie137e9118ef9cc41f5908ca32c72c33f3798cd71
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104860
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2022-10-07 20:53:17 +00:00
Ben Clayton a1c8527f6c tint/sem: Add Type::HoldsAbstract()
Tells you if there's an abstract numeric somewhere in the type.

Change-Id: I0573be9e57ec48f2fa63c46944214e7f5be7d67c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104823
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2022-10-06 20:58:46 +00:00
Ben Clayton 933eb5159e tint: Add _tint_materialize internal builtin
Returns a materialization of the given argument.

Bug: tint:1697
Change-Id: Id25f7e10baa884047af21f89245884c551560f7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104822
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-06 19:54:07 +00:00
Ben Clayton 73683027a3 tint: Use PascalCase for builtin enum names
Nicer names if we add some "_tint_*" builtins

Change-Id: I7574f5cfeeeb04ec5910b20068aa0dd12a460bd5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104821
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-10-06 19:23:29 +00:00
David Neto 76a709c760 spirv-reader: track module scope variables
Bug: tint:1041 tint:1643
Change-Id: Ifc0aed85eae758e674e90bb73693503888847f76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104761
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-06 19:08:22 +00:00
David Neto 861099fc81 spirv-reader: refactor definition info pertaining to pointers
Change-Id: I3999f85c60a08f3eeb921b6931c07ca3bdd1f417
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104760
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-06 16:55:10 +00:00
Antonio Maiorano 7aaf23eac9 Fix 32-bit build
Bug: oss-fuzz:51844
Change-Id: I7e6583c67ffa72659e00b5c8a4b692b44fe92a57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104642
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-05 18:25:22 +00:00
dan sinclair 8fd4ef26f5 Fix MSL packed_int casting.
In 104681 the vectors were cast to themselves to fixup an issue
with `packed_int`. That CL used an `as_type` which does a bit cast.
A `packed_int` can not be bitcast to an `int`. This CL changes to
a type cast, so instead of `as_type<int3>()` it does `int3()`.

Bug: tint:1677
Change-Id: I72218c06853e4e5ae1a0d34e2fc3e1ca597de993
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104682
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-05 17:49:00 +00:00
Brandon Jones f35c719054 Allow tolerance on compressed texture verification
Qualcomm GPUs are apparently decoding textures with a lower precision,
resulting in some of the rendered values when verifying the texture in
a test to be off by +-1 on any given channel. This change adds a
tolerance to those tests to allow a little wiggle room, since compressed
textures are inherently lossy anyway.

Allows Qualcomm GPUs to pass all compressed texture end2end tests.

Bug: dawn:1562
Change-Id: I08a21b9ce361486c247c34640080b369ae2b799d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104622
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-05 16:10:44 +00:00
John Stiles 761536d941 Improve robustness of FloatToString.
When converting floats to string, we now enforce the "C" locale, so
decimal points will be written as "." rather than the "," separator
used natively in some European locales.

Also, we now use operator>> to read back the number instead of
std::stof. std::stof works in the system locale, and will fail to
read back floats with the wrong decimal separator. (Also, std::stof
will throw if the number is out of range and can't fit in the
destination, which implies that the `if` check was probably never
failing.)

Skia encountered similar issues: see http://review.skia.org/587536
for the Skia implementation.

Change-Id: I5aded6acc7cfcf2ad4d5b974bc30c3b645eaec51
Bug: dawn:1686
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104680
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-10-05 15:47:25 +00:00
Antonio Maiorano 8800d885e7 tint: const eval of 'select' builtin
Bug: tint:1581
Change-Id: I222433acb6a30245ab319a15081811f691aca9ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104440
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-05 01:39:53 +00:00
Antonio Maiorano 6b3f4aaf26 tint: add vector cases for const eval builtin tests
- Make the const eval builtin tests use the same framework as the
unary/binary op tests, allowing for Vector cases.
- No longer always use float compare, instead enable it per case.
  Currently this is necessary because atan2 doesn't always return the
  same constant for PI on all platforms.
- Add vector cases for atan2 and clamp.

Bug: tint:1581
Change-Id: I7eaec10b4f9685c913a9d0d17b47c413f659be7a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104424
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-04 22:40:32 +00:00
Antonio Maiorano fc7994ba4c tint: fix intrinsic table lookup of mixed const and non-const with non-matching arg element types
Bug: tint:1581
Change-Id: I7676ec6857c5fd790cb9c5644bfe674a603113ab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104545
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-04 22:19:48 +00:00
dan sinclair 7a69a3411f Update type_decl grammar element name.
The `type_decl` term in the spec was updated to `type_specifier`. This
CL updates Tint to match.

Bug: tint:1633
Change-Id: I264ae78a4b09c3c69d8673e24fe4f60975539b8f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104421
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-04 21:12:01 +00:00
dan sinclair 1dbda6f254 Update variables in address space template.
This CL updates the address space template to remove some usages of
`stoarge`.

Bug: tint:1404
Change-Id: I4c10f62886d2be4b03bce85dac9d58e3547ca60b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104423
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-04 19:44:48 +00:00
dan sinclair e89c27c648 Remove some DISABLED tests.
Several of the disabled tests were added for things we may want to add
in the future. This CL removes those tests and we can add back if/when
we decide to implement the feature.

This brings the disabled tests from 69 to 31.

Change-Id: I22b66256ce4086f223d3be059450eab1a2ff7693
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104462
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-10-04 19:10:02 +00:00
dan sinclair 82023d6980 Enable disabled const eval tests.
The const evaluation of `<` has been implemented so the DISABLED const
evaluation tests can now be enabled.

Bug: tint:1581
Change-Id: I0cddad12aa637da6ae4cf8299517be723e410692
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104463
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-04 18:35:20 +00:00
Austin Eng 663932d741 vulkan: Validate that exporting a texture uses VK_IMAGE_LAYOUT_UNDEFINED
Using any other desiredLayout is deprecated. This simplifies future
changes which as much as possible eliminate any transitions during
texture export.

Bug: chromium:1359106
Change-Id: Ifb5818775e8f15ec77a229d3cbf593348740da46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104543
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-10-04 17:27:21 +00:00
Austin Eng 327cc706c2 vulkan: Use a static method to close semaphore handles
These functions don't need the device or external semaphore service
at all. Make them free functions so that a future change can allow
the handles to be closed after the device has destroyed its semaphore
service.

Bug: chromium:1359106
Change-Id: I246dd0a8f3f972c4547503d16bf8b00db14cdf58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104542
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-04 15:14:04 +00:00
Austin Eng 70c3a4d605 vulkan: Move handling texture wait requirements to SubmitPendingCommands
This moves handling the wait semaphores to the same place that the
signal semaphores are handled. It fixes a bug where the semaphores are
never waited on and never deleted if a texture is imported and then
exported without being used.

Bug: chromium:1359106
Change-Id: If226a38946d4a16598d78841e7b204ea91f8bbea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104541
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-10-04 15:12:32 +00:00
Austin Eng 5a687b084e Fix leak of D3D12 fence share handle
The D3D12 fence share handle should be closed when the device is
deleted.

A future change will make it valid to call EndAccess after the device
is destroyed, thus the handle is closed in ~Device instead of
Device::DestroyImpl. It needs to live as long as ExternalImageDXGI
holds a reference onto the device.

Bug: chromium:1359106
Change-Id: Ib9c9aaa7fb0b5a3de035b512f8fc0316d4bd225e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104540
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-04 15:10:26 +00:00
Dan Sinclair 2a3eae7371 Revert "Replace std::stof with std::strtof."
This reverts commit 5f9996dc9c.

Reason for revert: Issues around locale, will be revisited in a different fashion.

Original change's description:
> Replace std::stof with std::strtof.
>
> std::stof can throw std::out_of_range if the input is not actually
> representable. We had similar code in Skia which was using stof to
> test that a stringized float would round-trip successfully, and it
> would throw an exception on some older versions of libc++ for edge-
> case inputs like FLT_MIN.
>
> std::stof is documented as using strtof to do its conversion, so this
> shouldn't change your results in practice; it just removes the part
> where it could potentially throw for some inputs.
>
> Tangentially, have you ever seen a case where the scientific-notation
> path gets used? According to brucedawson@, nine digits should always
> safely round-trip (in 2013, testing gcc and MSVC). See
> https://randomascii.wordpress.com/2013/02/07/float-precision-revisited-nine-digit-float-portability/
>
> Change-Id: Ie215fb8502dd8c554020c6f73432f91e3d756563
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104500
> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
> Commit-Queue: John Stiles <johnstiles@google.com>

TBR=dsinclair@chromium.org,johnstiles@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com,dsinclair@google.com

Change-Id: I825f5677f98dea1a13b6423ec18ae3a1e750ce09
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104502
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2022-10-04 14:44:22 +00:00
Sunny Sachanandani 025880595d d3d12: Keep wait fences alive until GPU completion
In D3D12, objects need to be kept alive until they're done being used on
the GPU. This is particularly important for wait fences imported into
Dawn otherwise the waits don't happen sometimes.

Bug: dawn:576
Change-Id: Id2d8af59f1530a1e507471cf2e4653ac5cfbae06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104425
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-10-04 00:08:52 +00:00
Corentin Wallez 4ff00cc470 Ensure no VVL message is ignored and doesn't cause test failures.
Messages could be ignored if:
 - They are not associated to any device (for example an issue around
   instance or adapter operations)
 - They happened between the last Tick() and device destruction.

Fix both cases to print the error to the dawn::ErrorLog and crash in
debug so that the errors are visible.

Bug: chromium:1258986
Change-Id: I9a88cd078c60b42deb2336da038902639f9a35ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104360
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-03 23:07:23 +00:00
dan sinclair 40b5d01b06 Remove unused Resolver::TypeDeclInfo.
The TypeDeclInfo Resolver struct is not used. Removed.

Bug: tint:1313
Change-Id: I45eb432c8e7bc2cf4a98ea83cf36e8e6e374e4cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104461
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-03 22:44:01 +00:00
dan sinclair bdeee03c01 Remove unused Resolver::BlockInfo
The BlockInfo structure is not used in the resolver anymore. Removed.

Bug: tint:1313
Change-Id: Ie2fd2f5e4d473d1b113a2a65f79d2080f5bb6ab1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104460
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-10-03 20:48:59 +00:00
dan sinclair 6f39b6c416 Remove empty disabled generator tests.
This CL removes the empty FMix disabled test from the GLSL and HLSL
generators. There is no FMix in WGSL.

Change-Id: I620ed796249ce20b4b5ecb95e3035681743455c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104467
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-03 20:32:04 +00:00
dan sinclair 26aa582054 Remove Inspector test for unsupported feature.
Multisampled textures can only be 2D, not 2D Array. Remove disabled test.

Change-Id: I11363dc299b94f7c18c9503cdc5af77ecb0917d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104466
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-03 20:26:01 +00:00
dan sinclair ca6fedc96a Rename `array size` to `array count` in error messages.
Using `array count` is closer to the language seen in the spec and
clarifies the error messages.

Bug: chromium:1367602
Change-Id: I24388496b3a58c6a4fc62cc2db91c7ad8ca1a371
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104241
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-03 20:24:16 +00:00
dan sinclair 68124ab7d1 Add missing robustness tests.
A few of the robustness tests were missing due to lack of shadow and
override support when robustness was implemented.

This CL adds and enables the missing tests.

Change-Id: I3e4526a21b2d0106d0756e67de258c5441c6f8b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104468
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-03 20:22:47 +00:00
dan sinclair d4fa2a022e Enable DISABLED const evaluation tests.
This CL enables a couple const evaluation tests since the operators are
implemented.

Bug: tint:1581
Change-Id: Id4fe1221fed495a8c98d7120f7fd49a0455ac100
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104465
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-10-03 20:19:40 +00:00
Antonio Maiorano 933441b7b8 Revert "dawn: Suppress tests that fail on ANGLE/SwiftShader"
This reverts commit d909f2b9c5.

Reason for revert: Since https://crrev.com/c/3924863 landed in ANGLE, I was able to land https://crbug.com/dawn/104120 in Dawn, so these suppressions are no longer needed.

Original change's description:
> dawn: Suppress tests that fail on ANGLE/SwiftShader
>
> Fails roll of SwiftShader into Dawn. See crbug.com/dawn/1557 for
> details.
>
> Bug: dawn:1557
> Change-Id: Ibe97f1c3083b1fe254dd935b4abfdfbea9e34050
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104260
> Reviewed-by: Brandon Jones <bajones@chromium.org>
> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>

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

Bug: dawn:1557
Change-Id: I86f0c33d2c737c0e6ee92fc73e2f7051c513ed10
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104501
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-03 19:51:39 +00:00
dan sinclair e67c9f94d3 Remove disabled float inf and nan tests.
This CL removes the DISABLED writer tests for hex float infinity and
nan. The resolution is that these cannot be written in WGSL.

Change-Id: If7aef3a005ac438fdbd9d84c5843899d15c1a7ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104469
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-10-03 19:07:14 +00:00
dan sinclair d94a10ba7e Re-enable spirv reader tests after spirv-tools roll.
The SPIR-V tools roll to pull in the correct spelling of `preceded` has
landed. This CL re-enables the SPIRV-Reader tests with the correct
spelling.

Bug: tint:1406
Change-Id: I303b4b6d742f4bfcc76c6fcce66e4e1cef37b1af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104464
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2022-10-03 18:58:09 +00:00
dan sinclair 01b885bfde Fix comment in spirv-reader.
The referenced test is no longer disabled, so remove the DISABLED
marker.

Change-Id: I46b192d593a9f1dd22ef73fd936b63ac3ed92104
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104470
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2022-10-03 18:57:29 +00:00
dan sinclair 66d3efb669 Limit array element count to less then 65536 elements.
This CL adds element count limits to arrays. In FXC there is a maximum
of 65536 elements in an array. This limit is not yet in WGSL, but adding
this here allows us to fix the issue with large arrays and GLSL.

Bug: chromium:1367602
Change-Id: I7df9d3e4f6c3e5107420d5f8e576d1f33e453161
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104240
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-03 17:25:42 +00:00
Corentin Wallez 4d96762781 TextureVk: Don't transition to UNDEFINED in queue transitions.
When an imported texture with layout UNDEFINED was never used and then
exported with target layout UNDEFINED, Dawn would create a queue
transition barrier with dstLayout UNDEFINED which is not allowed by the
Vulkan specification. Instead detect this case and transition to
GENERAL.

Found by running dawn_end2end_tests with the VLL.

Bug: chromium:1258986
Change-Id: I5e36efda35cb27cecc0683846a314783a8a72fe6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103025
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-10-03 17:12:12 +00:00
John Stiles 5f9996dc9c Replace std::stof with std::strtof.
std::stof can throw std::out_of_range if the input is not actually
representable. We had similar code in Skia which was using stof to
test that a stringized float would round-trip successfully, and it
would throw an exception on some older versions of libc++ for edge-
case inputs like FLT_MIN.

std::stof is documented as using strtof to do its conversion, so this
shouldn't change your results in practice; it just removes the part
where it could potentially throw for some inputs.

Tangentially, have you ever seen a case where the scientific-notation
path gets used? According to brucedawson@, nine digits should always
safely round-trip (in 2013, testing gcc and MSVC). See
https://randomascii.wordpress.com/2013/02/07/float-precision-revisited-nine-digit-float-portability/

Change-Id: Ie215fb8502dd8c554020c6f73432f91e3d756563
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104500
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-10-03 15:05:54 +00:00
Corentin Wallez 324e446f9c Vulkan: Add support for using dedicated allocation when importing images.
This is required to make importing images work on some systems. The
ideal version would be detecting whether dedicated allocations are
needed as Vulkan provides reflection for that. However this reflection
doesn't work on Nvidia, so instead Dawn requires a
NeedsDedicatedAllocation enum on import that's Yes/No/Detect so the
application can force use of a specific code path.

Support for this enum and toggling dedicated allocations on/off is added
for all external memory service implementations.

Vulkan image wrapping tests are modified to add test parameters so that
the Yes/No/Detect code paths are covered by tests.

This is technically post-V1 work, but gl_tests in Chromium fail on
Nvidia workstations without this fix, which makes it hard to debug other
issues.

Bug: dawn:1552, dawn:206, dawn:1260

Change-Id: Iee4f7bb9dbec520432ec623551221ef9e4d3d984
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103560
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-03 15:03:52 +00:00
Antonio Maiorano 6ff74a6d3e dawn/opengl: require EGL_EXT_create_context_robustness
Latest SwiftShader roll into Dawn failed because tests like
TriangleStripPrimitiveRestartTests.Uint32WithoutPrimitiveRestart relies
on robustness checks being enabled, but a recent change to SwiftShader
no longer enabled robustness by default. This change makes sure to
enable the robustness extension.

Change-Id: I7168fc440ef19ef6acac1d1ce72f4bf5a947d4dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-10-03 14:45:12 +00:00
dan sinclair ff7cf21021 Rename StorageClass to AddressSpace.
This CL updates the internals to use AddressSpace instead of the old
StorageClass name.

Bug: tint:1404
Change-Id: Iecc208e839453437f4d630f65e0152206a52db7e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104420
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-10-03 14:05:23 +00:00
Brandon Jones da866181ab Don't advertise timestamp support on Qualcomm
The Android devices I've tested with Qualcomm GPUs (like the Pixel 4)
are exhibiting an issue where resolving timestamp queries after a
render pass is causing a crash. Until that issue can be resolved it's
safest to simply not advertise timestamp query support on these devices.

Bug: dawn:1559
Change-Id: Id76aa5095ffbb7f55579cc428388f55f4528581d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104441
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-09-30 23:46:48 +00:00
Yunchao He 7a4072e3e3 Add extra layers to work around array texture corruption issue
This change works around the array texture corruption issue for
some Windows Intel devices on some old drivers. The number of
extra layer for a given texture is precisely calculated according
to texture memory layout on these devices.

It also adds one more test: clearTexture.

Bug: dawn:949, dawn:1507

Change-Id: I0b2a6497c77f3edf45c49220517e13be76c6b608
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103120
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2022-09-30 17:57:38 +00:00
David Neto 82177da767 spirv-reader: add ColMajor decoration as needed for end2end
Add ColMajor decoration to matrix test cases that ultimately
become end2end test cases.

Corresponds to end2end test fix in
https://dawn-review.googlesource.com/c/dawn/+/103821

Change-Id: I30e9f706dcb935a6044ba650e5c9084363a1414b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104400
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-30 16:12:59 +00:00
Corentin Wallez be4b8cb4d1 Remove suppressions for passing tests.
Fixed: dawn:966
Change-Id: I852d2098030014c7ec750800462df95be2cc0417
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104361
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-09-30 15:14:08 +00:00
Brandon Jones fdbc31f76b Fix Qualcomm render pass attachment bug
Works around a driver bug described in
https://developer.qualcomm.com/forum/qdn-forums/software/adreno-gpu-sdk/68949

Requires the pResolveAttachments member of a VkSubpassDescription to
explicitly be null if the number of color attachments is 0.

Allows the removal of multiple test suppressions related to
depth/stencil readback.

Bug: dawn:1558
Change-Id: Ia03c74a35cbb619b5968f649d41848f53378bf35
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104183
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-30 04:19:18 +00:00
dawn-autoroll feb14eb761 tint: update spirv-tools and fix unittests
This should fix vulkan-deps roll into Dawn.

Change-Id: I3c6685fa140a5e7f6313c7420109864d7783ffed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104280
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-29 21:58:20 +00:00
Antonio Maiorano d909f2b9c5 dawn: Suppress tests that fail on ANGLE/SwiftShader
Fails roll of SwiftShader into Dawn. See crbug.com/dawn/1557 for
details.

Bug: dawn:1557
Change-Id: Ibe97f1c3083b1fe254dd935b4abfdfbea9e34050
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104260
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-29 20:39:17 +00:00
dan sinclair 2bcade246a Update MSL generator to handle casts of packed types.
Currently in the MSL backend we cast int values to uint in order to get
the correct WGSL behaviour for over/under flow. This fails in the case
of host shareable buffers as they use `packed` types which need to get
cast to the non-packed version first.

Bug: tint:1677
Change-Id: I57b70abaa8ca614472a26d63f19c1aef2bd64668
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103986
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-29 19:44:58 +00:00
shrekshao d1a5f93630 Add maxBufferSize limit
Also emits a warning when create buffer size exceeds
the maxBufferSize limit during the deprecation period.

Bug: dawn:1525
Change-Id: I7b47ae5c85b116035fdcea8b68fb574c0a550729
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Shrek Shao <shrekshao@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2022-09-29 19:02:11 +00:00
Antonio Maiorano 06844a5e24 tint/hlsl: remove [loop] attribute on all loops
I added the forcing of the "loop" attribute to all loops to address FXC
failing on uniformity errors related to gradients in loops. Since then,
Tint now implements UA and it recently became an error, so we no longer
need this hack. As a result, FXC is now better able to cope with loops
that it determines executes 0 times.

Most e2e tests are affected because so many use loops, but 27 tests that
were previously failing are now passing with this change:

tint/bug/tint/1538.wgsl.expected.fxc.hlsl
tint/bug/tint/1604.wgsl.expected.fxc.hlsl
tint/bug/tint/1605.wgsl.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_ClassifyCFGEdges_LoopBreak_FromLoopHeader_SingleBlockLoop_TrueBranch.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_ComputeBlockOrder_Loop_HeaderHasBreakUnless.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_EmitBody_IfSelection_TrueBranch_LoopBreak.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_FindIfSelectionInternalHeaders_TrueBranch_LoopBreak_Ok.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserFunctionVarTest_EmitStatement_Phi_MultiBlockLoopIndex.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserFunctionVarTest_EmitStatement_Phi_SingleBlockLoopIndex.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/cov-dead-code-unreachable-merge/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/cov-dead-code-unreachable-merge/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/similar-nested-ifs/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/similar-nested-ifs/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/spv-load-from-frag-color/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/spv-load-from-frag-color/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-false-if-discard-loop/0.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-false-if-discard-loop/0.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/0.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/0.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/write-red-after-search/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/write-red-after-search/0-opt.wgsl.expected.fxc.hlsl

Bug: tint:1522
Bug: tint:1538
Bug: tint:1604
Bug: tint:1605
Change-Id: I530b846b6b8df122ab351ff7b85d3e1c9ac11526
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104121
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-29 16:53:58 +00:00
Stephan Hartmann b764a15c23 libstdc++: replace bit_set::operator!= in ityp_bitset
C++20 removed the operator.

Bug: chromium:957519
Change-Id: Iba9c3fcdf4d7d3c4286b5f5dac86304faa6a0c02
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104201
Commit-Queue: Stephan Hartmann <stha09@googlemail.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-09-29 15:02:38 +00:00
Alastair Donaldson 2af7ab3b16 Add missing operator to regex fuzzer
Fixes a problem where the regex fuzzer would identify '==' as a
candidate operator for replacement, but where the replacement code did
not actually handle the '==' case.

Fixes http://crbug.com/1367902
Change-Id: I9a3bda9e7bae5e42872f17427419ab690d477533

Change-Id: If9cbb2db779c6873ff7a02d132981e8ee3410bb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104200
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Alastair Donaldson <afdx@google.com>
2022-09-29 14:36:08 +00:00
Zhaoming Jiang 5e22e46a63 dawn E2E: Refactor and add non-struct-member tests in ComputeLayoutMemoryBufferTests
This CL refactor the end-to-end test suit ComputeLayoutMemoryBufferTests
and add tests for non-struct-member scalar, vector, matrix, and array of
vectors and matrices types. This test suit is also intend to test f16
buffer read/write after it is implemented.

Bug: tint:1673
Change-Id: Iea4d3f70897d196ea00e3a3e0189a0372afe0382
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-09-29 04:02:48 +00:00
Brandon Jones f4faccbbbd Suppressions for Mali and Adreno Android devices
Adds suppressions for multiple failures in the end2end tests that are
showing up on Pixel devices I'm able to test. Majority (800+) affect
the devices with Qualcomm GPUs (Pixel 4, Pixel 2, etc) and 8 affect the
newer Tensor devices (Pixel 6).

Bug: dawn:1549
Bug: dawn:1550
Change-Id: Ia598734a1752e5f086e4e79c96a799156d84e448
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-09-28 19:17:18 +00:00
Shrek Shao 3a329f2209 Re-enable ValidationAfterOverrideStorageSize test
Also move Robustness transform to pipeline creation time on Vulkan
backend.

Bug: tint:1660, dawn:1041
Change-Id: I10220f34119d11f29be86fd29463a282175eccdd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103780
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2022-09-28 18:36:47 +00:00
Corentin Wallez 00aced1bbf Allow usage chromium_disable_uniformity_analysis
Only when unsafe APIs are allowed.

Bug: None
Change-Id: Idbe0494bec29bb623c0af39d3fb65d4995bb1a9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104100
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-28 17:55:27 +00:00
dan sinclair f9f583bfe4 Update align attribute to allow u32.
The WGSL spec has been updated to allow attributes to be i32 or
u32. This CL updates the attribute support in Tint to follow.

Bug: tint:1633
Change-Id: Ie6caa54f26a757c374c51c7d24e54d2a476f9c84
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103800
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-28 15:36:47 +00:00
Zhaoming Jiang f304f25e7d Dawn: fix default value of size in BindGroupEntry
This CL fix the missing default value WGPU_WHOLE_SIZE for
BindGroupEntry.size, and also add unit tests for using default offset
and size in BindGroupEntry when creating bind group.

Bug: dawn:1553
Change-Id: Ia9c426c0fff1eaea3a0b7c84e5528881199e2c4a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104023
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-09-28 12:49:27 +00:00
Sunny Sachanandani 3194b4a31f d3d12: Signal fence after PIX Present
Calling ID3D12SharingContract::Present issues GPU work on the command
queue which needs to be synchronized with resource deallocation. This
seems to work now perhaps due to the keyed mutex semantics keeping the
D3D11 texture alive for longer than necessary. With fences, this missing
synchronization causes the validation layers to complain about early
deallocation of the ID3D12Resource.

Moving the Present to SynchronizeImportTextureBeforeUse ensures that it
happens before NextSerial and hence the signal fence that's recorded
will include any GPU work issued by Present. Also, resource deallocation
will happen after this work. However, this has the side-effect of PIX
seeing more frames, once per ExecuteCommandLists, but it could be argued
that's more accurate and useful.

Bug: dawn:1544
Change-Id: I1b417049045a812837f67072d7f09ac47bc18125
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103841
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
2022-09-28 00:58:46 +00:00
dan sinclair a33bc2c6f2 Add some GLSL zero initialization tests.
This CL adds tests for GLSL zero initialization of an array, array of
arrays and array of structs.

Bug: chromium:1367602
Change-Id: I4246512f9238dcccc02c9c181b7a211958491dad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103880
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-09-27 20:44:06 +00:00
dan sinclair 764a2abc90 Have DeepestElementOf always return a type.
Currently deepest element only returns the type if it was a scalar
or the element of a vector, array or matrix. Otherwise it would
return `nullptr`. There are cases where we want to get the deepest
type which is a struct or some other type.

This Cl updates ElementOf to return the type instead of nullptr for
types which previously returned nullptr.

Change-Id: I7963d4ce55d2e2b1a537a7533fa332813eed035c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103900
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-27 19:20:06 +00:00
dan sinclair cb41b8f97f Convert `align` attribute to expressions.
This CL updates the align attribute to parse expressions.

Bug: tint:1633
Change-Id: I5412180ff62e6b286b35ea3297e2b4f136899960
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102841
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-26 15:54:55 +00:00
Ben Clayton 4c70d7fff2 tint: Make uniformity analysis failures a hard error
These have been warnings for multiple months.
Time to properly turn this on.

Bug: tint:880
Change-Id: I3b38f672309b5acd48c12a38dc5a1675f3c62470
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103480
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-09-26 12:30:05 +00:00
Corentin Wallez 03199c2b44 Protect against aspectReadOnly of unused DS attachements aspects
Unused aspects of depth-stencil attachments that are tagged as read-only
used to leak that read-only state to backends, even if the validation
made it seems like they always match (they only need to match if the
texture has both aspects). This confused backends like Vulkan which
checked for depthReadOnly || stencilReadOnly to choose between code
paths.

Instead reyify the depthStencilAttachement descriptor in the frontend to
protect against garbage values being passed for aspects that aren't
present in the texture.

Adds a regression test, with the caveat that a failure is only shown by
having the VVL output and error in stderr due to an unrelated issue.

Fixed: dawn:1512
Change-Id: I35d5581e46909b7f41ff4c7553d60c6ac844a56b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101121
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-26 11:13:35 +00:00
Corentin Wallez ab882c17a5 Vulkan: Fix incorrect barriers for T2T copies of DS.
T2T copies for depth-stencil formats where done one by one. Because
the two per-aspect copies where submitted with no barriers in between
them, incorrect synchronization could occur, making the end state of the
destination texture incorrect.

Fix this by using the combined aspects of the texture to perform copies,
such that depth stencil are copied in a single command instead of two
commands.

Unfortunately the VVLs don't catch this issue, but the reporter of the
issue confirmed that this commit fix the dawn_end2end_tests failures
they were seeing.

Fixed: dawn:1514
Change-Id: I2e1c5f8d9aabeb0119364d26c9d66d0763cfadcf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103421
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-09-26 11:07:25 +00:00
Antonio Maiorano 5f33facbc1 tint: const eval of binary left shift
Bug: tint:1581
Change-Id: I8c1b01bcae2a205e712b8004573cc26a3366785a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103061
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-23 21:58:29 +00:00
Yunchao He ef6696089d D3D12 Intel: change the driver version for array texture corruption issue
The previous driver version I got from Intel driver team is
not correct. That driver does contain the fix but it is not the
first version with the fix.

Bug: dawn:949, dawn:1507

Change-Id: I0044a181e4266b50f77734bbbf9cc8755a8334d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103502
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-23 16:03:37 +00:00
Corentin Wallez 05e7332ac8 Rework how combined aspects are handled in TextureVk
At the moment the computations to decide whether aspects should be
combined are executed on every call related to aspect in TextureVk.
These computations never change and can be computed once at the creation
of TextureVk and reused at runtime.

This is meant to be a noop change as a slight rework prior to fixing
depth-stencil T2T copies no using the combined aspects.

Bug: dawn:1514

Change-Id: I1177cdcf42d072bb2bc2c3a2f149dc480fe79f2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-09-23 09:56:06 +00:00
Sunny Sachanandani 85e6337027 d3d12: Move NextSerial out of ExecuteCommandList
Reverts to the code flow before fences were implemented. NextSerial is
now the reponsibility of the caller of ExecutePendingCommandContext like
it was before. We now use GetPendingCommandSerial to store the signal
fence value instead of GetLastSubmittedCommandSerial and check that the
signal fence value was submitted in EndAccess.

Bug: dawn:576
Change-Id: I616840a0932ec17f77fcab38058773006dfae32f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103501
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-23 00:52:56 +00:00
Jiawei Shao 5a0f8d32a2 Support optional query on adapter power preference
This patch adds DawnAdapterPropertiesPowerPreferenceDescriptor for
querying adapter power preference which is useful to distinguish
different logical adapters created on same physical device but with
different power preferences.

Bug: dawn:1516
Test: dawn_unittests
Change-Id: I12ed6e370f8b57c860520154565765f0ee894831
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102780
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-09-23 00:29:46 +00:00
Loko Kung 3354bf0d91 Add cleanup when encoding indirect draw validations.
- Cleanup is necessary because otherwise encoded render commands may be
  leaked if the validation encoding fails. (The leaked render commands
  can then trigger an assert in ~Device::Cache because the commands can
  hold a ref to an AttachmentState that was not destroyed, and hence
  still be in the device cache.
- Added explicit check in EncoderIndirectDrawValidationCommands for
  device 'alive-ness' since it may create new objects later and hit the
  same error later on anyways.
- Added regression test.

Fixed: chromium:1365011
Change-Id: I342479a4227fc43d82ea35f662d049e6db2b1740
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103340
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-22 23:45:36 +00:00
Ben Clayton c4ebf2cc57 tint: Implement textureSampleBaseClampToEdge
Fixed: tint:1671
Change-Id: Iaae5b5d571a4401c0255de727245bf8dbbe06740
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102642
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-22 22:59:16 +00:00
dan sinclair 78f8067fd5 Fix overrides in array size.
This CL fixes the usage of overrides in array sizes. Currently
the usage will generate a validation error as we check that the
array size is const.

Bug: tint:1660
Change-Id: Ibf440905c30a73b581d55b0c071b8621b61605e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101900
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-09-22 22:28:21 +00:00
Austin Eng 534a198f88 Validate that the device is alive when wrapping external images
Will be tested in Chromium's webgpu_mailbox_unittest.cc

Bug: chromium:1359106
Change-Id: I8a9bf01cd593f2835e2876fa04139fd3afda9b2e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103462
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-09-22 22:10:56 +00:00
Takahiro d4dd547bae Implement "rg11b10ufloat-renderable" feature
Implement "rg11b10ufloat-renderable" feature that allows
the RENDER_ATTACHMENT usage on textures with format
"rg11b10ufloat", and also allows textures of that format
to be multisampled.

Bug: dawn:1518
Change-Id: I4109dc0e9d90f4c0803219292edea554927a187a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102000
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-09-22 16:38:06 +00:00
Li Hao cbd3ef4bb9 Suppress TimestampQueryTests.ResolveTwiceToSameBuffer/D3D12 on Intel Gen12
This is a D3D driver regression on Intel Gen12 GPUs, the test could pass
on old driver version and pass with disable_timestamp_query_conversion
toggle on latest driver.

Bug: dawn:1546
Change-Id: I8cf63824d5147bb78f53a284cada8efdc653a3ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103380
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-22 09:52:35 +00:00
Ben Clayton 490d9889a7 tint: Simplify workgroup size resolving
A `@workgroup_size()` value must be a constant or override expression.
There's nothing specific here about literals or variable expressions.

Remove the semantic tracking of override variables, as these can be override expressions.
The backends will require the `SubstituteOverride` transform to be run, so gut the workgroup_size override handling from the backends.

Bug: tint:1633
Change-Id: Ib3ff843fc64a3595d49223c661b4d58130c0ab30
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100142
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-09-21 21:05:45 +00:00
Austin Eng 45a2c5193a Return false from IsTextureSubresourceInitialized for error textures
Otherwise, callers of this method will hit an ASSERT for error
textures.

Bug: chromium:1359106
Change-Id: I2602d209d837b3b27916221578f9ac4041f8848b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103281
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-21 20:18:30 +00:00
Ben Clayton f92830b623 dawn: Enable OpenGLBackend for ComputeLayoutMemoryBufferTests
The layout issues should now be fixed with the Std140 transform.

Bug: dawn:942
Change-Id: I714c2edb39f27b39f66c1e913f22232ad7908896
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103000
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-09-21 18:13:14 +00:00
Brandon Jones 773800b68d Reland "Implement maxBindingsPerBindGroup limit"
This is a reland of commit 4d67a883b6
Underlying issue fixed in https://dawn-review.googlesource.com/c/dawn/+/102461

Original change's description:
> Implement maxBindingsPerBindGroup limit
>
> Bug: dawn:1523
> Change-Id: Ifcf83f6836a5d7ed447080ccb033e4163970432e
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100706
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Brandon Jones <bajones@chromium.org>

Bug: dawn:1523
Change-Id: If0824b6f8fcb7c152feceb95a2709d0a3b8ce582
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103280
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-21 17:42:24 +00:00
Ben Clayton 4953dabab7 dawn/tests: Remove OverridesWithZeroDefault test
It's not invalid to have create a shader module using zero-defaulted `override`s as workgroup size parameters.
These can be initialized with non-zero pipeline override values.

Bug: dawn:1504
Change-Id: I2636cbe2d26a6604735b0c8b0f5526bbc14e8ce2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103220
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-21 16:42:34 +00:00
dan sinclair 1662f5578e Fixup some grammar.
This Cl updates some double negative grammar to be a bit more readable.

Change-Id: Id5d9c64acc1dd8422b8116d8a6c1bf149f99e592
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103260
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-21 14:44:33 +00:00
Corentin Wallez 30f51b94da Delete the remove_stale_autogen_files mechanism.
Previously when moving around directories for generated files, Dawn ran
into an issue where stale files where #included instead of the new ones,
causing compilation failures. To get around this a
remove_stale_autogen_files mechanism was added that scans the gen/
directory for files not in an allow-list of directories.

This mechanism is now causing problems for bringing up Dawn standalone
tests on Android as these test also generate files in Dawn's gen/
directories, and their files get deleted by remove_stale_autogen_files.

We are not foresseing any additional shuffling of directories and it's
safe to expect that all stale files have been removed from CI builder
caches at this time. So remove_stale_autogen_files can go. This is what
this CL does.

Fixed: dawn:1543
Change-Id: I7dbf1eae6c55b7659f3837b6d4a565052001ce57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103040
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-09-20 17:28:33 +00:00
Corentin Wallez eebb7d5e52 Fix leak of the eager exportable VkSemaphore.
Exporting an exportable VkSemaphore doesn't implicitly destroy the
VkSemaphore object. So instead of Detach()ing the VkSemaphore when it is
first consumed, just let it go out of the scope and be destroyed with
RAII. This also fixes the RAII by not destroying the VkSemaphore
immediately and instead wait until it becomes unused.

Found by running dawn_end2end_tests with the VVLs.

Bug: chromium:1258986
Change-Id: I858839b3094eee0f575c07a8f18504680afb53e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103024
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-09-20 17:02:32 +00:00
Corentin Wallez 1d100e4270 Dedent OnDebugUtilsCallback
While trying to debug why VVL failures don't cause test failures I
reworked this code a little bit. There is not CL that fixes the
behavior, but the code is marginally better with less indentation so
here's a CL to check that in.

Bug: None
Change-Id: I6fc460c4b4b7959ae405219615a03230bfb9847a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103022
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-20 16:01:31 +00:00
Corentin Wallez 9a6ca2878e Fix deprecation warnings of module-scope lets
By promoting them to "const" as the deprecation warning suggests.

Bug: None
Change-Id: I7110b8d38754a0785d7fd56343c2c905dc491e1a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103023
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-09-20 15:58:27 +00:00
David Neto 7d9140feb9 spirv-reader: Refactor tracking of locally-defined values
Based on suggestions from bclayton to use std::optional

Change-Id: I372472dbd5e239713eee5c2ec6ae6ea05fc384fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102660
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-20 15:37:19 +00:00
Corentin Wallez 6270ea7675 Suppress unnecessary VVL warning.
WebGPU allows having fragment outputs that don't match any attachments
so suppress this warning from the VVLs.

Bug: None
Change-Id: I49d3d876fdbc9e25ff71fd763593c7d810cb248c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103021
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-09-20 14:40:22 +00:00
Corentin Wallez 19826c30c1 Update the matchers for skipped VVL messages
The casing of some of the messages was updates in the Vulkan Validation
Layers which made the suppression in the Vulkan backend not match
anymore.

Bug: dawn:1225
Change-Id: I58c23986dce96453ded5b573bccee0ec90dcad91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103020
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-09-20 14:05:42 +00:00
Ben Clayton e68d4506c0 tint/resolver: Consistently use utils::Result in ConstEval
Instead of using builder.Diagnostics().contains_errors()

Produces cleaner code and reduces scope of error handling.

Bug: tint:1661
Change-Id: I35af5ad1c6553f2cf74d1ce92dc14984f93b9db4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102161
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-20 09:26:21 +00:00
dan sinclair 65edd3d23e Run SubstituteOverrides in fuzzers if needed.
With the change to remove support for `Override` in the various
backends, it is now possible for the fuzzers to send invalid programs
through to the generators by creating overrides.

This CL adds the `SubstituteOverride` transform into the fuzzers and
defaults any non-initialized override to 0. The transform is run
separate from the other transforms used by the fuzzers as the fuzzers
don't have to add transforms, this makes sure the substitution always
happens, regardless of other transform configuration.

Bug: chromium:1362815
Change-Id: I3c57128d24c5613079a62309f5d5edefa28e8413
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102840
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-19 18:59:41 +00:00
Alastair Donaldson b7da8f612e Fix out-of-bounds access in regex fuzzer
Fixes the regex fuzzer so that when searching for an operator to
replace, it takes account of the fact that the string being searched may
be very small, avoiding an issue where unsigned integer underflow would
occur.

Bug: crbug.com/1359193
Change-Id: I653a20429dc20385a64f8d684c81d023702458e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102641
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Alastair Donaldson <afdx@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-09-19 15:47:32 +00:00
Antonio Maiorano e14a27bc7f tint: remove LoopToForLoop and FoldTrivialSingleUseLets transforms for HLSL and GLSL
Change-Id: I18c807b2449dc2842cb9dbfaeba98dae640d2355
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102621
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-19 14:05:21 +00:00
Ben Clayton 90b29e500a tint/transform/std140: Correctly handle nested / bare matrices
Fixed tint:1673
Fixed tint:1674

Change-Id: Ifa5d2a69131cc1e4679d4d43143f857c7ba46dbd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102640
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-17 01:47:59 +00:00
Ben Clayton 84b43d61fa tint/writer: Handle unnested, uniform matCx2 matrices
Shuffle the transform orders to ensure that these are embedded in a structure before running the Std140 transform.

Add more end-to-end tests for these.

As pointed out in tint:1673, arrays of matrices are not correctly decomposed by the Std140 transform.
This will be addressed by a later change.

Bug: tint:1673
Change-Id: I47c93e458ff48578922d576819792e8ed3a5723c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102541
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-09-17 00:38:19 +00:00
David Neto a3f2bf6c60 spirv-reader: phis as a particular case of hoisting to a var
We already compute the "first" and "last" basic block that
uses a value, so we could know when to hoist a value into
a var declaration. You have to do this sometimes to make
sure all uses are in scope of the declaration.

Until now we tracked Phis with an entirely different mechanism.
But there are cases which broke down. That's what happens
in crbug.com/tint/1649.

Additionally, GraphicsFuzz cases generarte similar weirdness.

Also, be more careful about ensuring that the assignments
generated to feed phis behave as if they occur in parallel.
Within a single batch of such assignments, generate and
use intermediate let-declarations for phis that that batch
will overwrite.

Also, unwrap-references when rectifying the signedness of
binary operators.

Skip tests that fail due to crbug.comt/tint/98:
  test/tint/bug/tint/749.spvasm.*

Fixed: tint:1649
Change-Id: I7314c351b74a10bfa9a18011f3d80a520568011c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101220
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-16 20:18:39 +00:00
Antonio Maiorano ebc5bba671 tint: const eval of binary XOR
Bug: tint:1581
Change-Id: I5605426f0c4b9447ce770092de4ab2f639d0218d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102580
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-16 17:16:38 +00:00
Austin Eng d41981b5cc Deprecate sampleType "float" with multisampled textures
Bug: dawn:1540
Change-Id: I27608cc88c677205a2a41a5b041d2360f43d14f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102620
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
2022-09-16 16:33:28 +00:00
Li Hao 92182412b8 Implement timestampWrites on Metal
Metal configures the query set and query index for the beginning and end
of passes in pass descriptor when beginning a pass encoder, so we need
to record all timestamp writes information in BeginXxxPassCmd. For the
platfroms that support timestamp query, it must support timestamp write
at command boundary or stage boundary, if the stage boundary is
supported, use sampleBufferAttachments API for Metal implementation,
otherwise simulate timestamp write using sampleCountersInBuffer API
after begining a pass and before ending a pass.

Bug: dawn:1250
Change-Id: I462cb05a0102521cd2df4db3ac6f71863419b933
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2022-09-16 15:00:19 +00:00
Austin Eng 505e1a9368 Revert "Make it invalid to use sampleType "float" with multisampled textures"
This reverts commit 9b2f273d36.

Reason for revert: Breaking change needs deprecation period.

Original change's description:
> Make it invalid to use sampleType "float" with multisampled textures
>
> Fixed: dawn:1540
> Change-Id: I31f197d802c20ed7e6ef2ae00d4e107ab6f94278
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102420
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Austin Eng <enga@chromium.org>

TBR=cwallez@chromium.org,enga@chromium.org,shrekshao@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I5ac4b5691b0c4fb0ce76223c1997855e1b3485f3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102500
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
2022-09-16 01:14:28 +00:00
Jiawei Shao 233d64066c Make the validation on inter-stage shader variables match latest WebGPU SPEC
This patch updates the validations on the inter-stage shader variables to
match the latest WebGPU SPEC (in chapter "validating-inter-stage-interfaces").

With this patch the below validation tests in WebGPU CTS will pass:
- render_pipeline,inter_stage:max_shader_variable_location:*
- render_pipeline,inter_stage:max_components_count,*

Fixed: dawn:1448
Test: dawn_unittests
Change-Id: I3e4d98f03ec18e5d1642a4d7ecd3eed1b7ae04d0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102104
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-16 00:30:38 +00:00
Austin Eng 9b2f273d36 Make it invalid to use sampleType "float" with multisampled textures
Fixed: dawn:1540
Change-Id: I31f197d802c20ed7e6ef2ae00d4e107ab6f94278
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-09-15 23:03:38 +00:00
Loko Kung 18dfc4797c Track TextureViews in Textures so that they can be chain-destroyed.
- Adds Prepend function to LinkedList to avoid directly using the
  insert functions on the LinkNodes. (And tests for this as well.)
- Adds ApiObjectList class for tracking lists of objects for
  destruction.
- Renames and virtualizes some tracking interfaces so that they can be
  overriden for the TextureView/Texture cases.
- Removes explicit destroying of TextureViews from Device since
  destroying Textures will destroy TextureViews now.

Fixed: dawn:1355
Change-Id: I3522383ea7724d6e41ac0c805793a6c34d9bec27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101762
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-15 21:06:51 +00:00
Antonio Maiorano 6ab02659de tint/spirv-reader: add support for GLSLstd450MatrixInverse
Bug: tint:1670
Change-Id: I2faaec03117a00f55624c9a51419eb79cc6da40f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102261
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-15 17:22:25 +00:00
Austin Eng 44754c529f Revert "Remove code to set Vulkan backend debug labels"
This reverts commit c1f5112462.

Reason for revert: underyling issue in crbug.com/dawn/1539 fixed

Original change's description:
> Remove code to set Vulkan backend debug labels
>
> This is hitting a memory corruption issue inside the NVIDIA driver.
> Speculatively delete the code in the Vulkan backend until further
> analysis finds the root cause.
>
> Bug: dawn:1539
> Change-Id: Ie7bf5bed31976da5f13325c81033e787c4d376b9
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102100
> Reviewed-by: Loko Kung <lokokung@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Austin Eng <enga@chromium.org>

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

Bug: dawn:1539
Change-Id: Ic1e4c4ad05abd6f2e244e4a5364bf54e6288cffb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102107
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-09-14 18:36:18 +00:00
Austin Eng 945e2642d6 Fix race with FencedDeleter and VkShaderModule labels in async creation
FencedDeleter does not need to be used at all since we were deleting
a yet-to-be-used VkShaderModule.

Also, set the VkShaderModule label before cache deduplication since to
avoid a race where the VkShaderModule is in use by another thread.
The other thread may also be setting the label, or using it in a
pipeline creation.

Bug: dawn:1539
Change-Id: I5e3d7ce214c4c089c9cc3272f373aa8233017965
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102105
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-09-14 18:13:17 +00:00
Jiawei Shao 060137a712 Replace NULL with nullptr
This patch replaces NULL with nullptr as nullptr is preferred as null
pointers in Chromium coding style.

Bug: None
Change-Id: Ie6ab9d606d791bad2c50001815062c22e9ec0d25
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102102
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-09-14 14:39:37 +00:00
Wang Qing cd86adaf41 loongarch: Add ASSERT() breakpoint support on loongarch architecture.
Bug: dawn:1506
Change-Id: Icff59529676c1f2ad3b9e1779577cad467866797
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102146
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-09-14 13:31:37 +00:00
Shrek Shao b74ca3f8e0 Block NaN and Inf constants value as invalid
Bug: chromium:1362412
Change-Id: Ie3b8c447677ebb4bc12177a5dc4fd92d9033a359
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102280
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Shrek Shao <shrekshao@google.com>
2022-09-14 13:13:07 +00:00
Ben Clayton 751e6686aa tint/intrinsics.def: Implement saturate()
Fixed: tint:1591
Change-Id: I0b1397d74abd49cd44caf326a2063e50c5cf07de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101480
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-13 22:57:52 +00:00
Ben Clayton f3d9ea4bea tint: Error if statically indexing out of bounds.
Fixed: tint:1665
Change-Id: Icd5f24f3b4d6ebbdc18b536dc426da92558a3a4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101183
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-13 22:47:12 +00:00
Stephen White 05d8b02b0f GLSL: implement host-visible memory padding.
Since GLSL ES does not support the offset= attribute, struct members
with explicit @align or @size attributes require adding explicit
padding members.  This in turn requires rewriting any constructor
calls to initialize the new padding to zero, handled in the same
transform.

Note that this is currently overly-verbose, and will add padding where
GLSL doesn't technically need it (e.g., padding a vec3 out to 16 bytes).

Bug: tint:1415
Change-Id: Ia9ba513066a0e84f4c43247fcbbe02f5fadd6630
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101720
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-13 19:48:51 +00:00
Ben Clayton e667d777ac tint/fuzzers/tint_concurrency_fuzzer: Reduce number of threads
Should reduce memory and improve performance.

Bug: chromium:1360731
Bug: chromium:1357188
Change-Id: I94c3653f6d61db9d949ad27d8b666688ccad86dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102182
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-13 18:24:02 +00:00
Antonio Maiorano 0dfbaa9ef9 tint: Make ForEachElemPair return value an enum instead of a bool
Bug: tint:1581
Change-Id: Ia16a548c03f7dff4ebc45599e20c0004834da6ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102121
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-13 18:16:11 +00:00
Antonio Maiorano e53b6f9502 tint: const eval of binary bitwise AND and OR
Bug: tint:1581
Change-Id: Id6a7a1c8e45ee91bede8014dca03a59035b29678
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102060
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-13 18:13:01 +00:00
Antonio Maiorano 5b3707a2d7 tint: Implement const eval of unary not
Bug: tint:1581
Change-Id: If0a74b1f6739725a2284678aab97baf737d96937
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101761
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-13 17:32:17 +00:00
Antonio Maiorano 8175cff07b tint/const_eval_test: factor out testing framework from binary tests to use with unary tests
Bug: tint:1581
Change-Id: I55c46123f5adfcd9b48ef03f62ceb68a1d7aca58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101760
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-13 17:18:02 +00:00
Austin Eng c1f5112462 Remove code to set Vulkan backend debug labels
This is hitting a memory corruption issue inside the NVIDIA driver.
Speculatively delete the code in the Vulkan backend until further
analysis finds the root cause.

Bug: dawn:1539
Change-Id: Ie7bf5bed31976da5f13325c81033e787c4d376b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102100
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-09-12 21:43:21 +00:00
Brian Sheedy 3ada731606 Expand Mac Metal Intel suppression
Expands a couple of existing suppressions to also apply to Mac 12.5, as
the issue still occurs after the upgrade from Mac 12.4 to 12.5.

Bug: dawn:1462
Change-Id: Iba0041fd0f9deafeb3fb770867ffa2e2e4d12553
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101901
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-09-09 21:26:19 +00:00
Ben Clayton 4b70776aed tint: Fix transform errors when calling arrayLength() as a statement
Bug: chromium:1360925
Change-Id: If60fa4bb1cf4981c10dd15f8814c0aed70c0066e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101780
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-09 20:42:29 +00:00
dan sinclair 3526bc4f42 Remove GLSL override generation
This CL removes the override emission from the GLSL backend. The
override should be removed by the substitute_override transform
before making it to the backend.

Bug: tint:1155
Change-Id: Ic95413cfedaf417f54cab80aef413f745ccf3bfa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101664
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-09 16:55:58 +00:00
dan sinclair e1854b2d72 Remove SPIR-V override generation
This CL removes the override emission from the SPIR-V backend. The
override should be removed by the substitute_override transform
before making it to the backend.

Bug: tint:1155
Change-Id: Id00a58d497988908e15e3746ea05b57838acc8ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101740
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-09 16:18:48 +00:00
dan sinclair f6a9404978 Remove HLSL override generation
This CL removes the override emission from the HLSL backend. The
override should be removed by the substitute_override transform
before making it to the backend.

Bug: tint:1155
Change-Id: I6fecf47a5f5616a81281b179853e0f00ba31011f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101663
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-09 16:16:19 +00:00
dan sinclair 5432767a04 Remove MSL override generation
This CL removes the override emission from the MSL backend. The
override should be removed by the substitute_override transform
before making it to the backend.

Bug: tint:1155
Change-Id: I9d3852a7e20b258a2f0af200bff6268037eaa0b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101662
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-09 16:14:10 +00:00
dan sinclair 93df967003 Update StructMember{Offset,Size}Attribute to expressions.
This CL updates the StructMember Offset and Size attributes to
store expressions instead of uint32_t values.

Bug: tint:1633
Change-Id: I771b64fbd27a398ffbcb3f8cc2cbb7fa2606983e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101640
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-09 14:49:09 +00:00
shrekshao 14579b9da3 Add Overrides implementation for OpenGL/OpenGLES backend
As we are using SubstituteOverride, it is easy to add
overridable constants support for OpenGL/OpenGLES.

Also add validate workgroup size for null backend.

Bug: dawn:1537, dawn:1504
Change-Id: I293f10b9a6c606aee6c0ed25b1d966bc56a0b88d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2022-09-09 00:49:08 +00:00
Brandon Jones 7edef20bdd Add AHardwareBuffer support
Initial pass at adding AHardwareBufferSupport so that Dawn can display
content on Android. Confirmed that this will allow many WebGPU pages to
render when paired with
https://chromium-review.googlesource.com/c/chromium/src/+/3877262

Bug: dawn:286
Change-Id: I627fa2ab71f85bd3cb7ea21b0588dbd2089cdf5f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101460
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-08 23:03:28 +00:00
dan sinclair c4e076ffe6 Rename attribute values.
This CL renames the attributes to store `expr` instead of `value`.
This closer matches what is stored.

Bug: tint:1633
Change-Id: If1db34d1f9186afa111c394f18ed049dd2f56f91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101525
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-08 01:04:34 +00:00
Zhaoming Jiang 7ca82ac4d0 dawn: Refactor device creation and add shader-f16 feature
This CL modifies the way adapter creating devices, adds `shader-f16`
feature, and deprecates the `dawn-shader-float16` feature which is no
longer used.
Details:
1. Parse the toggles chained with device descriptor in
`adapter::CreateDeviceInternal`, which are then used to validate
features requirement within `CreateDeviceInternal` and passed to device
constructor as initializer.
2. When creating device, validate features requirement in
`CreateDeviceInternal` with toggles known, make sure to fail the device
creation if a required feature is not supported by adapter or is guarded
by certain toggles which were not enabled/disabled. Feature ShaderF16
and ChromiumExperimentalDp4a are validated in this way. Unittest is
added to check creating devices with toggles-guarded features required.
3. Add `shader-f16` feature, which allow `using f16;` in WGSL code.
End-to-end tests are added to test a trival f16 WGSL shader could be
used if and only if the device has `shader-f16` feature.
4. Deprecate the `dawn-shader-float16` feature, which will be completely
removed after cleaning up Blink code.

Bug: dawn:1510
Change-Id: I6cb2dcbe1ee584fdd6131c62df1ee850b881dbd2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100802
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-09-08 00:11:04 +00:00
dan sinclair f9eeed6106 Convert `@location` to store expression internally.
This CL updates the internal storage for a `@location` attribute
to store the `Expression` instead of a raw `uint32_t`. The current
parser is updated to generate an `IntLiteralExpression` so we still
parse as a `uint32_t` at the moment.

Bug: tint:1633
Change-Id: I2b9684754a657b39554160c81727cf1541bee96c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101461
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-07 22:25:24 +00:00
shrekshao 145337f309 Use SubstituteOverride transform to implement overrides
Remove the old backend specific implementation for
overrides. Use tint SubstituteOverride transform to replace
overrides with const expressions and use the updated program
at pipeline creation time.

This CL also adds support for overrides used as workgroup size
and related tests. Workgroup size validation now happens
in backend code and at compute pipeline creation time.

Bug: dawn:1504
Change-Id: I7df1fe9c3e358caa23235eacd6d13ba0b2998aec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99821
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-07 20:09:54 +00:00
dan sinclair 23cf74c30e Allow sem::GlobalVariable to hold a location.
During some transforms we may move an entry point parameter to
a global variable. This means the global may now have a Location
attached where it isn't permitted by the WGSL spec.

This CL adds a `location` to the GlobalVariable sem value and
populates it in the resolver.

Bug: tint:1633
Change-Id: I684f715fe52d39a0f890fe76c627c1ae543fc746
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101462
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-07 20:05:54 +00:00
Sunny Sachanandani 5881e735f9 d3d12: External image import using multiple wait fences and signal fence
To support concurrent readers on multiple command queues/devices, Dawn
must support importing via wait multiple fences and also export a signal
fence. The previous implementation of using a single fence for waiting
and signaling doesn't work for concurrent reads across queues.

This CL adds support for specifying multiple wait fences for
ExternalImageDXGI via a BeginAccess method that's meant to replace
ProduceTexture. There's also an EndAccess method that returns a signal
fence for the client.

For performance reasons, we use the same fence as the signal fence that
the Device uses internally, and record its value on the texture after
ExecuteCommandLists. Therefore, the CL also makes the Device's internal
fence a shared fence so that we can export it to the client.

This CL also expands the ConcurrentExternalImageReadAccess test so that
it tests fence synchronization across multiple devices. A number of test
helpers also now take an optional device parameter so that we can use
pixel value expectations with secondary devices.

Bug: dawn:576
Change-Id: I6bc86808ede9b5aacf87667106cbd16731a12516
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99746
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-07 19:48:45 +00:00
Antonio Maiorano 29aa613dcf tint: const eval of comparison operations
Change-Id: Iec6e78dbe00baaed8c90e709447a20f6c8ac9fb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101304
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-07 19:34:44 +00:00
Brandon Jones 567f06849b Add the "internal" error type
Currently only raised if Tint produces an Internal Compiler Error
(ICE). These were previously surfaced as validation errors.

Bug: dawn:1531
Change-Id: I9a10549b3e0bc2cbf962c99d157aa6dbe8032a3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101500
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-09-07 14:14:14 +00:00
Ben Clayton eeda18d55e tint::transform::SingleEntryPoint: Preserve global 'const's
These can be used in all sorts of places which are not tracked by sem::Function::TransitivelyReferencedGlobals().
As they're not emitted as variables by any backend, just preserve them.

Fixed: tint:1598
Change-Id: I2696486cb2ffe8408bd5dd3090d7d600ca1d170f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101481
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2022-09-07 13:05:24 +00:00
Jiawei Shao 72c042db41 Disable toggle D3D12DontSetClearValueOnDepthTextureCreation on Intel Gen11
This patch disables Toggle::D3D12DontSetClearValueOnDepthTextureCreation
on Intel Gen11 GPUs as we find it not needed after further tests.

Bug: dawn:1487
Test: dawn_end2end_tests
Change-Id: I2c378568328b758e83484cff514073b052cf5004
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101300
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-09-07 00:57:23 +00:00
Brandon Jones 8f3d7711d9 Add Vulkan extensions for AHardwareBuffer support
Just adds the appropriate extensions for AHardwareBuffer support on
Android doesn't yet attempt to expose any.

Bug: dawn:286
Change-Id: I1345d98044bbcaf91cb31235bffbdc28a163c6e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-09-06 22:40:13 +00:00
Antonio Maiorano 11e2571aed tint: Minor improvements
I forgot to fold this into crbug.com/tint/100861

Bug: tint:1581
Change-Id: I8f8faef7765b525316e2c927504cce88a93d24ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101303
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-06 18:40:33 +00:00
Austin Eng 185fd3deca Add go tests to presubmit
Change-Id: I2d56a463cecf0b1bcb96c51ae134c6fa07d87b21
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100560
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-09-06 18:20:33 +00:00
Ben Clayton 8b4ed5093e tint: Fix / remove tests that access OOB
With constant indices.
Also fix the SPIR-V builder tests that did something completely different from the test name / comment.

Bug: tint:1665
Change-Id: I83537cf6e44ffcb14d54de52649d1f9da1ef7e1b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101182
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-06 17:43:23 +00:00
Brandon Jones 2b0fce7071 Revert "Implement maxBindingsPerBindGroup limit"
This reverts commit 4d67a883b6.

Reason for revert: Seems to be causing MSAN issues with the Dawn/Chromium roll?

Original change's description:
> Implement maxBindingsPerBindGroup limit
>
> Bug: dawn:1523
> Change-Id: Ifcf83f6836a5d7ed447080ccb033e4163970432e
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100706
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Brandon Jones <bajones@chromium.org>

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

Bug: dawn:1523
Change-Id: I757457089be6af18dfce7f64c0da5d310351cece
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101401
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-09-06 17:38:03 +00:00
dan sinclair 72340d00ce Add location into `sem::Parameter`.
This CL adds a `location` value into the `Parameter` sem object.
This will be set if the parameter has an `@location` attribute
applied.

Bug: tint:1633
Change-Id: I55cb5cbda951f70d071ebe1400865b63af1fb20a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101065
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-06 16:05:54 +00:00
dan sinclair 766a458f53 Store location value into `sem::Function`.
This CL adds an optional location value to the `sem::Function`
which will store the resolved `@location` value.

Bug: tint:1633
Change-Id: I95130858d8a1cecae1389be74120da29fec2b448
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101063
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-06 16:00:13 +00:00
Ben Clayton c8278e5cbd tint/transform: Fix hasher return type
These should return `size_t`, not `uint64_t`.
Fixes x86 build.

Change-Id: I83125afc3bce9a9dab7d53c4818f9de3daf4cfb2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101320
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-06 14:53:33 +00:00
dan sinclair 97c9e0ba9f Store struct member location into the sem.
This CL adds the `@location` of a Struct Member into the
`StructMember` sem object as a `std::optional<uint32_t>`. The
resolver then populates the location value if an attribute is
found during resolution.

This will provide a place to store the evaluated expression value
for a location in the future.

Bug: tint:1633
Change-Id: I6f696968dddf95af1f933d96cdb4a7630badac2e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101062
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-09-06 14:41:16 +00:00
Ben Clayton d7d71889d8 tint: Add FriendlyName() to Program
Use this instead of ProgramBuilder::FriendlyName() in the Std140 transform.
If this were called, we'd ICE that the program ids wouldn't match the type, as the type belongs to the source program, not the target program builder.

Change-Id: I29066b18789493c231a89f7ee1dbc24d7e66d33f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101180
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-09-05 20:51:23 +00:00
Ben Clayton 0cd830c571 tint: Fix type is_signed_integer helpers which were ignoring abstracts
Abstracts are now considered scalars, so these should be returning true for abstract-integers.

Change-Id: If15f87932d412663d2aef4f9737675a8ece9e551
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101181
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-05 10:43:03 +00:00
Antonio Maiorano 3740ac6092 tint: implement const eval of binary divide
Bug: tint:1581
Change-Id: I72f7f34046086ad00d3bf8f21d67db831903d60b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100861
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-03 22:42:51 +00:00
Antonio Maiorano 679cf4f351 tint: HLSL and GLSL backends now emit 0 for inf and nan
Bug: tint:1581
Change-Id: I62dcde177c3b82408cd8d737526d10d481b48a17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-03 21:43:01 +00:00
Antonio Maiorano 1741f4443e tint: add CheckedDiv for abstract numbers
Bug: tint:1581
Change-Id: Iafed168a916ac3a1062bcf53299e8ff17fc389fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101041
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-03 21:31:23 +00:00
Robert Stewart 89dd52881c spirv-reader: Fix for SelectUsingReferenceVariable
Started from https://dawn-review.googlesource.com/c/dawn/+/99220/2

Fixed: tint:1650
Change-Id: Ic5e097135a54c68e2cb9736198082179b522a4ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101069
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-03 00:10:30 +00:00
Antonio Maiorano 8478dfca56 tint: improve error message for const eval operator overflow
Bug: tint:1581
Change-Id: I112c7981d6b1998dd8133d1f80409fdc12a16a21
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101042
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-02 23:01:00 +00:00
Stephen White 863d9edf59 GLSL: Change Add[Spirv]BlockAttribute to support GLSL
Modify the AddSpirvBlockAttribute transform to fix top-level structure
access of uniform, storage and push-constant buffers for use in the
GLSL backend. The small change to the transform makes the transform
wrap host-sharable buffers, if they're also used as a
non-host-sharable structure. Also rename the transform to
AddBlockAttrbibute in order to reflect its wider applicability.

Change-Id: Ib2bf4ebf6bce72790791dbae9387032be765e4b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101061
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-09-02 19:19:10 +00:00
David Neto 822de46c74 spirv-reader: fix image write texel conversion for scalar integer cases
Started with https://dawn-review.git.corp.google.com/c/dawn/+/98980,
then took ownership to add tests and land.

Change-Id: I8da4d5e626be3a5cadc6addb36cdbe00a87b8a3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101064
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-02 18:09:30 +00:00
Robert Stewart ece807852d spirv-reader: Fix texel type confusion in loop
Started from https://dawn-review.googlesource.com/c/dawn/+/99001

Fixed: tint:1642
Change-Id: Ia5d7e45dc3de5de8303a2f161c9bf365227f9b5e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101068
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-02 16:48:32 +00:00
Stephen White ae4d073b49 Revert "Skip tests about writeonly storage texture In render pass on ANGLE"
This reverts commit d144805688.

Reason for revert: offending ANGLE problem should be fixed now

ANGLE bug was fixed here: https://chromium-review.googlesource.com/c/angle/angle/+/3790473

Original change's description:
> Skip tests about writeonly storage texture In render pass on ANGLE
>
> StorageTextureTests.WriteonlyStorageTextureInFragmentShader and
> StorageTextureZeroInitTests.
> WriteonlyStorageTextureClearsToZeroInRenderPass starts to fail on
> the bots after the latest roll of ANGLE, so we have to temporarily
> suppress them.
>
> Bug: dawn:1503
> Test: dawn_end2end_tests
> Change-Id: Id8abf7c0a5bd30e5de12c838f871e1ab896ab4fd
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97127
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ben Clayton <bclayton@google.com>

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

Bug: dawn:1503
Change-Id: I339eb503b2f8156899b7db3358c9948d58de308d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101066
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-02 14:05:20 +00:00
Ben Clayton 8b30ca3efa tint/transform: Fix FoldTrivialSingleUseLet for abstracts
If the let initializer was an abstract numeric that was implicitly materialized to a concrete type, then we could inlining the initializer into the use without the implicit materialization cast.
This could lead to validation errors, and subtly different results in the program.

In this situation, add an explicit cast to keep the types the same before and after inlining.

Fixed: tint:1664
Change-Id: Icca980cf8af74673906ad6c681a6b07d0c1932fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101160
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-02 13:58:00 +00:00
Robert Stewart 188be384f7 spirv-reader: UnwrapRef on image coords
The coordinate value may have been hoisted into a 'var'.
So when inspecting the coordinate type, UnwrapRef first.

Fixed: tint:1646
Change-Id: I713018e1dc37d820fdda5694fa214db84cad8ac3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101067
Kokoro: 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>
Auto-Submit: David Neto <dneto@google.com>
2022-09-02 13:52:25 +00:00
Ben Clayton 648bd7b4be tint: Add TINT_REFLECT() & ForeachField()
This uses template and macro magic to reflect the fields of a class.

Dawn:
* Reflect the fields of the types that are used by Dawn's stream::Stream<T> specializations, and use tint::ForeachField() to call StreamIn().

Fuzzers:
* Replace tint::fuzzers::DataBuilder::BuildImpl<T> specializations with the new reflection system.
* static_assert that the type is either POD or reflected. Add a specialization for std::optional which was missing.

Move tint::transform::BindingPoints into MultiplanarExternalTexture, as this is only used by MultiplanarExternalTexture.

All this reduces fragility of the struct declarations slipping out of sync with the uses.

Bug: tint:1640
Change-Id: I08729c1c356f1b427e85983efe3c2678fc2ce717
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101001
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-09-02 11:40:19 +00:00
Ben Clayton 657e61d43d tint: Add and use new Std140 transform
This transform breaks up matNx2<f32> matrices used in uniform buffers
into column vectors, which fixes std140 layout rules.

Used by the SPIR-V and GLSL backends.

Re-enable tests that were disabled for these cases.

Bug: tint:1632
Change-Id: I596d016582b4189a0b413d762b3e7eabd3504b22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100907
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-09-01 22:12:19 +00:00
dan sinclair 644d23b3f8 Update sample code WGSL.
This CL fixes up the sample code to use ',' instead of ';' for
struct members. This allows the Animometer and ComputeBoids samples
to execute again after the Tint change.

Change-Id: I96fae4fe3b96b0a6cc596edfd73013f2aa6ef0da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101060
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-09-01 18:19:19 +00:00
Ben Clayton 655db07022 tint/sem: Rename sem::Manager to TypeManager
This used to live in a `type` namespace, and wasn't prefixed when types were moved to sem.

Change-Id: Ic7a08c2fb40aff034247524c755d9f66157e4da2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101000
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-01 17:35:39 +00:00
Antonio Maiorano c20c5dfb4a tint: Implement const eval of binary multiply
Bug: tint:1581
Change-Id: I70ff40ed4d8faf0a665824fef936ffbafb3f0948
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99362
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-09-01 14:57:39 +00:00
Ben Clayton 2b47c21640 tint/sem: Add Find() to the type manager
Lets you lookup a type without modifying anything.

Change-Id: I7a37d37f1c49c7f37f96c35b8e73a66743d9000a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100906
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-09-01 09:15:20 +00:00
Zhaoming Jiang 426b47e481 tint: add missing F16 conversion expression support
This CL add missing type conversions for f16, especially for SPIRV
backend which require special handling. A transform,
VectorizeMatrixConversions, are also added for SPIRV to replace a matrix
conversion to a matrix construction with converted column vectors.
Unittests for the transform and SPIRV writer, and end-to-end tests for
all conversion rules are added.

Bug: tint:1473, tint:1502, chromium:1356215
Change-Id: Iaff125e5dd295d35c4ab74757eb56b642802a51a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100483
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-01 03:08:20 +00:00
Brandon Jones 0df4e4aea3 Disabled Swiftshader for Android Builds.
Currently fails to build with the following error:

../../third_party/swiftshader/src/Vulkan/VkImage.hpp:24:11:
  fatal error: 'vulkan/vk_android_native_buffer.h' file not found

Bug: dawn:286
Change-Id: I7daa992ba775621524ae936e9fa6ed4ee8a5727a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100940
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2022-09-01 00:04:39 +00:00
Ben Clayton 0c7c23b9c4 tint: Misc hash / container contract improvements
Add a hash implementation to tint::Number.
Add a utils::Hasher specialization for std::variant.
Add an operator!= for Vector. Needed for std::variants.
Drop the need for explicit on Vector constructors from refs.

These all help general usage with STL and util containers.

Change-Id: I1e594edf532e78f531062c534dacaee7616cded5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100905
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-31 23:51:48 +00:00
Ben Clayton 6a17e33f3d tint/writer: Remove spirv::Operand hasher
It's not used any more. utils::Hasher is specialized for vectors.

Change-Id: Ic7c6978ae1f54b608b4dba98abeac077c1be9567
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100904
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-31 23:51:18 +00:00
Ben Clayton b04d992f83 tint/utils: Fix Hashmap::GetOrCreate() for map mutation in create
Its not unreasonable for the create callback to mutate the map. If this
happened, the map would be corrupted.
This change fixes this.

Change-Id: I2bb3820061c741c6da36ebe3667cb6b878515a27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100903
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-31 23:15:38 +00:00
Antonio Maiorano b6d524380e tint: Improve resolver test helper to specify more than one expression arg
Bug: tint:1581
Change-Id: Ie77c56c15a5965b20008036cd99a81cbabd86988
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100340
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-31 22:59:08 +00:00
Ben Clayton cd716e6f01 tint::CloneContext: Use Hashmap::Generation()
Instead of tracking its own generation.

Change-Id: Iea9710fd6665cfc13fb72741b8a80c6dde4f64e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100902
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-31 19:43:48 +00:00
Ben Clayton 4e0335c5af tint/utils: Add Generation() to Hashmap and Hashset.
Useful for knowing if you have to look up an entry again since the last
lookup.

Change-Id: Ib0374627ef5cd7fcff7fa2d9e72b4214260b2df3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100901
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-08-31 19:04:28 +00:00
Brandon Jones 4d67a883b6 Implement maxBindingsPerBindGroup limit
Bug: dawn:1523
Change-Id: Ifcf83f6836a5d7ed447080ccb033e4163970432e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100706
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-08-31 17:01:58 +00:00
Antonio Maiorano ff0295ebd8 tint: Fix AInt -> AFloat implicit conversion from construction
Bug: tint:1581
Change-Id: I8c6a1e375130ab38ef52cb0d8dddaca03cc098da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100800
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-31 13:48:41 +00:00
dan sinclair 5361d9e778 Convert @id to an expression.
This CL updates the @id AST nodes to store an expression instead
of a literal value. This is in anticipation of the parser updates
for ID expressions.

Bug: tint:1633
Change-Id: I4dd626007dd1f9093999a0236e220ffdbc9e62db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100760
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-31 13:39:48 +00:00
jchen10 fb2c8fb6a1 Enable gbm VideoViewsTests
When writting texels into the mapped texture, we need to take
'stride' into consideration.

chromium:1258986

Change-Id: Icc892d4ce324539e6280307d1699599d59204a9d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100480
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-31 01:16:47 +00:00
Ben Clayton 54bcbdbbf3 tint/resolver: Fix intrinsic table matching of AInt as AFloat
An AInt argument can be passed to a parameter of type AFloat.
Fix the matcher for AFloat so that it includes AInts.

Change-Id: I6aeebb567b6176b146920a2035f09cd07c11c014
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100780
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-31 01:06:28 +00:00
Corentin Wallez ef8b50f9d2 Suppress an additional OOM allocation test on M1.
Bug: dawn:1506
Change-Id: I0ebd89c17284ff724a5cf8b875fbb01d2366f3e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100703
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-31 00:49:18 +00:00
dan sinclair 7b332abc82 Remove cmake visibility flags.
This Cl removes the visiblity flags from the CMake file. In both
Debug and Release mode on OSX setting these flags caused piles
of warnings about mis-matched visibility settings throughout the
third_party libraries.

This CL fixes that by removing the flags. This maynot be the right
way to fix this, but it does fix the warnings. We need to decide
if we want to hide symbols by default and, if so, figure out how
to fix the downstream projects.

Change-Id: I8ee7422cfa2aec3715dba226da58e974f39e0d18
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100420
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-30 20:42:48 +00:00
Corentin Wallez 1105ec78fe Merge DAWN_FORMAT_VALIDATION_ERROR in DAWN_VALIDATION_ERROR.
Done with changes to Error.h and the following command:
git grep -l DAWN_FORMAT_VALIDATION_ERROR | xargs sed -i "" "s/DAWN_FORMAT_VALIDATION_ERROR/DAWN_VALIDATION_ERROR/"
then fixing compilation errors in ErrorTests.cpp, Pipeline.cpp and
CommandEncoder.cpp.

Bug: dawn:563
Change-Id: I081a514d662e81f4842b6d7fadfcea67c12720d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100468
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-30 13:39:47 +00:00
Corentin Wallez 1eb6d2dd02 Convert a few remaining DAWN_VALIDATION_ERROR.
There are still DAWN_VALIDATION_ERROR occurences left but they don't use
any format string so it is fine to merge DAWN_FORMAT_VALIDATION_ERROR
into DAWN_VALIDATION_ERROR in follow-up CLs.

Bug: dawn:563
Change-Id: Ic1ba1de44216b36ef6a972712b957685e0ee193e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100467
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-08-30 13:33:37 +00:00
Corentin Wallez 7143450998 Remove support for snake_case wgpu::Features.
Chromium has been updated so the fallback is no longer needed.

Bug: dawn:550
Change-Id: I25b054617fc054926e0eb850229f244ddc51bb61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100470
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-30 01:00:50 +00:00
Corentin Wallez 5fee3f93aa Remove ToSampleTypeBit as it is unused.
Bug: dawn:527
Change-Id: I09ce1e7e30b7d1329e3e42db9308f7220199cdd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100469
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-30 00:57:33 +00:00
Corentin Wallez 59b2ccc09a Remove TODO that's already done.
Bug: None
Change-Id: Iee58a385868e46879bb003b7e1fa8b39e9812fc3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100471
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-30 00:51:30 +00:00
Loko Kung 3a53edcf18 Promote LoseForTesting to ForceLoss device so that user agents can use.
Bug: chromium:1356738
Change-Id: I348837ad4224124d9adba1ecf69a05b2060760c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100566
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-29 22:33:50 +00:00
dan sinclair be4c9f48aa Convert @group to an expression
This CL updates the group attribute to store an expression
instead of a single value. The parser always produces an
IntLiteralExpression at the moment.

Bug: tint:1633
Change-Id: Ice05c26d652c7f5c21825f745f270e96e3d88e08
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100441
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-29 21:22:31 +00:00
dan sinclair f9b831c39a Convert @binding to an expression
This CL updates the binding attribute to store an expression
instead of a single value. The parser always produces an
IntLiteralExpression at the moment.

Bug: tint:1633
Change-Id: I14b2a61b5bcdea66e9e24df7afbb55fb60be785e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100440
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-29 21:13:00 +00:00
Antonio Maiorano cbe8b36256 tint: spir-v reader: add support for GLSLstd450Determinant
Bug: tint:1061
Change-Id: I18f6d0726c2fac192b8893f35dcbf45bf4a3d752
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100466
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-29 20:52:00 +00:00
Austin Eng c165937955 Return false from IsDeviceIdle if there are pending callback tasks
Fixes a race where async pipeline compilations could never see their
callbacks called because Chromium stopped calling device.Tick().

Fixed: dawn:1527
Change-Id: I273409d427ef02a7a6817647eb38564adfdf0da8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100565
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-08-29 18:46:10 +00:00
Corentin Wallez bc93cbc2a2 Correctly print backend type in DiscoverAdapters logs.
Bug: chromium:1348664
Change-Id: Id2eaf25a9f46b1f6614d80642dc7f8e8aef09b9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100520
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-29 16:38:39 +00:00
Yunchao He 81d62d7ca9 Texture corruption issue: add tests for a few rendering types
The original tests for texture corruption only contain WriteTexture
and B2TCopy, this change adds more write types like rendering a
constant color, rendering from texture sampling, and rendering
from textureLoad, all of which need a render pipeline and shaders.

The new tests manifest that:
For a given 2d-array texture dimension, if WriteTexture and B2TCopy
fail, rendering, sampling and textureLoad also fail, and vice versa.

Bug: dawn:949, dawn:1507

Change-Id: I28035fe3dd84d36c01befd7fd8ff9d78b312446a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100061
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-26 21:23:47 +00:00
Ben Clayton 92943b2831 dawn: Fix unreachable code warning
Change-Id: I98fd18b4747365c6474dc1ca1f9003464d171ec7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100580
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-26 20:52:53 +00:00
Jiawei Shao 8b99a54b26 Call ExecutePendingCommandContext() in ExternalImageDXGIImpl::Destroy()
Before destroying ExternalImageDXGI we should execute all the pending
commands before calling NextSerial(), or the device will be lost as
the CommandAllocator will be destroyed before the pending commands are
executed.

Bug: dawn:576
Test: dawn_end2end_tests
Change-Id: I6e291586cd78a7e0feaf2f8dfee87a289ec27f77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100100
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-08-26 03:08:28 +00:00
Corentin Wallez 667db19838 Build with -Wextra-semi
Bug: chromium:1355871
Change-Id: Id6c9774e7f7a86837f02cddfea0b36724e7c609e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100343
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-25 13:17:31 +00:00
dan sinclair 7517e213cf Update `workgroup_size` to use `expression`.
This CL updates the `workgroup_size` attribute to use `expression`
values instead of `primary_expression`.

Bug: tint:1633
Change-Id: I0afbabd8ee61943469f04a55d56f85920563e2da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99960
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-24 21:31:45 +00:00
dan sinclair 436b4a2bd0 Drop `maybe_` from method names.
With the old grammar elements removed, rename the new elements and
drop the `maybe_` prefixes.

Bug: tint:1633
Change-Id: Iafe223546f8af1ddd8a4b60572a106160a226b72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99921
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-24 19:11:55 +00:00
dan sinclair 202362f47d Convert to new expression grammar
This CL moves all the grammar rules to use the new
`maybe_expression` rules. All of the old `expression` rules
are removed.

Bug: tint:1633
Change-Id: I29637a4c6fcd200650a2b57011b6539c66be942a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99920
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-24 18:05:26 +00:00
dan sinclair acdf6e1a53 Remove `ast::VariableBindingPoint` in favour of `sem::BindingPoint`.
This CL removes `VariableBindingPoint`. The `Variable` object has a
`has_binding_point` method added which returns true if there is
_both_ a `Group` and `Binding` attribute. Code has all been updated
to use the `sem::BindingPoint` which is populated during the resolve.

Bug: tint:1633
Change-Id: I79a0da662be61d5fb1c1b61342ab239cc4c66809
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-24 15:47:25 +00:00
Tom Anderson a85290b909 Fix build with -Wextra-semi
Change-Id: I48b8ca89dfe90e138fb6d9c00a69353a05f19cd2
Bug: chromium:1355871
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100241
Auto-Submit: Tom Anderson <thomasanderson@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2022-08-24 00:03:35 +00:00
Ben Clayton 93c2d559a1 tint/utils: Default to using Hasher instead of std::hash
STL std::hash<T*> implementations have a tendency of just reinterpreting the
pointer as a size_t. This is fast, but produces a bad hash, as most pointers
tend to be 4 or 16 byte aligned. The lack of entropy in the LSBs causes
clustering of hashmap slots. Use tint::utils::Hasher to get better hashes.

Change-Id: Ife768d573cd1875e746ca9d77a4ac19e43b06aca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99281
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-23 19:09:34 +00:00
Ben Clayton 18dc315ccb tint::CloneContext: Use utils::Hashset and utils::Hashmap
For fewer heap allocations, faster lookups.

Also use a generational counter to cache `ListTransforms` map lookups between clones. Reduces repeated map lookups in super-hot code.

Change-Id: I34865bb39c756129be845b1eb6255ce436e275f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99280
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-23 18:38:35 +00:00
Ben Clayton b90b6bff1d tint: Minor no-op cleanup changes
Change-Id: I91ad6044e7809ed2deab0fbd4417da90c7870d81
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99705
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-23 16:23:05 +00:00
Ben Clayton e3f2005b2d tint/utils: Cleanup & optimize hash utilities
Do less work for single-value hashes.
Specialize pointer hashing to improve hash quality.

Change-Id: I2f3839d15754543735728814c7f54a5e7ac81569
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99282
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-23 16:10:35 +00:00
Ben Clayton e5d337171a tint: Castable - optimize IsAnyOf()
`HashCodeOf()` sets two bits in the mask to `1`.
We can check for two bits set, after masking, to quickly eliminate impossible Is() tests.

Change-Id: I8d9c1ece87b714e83bd292d02e02274d42e143ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92664
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-23 15:39:15 +00:00
Ben Clayton cdcc85973b tint: Clean up AddSpirvBlockAttribute
* Walk the sem type list, instead of all AST nodes to just find the
  types.
* Walk the AST global list, instead of all declarations, then filtering
  to globals.
* Use the ast::IsHostSharable() helper where possible.
* Only lookup the sem node once instead of twice, per global.
* Use the new utils::Hashmap and utils::Hashset containers instead of
  std::unordered_map and std::unordered_set.

Change-Id: Idb47c855ae9dfd27515774a89cedb7ed06e07035
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100140
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-23 14:30:24 +00:00
dan sinclair 4964d9bc20 Convert `@align` to hold an expression.
With the updated WGSL grammar the `@align` attribute takes an
expression instead of a value. This CL updates the internal data
structures to store an expression instead of an integer value.

The parser still only parses integers, they're just turned into
`IntLiteralExpressions` at the moment.

Bug: tint:1633
Change-Id: If34901798ed6ceaced354bc06ae9b6df875b700e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99980
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-23 13:28:44 +00:00
dan sinclair 64b09959f7 Update `type_decl` and `primary_expression`
This CL updates the `type_decl` and `primary_expression` rules
to the new WGSL grammar.

Bug: tint:1633
Change-Id: Ifc457e01f43fe33e083fc8f9e316fdd02bfd87c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99881
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-22 19:42:14 +00:00
dan sinclair 08d735e6a9 Add missing relational_expression.post.unary_expression checks.
This CL adds the missing checks and tests for `==` and `!=` into
the `relational_expression.post.unary_expression` grammar elements.

Bug: tint:1633
Change-Id: Ib5fbb42994ea12af133ca531989421fddc2393f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99940
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-22 19:23:24 +00:00
dan sinclair a838e34954 Handle peeking past placeholder elements.
Currently when peeking, if there is placeholder then anything after
the `peek(0)` will be off by 1 position as the placeholder will
end up included in the index count.

This CL updates the peek routine to correctly skip over any
placeholder element between the current index and the requested
peek token.

Bug: tint:1633
Change-Id: Idd2905cc3b9c0a0dcbbcc94c0f6dd349b569ec3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99900
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-22 19:19:44 +00:00
dan sinclair 393de082d3 Add `mat_prefix`, `vec_prefix`, `callable` and `type_decl_without_ident`
This CL adds the `mat_prefix`, `vec_prefix`, `callable` and
`type_decl_without_ident` constructuctions.

Bug: tint:1633
Change-Id: Id1fb0417f522b7da2ac6bd4441d17b0a35ae5f14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99880
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-22 16:15:04 +00:00
dan sinclair 9284f8ab55 Add test for let with complex constructor
This CL adds a let unittest with a complex constructor. The test
verifies the entire statement is parsed.

Bug: tint:1633
Change-Id: I56bb7c009efb5668aa41c9b7ec80dcde65c4ec40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99863
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-22 16:02:19 +00:00
dan sinclair 96a7d5a6bd Add some parenthesis.
With the upcoming expression changes we need to put parenthesis around
boolean expressions which mix `&&` and `||`.

Bug: tint:1633
Change-Id: I7a304e5a23998d9977630c2d4466312be7ae169e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99862
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-22 15:59:34 +00:00
dan sinclair e76521153f Fixup shift_expression parsing.
This CL fixes the shift_expression to call the higher level math
expression instead of multiplicative_expression. This allows addition
in shift expressions along with multiplicative expressions.

Bug: tint:1633
Change-Id: I29414bfa540bff612110d5ea16c5c89222a5eb6b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99861
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-22 14:55:04 +00:00
dan sinclair ee25586aec Sync `expression` grammar element with WGSL spec.
This CL updates the `expression` grammar element with the WGSL
spec.

Bug: tint:1633
Change-Id: Iad1f16f5d73cf4d9ba53ef638aaad73418712403
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99822
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-22 14:06:44 +00:00
Austin Eng a09d05c10b Make Adapter and Instance lifetimes more robust
Previously, we would get a use-after-free if you dropped the instance
before an adapter created from it. This CL fixes up the lifetimes
such that Device refs Adapter refs Instance. Instance uses a
cycle-breaking refcount so that it releases internal refs to its
adapters when the last external ref is dropped.

Bug: none
Change-Id: I5304ec86f425247d4c45ca342fda393cc19689e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99820
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-20 02:22:41 +00:00
dan sinclair 158c85dab4 Add new relational rules to WGSL grammar.
This CL adds the `relational_expression.post.unary_expression` grammar
rule into the WGSL parser. A `shift_expression` helper and a
`relational_expression` helper are also added.

Note, the two helpers have `maybe_` as name prefixes. This will be
dropped when the old parser path is removed which current uses the
other versions of those names.

Bug: tint:1633
Change-Id: I6431edfe8fdb9f5a6eea804a7d6fa9a4982ea04e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99761
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-19 22:19:11 +00:00
dan sinclair 97e0c71eb6 Add new shift expression grammar rule.
This CL adds the `shift_expression.post.unary_expression` grammar
rule into the WGSL parser.

Bug: tint:1633
Change-Id: I833ddb05399afe8c792bd0b1abf3eda7f1d114e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99760
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-19 22:16:21 +00:00
dan sinclair 9d27ab7043 Update parser comments.
This CL updates a few parser comments to match spec.

Bug: tint:1633
Change-Id: I8cde5ea9a85f0ca58b914d2741ad131d1fa374c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99700
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-19 22:07:23 +00:00
Ben Clayton d0ccb1aae6 tint/fuzzers: Add a fuzzer that tests concurrency
Currently triggers a bunch of simultaneous program writers, sharing the
same program.

Bug: tint:1651
Change-Id: I9114a3072fb14182f72d5823fa8120088c2ab167
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99802
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-19 21:33:01 +00:00
dan sinclair 2788becd09 Add `element_count_expression` to WGSL parser
This CL adds the `element_count_expression` and the requisite math
expression parsing to support along with tests.

Bug: tint:1633

Change-Id: I54ab37339754217f417f69dcd6140adbc14cbf83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99560
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-19 21:26:01 +00:00
Ben Clayton 5d7de871b4 tint/writer/msl: Remove TODO and old logic
crbug.com/tint/1580 has been implemented for some time.
Remove the bodge to handle constant value lets.

Bug: tint:1580
Change-Id: I9a71ed8f91b6c9925fa0557bcb4c95d90461421f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99704
Commit-Queue: 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>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-08-19 20:07:22 +00:00
Ben Clayton 58794ae118 tint::ProgramBuilder: Simplify variable constructors
Expand the Option argument paradigm to:
* Remove the requirement to always pass a 'type' parameter. Type inferencing is the easier, and increasingly common way to declare a variable, so this prevents a whole lot of `nullptr` smell which negatively impacts readability.
* Accept attributes directly as arguments, removing the `utils::Vector{ ... }` smell.

Rename `ProgramBuilder::VarOptionals` to `VarOptions`, and add equivalent `LetOptions`, `ConstOptions` and `OverrideOptions`.

Clean up all the calls to `Var()`, `Let()`, `Const()` and `Override()`:
* Use the `Group()` and `Binding()` helpers where possible
* Removing `nullptr` type arguments
* Replace attribute vectors with the list of attributes.
* Remove already-defaulted `ast::StorageClass::kNone` arguments.
* Remove already-defaulted `ast::Access::kUndefined` arguments.

Finally, remove the `GroupAndBinding()` helper, which only existed because you needed to pass attributes as a vector.

Change-Id: I8890e4eb0ffac9f9df2207b28a6f02a163e34d96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99580
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-08-19 17:28:53 +00:00
Takahiro 6a314e49e1 Accept unfilterable-float sample type for depth format texture
Allow unfilterable-float sample type for depth format texture
and add unit tests and end2end tests to check it.

Bug: dawn:1508
Change-Id: I46fc22d66d0c2ad5e3923a18e4d13d174203964a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99060
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2022-08-18 21:07:19 +00:00
Ryan Harrison 841db7f515 Add libfuzzer_exports.h to Tint fuzzer common code
BUG=chromium:1353969

Change-Id: I66a08a3ad19a175b52737a5c3a81d3b1a5a786f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99702
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-18 18:41:17 +00:00
Austin Eng bf3243568c Add DeviceBase::APIGetAdapter
Adds a way to query the adapter from a device. Only valid in Dawn Native.
Returns a new reference to the caller. The caller is responsible for
releasing it.

This is needed so in Chrome, SharedImage can query the WGPUAdapter from
the WGPUDevice, and then WGPUAdapterProperties may be queried from the
WGPUAdapter.

Change-Id: I719a8728eff06ab7a22be3db5fb5cfd2ebb2f0f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99703
Reviewed-by: Zhenyao Mo <zmo@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-18 18:02:00 +00:00
dan sinclair ff2cb02e92 Add bitwise_expression to the WGSL parser.
This CL adds the `bitwise_expression.post.unary_expression` parsing
into the WGSL parser.

Bug: tint:1633
Change-Id: Idaf1a413662d1c10d9d9f25d3b35ed5323b8f883
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99383
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-18 14:37:17 +00:00
Loko Kung 30fa0d8d2c Makes sure to zero-init D3D12 descriptors for cache keys.
Fixed: dawn:1471
Change-Id: I2692d3caa9b0d4dabe473b7a7d5249473da80c5b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99600
Auto-Submit: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-18 02:34:40 +00:00
Ben Clayton e86758cb26 reader/wgsl: Error if 'struct' has attributes
Attributes were being parsed, constructed, then thrown away, when declared on a structure. This was triggering the unreachable-AST node seatbelt in the Resolver.

Replace the confusing `Maybe<bool>` return types with `Maybe<Void>`. The boolean return value was not actually being used, as logic was (correctly) using the `Maybe` error / matched state.

Bug: chromium:1352803
Change-Id: I39e4994e3e9b13201ba4f4e4820cd4b2f46e93c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99100
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-08-17 18:57:49 +00:00
Zhaoming Jiang ff1330240b tint/transform: Fix index 0 accessing in DecomposeMemoryAccess
This patch fix a bug in DecomposeMemoryAccess, allowing access index 0
of a member in uniform and storage buffer being recognized as constant
index.

Bug: tint:1652
Change-Id: Ia428de17c860bdafe87c3af9e46426c74fe8fd68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99480
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 18:15:00 +00:00
Ben Clayton dce63f5717 tint/utils/UniqueVector: Use utils::Vector and utils::Hashset
For fewer heap allocations, faster lookups.

Change-Id: I02da7c1a63608096ec898b0d89f9f97c6db8733f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 18:07:20 +00:00
Antonio Maiorano b79238d7ec tint: Implement const eval of binary minus
Bug: tint:1581
Change-Id: I90ce59e89a5b4b9e94de1181ca9d85e9040be3e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99421
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-17 17:38:23 +00:00
dan sinclair eb0af9def7 Add optionally_typed_ident to WGSL parser.
This CL adds the `optionally_typed_ident` construct into the WGSL
parser and uses it where the conditional was used previously.

Bug: tint:1633
Change-Id: I15eaf838792208f56b4ddebd950086f14c8962b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99382
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-17 17:38:17 +00:00
Ben Clayton 0f0ba20208 tint/transform: Fix PromoteInitializersToLetTest for materialized constants
PromoteInitializersToLet was not handling sem::Materialize nodes.
This can happen for const arrays when they are dynamically indexed.

Fixed: tint:1653
Change-Id: I3d67d8139e481c89b31a3a30c7ef44384b7545ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99500
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 17:26:41 +00:00
dan sinclair 873f92e741 Convert assignment_statement to new WGSL grammar.
This CL converts the `assignment_statement` to
`variable_updating_statement`. Some more test cases are added
around the phony assignment and usage of compound operators.

The `lhs_expression` and `core_lhs_expression` are converted to
return `Maybe`s.

Bug: tint:1633
Change-Id: Iaed6373e2f202609adf341b57dc9027e5a04af34
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99380
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 17:20:50 +00:00
dan sinclair 6c8dc15d64 Add core_lhs_expression and lhs_expression to parser.
This CL updates the WGSL parser to have a `core_lhs_expression`
and a `lhs_expression` grammar rule. The rules are not used anywhere
yet, but are standalone so are added with tests.

Bug: tint:1633
Change-Id: I87bdaefeb06be637f72a7e6fa72ce2b6298c7bb7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99240
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-17 16:30:30 +00:00
Ben Clayton e13160efb6 tint/utils: Add Hashmap and Hashset
Algorithmically faster than `std::unordered_[map|set]`, and use a small vector internally reducing heap allocations.

Change-Id: I9c0b00468272d9d7c72ab077d832d66d1368500c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98123
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-17 16:28:23 +00:00
Ben Clayton 81f0686523 tint/utils/vector: Allow use of incomplete types
Attempting to make a Vector of an incomplete pointer type would trigger an error as the `CanReinterpretSlice` trail magic is wanting to know the base types, which isn't known yet.

Split `CanReinterpretSlice` into class specializations, where the common case of no-cast doesn't look at the base types.

Change-Id: Id016b027b131f7988ccf3cae93622dacb7802a1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-17 15:42:15 +00:00
dan sinclair 6e716c77ac Sync some WGSL grammar names to spec
This CL updates some of the names used in the WGSL parser to match
the grammar rules in the spec.

Bug: tint:1633
Change-Id: I489e1c6a945bdd6063d400cfdbd87aa81a97c5f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99200
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-17 14:28:31 +00:00
Antonio Maiorano f8a34d08dd tint: Add CheckedSub functions
Bug: tint:1581
Change-Id: Iee836af4b5a1252335f680cba7ab4e04c2996728
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99420
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-17 12:46:39 +00:00
Sunny Sachanandani 1130a602ef d3d12: Disallow creating external image after device destruction
ExternalImageDXGIImpl holds a weak reference to the device. If the
device is destroyed before the image is created, the image will have a
dangling reference to the device which can cause a use-after-free.

This CL fixes that by adding a ValidateIsAlive() check before creating
the image similar to creating other API objects.

Bug: chromium:1352802
Change-Id: I477f15680ffd27e1ad0166835c4debb80b4be761
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99384
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-17 03:52:59 +00:00
Loko Kung f83652f019 Remove suppressions from dawn:1471.
- Tests seem to be passing fine in manual testing. Fixes throughout key
  generation and stream implementation may have unintentionally fixed
  this issue.

Fixed: dawn:1471
Change-Id: I17268d66be6dfc47cd7f3b480b424909f18e7f1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99422
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-16 22:44:09 +00:00
Jiawei Shao d9d6dfac9a Enable the workaround about T2T copy on Intel Gen11 GPUs
This patch enables the workaround about using a temporary buffer in
the T2T copy on Intel Gen11 GPUs after running WebGPU CTS on these
platforms.

Bug: chromium:1161355
Change-Id: Id4a4f189b4a7a3954dc66062d27e9b226d1409f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99320
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-16 18:05:03 +00:00
Antonio Maiorano 2de4deea1f tint: Fix implicit conversion of vector-scalar of abstract types in binary operations
Example: const v2 = vec3(1) + 2.2;

Bug: chromium:1350147
Change-Id: Ie75d76bf00a6b2f6abd49293290f6e5065c31dfb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99301
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-16 16:00:02 +00:00
Antonio Maiorano fa4a7291f2 tint: add [[nodiscard]] on utils::Result class
Helps when changing the return type of a function from `void` to
`Result<T>`. The compiler fails in places where the return value is
ignored, which is never what we want with Result.

Change-Id: Id3271ea9fb1128f8f493030f013b2b577235be8f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-15 19:31:51 +00:00
Peter Kasting c935b497e6 Split some structs out of DawnTest.h into their own file.
This allows them to be fully defined before being referenced, which
fixes compile errors in C++20.

Bug: chromium:1284275
Change-Id: I3c0f874406247c04d53710431931f82c3deaff3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99080
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peter Kasting <pkasting@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
2022-08-15 18:55:41 +00:00
Antonio Maiorano cc937971c9 tint: natvis: add utils::Slice, utils::Vector, and utils::VectorRef
Bug: tint:1331
Change-Id: I710c3f390234160d1c21a04f71bd26eb56ff585a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99140
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-15 18:29:21 +00:00
dan sinclair 735e4b4fa1 Emit deprecation for fallthrough.
The `fallthrough` statement is being removed from WGSL. This CL adds
a deprecation warning into the current implementation to prepare folks
for the upcoming removal.

Bug: tint:1644
Change-Id: I599984b6a30b39312c4b794a9ecd70f0f626c759
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98841
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-15 11:41:07 +00:00
dan sinclair 52cc4f5d1c Add a target for the GLFW surface helper.
This CL moves the GLFWUtils.cpp into a dawn/glfw/utils.cpp and
GLFWUtils.h into include/webgpu/webgpu_glfw.h. A build target
(`webgpu_glfw` alias to `dawn_glfw`) is added in order to allow
using that target in downstream projects without having to re-implement.

Change-Id: I93e85d5af3f486b3c754f2f854aafbda51901d6d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98700
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-08-14 15:59:25 +00:00
Austin Eng f7ee534b2c Beautify visitable structs with more helpers
Bug: dawn:1480
Change-Id: I01450e1916766daba016f71c0ed825e6b6664541
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98840
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-12 20:39:03 +00:00
Ryan Harrison 4acf608cf2 Include 'libfuzzer_exports.h' in fuzzers that are missing it
This is part of a workaround in the Chromium build infrastructure for
the fact that on Mac, the linker tends to strip LLVMFuzzer*
implementation because of how they are loaded/used.

All of the rest of the machinary is already setup and working, just
need to actually include the header. Dawn and other fuzzers use this
same fix.

BUG=chromium:1319605

Change-Id: Ifced8e0b29a48cdf64cd82002c90eb3c765b01c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98880
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-11 20:41:31 +00:00
dan sinclair 3abad2c125 When emitting a MSL struct initializer emit the struct name.
This CL changes the MSL emission for struct initializers to emit the
struct name first.

`const a = {.f=float3(1)}` becomes `const a = Normals{.f=float3(1)}`.

This fixes an issues where the initialization happens inside an array
which the downstream compiler rejected without the explicit struct
naming.

Bug: tint:1641
Change-Id: I948b9ca94f4b89eac6d5bbbaa615b3d71d50c737
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98760
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-11 02:28:01 +00:00
jchen10 7126ed9111 Add eager Transition support for external textures
This eagerly transitions external textures to be ready for export
on every submit. With this support, we can save the current submit
of export.

Bug: chromium:1258986
Change-Id: I92c2019ff486afc24adc190a1f7b2f85f416cd52
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97642
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2022-08-11 01:36:21 +00:00
Antonio Maiorano a58d8c9fac tint: fix builtin calls and binary ops with abstract args of different type
If a call to atan2 with args of type AFloat and AInt is made, Resolver
would correctly select the atan2(AFloat, AFloat) overload, but if the
input args were of type (AFloat, AInt), it would attempt to constant
evaluate without first converting the AInt arg to AFloat. The same would
occur for a binary operation, say AFloat + AInt. Before constant
evaluating, the Resolver now converts AInt to AFloat if necessary.

Bug: chromium:1350147
Change-Id: I85390c5d7af7e706115278ece34b2b18b8574f9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98543
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-10 20:01:17 +00:00
Antonio Maiorano 90d5eb6128 tint: Add RemovePhonies transform to spir-v backend
This will be needed by an upcoming CL that fixes call statements to
builtins that return a constant value. Without this transform, the
constant value reaches the backend, where we don't currently deal with
abstract numbers. Note that the other backends (HLSL, MSL, GLSL) already
use this transform.

Bug: chromium:1350147
Change-Id: Icc1f1416a07db228f8e3f39851a9ac079c48319f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98740
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-10 19:32:23 +00:00
dan sinclair b91d7e1b31 Spit `expect_variable_ident_decl` into helper and calling methods.
This Cl spits the `expect_variable_ident_decl` apart to only accept
the `variable_ident_decl` grammar element. A
`expect_ident_or_variable_ident_decl` is added for the ident optional
version and a helper used by those two methods.

This makes it a lot clearer at the caller side how the calls relate
to the grammar.

Bug: tint:1633
Change-Id: I50aa4852926ff217129fe728e434255ed008da61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98661
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-08-10 18:54:43 +00:00
Antonio Maiorano 7058a17bda tint: refactor ConstEval API to accept vector of constants rather than of expressions
This is needed for a follow-up change to apply implicit conversions for
AFloat to AInt.

Bug: chromium:1350147
Change-Id: Id903322d01b7aa420452c3e0fc1fa4e1c480c794
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98683
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-10 18:06:43 +00:00
Antonio Maiorano a8e9a6ef2b tint: Fix Resolver erroneously materializing matrices of abstract numeric type
ShouldMaterializeArgument must check that the deepest element is not
abstract numeric to support matrices.

This CL also enables the "no materialize" tests for binary ops, as
constant evaluation of binary addition was recently landed, and that's
what the test uses. The fix in this CL is also necessary for this test
to pass the matrix addition case (it would fail because it erroneously
materialized).

Bug: tint:1581
Change-Id: Id55341c05604c1ac560127826fc415eb38792503
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98682
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-10 14:32:19 +00:00
Jiawei Shao 6f81e13a20 Metal: Enable Toggle::ApplyClearBigIntegerColorValueWithDraw on Intel GPUs
This patch enables Toggle::ApplyClearBigIntegerColorValueWithDraw on
Metal backends using Intel GPUs to workaround an issue about clearing
int32 and uint32 formats with big integer values that cannot be represented
by float.

Bug: dawn:1109, dawn:1463
Test: dawn_end2end_tests
Change-Id: Idb77f57ea5909ad67fa2a79956634bacfc2a2e15
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98480
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-08-10 06:44:13 +00:00
Jiawei Shao 76eeb828c8 Align offset to 512 when writing into depth stencil textures on some platforms
On the D3D12 platforms that don't support programmable sample positions,
the source box specifying a portion of the depth texture must all be 0,
or an error and a device lost will occur. This patch adds a workaround
for this issue by alignning the offset of internal staging buffer to 512
when calling Queue.WriteTexture() with depth stencil textures

Bug: dawn:727
Test: dawn_end2end_tests
Change-Id: I6bc5843d62d0aec3964ee5b544a06c0b2657031a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98601
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-08-10 05:12:16 +00:00
Jiawei Shao 7267d99251 D3D12: Apply big integer clear color values with draw
This patch implements the use of big integer values (>2^24 or <-2^24) as
the clear values of a render pass with an internal draw call as D3D12 API
only supports using float numbers as clear values.

Bug: dawn:537
Test: dawn_end2end_tests
Change-Id: Id0a7835d611f598fb77950915f69919f804a8702
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98104
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-10 04:25:34 +00:00
Antonio Maiorano 50bc60359e tint: Add unit test for HasSideEffects for builtins
Change-Id: I7f2546c36a06cd9646ddf39601636954b9da0459
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98541
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-09 18:18:22 +00:00
Antonio Maiorano f7e2de7971 tint: make RemovePhonies remove call statements to builtins that return a constant value
If the return value of a builtin is a constant value, it may be an
abstract number, and our backends currently do not deal with abstract
numbers. As these builtins have no side-effects, and the return value is
unused, we can just drop the call altogether.

This is needed for the follow-up CL that fixes calls to builtins with
abstract args of different type.

Bug: chromium:1350147
Change-Id: Iebd853372fdb9242fe0f28706944eabe9df03459
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98542
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-09 18:14:12 +00:00
Austin Eng 8830991b41 Cache WGSL -> GLSL compilation
Fixed: dawn:1480
Change-Id: I5c1453a4e37d0e97805391a6c807091d0a8fc1c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98281
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-09 17:22:22 +00:00
dan sinclair e62fbbc75c Syncing WGSL grammar to Tint.
This CL syncs some more grammar changes into Tint. The `break if`
statement is stubbed out to be completed later.

Bug: tint:1633
Change-Id: I9223278288383698f9cdecc1ae854720cc55dd2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98660
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-09 16:52:42 +00:00
Corentin Wallez 6d5542d703 Fix compilation error in delete_statement.cc
There seems to have been a race between changes and
SwitchStatement::body is no longer an std::vector but a utils::Vector.

Bug: tint:1110
Change-Id: I84d19049ecd54b1eba3f826e6c8c7d07ad3746ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98641
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-09 14:15:30 +00:00
dan sinclair 11e415d0bd Add some CMake build target updates.
This CL adds the `dawn_headers` into the `webgpu_dawn` library in order
to find the generated `dawn/webgpu.h` and `dawn/webgpu_cpp.h` header
files during the build.

An alias is added for `dawncpp` called `webgpu_cpp` so it can be used to
link instead of referencing dawn directly

Change-Id: I93fa97534e1e6e7aea349e5d7efb08807f6a0d61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-09 13:33:10 +00:00
Antonio Maiorano 1884c964d7 tint: Fix utils::Vector<T, 0>::Push segfaulting
Grow multiplies capacity by 2, but for a 0-sized Vector (i.e. no small
array), capacity is 0, so Grow wouldn't grow.

Bug: tint:1613
Change-Id: I6f2954cbfdb0c638e02b2f441e17a016c0198ad7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98540
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-09 02:57:00 +00:00
Shiyu Liu 953d610aa2 AST fuzzer: mutation that deletes statements
Adds a mutation that deletes a statement.

Fixes: tint:1110
Change-Id: I8a8595378481d12e7586103e2e88a0858d869ef9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88446
Commit-Queue: Alastair Donaldson <afdx@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-09 00:09:00 +00:00
Corentin Wallez 142141cdf2 Do simplifications assuming macOS 10.11 is the min version supported.
Bug: dawn:1397
Change-Id: I42a588b2a30e12eb7b6889a8954311b632547c58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90243
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-08 17:42:41 +00:00
Jiawei Shao 5344184403 Add comma between non-undefined and undefined format in error message
This patch adds a missing comma between non-undefined and undefined
format in the error message for incompatible attachment states. In
previous implementation, when we output an "undefined" just after a
non-undefined format, we will always miss a comma as "needsComma" is
ignore before the output of "undefined".

Bug: dawn:563
Change-Id: I39ba4e33d88382df12d5de0271f1274559cf027d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98481
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-08 16:36:30 +00:00
Corentin Wallez 2e81814184 Suppress a failure with new (std::nothrow) on Mac ARM64.
This happens when trying to allocate the backing storage for an error
buffer when the allocation would cause an OOM.

new (std::nothrow) doesn't work on Mac ARM64. The code in libc++ that's
compiled into dawn_unittests seems correct, but macOS's libunwind
returns "end of stack" when trying to unwind.

Bug: dawn:1506
Change-Id: Ibc5d7251ea7a411b0e3cc91646a059270d965a90
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98122
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-08-07 11:59:19 +00:00
Corentin Wallez af908a3267 dawn: Make ASSERT() breakpoint on all supported platforms.
This moves the implementation of DAWN_BREAKPOINT() in the only file
that uses it and completes it for all supported architectures. If in
the future breakpoints are needed in other places, it would be possible
to expose the function in a header.

Add DAWN_PLATFORM_IS macros for all supported architectures so they can
be used for implementing Breakpoint() and add support for RISCV.

Bug: dawn:1506
Change-Id: Ib1b92c2d0c119cfc1b348fe905029fe366f5ad04
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98121
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-08-07 11:01:49 +00:00
Jiawei Shao 4b9ebb1465 D3D12: Workaround buffer-texture copy with depth-stencil on some platforms
On the D3D12 platforms that don't support programmable sample positions,
the source box specifying a portion of the depth texture must all be 0, or
an error and a device lost will occur. This patch adds a workaround for this
issue by splitting the original buffer-texture copy into two copies:
1. copy from the source resource into a temporary buffer at offset 0
2. copy from the temporary buffer at offset 0 into the destination resource.

In the next patch we will fix the corresponding issue in Queue.WriteTexture.

Note that on newer version of D3D12 the restrictions about
D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT and D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
have all been lifted out, so the workaround added in this patch will also be
disabled on the platforms that don't support programmable sample positions
but the restrictions about D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT and
D3D12_TEXTURE_DATA_PITCH_ALIGNMENT are no longer available.

Bug: dawn:727
Test: dawn_end2end_test
Change-Id: I9f1d848a0eeac5bd52c9219af6992a2821307746
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97182
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-06 04:36:08 +00:00
Austin Eng a0df1384f2 Cache WGSL -> DXBC/DXIL compilation
Bug: dawn:1480
Change-Id: I858111f62be457c2e7cd5017bbf4c10e76395e83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95340
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-05 20:09:07 +00:00
Zhaoming Jiang 20cddbf04c tint: Implement modf and frexp built-ins for f16 types
This patch implement modf and frexp built-ins for f16 types, and also
simplify their implementation for f32 in MSL and HLSL, and clean up
deprecated code in GLSL writer. Corresponding unittests are also
implemented, but end-to-end tests for f16 are not implemented yet.

Bug: tint:1473, tint:1502
Change-Id: I12887ae5303c6dc032a51f619e1afeb19b4603b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98102
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-05 15:11:44 +00:00
dan sinclair 1cd4706f85 Sync the `statement` grammar element.
This CL updates a few names in the statement element to match the
spec. The `body_stmt` is now `compound_statement`.

Bug: tint:1633
Change-Id: I23a622fc8587641d3b6c5ff2641f29a3471fa4e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98280
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-08-05 14:53:47 +00:00
dan sinclair 7d8307122e Cleanup some strings; Reorder `attribute` rule.
This CL inlines some strings which were listed at the top of the
parser. In general, we've inlined the strings there were just a few
which ended up being declared at the top of file.

The `attribute` rule is re-ordered to sort the attributes in
alphabetical order so they're easier to locate.

The `expect_storage_class` rule is renamed `expect_address_space`

Bug: tint:1633
Change-Id: Ie659742b9758142b6971493be6d0d62a092999b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98262
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-08-05 14:47:57 +00:00
dan sinclair 69a9415084 Extract interpolation sample and type name parsing
This CL pulls the interpolation sample and type name parsing out
to methods to closer match the WGSL spec. This will also make it simpler
to convert to using generated parsing for these strings if desired.

Bug: tint:1633
Change-Id: Ib7b663a3eeef7f3ecacae8bf160d41641b5474f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98260
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-04 21:21:37 +00:00
dan sinclair 737fd8223e Add `expression` into the WGSL parser.
The parser skipped over the `expression` node and went straight
to `logical_or_expression`. This CL adds `expression` which just
calls `logical_or_expression`. This will allow moving the rest of the
parser to more closely match the WGSL spec.

Bug: tint:1633

Change-Id: I994a186ea50f3b3196c9ded77d9c478cb08b019b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98220
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-04 21:06:07 +00:00
Antonio Maiorano 7e9f571814 tint: const eval of binary add
Bug: tint:1581
Change-Id: Ie34ee52bdd4a4c5d45a5f6c0d8d923cc690c8b2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98021
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-04 19:48:27 +00:00
dan sinclair b8893b4c2f Sync the `global_decl` grammar rule
This Cl updates the parser implementation of the `global_decl` rule.
The `type_alias` rule is renamed to `type_alias_decl` and the `struct`
parsing is moved out of the synchronization to `;` code as a `struct`
no longer has a trailling `;`.

Bug: tint:1633
Change-Id: I44b25035cbe0ea0963ec73400986205e1623060e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98065
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-04 17:57:26 +00:00
Antonio Maiorano c2a052eaa4 tint: Allow ConstEval functions to fail
They now return a utils::Result so they can add an error to diagnostics
and return Failure. Returning nullptr still means cannot evaluate at
compile time, but not a failure.

Bug: tint:1581
Change-Id: Ic30d782fb9fa725ec2faf89a87f74de6282d0304
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98107
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-04 13:59:36 +00:00
Austin Eng 0671fe28bf Cache WGSL -> MSL compilation
Bug: dawn:1480
Change-Id: Ie2ef7860b38d7f350c99cf2c5451299b23413ec6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97882
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2022-08-04 01:12:56 +00:00
Antonio Maiorano 50bddbffca tint: Fix dxc on Linux
Fixes "dxc failed : unable to parse shader model.".

On windows the called program is responsible for splitting arguments
from one joined string. Command line arguments on 'nix systems need to
be passed as separate strings. This CL makes it so that we pass in the
arg separately, and support ignoring empty string args to make writing
this code easier.

Change-Id: Ia9618c2a743f8fdb49913572e2bbfc4bd1519d3a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98110
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-03 21:40:46 +00:00
Antonio Maiorano 50940aeef1 tint: add CheckedAdd AFloat overload
Bug: tint:1581
Change-Id: I3d346a5ced345dbd720cce3404b4a0a402e71838
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98106
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-03 21:20:26 +00:00
Jiawei Shao 3c797eba3b Add tests about clearing with big integer values
This patch adds several dawn_end2end_tests as a preparation to support
clearing color attachments with arbitrary 32-bit integer values on
D3D12.

Bug: dawn:537
Test: dawn_end2end_tests
Change-Id: I5e5232d4ebb2ed0e0da007fea101ed13f972ce9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98103
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-08-03 15:54:35 +00:00
Ben Clayton f3015a81cc tint/reader: Parse static_assert
Bug: tint:1625
Change-Id: I440de9a5f0f6817520d59d0d918acc6ac0555c42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97963
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-03 10:08:46 +00:00
Zhaoming Jiang 7d7976d590 tint: Add end-to-end tests for expressions using f16 types
This patch add DXC compile flag "-enable-16bit-types" and change profile
to SM6.2 when validating generated HLSL using DXC if f16 extension is
enabled in the WGSL program.
The patch add Tint end-to-end test cases for expressions using f16 type,
including constructor, binary operator, splat, zero-init, and others.
Testcases that use f16 types in uniform or storage buffer are SKIPped,
because such usage is not implemented yet.

Bug: tint:1473, tint:1502
Change-Id: I481ab3d12cbb822f11ef85ba807bca3f9770089b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96252
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-08-03 08:45:25 +00:00
Ben Clayton 7d04cedce3 tint/resolver: Pre-allocate containers
Reserve the memory for the dependency graph containers.
Reduces expensive heap allocations.

Change-Id: Ia650fcb9f9e461afb8b240c9472a9a478a9968d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98081
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-03 08:43:15 +00:00
Ben Clayton 6d66921053 tint/resolver: Reduce small-vector sizes
The vector sizes for expression traversal were excessive.
Reduce.

Change-Id: I3a2b7e7ba4cd82310565b883f85322834275ea8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98082
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-03 08:00:15 +00:00
Ben Clayton b4744ac359 tint/writer: Handle static_asserts
These (with exception to the WGSL writer) are not emitted.

Bug: tint:1625
Change-Id: Id8b36b5c83a6fe2dab042cf46b0c3dbca75e0926
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97962
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-03 07:01:08 +00:00
Ben Clayton 759ac33cd1 tint/resolver: Optimize intrinsic lookups
Replace use of std::unordered_map with a utils::Vector.
Significantly reduces heap allocations.

Change-Id: I501bfffb7620df9b4e09cd8569c39e418b25e32a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98080
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-03 06:55:57 +00:00
dan sinclair 6f8d945dd6 Sync reserved token list to WGSL spec.
This CL updates the list of reserved words to match the WGSL spec. The
use of a reserved word is changed from an error to a deprecation at the
moment be cause the majority of the list would be new errors.

Bug: tint:1633 tint:1624
Change-Id: I498db41689cdd666dfb291b1a6761a1182c87ec8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98042
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-03 02:49:28 +00:00
Loko Kung 16ee6f8566 Suppresses failing tests due to tint:1632.
Bug: tint:1632
Change-Id: I432cc08d5a7f9e47bcd5381e144a7d8195d3e45e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98062
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Loko Kung <lokokung@google.com>
2022-08-02 23:35:45 +00:00
Ben Clayton 02791e95f3 tint/resolver: Resolve static_assert
No readers produce this, yet.

Bug: tint:1625
Change-Id: I94ce3e5afd7bd81b0a5059451136aa0eed7e9283
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97961
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-02 23:28:28 +00:00
Ben Clayton bfd1a81364 tint/ast: Add StaticAssert node
Nothing uses this, yet.

Bug: tint:1625
Change-Id: I93aa21d2a8090bebbbfbbe3dba7d60818a0e3a5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97960
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-02 23:16:25 +00:00
Brandon Jones 462f648896 Make adapter info device matching more flexible
Previously all of the device IDs I was aware of for a given vendor could
be comfortably filtered with a single mask, but there's at least one
exception that has come up since that indicates that support for
multiple different masks per vendor is necessary.

This change allows devices to be identified in groups, with each group
being given a different mask or no mask at all. Architectures may be
shared between groups.

Also added the ability to mark a device group as internal, which will
generate the helper functions (like `IsVendorArchitecture()`) for the
internal architectures but not allow them to be exposed in
GPUAdapterInfo. Internal device IDs may overlap with non-internal ones.

Finally, added some validation logic to prevent duplicate deviceIds or
conflicts between device sets/architectures. This was actually supposed
to be in an earlier CL but somehow got omitted from the version that
eventually landed.

Bug: dawn:1498
Change-Id: Icb8bfbee47324cbd9791f63089877ace86c763db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96900
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2022-08-02 22:14:35 +00:00
dan sinclair ce6246502c Add `global_directive` rule to the WGSL parser.
This CL adds the `global_directive` rule into the WGSL parser and
moves `enable_directive` under that rule. This matches the WGSL
specification.

Bug: tint:1633
Change-Id: I48b809cd1d2f2ffa6ec0d83474c716d4015e1dea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98041
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-02 21:17:05 +00:00
dan sinclair ab5fc1c4dc Fixup utils::Vector merge conflicts.
This CL fixes various util::Vector calls that were needed after
the push constant CL landed.

Change-Id: I0a21ad61ece6327b8789c5c083f4d1fcfd6339b1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98040
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-08-02 19:43:14 +00:00
dan sinclair 73778d3b0b Add support for >>= and <<=.
This CL adds `<<=` and `>>=` to the supported operators in WGSL. The
ExpandCompoundAssignment transform is used to convert to the expanded form.

Bug: tint:1594
Change-Id: I20519052c52d4b69bc90def1acc5c0a30c36fd8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97980
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-02 18:18:05 +00:00
Yunchao He 6f0884983f Revise Intel GPU generations in gpu_info.json
Intel Xe is also called Intel Gen 12. Quite a few Intel architectures
are classified into Gen 12. Some of these architectures are Gen 12
LP (low power), while the others are Gen 12 HP (high performance,
for example, some Intel discrete GPUs). For more details, see
https://en.wikipedia.org/wiki/Intel_Xe. We need to separate Intel Gen
12 LP from Intel Gen 12 HP for some toggles on D3D12 backend.

Bug: dawn:949

Change-Id: Id5d10c0ecb31ca9e323ede65c3d55e6d4954370e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97901
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: yang gu <yang.gu@intel.com>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-02 18:10:05 +00:00
Ben Clayton 783b169bf4 tint/ast: Migrate to utils::Vector
Change-Id: I10dd2feeaeb86a1ee7769d2bfd172e49c2805cb3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97843
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-02 17:03:35 +00:00
Ben Clayton 34d46731bb tint: Replace VectorRef with ConstVectorRef.
The elements of the VectorRef is now immutable, but can be
moved, if the caller relinquishes ownership by explicitly using
std::move() at the callsite.

Also add utils::Empty as a way of signalling that a vector should be
constructed with no elements. This is helpful in templated code where
{} cannot be used due to overload ambiguity.

Change-Id: I24a50a13956b0692771a8bc9046336ad46261562
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97842
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-02 16:52:25 +00:00
Corentin Wallez bdc619f5ef dawn: Make adapter creation error less scary in stdout.
Bug: chromium:1348664
Change-Id: Ieba886ccc6c0d8813cd175c648849c92b3820f2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97840
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-02 16:46:25 +00:00
dan sinclair 4abf28e29b tint: Add basic support for chromium_experimental_push_constant.
This extension adds support for the push_constant storage class such
that it can be tested with WGSL test files. The real goal is to allow
future transforms that will add push constants that the SPIRV writer
will output.

The extension:

 - Adds the `chromium_experimental_push_constant` enable.
 - Allows the push_constant storage class for global variables.
 - Adds validation that the types are host-shareable for push_constant
   variables, and that they don't contain f16 (must be 32bit types
   only).
 - Validates that at most one push_constant variable is statically used
   per entry-point.
 - Skips validation that the extension has been enabled if
   kIgnoreStorageClass is used.

Tests are added:

 - For parsing of var<push_constant>
   - Caught a missing conversion.
 - For each of the validation rules.
 - For the wrapping of push constants in structs if needed by
   AddSpirvBlockAttribute.
 - For the layout and type rules of the storage class.
 - For a shader with multiple entry-points using various push constants.
    - Caught a missing reset of the previous push constant variable in
      the validation check that at most one is used.
    - Caught the missing wrapping in structs that had to be added to
      AddSpirvBlockAttribute.
    - Caught incorrect logic when adding diagnostics about the call
      graph leading to the reference to push constants.

Bug: tint:1620
Change-Id: I04a5d8e5188c0dcef077f2233ba1359d1575bf51
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96682
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-02 15:55:35 +00:00
Alastair F. Donaldson 24d36b0227 AST fuzzer: fix change unary operator mutation
The "change unary operator" mutation now ignores the indirection
operator.

Fixes: tint:1631
Change-Id: Ie1878d8bf65807f3319858b62292bc97fba81044
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97680
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
2022-08-02 15:42:21 +00:00
jchen10 27343ffdb3 Explicitly reset mDeleter when moving Blob
It's not automatically cleared to empty when moving on ChromeOS, so
the same mDeleter can be executed more than once.

Bug: chromium:1348193

Change-Id: If96a73f0b9bf62b2212a9f47108c465d6c911617
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97865
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-02 15:32:45 +00:00
Zhaoming Jiang 0ea0d4b16e tint/resolver: Test f16 types in materialize unittests
This patch add f16 types materialize unittests.

Bug: tint:1473, tint:1502
Change-Id: Ifc4e991cf19e58a9fbfb4f032462d548694c2a5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97820
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-08-02 03:16:34 +00:00
Jiawei Shao 8c590acda0 Remove the deprecated toggle DEPRECATED_DumpTranslatedShaders
Bug: dawn:792
Change-Id: I2eee16490617c3371bfd65a69aca678aa4a6f3dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-08-02 01:45:34 +00:00
Li Hao 9afd92be3f Implement timestampWrites on D3D12 and Vulkan backends
Metal implementation is more complex and has more issues, submit D3D12
and Vulkan frist and another CL for Metal.

Bug: dawn:1250
Change-Id: I718d323e01bb41b0209bfd1f1026faf64b4f1076
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97640
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2022-08-02 00:20:34 +00:00
Ben Clayton 6835c8df3e tint/reader: Parse arrays with no type / size
Bug: tint:1628
Change-Id: Ieb3c07e7dae6fd1e5acf4dd4819312092e5b5bf5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97586
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-08-01 21:42:54 +00:00
Ben Clayton 86329e286b tint/cmd: Dump disassembly with --verbose
Change-Id: I2701117b6c253b632091a59fc1a63d97526d5ce2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97500
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@google.com>
2022-08-01 19:56:24 +00:00
Ben Clayton 92f2cb79b5 tools/gen: clang-format generated .cc, .h and .inl files
Change-Id: I5a79cc0b5da1967632d9df02e058a8e3e5073d2d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97441
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-08-01 19:29:14 +00:00
Ben Clayton 4aa360db5d tint/resolver: Fix null-deref.
Check the result of Materialize() for an index accessor.

Bug: chromium:1347541
Change-Id: Iac1b030a1923c96d65d531a0ca5fd1f4bd4271b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97851
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-08-01 18:46:54 +00:00
Ben Clayton db5d2ea4f2 tint/writer/wgsl: Emit inferred-type arrays
Bug: tint:1628
Change-Id: If0907ee7c4dc3d0216aba0282dc2c5203a3ea727
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97590
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-08-01 18:11:25 +00:00
Ben Clayton 4a65620716 tint/resolver: Handle array() constructors
If the array constructor has no explicit type and count, infer from the
arguments.
Implement and test array materialization.

Also:
* Change sem::AbstractNumeric::IsConstructable() to return true. This
  has changed in the WGSL spec.
* Fix the test-helper builder for DataType<array<N, T>> - it was
  incorrectly calculating the array size.

Bug: tint:1628
Change-Id: I0ec4e55b469ca6423b4d1848f27bb11df4fa683b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97663
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2022-08-01 17:36:54 +00:00
Antonio Maiorano 70a43fa5b9 tint: Fix doxygen error.
Change-Id: Ibca03d2838aac894ccd46a6999f2d8ab745ed15b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97881
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-08-01 17:25:44 +00:00
Antonio Maiorano 239a92d2d0 tint: transform::RemovePhonies: skip builtins with no side effects
This transform was attempting to remove builtins with no side
effects, such as a call with abstract int/float args, which is unhandled
by this transform. For example, this would cause the transform to ICE:

_ = clamp(1, 2, 3);

Fixes ClusterFuzz issue crbug.com/1348739.

Bug: chromium:1348739
Change-Id: Ie355eb36c6c020417c2d93f2dc434c11dbb72d1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97880
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-08-01 17:21:54 +00:00
Ben Clayton 6315a27778 tint/resolver: Tidy up type_constructor_validation_test.cc
Rename tests to remove redundancy.
Add missing 'Source' flavoured constructors to ProgramBuilder. Use them.

Change-Id: I9a41db2ebc8fdc12e2654836247370844990272a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97662
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-08-01 17:18:04 +00:00
Ben Clayton bf32bd4e96 tint/ast: Tighten AST definition of runtime-sized array
Just checking whether the count is nullptr is not sufficient to know
whether the array is fixed-size:

`array` represents a infered type, infered fixed-size array
`array<T>` represents an explicit type, runtime-sized array
`array<T, N>` represents an explicit type, explicit fixed-size array

Bug: tint:1628
Change-Id: I03f547078c015d1d2a8a38308bb5e41c733715ec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97589
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-08-01 17:04:54 +00:00
Stephan Hartmann b779b2b13d IWYU: add cstdint for uint*_t in dawn::native::Blob
Bug: chromium:957519
Change-Id: Id7bf01df556fd9dd1ac7e587bfecd2a522122c9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97841
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephan Hartmann <stha09@googlemail.com>
2022-08-01 16:02:43 +00:00
Ben Clayton 8c9cc86076 tint/resolver: Simplify / optimize Validator::Call()
The resolver has sensible places to dispatch to ArrayConstructor() and
StructureConstructor(), so don't do additional, unnecessary type
dispatches.

Change-Id: Id4edb1fc0dedf431d94507b1c3378bca164746a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97588
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-08-01 15:19:54 +00:00
Ben Clayton 9c4d0c9410 tint/resolver: Split up the Array resolving logic
In preparation for array constructors that can infer type and count
based on constructor arguments.

Bug: tint:1628
Change-Id: I9f12d7a30de232cf0d34ed7e1a356dd5b92d26d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97587
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-31 19:33:04 +00:00
Yunchao He 122322b532 D3D12: Mitigate the security issue for texture corruption
2D Array texture might corrupt on some devices, making out-of-bound
texture access and memory information leak from another texture.
This is a critical security issue.

This change aim at mitigating the security issue via allocating
sufficent extra memory for each texture allocation for 2D array
texture on such devices.

Bug: dawn:949

Change-Id: I3629eeb13be872b2107effa55539e5c24522d0fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96220
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-30 07:00:33 +00:00
Antonio Maiorano d060f36a1c tint: refactor Number<T> constants for highest, lowest, etc.
Bug: tint:1581
Change-Id: I3945e8d6021370e5b9837e77d29eeb46fcb97082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97560
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-07-29 17:12:01 +00:00
Alastair F. Donaldson 00cc485add Regex fuzzer: add swizzles
Adds random swizzle operations to candidate vector expressions.

Also excludes certain common keywords from the set of identifiers that
are matched by the regex fuzzer, which will serve to make other
mutations performed by the regex fuzzer more preise.

Fixes: tint:1619
Change-Id: I10b6937f2c6f7341ec4a85d3b7ab56b3a36ef169
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96780
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
2022-07-29 16:29:21 +00:00
Ben Clayton 3ca6880caf tint/sem: Add conversion handling of array types
Required for arrays of, or nested arrays of abstract-numerics,
abstract-numeric vectors and abstract-numeric matrices.

Bug: tint:1628
Change-Id: Ib360c687163d3b88be780fdbc2d3eb1a93689520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97585
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-29 14:46:41 +00:00
Ben Clayton 6fb5d379c2 tint/sem: Add const to StructMember 'type'.
This should be immutable once the sem tree is built.
Add a hacky const_cast in Resolver for now, as this is preferable to
having some things non-const in sem.

Bug: tint:745
Change-Id: I67ebce76730347c9543875ab8e1c21a47d71fd56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97584
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-29 14:32:51 +00:00
Ben Clayton 8e0368e554 tint: Use utils::Vector for sem::Type::Common()
Instead of a C-style array.

Change-Id: Ieb3e9811cddf505bfd3b484b7f265459f7b0e66b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97583
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-29 14:15:01 +00:00
Ben Clayton 05a76183e0 tint: Split Resolver::Materialize()
Add Resolver::ConcreteType() to determine the concrete type for an
abstract-numeric (or composite of abstract).

Will be used to recursively infer the concrete types of abstract arrays.

Bug: tint:1628
Change-Id: Ia26b778abc827b531848b346f3e36938ad1a0470
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97582
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-29 13:19:12 +00:00
Ben Clayton ea84b9b072 tint/sem: Treat abstract-numerics as scalars.
This tracks the WGSL spec and reduces tint complexity.

Change-Id: I240a87fc7bb7f51d9e0ff180af4911cd00a33758
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97581
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-29 13:08:11 +00:00
Zhaoming Jiang 6fe1f515d4 tint: Add f16 support for parts of float built-in, part 1
This patch add f16 support for a major part of numeric built-in, and
implement corresponding unittests for resolver and backends. This patch
also enable f16 constant evaluation for unary minus operator, `atan2`
and `clamp`.

The following numeric built-ins are not supported yet:
* frexp
* modf

The end-to-end tests for f16 built-in are not added yet.

Bug: tint:1473, tint:1502
Change-Id: If807185617b21c510a1a9c371179a60800c4f875
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96722
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-07-29 11:41:51 +00:00
Zhaoming Jiang 65dcdcbad0 tint/resolver: Clean up the SPIRV builder built-in unittests
This patch clean up the writer/spirv/builder_builtin_test. The major
changes are:
1. Group the testcases by built-in types (array built-ins, logical
built-ins, derivative built-ins, texture built-ins, etc.), and put each
types in a namespace, which may help reading the code.
2. Make sure all tests for numeric built-in use variable rather than
literal as input, in order to prevent supporting constant evaluation for
these built-ins break the unit tests.
3. Make float type (`f32` for now) explicit in test names for float
built-ins, to help implementing corresponding f16 testcases.

Bug: tint:1473, tint:1502
Change-Id: I6a1ad5fe24729d36d01f4fd570bfae5fae7351ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97384
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-29 09:52:31 +00:00
Austin Eng bc285fb573 Rename CacheKey-related files to Stream
Bug: dawn:1480, dawn:1481
Change-Id: If61f0466d79e7759ed32c4ddf541ad0c17247996
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96904
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-07-29 00:36:21 +00:00
Austin Eng 79ab0d38bb Refactor [de]serialization functions out of CacheKey
Storing values into the cache will need to serialize and deserialize
values in addition to keys. This patch factors the serialization
utilities out of CacheKey into a more general "Stream" utility that
supports both input and output for serialization and deserialization.

Multiple files are not renamed to make parsing the diff easier. They
will be renamed in Change If61f0466d79e7759ed32c4ddf541ad0c17247996.

Bug: dawn:1480, dawn:1481
Change-Id: If7594c4ff7117454c1ab3d0afaeee5653120add8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96480
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-07-28 23:04:31 +00:00
Ben Clayton 316fb47afe dawn/node: Fix crash when using device after destroy()
Do not assign null to the wgpu::Device, as this will result in a nullptr dereference if you attempt to use the device after destruction.
The wgpu device correctly handles the error state of being used after destroy().

Fixes crashes of CTS tests:
'webgpu:api,validation,state,device_lost,destroy,*'

Change-Id: Ibee1078436efadf25f53735fbaa47d5fc5f74898
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97442
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-28 14:11:17 +00:00
Zhaoming Jiang 5af9ce441b tint/resolver: Clean up the resolver built-in unittests
This patch clean up the resolver/builtin_test. The major changes are:
1. Group the testcases by built-in types (array built-ins, logical
built-ins, derivative built-ins, texture built-ins, etc.), and put each
types in a namespace, which may help reading the code.
2. Rewrite the parameterized tests for float and integer built-ins, i.e.
numeric built-in overloads that take at least one float parameter and
all integer parameters. Built-ins that may take either float and integer
parameters, e.g. `abs`, `min` and `clamp`, are tested in both testsuits,
rather than having a third testsuits.
3. Stop checking the detailed candidate lists for float and integer
built-ins in parameterized testsuits.

This patch is helpful for implementing f16 built-ins.

Bug: tint:1473, tint:1502
Change-Id: I23d46a7b0ac2ef4a35d4aa462ede39025ba92158
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97382
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-28 13:14:40 +00:00
Ben Clayton 634a2430d8 tint: Use OverrideId for SubstituteOverride transform
Makes the tint public API use the same standardized way to identify overrides.

Bug: tint:1155
Bug: tint:1582
Change-Id: Ib25d9ed5d41844486581e088add24b9131f5f4bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97007
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-28 10:22:17 +00:00
Jiawei Shao 6d40394d89 D3D12: Add RENDER_ATTACHMENT usage on depth stencil textures on Intel GPUs
This patch adds RENDER_ATTACHMENT to the internal usage of D3D12 depth
stencil textures on Intel GPU because due to a driver bug we have to
initialize all the depth stencil textures with clear on Intel GPUs
before copying with them. Otherwise, if a depth stencil texture is created
without RENDER_ATTACHMENT usage, it will be initialized by copies, which
will still trigger the driver bug mentioned above.

Bug: 1487
Test: dawn_end2end_test
Change-Id: I78b9a3e2bc4098d6f3f2619644c80fd54dafd4e8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96985
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-07-28 02:14:00 +00:00
Jiawei Shao c44a577cd8 D3D12: use typeless format when CastingFullyTypedFormatSupported is false
This patch adds a check in the creation of D3D12 texture that we should
always use typeless formats for castable textures on the platforms where
CastingFullyTypedFormatSupported is false.

With this patch the test TextureViewSamplingTest.SRGBReinterpretation will
pass on Intel HD530 GPUs.

Bug: dawn:1276
Test: dawn_end2end_tests
Change-Id: I3f49b1c5aac9a0b881469968e22a5228aac9f35f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97184
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-07-28 01:48:38 +00:00
dan sinclair 3b2ce130b6 Stay within lex'd token bounds.
If we've walked to the end of the list, make sure we don't advance past
the EOF or Error tokens.

Bug: 1347943
Change-Id: I79c9254c39747cc0fb236ae92f8a0f3aa035a932
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97460
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-27 22:54:50 +00:00
Ben Clayton 08659d098d tint/ast: Generate ast::TexelFormat from intrinsics.def
Emit unit tests for parsing and printing.
Emit benchmarks for parsing.
Uses intrinsics.def as a single-source-of-truth.
The generators provide a way to optimize the enum parsers.

Change-Id: I603c2a1bd238eb8d059f3d13238e5e48379de6af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97202
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-27 22:30:10 +00:00
Ben Clayton fe8e6ee682 tint/ast: Generate ast::BuiltinValue from intrinsics.def
Emit unit tests for parsing and printing.
Emit benchmarks for parsing.
Uses intrinsics.def as a single-source-of-truth.
The generators provide a way to optimize the enum parsers.

Change-Id: Ic95177b8b60a51f0bcd6dab4138984f54f30ed6d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97201
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-27 22:21:30 +00:00
Ben Clayton 9a6acc419e tint: Add tint::OverrideId
This is a public API definition of a program-unique override identifier.

Bug: tint:1155
Change-Id: I6e55d43208e72a7a316557a89e2169d1b952f9bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97006
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-27 20:50:40 +00:00
dan sinclair b2306e27fc Drop line and col in intrinsic file
Change-Id: I282ada54b2ff9d5101dd1e8d4f2c01c3cf0b5a05
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97401
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-07-27 19:47:36 +00:00
dan sinclair 8dbd4d0280 Add storage_class error reporting to generators and transform.
With the experimental push_contants PR we will have AST which can not be
generated by all backends. Historically this would trigger the fuzzers as
an error. This CL changes the storage_class to an error from an ICE and
updates the code so the fuzzers only error on ICE or Fatal errors.

Change-Id: I2039a3d4cb457d805d38e2d6a790121318d1f07d
Bug: tint:1620
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97281
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-27 18:54:05 +00:00
Ben Clayton f330229de5 tint/ast: Rename Builtin to BuiltinValue
This is what it is called in the spec, and avoids confusion with the builtin functions.

Change-Id: I5cd4a250351c10928e90b640a8c68c7834bcf2a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97200
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-27 18:48:06 +00:00
Ben Clayton f50d56aa05 tint/ast: Generate ast::Extension from intrinsics.def
Emit unit tests for parsing and printing.
Emit benchmarks for parsing.
Uses intrinsics.def as a single-source-of-truth.
The generators provide a way to optimize the enum parsers.

Change-Id: I7f13128f510b2156c2ef724c89df7bb85dae17ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97151
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-27 18:32:19 +00:00
Ben Clayton a1571ac403 tint/inspector: Use a std::optional for workgroup_size
No-value represents a workgroup size that is derived from an override-expression.

Bug: dawn:1504
Bug: chromium:1346929
Change-Id: Idf6caa9d052aa56e8ef1913d16d1f68d2c5844ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97362
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-27 17:05:56 +00:00
Ben Clayton a123b892a5 tint/ast: Generate ast::StorageClass from intrinsics.def
Emit unit tests for parsing and printing.
Emit benchmarks for parsing.
Uses intrinsics.def as a single-source-of-truth.
The generators provide a way to optimize the enum parsers.

Change-Id: I1669c123d375f24aca45f3ea4abf04d7892673c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97150
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-07-27 16:36:35 +00:00
Antonio Maiorano bf8ee35498 const eval of clamp
Bug: tint:1581
Change-Id: Icffaf023021e704b3beaacf35136a9d6263b31e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97221
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-27 15:02:25 +00:00
Antonio Maiorano 4de90f0bb1 const eval of atan2
Bug: tint:1581

Change-Id: I6268e291540bc8c712f6925f0bcb82c5873359c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96902
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-27 14:51:27 +00:00
Jiawei Shao d144805688 Skip tests about writeonly storage texture In render pass on ANGLE
StorageTextureTests.WriteonlyStorageTextureInFragmentShader and
StorageTextureZeroInitTests.
WriteonlyStorageTextureClearsToZeroInRenderPass starts to fail on
the bots after the latest roll of ANGLE, so we have to temporarily
suppress them.

Bug: dawn:1503
Test: dawn_end2end_tests
Change-Id: Id8abf7c0a5bd30e5de12c838f871e1ab896ab4fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97127
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-27 10:09:25 +00:00
Jiawei Shao dd96f830f9 Test non-zero buffer copy offset in DepthStencilCopyTests
This patch adds the tests on the buffer-texture copies with depth
stencil textures when buffer copy offset is not zero.

Note that the tests about texture-buffer copies with depth stencil
textures are temporarily skipped on D3D12 backends as there is still a
bug on the texture-to-buffer copies with depth stencil textures on some
D3D12 platforms. We will fix this issue in the next patch.

Bug: dawn:727
Test: dawn_end2end_tests
Change-Id: I1d92cca80945ad77506db5441c396ce3eea00cca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97180
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-07-27 00:57:55 +00:00
Ben Clayton 48085845bd tint/ast: Clean up StorageClass enum
Remove unused enum entries.
Add a ParseStorageClass() function. Have the WGSL parser use this.

First step to standardizing the way we parse enum-backed token sets.

Change-Id: I31c02816493beeabda740ff43946edce097f5fd1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97148
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-07-26 22:51:36 +00:00
Austin Eng ce8876074f Move code around in prep for CacheKey -> Stream refactor
Moves code around to simplify viewing the diff for Change
If7594c4ff7117454c1ab3d0afaeee5653120add8

Bug: dawn:1480, dawn:1481
Change-Id: Iecfe4356b1a933a46741cec185008ca1d927c0a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96903
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-07-26 21:01:24 +00:00
Ben Clayton c768e640f4 tint/intrinsics.def: Change language for enums
Previously enum members were added to the global namespace, so that
overload template parameters could be constrained to a single
enum-entry without the need to declare a matcher. While this was a minor
convenience feature, it means that you cannot declare an enum with
members that share the same name as a type. This will be very common for
extensions, like 'f16' where 'f16' is the name of an extension and a
type name.

Change scoping so that enum members need to be fully qualified. Also
change the intrinsic syntax so that enums always need to use a matcher
for enums.

Change-Id: Ided91130e9df537d38dc8ecb41325c0992dea14b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97146
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-26 17:49:54 +00:00
Ben Clayton 02e9ce19ec tint: Make tint::ast::HasAttribute() accept multiple template arguments
Change-Id: I42efb3e603ac1d92c77e48784f7a9d010ade3047
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96021
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-07-26 16:40:15 +00:00
Corentin Wallez a55b686ded Remove unused dawn::native:🤘:GetMetalDevice
Bug: None
Change-Id: I07d4c2f4afce9202619e9def9dd1a214ae0906a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97203
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-07-26 16:28:45 +00:00
Ben Clayton cde5009be3 tools: Shuffle 'intrinsic-gen' tooling
Rename to 'gen', so that more templating can be added without having a confusing name.

Can now be run with './tools/run gen'

Move the bulk of the intrinsic-gen logic to `tools/src/tint/intrinsic`

Change-Id: I750989a5aa86272c10c2ad37adffe7def11c61f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97141
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-26 15:46:44 +00:00
dan sinclair 62c58a076c Stay at the EOF or Error token.
When the `next` token is requested, if we're already at EOF or Error
we can just return that token and stay at that index.

Bug: crbug:1347298
Change-Id: I1c31cf32a7030166c174d336455c7adabf97c6c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97220
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-26 14:59:54 +00:00
Ben Clayton 0fba14e3c6 tint/val: Make DXC validation output stable
Replace the temporary file name with 'shader.hlsl', so that
skip-expectations can be stably re-generated.

Change-Id: I5ead2235e6e0d84ad67c8d90f8d06b812c8fd593
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97145
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-26 14:23:24 +00:00
Ben Clayton e9585f5548 tint/val: Fix HLSL validation with DXC
Unlike on Windows, where command line argument splitting is done by the
callee, on 'nix systems, the arguments need to be split by the caller.

Fixes issues where validation was different on windows to other
operating systems.

Change-Id: If55738c431586f706e3edf0ac683661f34b53391
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97144
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-26 14:19:54 +00:00
Ben Clayton 958a4642f1 tint/resolver: Use utils::Vector in a few places
Use the new vector type in some of the hot code paths of the resolver.

Bug: tint:1613
Change-Id: Ie56d8c96f73c9112f37934ad67e588513aafb982
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96282
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-26 07:55:24 +00:00
dan sinclair d9a61cedaf Remove source copies in the parser.
This CL removes the copies of the `Source` and, in some cases, the token
name in the parser implementation.

Change-Id: I91c0797244a19fa5a36d39029d02823a20cee0cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97072
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-07-26 00:28:37 +00:00
Ben Clayton 4d1d143977 tint/utils: More Vector polish
* Added a class template argument deduction guide (CTAD) to infer the
  `T` and `N` template arguments. This lets you write `Vector{1,2,3}`
  instead of `Vector<int, 3>{1,2,3}`. This is important as a mismatch
  between the number of constructor arguments and the `N` template
  argument can cause silent heap allocations, which we're trying to
  avoid. The `T` deduction uses the same smarts as the return-type
  deduction of `Switch()`, so:
   * `Vector{1, 2.0}` would construct a `Vector<double, 2>`
   * `Vector{i32, u32}` would construct a `Vector<const sem::Type*, 2>`
* Removed the Vector(size_t) and Vector(size_t, const T&) constructors.
  This is a move away from the std::vector style API, but these are
  rarely more efficient than calling Reserve() and Push(), as you remove
  the redundant initialization. The main reason for doing this is to
  remove ambiguity between `Vector{1}` and `Vector(1)`.
* Added support for covariance conversion
  (`Vector<Derived*, N>` -> `Vector<Base*, N>`).
  Only supports pointers to `Castable`, as this can  only safely work
  with single-inheritance.
* Added support for conversion of `Vector<T*, N>` -> `Vector<const T*, N>`.
  This will remove pointless vector copies from the sem package.

Bug: tint:1613
Change-Id: I79b9f82d623f90afa14f8ba1613ee49cccceafeb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97020
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-25 23:37:34 +00:00
dan sinclair 0cbf5a922f Pre-parse token list.
This CL updates the parser and lexer to pre-parse the token list and
then the parser works off the list of tokens. This allows the parser to
work with references to the tokens and not have to worry about them
going stale.

For any splittable token a placeholder token is injected after the
token. If the token ends up getting split the placeholder is overwritten
with the new type.

Change-Id: I5a8ccca15d8c14b5027df7dd2734be6753e46fa9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97070
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-25 16:43:08 +00:00
dan sinclair 833ccab384 Optimize the lexer match method.
This CL updates match to compare against characters instead of strings.
If the prefix character doesn't match we stop checking for any
punctuation which starts with that character.

Change-Id: Ifddc1ff3f3936ab3a53c37e080394ed35dc2aecf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97065
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-25 14:54:18 +00:00
dan sinclair 08482ec7ed Expand ASCII short circuit.
This CL expands the ASCII short circuit to add the number range and _
into IsXIDContinue.

IsXIDStart is updated to filter out anything less then the first
sequence after the (a-zA-Z) blocks as they won't be XIDStart but do cover
all of the common ASCII punctuation characters.

Change-Id: Ib839d9840f5a1ecc3d2e80774b11af2444e9f439
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97071
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-25 13:41:21 +00:00
dan sinclair b0499e446f Add optional attribute trailing commas.
This CL allows optional trailing commas on attribute lists.

Bug: tint:1423
Change-Id: I80f3b1580c95cac328b4ab846c6a3d4999fe34cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96907
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-07-25 13:30:18 +00:00
Zhaoming Jiang 659d58ceca tint/resolver: Fix BuiltinCall validator nullptr deref
This patch fix a nullptr dereference case in Validator::BuiltinCall,
which check if a no-return-value built-in is called in something other
than call statement. Such call may don't have a statement context at all.

Bug: chromium:1346830
Change-Id: Ieef02daa5c93a3ac253cd7a7366a53e0fc7887b1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96986
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-25 12:18:38 +00:00
dan sinclair f9a43b982d Remove unused string.
We saved the string in the lexer try_float for use in error messages,
then changed the message to not show the string. This CL removes the
creation of the float string.

Change-Id: I9bb381bebe31f25609c66d5ccda91de0277199cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97069
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-24 19:45:17 +00:00
dan sinclair 3f9cc84d0a Short circuit IsXIDStart check.
Our common case is ASCII characters but, because those come at the start
of the XID Start range they'll end up being checked _last_ as we binary
search through the range. This means we're getting the worst case
behaviour for our common character.

This CL adds a quick check for [a-zA-Z] at the start of IsXIDStart to
quickly determine if we're an ascii character.

Change-Id: Iae733b0e8a64c855764cf58c0563a407e6a81f7d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97068
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-24 19:06:07 +00:00
Kai Ninomiya e657fa7cb7 Suppress new VVL error
This VVL check seems either impossible to satisfy, or difficult due to
underspecification of the error in the Vulkan spec.

Bug: angleproject:7513
Change-Id: I82873fb41aa7f03413114ed6672ba2bebd98f009
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96982
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2022-07-22 22:24:16 +00:00
Ben Clayton 7d34de88f1 tint/test-runner: Split expectations for FXC and DXC
Change tint's `--fxc` flag to take the path of the FXC compiler DLL.
Have tint attempt to validate with both FXC and DXC if `--validate` is
passed.

Fix the 'dirsWithNoPassExpectations' logic which looks like it got
broken with the tint -> dawn merge. It also incorrectly applied
filepath.FromSlash() on windows.

Change-Id: I0f46aa5c21bc48a2abc48402c41f846aff4a8633
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96800
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-07-22 17:43:27 +00:00
dan sinclair a089376daf Context aware address space parsing.
This Cl remoevs the address space names from the keyword list and
makes their parsing context dependant. The mechanism in the parser
is the same, we just change to looking for an `ident` in
`expect_address_space`.

`storage_buffer` is kept for now, this keeps the functionality the same.

Bug: tint:1621
Change-Id: I928a5472d8ac194b2bef2da56a224e9f4abb65a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96905
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-22 16:09:55 +00:00
dan sinclair 87254ff58e Update error messages to say initializer
The spec talks about initializers for `var`, `const` and `let`
constructs. The parser was emitting `constructor`. This CL updates
the terminology to match the spec in order to make searching for
answers easier.

Bug: tint:1600
Change-Id: Ic135856ba9afbfd2580b648d8f2e402059bac8be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96906
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-07-22 16:08:35 +00:00
dan sinclair 05288f6cff Rename paren_rhs_stmt to paren_expression.
This CL renames paren_rhs_stmt to match the new spec name of
paren_expression.

Bug: tint:891
Change-Id: I040137d8264916ce2fecce90edad97f622be354d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96940
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-22 16:07:36 +00:00
dan sinclair 256f1116b8 Add transform to substitute overrides with const expressions.
This CL adds a SubstituteOverride transform which will convert
an `override` into a `const`. The transform is provided a map of
(string, double) which matches what the WebGPU API accepts as
data for overrides.

Bug: tint:1582
Change-Id: I6e6bf51b98ce4d4746f8de55128666c36735e585
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96760
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-22 16:05:06 +00:00
Ben Clayton af47388345 tint/resolver: Optimize node marking
Use the new utils::Bitset to replace the much slower unordered_map.

Bug: tint:1613
Change-Id: I80503d2b897f754408c4ce14a221210d6abc18f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96403
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2022-07-21 23:46:15 +00:00
Ben Clayton e43034bef2 tint/utils: Add Bitset.
A compact, dynamically sized, vector of bits.

Bug: tint:1613
Change-Id: Ida10d1bdedad48dd4c2ab7908732f328b4b96055
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96544
Reviewed-by: dan sinclair <dsinclair@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-07-21 23:32:24 +00:00
Antonio Maiorano 6863be0487 tint: Fix TINT_SYMBOL_STORE_DEBUG_NAME
Change-Id: Id585354c5e3630d6921d74b58a6d602689be48ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96901
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-21 22:06:05 +00:00
Zhaoming Jiang 1e98a9ba4a tint: Normalizing type matcher's name in intrinsics.def
This patch normalize the abstract interger and abstract float type name
to `ia` and `fa` and the type matcher name to `fia_fiu32_f16` format in
intrinsics.def, and also rename `aiu32Dispatch` and `afi32f16Dispatch`
in resolver/const_eval.cc to `Dispatch_ia_iu32` and
`Dispatch_fia_fi32_f16`.

Bug: tint:1581
Change-Id: Ia48e150d6028e4a7b999f72e57508df369b3e2d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96721
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-07-21 19:55:35 +00:00
Ben Clayton 3bc20e3786 tint/utils: Add utils::Vector
A small-object-optimized vector container.

Bug: tint:1613
Change-Id: I1c482027db4624d4a2fd00ddeec02cfd0bb9b27f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96281
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-21 19:34:05 +00:00
Corentin Wallez a84b9119eb tint: Make the error message on `enable(f16)` more clear
Explicitly call out that enable directives don't take parenthesis
instead of saying "invalid extension name".

Bug: tint:1620
Change-Id: I124568fdee2fa5bddf1426bed52762a329bd5d9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96686
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-21 15:53:55 +00:00
Ben Clayton 5716611bf0 tint/resolver: Materialize objects when indexed with non-const index
If an abstract-vector or abstract-matrix is indexed with a non-constant index expression, then the resulting value is non-constant, and so cannot be abstract.

In this situation the materialization cannot be done post-index, so materialization must happen on the object before indexing.

Bug: chromium:1345468
Change-Id: I9f29dc40301779a7ff8f173724374bd845a3a5b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96684
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-07-21 15:25:35 +00:00
Antonio Maiorano 3b8b9699d6 tint: Implement const eval of unary minus
Bug: tint:1581
Change-Id: I228e8d083229fabfe8a4c0876160d673502e10a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96422
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-20 18:00:35 +00:00
Corentin Wallez 256e026f64 dawn: Add Device::CreateErrorTexture(desc)
This will be used by Blink to create error textures with correct
reflection information exposed to JavaScript.

Bug: chromium:1345736
Change-Id: I0bc3a72d602c1bb57dc76e90f4883951f86ef428
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96681
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-07-20 16:07:44 +00:00
Alastair F. Donaldson eb02cd3301 Regex fuzzer: replace function calls with builtins
Replaces random identifiers used as function names in calls with the
names of builtin functions.

Fixes: tint:1617.
Change-Id: I4e70276c9023bcb35b860c98fca6a95dc284f60a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96580
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-20 16:05:14 +00:00
Alastair F. Donaldson ca21fa019f Update dictionary for fuzzing
Updates the dictionary that will be used by libFuzzer fuzzer targets
to reflect the latest developments in WGSL.

Bug: None
Change-Id: I9f9915f14289b15fcc04829d463e90bb96948880
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96685
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
2022-07-20 16:04:44 +00:00
dan sinclair 46c32d882d Early out Is checks.
This CL adds a check to the `Is` castable methods to determine if the
target type is `final`. If the type being compared too is `final` we
bail out early in the walk up the hierarchy as it won't be a parent
class.

Change-Id: Ieba4dd686e47207a3db0cf3a8ea46fbc1a8d1c91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96600
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-07-20 15:53:14 +00:00
Corentin Wallez 633cdf41cc tint/resolver: Make the F16 ban error message show a single SC.
The error message mentioned "'uniform' or 'storage'" and will need to be
updated to also mention 'push_constant' in follow-up commits. Instead
make the error messages show only the storage class of the variable.

Bug: tint:1620
Change-Id: I266a948f8a8fb70d57031d15306a5e82400e4c75
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96683
Reviewed-by: dan sinclair <dsinclair@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-07-20 14:15:54 +00:00
Brandon Jones 81768c131f Validate that depth clear values are between 0, 1
Fixes missing validation exposed by the addition of
https://github.com/gpuweb/cts/pull/1640 to the CTS.

Change-Id: Ib51124603a6fcec973eeab9ac1ed989add209c9a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96481
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-20 04:18:35 +00:00
Jiawei Shao 44b0a5e9a3 D3D12: Don't set D3D12_CLEAR_VALUE on depth textures on Gen12 GPUs
This patch adds a workaround for Intel Gen12 GPUs that we don't set
D3D12_CLEAR_VALUE when creating a texture with any DXGI depth formats
(DXGI_FORMAT_D16_UNORM, DXGI_FORMAT_D32_FLOAT,
DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_D32_FLOAT_S8X24_UINT)
because on these GPUs the texture data may be corrupted after several
call of ClearDepthStencilView() if D3D12_CLEAR_VALUE is set in the
call of CreatePlacedResource() or CreateCommittedResource().

Bug: dawn:1487
Test: dawn_end2end_tests
Change-Id: Id44af0f6fe31773820f5e20d05edd275dd921e53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-07-20 02:28:34 +00:00
Yan,Shaobo aea3154e46 CopyTextureForBrowser supports RGBA16Float as source texture format
Source canvas format could be RGBA16Float so expand CopyTextureForBrowser
source texture format to support it.

Bug: dawn:856
Change-Id: I35d072ef3b7f58b96ae50a24e135b344ef7eb9b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96483
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-20 00:06:13 +00:00
Alastair F. Donaldson e4df87fd01 Regex fuzzer: Add break and continue statements
Adds a break and continue statements to randomly-chosen loops. Also
overhauls support for adding return statements to functions.

Fixes: tint:1125.
Change-Id: Ib1a82b49e3fbb0b5520c725c8b8459d68383bed2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96543
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-19 16:59:33 +00:00
Alastair F. Donaldson 84f7830874 Regex fuzzer: replace operators
A mutation that replaces operators in a WGSL-like string at random.

Fixes: tint:1092.

Change-Id: I912825365f338266d34a1bffb5c8a96cecaba179
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96404
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-19 15:55:43 +00:00
Ben Clayton 056f97a9e5 tint: Add a benchmark for atan2 const eval
And increase the test runner timeout from 30s to 2min.
FXC really doesn't like this shader, however I expect this to be
made much faster once constant evaluation for atan2 is implemented.

Change-Id: Id8a8ba97b5a99a2f94633a0732300a35ba6dc1c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96401
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-19 14:50:33 +00:00
Corentin Wallez 73a5a716b5 Clarify that dawn/common:internal_config doesn't leak out of Dawn.
Fixed: dawn:1491
Change-Id: I6b1560d9918762b935800eb13c7bccae970724cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96542
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-19 12:49:03 +00:00
Alastair F. Donaldson 853cbadc8f Clean regex fuzzer API
Introduces a class to clearly identify the interface of the mutation
functions used during regex-based fuzzing.

Bug: None

Change-Id: Ia6d125227cffc1c0b8944764c4e21825fd31d5cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96360
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <allydonaldson@googlemail.com>
2022-07-19 09:31:33 +00:00
Kai Ninomiya 574f61e892 Skip some tests on ANGLE
SwANGLE implemented GL_NV_read_depth_stencil but it isn't working for us
for some reason.

Bug: dawn:1497
Change-Id: I8c48ec4142169c89c33c6ea1dfc81d978c8962dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96500
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2022-07-19 00:28:52 +00:00
Sunny Sachanandani 6cbe015429 d3d12: Fix fence signal race when no command lists are submitted
Signaling a fence in Dawn without waiting can cause a race between Dawn
and Chromium over who signals the fence. Since D3D12 fences are allowed
to be rewound this can cause future waits to hang indefinitely if Dawn
loses the race and signals a lower value than what Chromium expects.

The signal without wait case happens when Dawn submits no command lists
e.g. when CopyExternalImageToTexture uses a zero-sized dimension. This
is the reason for the test failures in https://crrev.com/c/3700811 e.g.
https://ci.chromium.org/ui/p/chromium/builders/try/dawn-win10-x64-deps-rel/24617/overview

To fix the race, it's sufficient to wait before signaling if not already
waited which is what this CL does. This CL also makes the fence stay
alive until pending signals are done - this wasn't the root cause of the
hang described above, but it's still a good idea for robustness, and
also recommended based on discussion around past Chromium XR fence use.

Bug: dawn:576
Change-Id: I8c1d1a19fdb022ae28d26f6723c2f2bfc9c1c3c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96321
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
2022-07-18 22:04:52 +00:00
Ben Clayton 4a92a3c904 tint: Optimize sem node lookup
Add a 'NodeID' to each ast::Node which is the sequentially allocated
index of the node. Use this in sem::Info to map the AST node to the
semantic node, instead of using a std::unordered_map.

Optimised very hot code by entirely eliminating map lookups, and
dramatically reducing cache misses (lookups are usually sequentually
ordered).

Timings running
'webgpu:shader,execution,expression,call,builtin,atan2:f32:inputSource="const";vectorize="_undef_"'
with dawn/node, using SwiftShader:

    Without change: 3.22647107s
    With change:    3.10578879s

Bug: tint:1613
Change-Id: I22ec48d933b2e5f9da04494bff4e979e6f7b1982
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96140
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-18 20:50:02 +00:00
Austin Eng 8d73198aca Remove depth-clamping and add depth-clip-control feature
Fixed: dawn:1178
Change-Id: I251a7e05fec9ecef44300d4f948b2d0611888109
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96320
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-18 20:38:05 +00:00
Ben Clayton 70f7a1ee51 tint: Optimization: Avoid dynamic cast in TINT_ASSERT
We don't need / want to consider whether the node in the map is of
the SemanticNodeTypeFor type.

Change-Id: Ia0deb3f4e4624bf47e2155fea05f91547d747310
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96144
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-18 17:03:32 +00:00
Ben Clayton b71bcdd45e tint: Optimization: Pre-allocate the ast -> sem map.
Change-Id: I674fe31786b08153509b470d14844d50cb7c3d9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96143
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-18 16:47:32 +00:00
Zhaoming Jiang 59e640b208 tint: Add f16 support for operator
This patch add support for using f16 types in unary operator `-` and
binary operator `+`, `-`, `*`, `/`, `%`, `<`, `>`, `<=`, and `>=`.
`==` is already supported. Unittests are also implemented.

Bug: tint:1473, tint:1502
Change-Id: I1123fa5e9e586ec0d8522b0f6bacafb4ad53ffcf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96380
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-18 14:38:32 +00:00
Ben Clayton 69cafb99e4 run-cts: Add `--dump-shaders` flag
A helper alias for `--verbose --flag=enable-dawn-features=dump_shaders`, which is hard to remember.

Change-Id: I4795a2c3b6f20834cf81d2d6ec4bfca67d29a6f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96400
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-18 11:11:12 +00:00
Ben Clayton 605b7fbadc tint/writer/glsl: Simplify map keys with UnorderedKeyWrapper
And remove the unused DMAIntrinsic struct / field.

Change-Id: I641c066a7bc22dc903592b3928705be56d83392c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96145
Reviewed-by: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-07-16 00:00:29 +00:00
Ben Clayton ac660c2794 tint: Implement const eval of unary complement
Bug: tint:1581
Bug: chromium:1343242
Change-Id: I76b4f041494ceb2afcf5a604fcda32e046ffca35
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96100
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 23:54:10 +00:00
Ben Clayton 83bd738ab4 tint/resolver: Track evaluation stage
Keep track of the earliest evaluation point for an expression.
Required to properly track what can be assigned to a `const`, `override`, `let`, `var`.

Bug: tint:1601
Bug: chromium:1343242
Change-Id: I301eec21b71e9036dc1bf6c9af8079317d724762
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95949
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 23:46:31 +00:00
Ben Clayton db89595550 tint: Add a Count() method to BlockAllocator.
Tells you how many things you've allocated.
Will be used for various optimizations.

Change-Id: I8a31bb06e2b23781245bbfd16fabc9b85e440d14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96142
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-15 23:42:14 +00:00
Ben Clayton 6a80ce6c66 tint/resolver: Use the intrinsic table for type const dispatch
Use the @const annotations to more efficently dispatch to the right
method of the ConstEval class.

Reduces a whole lot of dynamic casting logic.

Change-Id: I6791aac51b935b46d63af29abd1e577b3306a0ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95950
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-07-15 22:27:50 +00:00
Ben Clayton 8b0ceea0b1 tint: Clean up legacy type cruft
Fix TODOs dating back to when types were an AST / SEM hybrid concept.
Bring the `arch.md` to reflect how things work today.

Bug: tint:724
Change-Id: I6bf4174158cf490f2839aeed78164b66e3410f27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96141
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 17:16:49 +00:00
Ben Clayton f19cb029b8 tint: Remove single scalar matrix constructors.
These were never part of the spec, and they were not correctly
implemented for all backends.

Fixed: tint:1597
Change-Id: If1a23f1619c61c53baae277f1cf37aee4460ab7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95952
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-15 15:25:30 +00:00
Ben Clayton 65c5c9d92b tint/resolver: Add ConstEval class
Extract out the methods of Resolver::EvaluateXXXValue() to a new
tint::resolver::ConstEval class.

Removes more bloat from Resolver, and creates a centralized class for
constant evaluation, which can be referred to by the IntrinsicTable.

Change-Id: I3b58882ef293fe07f019ad2138a7e9dbbac8de53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95951
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-15 14:14:09 +00:00
Ben Clayton cfe07a1b33 tint/resolver: Shuffle validation code
Restructure the logic so there's less, pointless dynamic casting, and the complexity is reduced.

This alters the order in which variables are validated, hence the change of test.

Change-Id: I9a3120c0278faa5ac9f1db65eeb71a8e4a705596
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95948
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 13:01:49 +00:00
Zhaoming Jiang e0ecd86e73 tint/writer/glsl: Fix emitting float modulo with mixing type
This patch fix the GLSL writer issue that emit only one helper function
when using both `v % s`, `s % v` and `v % vs in the shader, where `s` is
of `f32` and `v` is a vector of `f32`. Unittests are added for GLSL.

Bug: tint:1614
Change-Id: Ia89ae010341b9c88b8101cc6febab7d83c96bb17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96085
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-07-15 11:05:29 +00:00
Ben Clayton 32bdf41ed3 tint/resolver: Remove logic for module-scope let
This has been replaced with module-scope const.

Change-Id: I03d5e076cf150d2931c9cfb1c6025e98200d91a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95947
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 09:17:29 +00:00
Jiawei Shao e52cc0419e D3D12: Always initialize depth stencil texture to 0 on Intel GPUs
This patch adds a toggle to force initializing depth stencil textures
to 0 on Intel D3D12 drivers as a driver issue will occur when we
create and copy into a depth stencil texture that is just created with
CreatePlacedResources() on Intel D3D12 drivers:
- For the depth stencil textures with RenderAttachment usage, they will
  always be cleared with ClearDepthStencilView() instead of copy, then
  the following copies will be correct.

In next patch we will handle the situation when the depth stencil
texture is not created with RenderAttachment usage.

Bug: dawn:1487
Test: dawn_end2end_tests
Change-Id: I0f7db86a2e6db55e4b82defb510ccc829c6b0d38
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95989
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-07-15 04:21:01 +00:00
Ben Clayton 6c098baedf tint: Implement constant expression structures
Bug: tint:1611
Change-Id: Id04c31ade297a68e7e2941efafbd812ba631fc41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95946
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-14 20:46:39 +00:00
Ben Clayton 2a8c00f53a tint: Limit const expr vector reserve size
The `el_count` will match the WGSL declared array size *before validation*.
Fuzzers have started triggering out-of-memory cases by constructing large constant arrays, just to then error out.

Bug: chromium:1343963
Change-Id: I537ff3a570fe56b40e510b3bc6dfcd9b9752386a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96102
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-13 14:28:23 +00:00
Stephen Gutekanst 4a9ce59cb2 dawn/native/d3d12: use correct __uuidof operator
This code uses `_uuidof` (single undescore) instead of `__uuidof`
(two underscores), only the latter is documented as the officially
supported operator by Microsoft:

https://docs.microsoft.com/en-us/cpp/cpp/uuidof-operator?view=msvc-170

I suspect `_uuidof` and `__uuidof` are the same under the msvc compiler,
but in other compilers (Zig/clang/MinGW) only the officially supported
`__uuidof` is exposed. This change improves compatability with such
compilers.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Change-Id: If2850a1a98507161739fcd5f52ebd4ceaefffe75
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87309
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-13 12:28:50 +00:00
Sunny Sachanandani 7ae5c41412 d3d12: Destroy ExternalImageDXGI resources on device destruction
D3D12 objects can have implicit dependencies on device resources that
are not captured by holding ComPtrs:

"Direct3D 12 uses COM-style reference counting only for the lifetimes of
interfaces (by using the weak reference model of Direct3D tied to the
lifetime of the device). All resource and description memory lifetimes
are the sole responsibly of the app to maintain for the proper duration,
and are not reference counted. Direct3D 11 uses reference counting to
manage the lifetimes of interface dependencies as well."

Source: https://docs.microsoft.com/en-us/windows/win32/direct3d12/important-changes-from-directx-11-to-directx-12

ExternalImageDXGI can outlive the device it was created on e.g. the D3D
shared image backing holds on to the ExternalImageDXGI for its lifetime.
ExternalImageDXGI destructor can invoke code that depends on D3D12
resources that might have already been destroyed. In particular, this
shows up as ComPtr::Release for ID3D12Fence crashing mysteriously, and
is also speculated as the cause for a racy invalid function pointer
dereference in crbug.com/1338470.

This CL makes the D3D12 backend device destroy the ExternalImageDXGI's
resources on device destruction making it effectively a weak pointer.
This unblocks landing https://crrev.com/c/3700811 and hopefully fixes
crbug.com/1338470 as well.

This CL also deprecates unnecessary WGPUDevice param to ProduceTexture,
and adds an IsValid() method so that the shared image can check it and
decide to recreate the ExternalImageDXGI if needed.

Bug: dawn:576, chromium:1338470
Change-Id: I2122cf807587cf3b1218ba29ea291263df0cf698
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95860
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-07-13 11:33:51 +00:00
Zhaoming Jiang 9a32a720ac tint/writer/wgsl: Support for F16 type, constructor, and convertor
This patch make WGSL writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

Bug: tint:1473, tint:1502
Change-Id: Id2a5eec54b95add330366cf141b36999e604a63b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95990
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-13 08:49:20 +00:00
Ben Clayton 51719ccc01 tint: Fix SPIR-V validation around interpolation decorations
SPIRV-Val has tightended up validation around input / output interpolation decorations.
This change ensures that the parser and writer do the right thing.

Change-Id: I29c97fdcc48c62aa77b106c42e64fbc54204d607
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96020
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-12 19:10:39 +00:00
Ben Clayton 7fe690b555 dawn/node: Fail tests where the process aborted abnormally.
If the process exits with a non-zero status (like crashing), then don't pretend the test passed.
This would only occur if the test result had already been printed.

Change-Id: I29e81362b6e09f1fca48c55b1798ba409e9a703e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95942
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-12 12:53:09 +00:00
Zhaoming Jiang 66d4f6e6fb tint/writer/spirv: Support for F16 type, constructor, and convertor
This patch make SPIRV writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

Currently SPIRV writer will require 4 capabilities in generated SPIRV:
`Float16`, `UniformAndStorageBuffer16BitAccess`,
`StorageBuffer16BitAccess`, and `storageInputOutput16`.

Bug: tint:1473, tint:1502
Change-Id: Ia1af04f1f4a02bf1b1c2599a5d89791854eabc16
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-07-12 12:35:09 +00:00
Austin Eng d4e3fcb4a1 Add Tint public/common configs to dawn_unittests
Fixes a breakage compiling dawn_unittests in a Chromium checkout.
These tests have started testing passing public Tint structs like
tint::sem::BindingPoint to Dawn internals.

Bug: dawn:1480
Change-Id: I41a30abbf73384c86b966223f5f689bd3339ce06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95986
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
2022-07-12 09:08:29 +00:00
Austin Eng f9518dfca2 Actually pass the instance descriptor in APICreateInstance
This argument was getting dropped, so the default descriptor was
always used.

Bug: chromium:1343047
Change-Id: I521e00a3c390ff193fcc18072a037c069e98c680
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95982
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-12 01:00:19 +00:00
Stephen Gutekanst 9514098b31 dawn/native/d3d12: improve constexpr compatability with clang
In Mach engine we compile Dawn's d3d12 backend using Zig as a C/C++
compiler, effectively clang with MinGW windows headers. Unfortunately,
this `static constexpr` fails to compile:

```
error: constexpr variable 'kD3D12PromotableReadOnlyStates' must be initialized by a constant expression
```

As kangz previously noted, the reason appears to be because `D3D12_RESOURCE_STATE_COPY_SOURCE`
is not `constexpr` [in MinGW headers](1de9cc347d/mingw-w64-headers/include/winnt.h (L682)).
The thought process is that making this just `const` is fine because
constant propagation would make it a constant anyway.

If we're comfortable merging this, it'd be one less change we have to
maintain on our side - and probably no impact otherwise. On the other
hand, I understand the most-correct fix would be in MinGW headers
themselves. I'd love to land this change, but it's no big deal if you
prefer not.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Change-Id: I772f1cb7e2b4f1b200820cd50f6b7df45850abbb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87381
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-11 20:12:48 +00:00
shrekshao a3f4a32022 Add clear alpha to one step to copy texture for browser
Bug: chromium:1331139
Change-Id: I69c31aea0320f302be686adf0167649a98db3414
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95682
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-11 18:11:14 +00:00
shrekshao c6cbcdb05b Add internal usage for copyTextureForBrowser
Add an internal usage option for copyTextureForBrowserOption
allowing internal calls from call to use canvas context
texture as source/destination.

Bug: chromium:1331139
Change-Id: Ida8421b3962a6434e8ef57c581c7a2e1d607954c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94985
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-11 18:11:14 +00:00
Corentin Wallez e629aee91a dawn::native: Check that ExternalTexture bindings are ExternalTextures
The code was checking the equivalence in one direction but not the
other, leading to a case where passing a TextureView instead of an
ExternalTexture passed validation and lead to crashes in the backends.

Bug: chromium:1343099
Change-Id: I428252796df375e7cf3a6df1a03192d65364e370
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95944
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-11 17:21:17 +00:00
Ben Clayton 8ce7183e68 tint: Remove public include of ast include
ast::PipelineStage is private API. Duplicate the enum for the inspector.
Change-Id: Ib79600d2ef86cc13f409c7c800f98ea42bb3ace4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95943
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-11 17:17:23 +00:00
Zhaoming Jiang a5988a3058 tint/writer/hlsl: Support for F16 type, constructor, and convertor
This patch make HLSL writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

The HLSL writer will emit f16 literal as `float16_t(1.23h)`, making the
type explicit, and map f16 types as follow. The generated code require
DXC with SM6.0 or higher, and `-enable-16bit-types`.
WGSL type   -> HLSL type
f16         -> float16_t
vec2<f16>   -> vector<float16_t, 2>
vec3<f16>   -> vector<float16_t, 3>
vec4<f16>   -> vector<float16_t, 4>
mat2x2<f16> -> matrix<float16_t, 2, 2>
mat2x3<f16> -> matrix<float16_t, 2, 3>
mat2x4<f16> -> matrix<float16_t, 2, 4>
mat3x2<f16> -> matrix<float16_t, 3, 2>
mat3x3<f16> -> matrix<float16_t, 3, 3>
mat3x4<f16> -> matrix<float16_t, 3, 4>
mat4x2<f16> -> matrix<float16_t, 4, 2>
mat4x3<f16> -> matrix<float16_t, 4, 3>
mat4x4<f16> -> matrix<float16_t, 4, 4>

Bug: tint:1473, tint:1502
Change-Id: Iaf564f3ce29ace2984cef19d7df5a7dfb0fab2ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95685
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-11 15:43:38 +00:00
Ben Clayton 94c6495ad2 dawn/node: Don't abort if the GPUDevice is not destroyed
Before being destructed.
If the Destroy() method is not called, then the lost_promise_ is not resolved or rejected, triggering an assertion.

Change-Id: I0a7c06674bc58d2e7c4df4229452bd2de27ca2b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95941
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-11 13:33:48 +00:00