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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Attempting to print a long string can cause output to go missing.
Split long strings up into 4k chunks.
Change-Id: Ibcb07459bd8fb4a1a11b6f8db41c8378274a6d09
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Textures with particular dimensions may corrupt on some devices for
copy and rendering. This change add a test to detect it.
Bug: dawn:949
Change-Id: Idcb346191c1c7beac4c5ff91464bd14d8eeba6f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95680
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This patch make resolver reject using f16 types in uniform or storage
buffer, pipeline IO or overridable variable, since these are not
implemented yet. This can help prevent hitting invalid path in writers.
Bug: tint:1473, tint:1502
Change-Id: I5ea753e4254276a6d141d7012a6d0987423a61cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95827
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Offset > 0 is already implicitly included in this if statement
(when `offset == 0` then `size > mDataLength` could safely assert it's invalid).
So we could remove it and use `offset > mDataLength` instead of `>=`.
Bug: chromium:1340654
Change-Id: Ieafe1ea6bef5aae29bc6ef2bd9702d6f7a92d8b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95820
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Materialize() was re-evaluating the constant values for the incoming
semantic expression, despite this already being evaluated. Just use the
sem::Expression::ConstantValue().
resolver.cc already has all the semantic pointers, so pass them in
instead of pointlessly hitting the ast -> sem map.
Change-Id: If2bc7cd10f79079fb811e9d83c5150dd3c0c244c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95764
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Any AST expression may map to a sem::Materialize, so the inferred
mapping is bug-prone (the implicit sem type may mismatch and Get() may
return nullptr).
Change-Id: I34485a4a067635df930a407316fae8b2e9628c3d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95763
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
No builtins are implemented as `@const` yet, but validation handles this already.
Bug: chromium:1341472
Change-Id: Id85893345299ba3414e2d15b85dd071c326f481d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95762
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Materialize() can return nullptr, if there's an error.
Check the returned pointer for nullptr, before continuing on to using the pointer.
Bug: chromium:1341313
Change-Id: Ib7c9e593fbf2bb4374305c341c2b04e34e7487e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95761
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Required to build Dawn with GN flag `is_ubsan = true`
Change-Id: I80b49b81377f0a9c8bd2c1310e12786427947c38
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95760
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
The Depth16Unorm specific issue should now be fixed:
https://swiftshader-review.googlesource.com/c/SwiftShader/+/66888
so the test suppressions can be removed.
Bug: b/204919030
Change-Id: Ib221d2e11712995237da506ecc6de1f292bfa0bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95700
Auto-Submit: Alexis Hétu <sugoi@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This CL add methods that return the binary16 bit pattern for a
constructed Number<detail::NumberKindF16>. This is required for
generating SIPR-V oprand.
Bug: tint:1473, tint:1502
Change-Id: Ia3680cdb5a0e64d31bfe2f48432cda3850c1f5a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95240
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>