Commit Graph

6966 Commits

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