Commit Graph

19 Commits

Author SHA1 Message Date
Corentin Wallez 943a1a2d7a Add SwapChain::GetCurrentTexture
This is to eventually allow more using swapchain textures as CopySrc and
CopyDst. Note that this commit doesn't add any additional usages.

Because textures can reflect their creation parameters, swapchains now
need to pass in the correct texture descriptor in all code paths. This
requires additional handling in dawn::native error swapchains, and
dawn::wire::client's SwapChain reservation and Device::CreateSwapChain
code.

Tests are added for all of these code paths except
dawn::wire::client::Device::CreateSwapChain because there is no way to
create a Surface in wire tests at the moment (they don't have an
instance).

Bug: dawn:1551
Change-Id: I22d5e909e1e94d48eb52cae57aabff8a7f0c04c1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133463
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-05-26 10:32:17 +00:00
Brandon Jones 112b7fd856 Allow device lost callback to be passed at creation
This change updates the Device descriptor to allow a device lost
callback to be passed in at device creation time. This will be
important for allowing the API to return devices which have
already been lost in a future CL, which is the behavior required
by the spec.

This change does not yet deprecate the old method for setting the
callback, as there's still some tricky scenarios that will need to
be worked around to enable that and this CL is already fairly
large. (The uses in question pass the device or a value created
from the device as the userdata.)

Bug: chromium:1234617
Change-Id: I1adea5ceffdfdcfedff9fff4960f12303abba29c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121041
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2023-05-17 01:52:30 +00:00
Loko Kung 4e9ebeff02 Deprecates PopErrorScope returning a bool.
Bug: dawn:526
Change-Id: Ia4e985fbe4fcb5edb3fe80849f5b0df0190eea00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130340
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-05-01 19:25:18 +00:00
Ben Clayton df218948ba Run clang-format
Change-Id: I9f93208a6670d9dc32a8900d03e0cfbc076adc41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-27 14:00:57 +00:00
Le Hoang Quyen 335573116c Add Device::GetSupportedSurfaceUsage() method.
This method will return supported usage flags that can be used to create
a swap chain.

Bug: dawn:1760
Change-Id: I7699c2c4ef7142c6bd06e72239d6e4f9112f15a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127440
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-20 20:42:05 +00:00
Jiawei Shao 806c58324c Wire: Make validation error prior to OOM if mappedAtCreation == false
This patch updates the validations about CreateBuffer() with dawn_wire
to match the latest WebGPU SPEC.

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

Bug: dawn:1586
Change-Id: I97ff5f82a42208442ddf6e46e66381c3b3680450
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109040
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2022-11-23 02:06:11 +00:00
Jiawei Shao e052683e3f Remove two unused function declarations in wire::client::Device
Bug: dawn:1586
Change-Id: Ic3a7bdedc62ff6765a559f94a7ad379741687fed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109080
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-08 15:11:31 +00:00
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
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
Corentin Wallez 3b808be7c5 dawn::wire::client: Make ObjectBase destructor virtual.
Also adds override to all child classes' destructor so they correctly
get put in the vtable.

Bug: dawn:1451
Change-Id: Ic03841392b994f9bdc8487b6abc88bd86128e783
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93443
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-14 16:34:46 +00:00
Corentin Wallez 60f3832435 dawn::wire::client: Write ObjectBase constructor params in a struct.
This will allow easily adding new parameters to ObjectBase in the future
(like an object generation).

Bug: dawn:1451
Change-Id: I4fc81384987cdd9c33e672d15fcd960dbf0367a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93144
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-06-14 09:31:46 +00:00
Corentin Wallez 45820ae995 Add reflection APIs for wgpu::QuerySet.
Bug: dawn:1451
Change-Id: I8bce40e4fc0c7caca3c3a4b8c385ba8a393a3f1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92662
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-06-09 10:12:13 +00:00
Corentin Wallez 736e97c5e0 Add reflection APIs for wgpu::Texture.
This requires adding a custom implementation of DeviceCreateTexture and
the Texture object in the wire client.

In dawn::native this requires the format enum separately from mFormat
which is a `const Format&` so that garbage format values can be
reflected correctly for error textures.

Bug: dawn:1451
Change-Id: I75b5635f36647f6f04dae54e92154f2b552beb64
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92661
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-06-08 18:14:02 +00:00
dan sinclair 41e4d9a34c Consistent formatting for Dawn/Tint.
This CL updates the clang format files to have a single shared format
between Dawn and Tint. The major changes are tabs are 4 spaces, lines
are 100 columns and namespaces are not indented.

Bug: dawn:1339
Change-Id: I4208742c95643998d9fd14e77a9cc558071ded39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87603
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-01 14:40:55 +00:00
dan sinclair b02535557e Fixup build/include_order issues in src/dawn.
This Cl moves the cpp includes to above the project includes fixing up
the build/include_order issues and enabling the lint check.

A couple includes are marked as NOLINT as the c header has to come after
the project header due to setting defines.

Bug: dawn:1339
Change-Id: Ia47499c94fff99106397b83f6c5c7fe100c44a0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86513
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-04-19 20:38:44 +00:00
dan sinclair d0fb4a36ac Convert all dawn includes to use non-system include syntax.
This CL changes several includes which were using the system include
syntax to the local syntax. This causes GN check to verify that the
headers are specified correctly in the dependencies.

Two missing dependencies are added to the BUILD.gn file for the
Dawn tests.

Bug: dawn:1373
Change-Id: I7afd5ab48f4f2e2ddaf1839058c6bbeec2b97fd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-04-19 14:24:04 +00:00
dan sinclair 479dc6b7eb Enable build/header_guard
This CL enables the build/header_guard lint check. The existing headers
which failed the check were updated, missing headers added. An exclusion
file for the generator templates was added as well.

Bug: dawn:1339
Change-Id: If572e460179ad501293d5d6cf01e0ea900daa979
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86207
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-04-11 18:30:50 +00:00
Loko Kung a9386f3060 Fixes popErrorScope to match the specs.
- Prepares for removal of unnecessary bool return, and just call callbacks appropriately. For now always returns true until all users are updated.
- Removes PushErrorScope from handwritten commands now that we no longer need to do anything special.
- Updates tests to reflect the change and make sure to set EXPECTs before calling functions to make tests easier to follow.

Bug: dawn:1324, dawn:526
Change-Id: I90b09c54f9adbf2d6d50ad20dcedf68b5ed0b1fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/83942
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-03-22 14:45:34 +00:00
Ben Clayton 20cbe6d9e8 tint->dawn: Move src/dawn_wire -> src/dawn/wire
Bug: dawn:1275
Change-Id: I56535bf4d387c4bd423140705ea70812be073eac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79081
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-02-04 12:51:25 +00:00