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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>