Commit Graph

6816 Commits

Author SHA1 Message Date
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