Commit Graph

44 Commits

Author SHA1 Message Date
Loko Kung 0edb5204ab Adds AllowUnsafeAPIs toggle and fixes code-paths to use it.
- Note unsafe API paths currently check both AllowUnsafeAPIs and
  DisallowUnsafeAPIs toggle, allowing unsafe APIs if either is set to
  explicitly allow them. This will be removed once users have been
  updated.

Bug: dawn:1685
Change-Id: If322cc6dbe5ac3a02a31956df6fed0f5d3ec8e8f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2023-05-04 21:09:40 +00:00
Brandon Jones 45b44fdb9f Remove DawnDeviceDescriptor code paths
This was listed as deprecated and has been for a while (at least a
year.) No code paths in Dawn make use of it and the few remaining
uses in Chrome are being removed in
https://chromium-review.googlesource.com/c/chromium/src/+/4501347

Bug: dawn:1797
Change-Id: Ifff4e5609e228080361e5d3a20a881eaf811ab6c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131321
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2023-05-04 02:01:52 +00:00
Peng Huang a246d8d3c2 d3d: remove external image related name alias from d3d12 namespace
Bug: dawn:1705
Bug: dawn:1724
Change-Id: Idd62c8f0a4f77ec975161fad7e981efb8326a2a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131220
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-05-03 18:03:27 +00:00
Stephen White fed6b6b35b Turn AdapterBase into a wrapper class.
Change AdapterBase from an alias to PhysicalDeviceBase to a thin
wrapper class holding a ref to a PhysicalDeviceBase. This way,
mutiple AdapterBases can point at the same PhysicalDeviceBase.

For now, InstanceBase wraps all PhysicalDeviceBases discovered by a
backend in a single AdapterBase. In the future, this relationship will
become many-to-one.

Since Devices now maintain a ref on the AdapterBase wrapper (in order to
query toggles, etc), PhysicalDeviceBase::CreateDeviceImpl() now takes
the AdapterBase as an argument, so that the PhysicalDeviceBase knows
which AdapterBase to vend a Device for.

Note that the Toggles also still remain on the PhysicalDeviceBase, to
be moved up to the AdapterBase in a future change.

Bug: dawn:1774
Change-Id: Idef5d24fbd66d8552959230e246e453abddcc736
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131001
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-05-03 01:29:44 +00:00
Stephen White e4877b7e68 Rename AdapterBase -> PhysicalDeviceBase.
AdapterBase will become a (thin) wrapper class in an upcoming patch,
allowing a single PhysicalDeviceBase to be wrapped in multiple AdapterBases,
each with different toggles and flags.

For now, alias AdapterBase to PhysicalDeviceBase.

Design doc: https://docs.google.com/document/d/1Ag3UAD6D1OVt9-MwKltzLefVhwKRdX0RqML2etrYVS4/edit

Change-Id: Ie77e99508be5285b651aa24ccb412bc9ff8b0111
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130300
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-05-01 16:39:04 +00:00
Corentin Wallez 8ddaa51889 Remove dawn::native::ExternalImageDescriptorIOSurface::plane
It is no longer used anywhere.

Bug: None
Change-Id: Ife3fa9470f3059efe34e29aa96adb2922ce91ebc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129580
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-05-01 09:01:27 +00:00
Peng Huang d7a4483148 d3d: move some external image related code to d3d namespace
Expect ExternalImageDXGIImpl, most external image related code can
be shared between d3d11 and d3d12. This CL move those code into
d3d namespace

Bug: dawn:1724
Change-Id: I6c32cfd36880d4d009b272886a9369dc99dffbe6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130100
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-04-28 16:53:28 +00:00
Sunny Sachanandani 1ff6a0c25b d3d12: Remove deprecated useFenceSynchronization param
After https://chromium-review.googlesource.com/c/chromium/src/+/4483506,
Chromium has stopped using the deprecated useFenceSynchronization param.

Bug: dawn:1612
Change-Id: I5748000d947c1665606b0d0b145f7f5f86786441
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129900
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-28 00:33:31 +00:00
Sunny Sachanandani c820dcc53e d3d12: Remove keyed mutex support
Keyed mutex support was deprecated and the only known client using it,
Chromium, has migrated to fences. Remove all related keyed mutex related
code and tests. The useFenceSynchronization field is still present in
the external image descriptor since it's set by Chromium (to true) -
it'll be removed once Chromium stops setting it.

Bug: dawn:1612
Change-Id: Iaec3c16b18bb8ddbde55a7f54eaf4b944d0f06c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129300
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-04-27 14:46:56 +00:00
Corentin Wallez 961f7eae70 Remove all NativeSwapChain*
These were helpers to avoid the need for users of implementation-based
swapchains to implement them themselves. They are no longer used and can
be removed.

Also removes SwapChainuUtils.h that's no longer used.

Bug: dawn:269
Change-Id: I3c563edaf107e9ce04f708e8bacae9d231b0f40d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126421
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-04-05 07:24:44 +00:00
Peng Huang ebfd505d29 d3d11: implement Adaptor, Backend, etc
This CL also moves some comman code in d3d12::Adapter and
d3d11::Backend to d3d::Adapter and d3d::Backend, so it can be
shared with d3d11 backend.

Bug: dawn:1705
Change-Id: Ica3bf33232d3380b7d4799c77bf9b43a8374a66e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-03 21:33:54 +00:00
Le Hoang Quyen 947a7deb99 DawnNative: Add dawn::native::InstanceProcessEvents()
Make this a standalone function instead of a dawn::native::Instance's
member method.

Some code base don't use dawn::native::Instance but instead use
wgpu::Instance. And InstanceProcessEvents() function actually returns
a bool unlike wgpu::Instance::ProcessEvents() which returns void.

Bug: dawn:752
Change-Id: Ia354a4ed5b5568ee23bcc70935c104059a9f6fc8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125660
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-03-29 07:06:18 +00:00
Le Hoang Quyen 69e1c4b638 DawnNative: implement Instance::ProcessEvents
Since https://dawn-review.googlesource.com/c/dawn/+/120940, callbacks
will be deferred to be executed in next device.APITick() instead of
immediately.
However, if the device is already destroyed (last ref dropped),
user/wire_server has no chance to call device.APITick() anymore, leading
to the callbacks waiting in queue forever.

This is also possibly the cause of memory leaks in cluserfuzz tests.

This CL attempt to fix it by implementing Instance::ProcessEvents():
In this method, every created device will invoke APITick() even if it is
already lost/externally released.

bug: chromium:1422507
bug: dawn:752
Change-Id: Iec69ad3b547a7e88c6e1a2225b13ad060a501a4f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123420
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-14 19:03:10 +00:00
Zhaoming Jiang c2657b21d5 Dawn: Promote DisallowUnsafeAPIs as instance toggle
This CL add Instance and Adapter toggle stage, and promote
DisallowUnsafeAPIs as an instance toggle, and can be required using
DawnTogglesDescriptor chained in instance descriptor when creating
instance. The instance's toggles state will get inherited to adapters
and devices it create. Related tests are implemented and updated.

Toggles inheritance can be overriden if not forced, so requiring
DisallowUnsafeAPIs when creating device is still available and working
like before.

Note that currently we don't have toggle of adapter stage, and can not
require toggles when creating adapter, until follow up CLs implement it.
Currently the toggles state of a adapter is simply inherited from
instance.

Bug: dawn:1495
Change-Id: I6bf7aa0f950a99451afcc2cab5322c924b7d9520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122021
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-03-07 02:03:54 +00:00
Austin Eng 20881f39e7 Add basic Adapter blocklist
Adds a basic adapter blocklist and adds two cases to it.

By default, the blocklist is disabled until Chromium can enable it
explicitly - perhaps based on --enable-unsafe-webgpu or some other
flag. It will be switched to default to true in the future.

about://gpu would disable the blocklist so all the adapters are
visible there, but WebGPU would enable it. Trusted users of Dawn
that are aware of potential bugs may also disable it.
One downside is that about://gpu won't surface directly that an
adapter is on the system, but blocklisted for WebGPU. Something
like that can be added in the future, if necessary.

In the future, this should probably be merged with Chromium's
software_rendering_list.json, but that list doesn't support
multi-adapter systems well (for blocklisting just one adapter),
and it doesn't understand all the information we need for the
current blocklist.

Bug: dawn:1254, dawn:1196, tint:1753
Change-Id: I992bcd10dd5d3f5b23319fc4ec699b06bb1117da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119061
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-13 17:10:44 +00:00
Zhaoming Jiang 63b777b552 Dawn: Refactor device toggles
This CL refactor the logic adapter creating device toggles set when
creating device and the way device holding its toggles. This CL also
introduce the concept "toggle stage", currently "device stage" only but
in future will add "instance stage" and "adapter stage" for instance and
adapter toggles. No changes on Dawn API.
More details:
1. Introduce `TogglesState` objects that represent the complete toggles
   state of a device (and will used for instance and adapter in future).
2. When creating a device, adapter set up a TogglesState object for it
   in `AdapterBase::CreateDeviceInternal` and
   `Adapter::SetupBackendDeviceToggles`, no other place would change
   the device's toggles state. This change simplify the logic.
3. Introduce the `ToggleStage` enum for every toggle and `TogglesState`
   object. Currently we only have `Device` toggle stage, but in future
   will have `Instance` and `Adapter` for instance and adapter toggles.

Bug: dawn:1495
Change-Id: Ifafac6a6a075b5b9a733159574ae5b6d4f3ebde9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118030
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2023-02-10 01:43:55 +00:00
Austin Eng 270c044100 Metal: Implement begin/end access synchronization with MTLSharedEvent
Bug: b/252731382
Change-Id: Ie2bf978c10dcb7b2c03a2c7ff81ddd8b9b77ac20
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106760
Reviewed-by: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-11-04 22:06:20 +00:00
Austin Eng 663932d741 vulkan: Validate that exporting a texture uses VK_IMAGE_LAYOUT_UNDEFINED
Using any other desiredLayout is deprecated. This simplifies future
changes which as much as possible eliminate any transitions during
texture export.

Bug: chromium:1359106
Change-Id: Ifb5818775e8f15ec77a229d3cbf593348740da46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104543
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-10-04 17:27:21 +00:00
Corentin Wallez 324e446f9c Vulkan: Add support for using dedicated allocation when importing images.
This is required to make importing images work on some systems. The
ideal version would be detecting whether dedicated allocations are
needed as Vulkan provides reflection for that. However this reflection
doesn't work on Nvidia, so instead Dawn requires a
NeedsDedicatedAllocation enum on import that's Yes/No/Detect so the
application can force use of a specific code path.

Support for this enum and toggling dedicated allocations on/off is added
for all external memory service implementations.

Vulkan image wrapping tests are modified to add test parameters so that
the Yes/No/Detect code paths are covered by tests.

This is technically post-V1 work, but gl_tests in Chromium fail on
Nvidia workstations without this fix, which makes it hard to debug other
issues.

Bug: dawn:1552, dawn:206, dawn:1260

Change-Id: Iee4f7bb9dbec520432ec623551221ef9e4d3d984
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103560
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-10-03 15:03:52 +00:00
Brandon Jones 7edef20bdd Add AHardwareBuffer support
Initial pass at adding AHardwareBufferSupport so that Dawn can display
content on Android. Confirmed that this will allow many WebGPU pages to
render when paired with
https://chromium-review.googlesource.com/c/chromium/src/+/3877262

Bug: dawn:286
Change-Id: I627fa2ab71f85bd3cb7ea21b0588dbd2089cdf5f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101460
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-08 23:03:28 +00:00
Zhaoming Jiang 7ca82ac4d0 dawn: Refactor device creation and add shader-f16 feature
This CL modifies the way adapter creating devices, adds `shader-f16`
feature, and deprecates the `dawn-shader-float16` feature which is no
longer used.
Details:
1. Parse the toggles chained with device descriptor in
`adapter::CreateDeviceInternal`, which are then used to validate
features requirement within `CreateDeviceInternal` and passed to device
constructor as initializer.
2. When creating device, validate features requirement in
`CreateDeviceInternal` with toggles known, make sure to fail the device
creation if a required feature is not supported by adapter or is guarded
by certain toggles which were not enabled/disabled. Feature ShaderF16
and ChromiumExperimentalDp4a are validated in this way. Unittest is
added to check creating devices with toggles-guarded features required.
3. Add `shader-f16` feature, which allow `using f16;` in WGSL code.
End-to-end tests are added to test a trival f16 WGSL shader could be
used if and only if the device has `shader-f16` feature.
4. Deprecate the `dawn-shader-float16` feature, which will be completely
removed after cleaning up Blink code.

Bug: dawn:1510
Change-Id: I6cb2dcbe1ee584fdd6131c62df1ee850b881dbd2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100802
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-09-08 00:11:04 +00:00
Sunny Sachanandani 5881e735f9 d3d12: External image import using multiple wait fences and signal fence
To support concurrent readers on multiple command queues/devices, Dawn
must support importing via wait multiple fences and also export a signal
fence. The previous implementation of using a single fence for waiting
and signaling doesn't work for concurrent reads across queues.

This CL adds support for specifying multiple wait fences for
ExternalImageDXGI via a BeginAccess method that's meant to replace
ProduceTexture. There's also an EndAccess method that returns a signal
fence for the client.

For performance reasons, we use the same fence as the signal fence that
the Device uses internally, and record its value on the texture after
ExecuteCommandLists. Therefore, the CL also makes the Device's internal
fence a shared fence so that we can export it to the client.

This CL also expands the ConcurrentExternalImageReadAccess test so that
it tests fence synchronization across multiple devices. A number of test
helpers also now take an optional device parameter so that we can use
pixel value expectations with secondary devices.

Bug: dawn:576
Change-Id: I6bc86808ede9b5aacf87667106cbd16731a12516
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99746
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-07 19:48:45 +00:00
Austin Eng a09d05c10b Make Adapter and Instance lifetimes more robust
Previously, we would get a use-after-free if you dropped the instance
before an adapter created from it. This CL fixes up the lifetimes
such that Device refs Adapter refs Instance. Instance uses a
cycle-breaking refcount so that it releases internal refs to its
adapters when the last external ref is dropped.

Bug: none
Change-Id: I5304ec86f425247d4c45ca342fda393cc19689e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99820
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-08-20 02:22:41 +00:00
Corentin Wallez a55b686ded Remove unused dawn::native:🤘:GetMetalDevice
Bug: None
Change-Id: I07d4c2f4afce9202619e9def9dd1a214ae0906a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97203
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-07-26 16:28:45 +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
Stephen White 9434949241 GL: implement EGL context creation in Dawn native.
An abstract base class (Device::Context) is used to avoid adding dependencies to Device, with ContextEGL derived from it. This also
leaves open the possibility of supporting other native GL contexts
in the future (e.g., glX). One temporary EGLContext is created by opengl::Backend during Adapter discovery, then one is created for and
owned by each Device.

Contexts for the desktop GL backend are also managed via EGL, which
works for most modern drivers. This also means that GLFW is now
always used in GLFW_NO_API mode.

Since contexts are now per-device, all of the default GL state
setting and debug output setup was moved from Adapter to Device.

Bug: dawn:810
Change-Id: Idfe30939f155d026fcad549787fc167cc43aa3cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93981
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-29 15:29:41 +00:00
Austin Eng 1faf5921c6 Delete WGPUDeviceProperties
This struct is no longer needed now that the adapter exposes
a way to query its features that works both in native and the
wire.

Change-Id: Ib0d865330f65473bb0363858a9284e630da52eb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93340
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-06-13 16:58:27 +00:00
Sunny Sachanandani 7ce85091b9 d3d12: Add support for fences for external images
DXGI external images can now be imported with both fence and texture
shared handles. Fence wait and signal values can be specified for
ProduceTexture. Keyed mutex functionality is kept as is with no change.
The D3D12 resource wrapping tests now run in both keyed mutex and fence
modes.

Bug: dawn:576
Change-Id: Ic793bcc828e5a8850c1367ecffabedd1c67184d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78604
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
2022-06-10 18:47:05 +00:00
Shrek Shao 7e74c21873 DAWN_PLATFORM and DAWN_COMPILER macro improvements
Change #if DAWN_PLATFORM_XXX to #if DAWN_PLATFORM_IS(XXX)
To prevent #ifdef usage and reference without including
dawn/common/Platform.h

Also change #if DAWN_COMPILER_XXX to # if DAWN_COMPILER_IS(XXX)

Bug: dawn:1447
Change-Id: If6c9dab15fd2676f9a087507f5efcceeff468d33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92625
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-06-08 19:52:42 +00:00
jchen10 ad8caa2540 Remove stride in ExternalImageDescriptorDmaBuf
Use planeLayouts instead.

Bug: chromium:1258986
Change-Id: I16c041a8e0b739fa347ea4695988ad1eed82cccc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92202
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-06-02 00:34:30 +00:00
jchen10 238716e833 Explicit vkImage create to wrap video frame
This uses VkImageDrmFormatModifierExplicitCreateInfoEXT instead of
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT to
import mulit-planar external images.
More discussions about this change can be found at this Mesa issue:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/6530

Bug: chromium:1258986

Change-Id: Ifde3d89e7ddf37d6a295c9d7fcc7c762f8da1e81
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91940
Reviewed-by: Jie A Chen <jie.a.chen@intel.com>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-06-01 01:10:29 +00:00
Austin Eng 6b52f9d1d4 Return an error surface if surface creation fails
Fixes an ASSERT checking the created surface is non-null.

Fixed: chromium:1330113
Change-Id: Iebbcd6e69042abea5b424953d78e294a92ce5c82
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-05-31 20:55:39 +00:00
Austin Eng ba2b7fc9b1 Fix multiple device leaks in dawn_end2end_tests and dawn_unittests
Adds ForTesting APIs to the instance to track the number of devices.

Bug: dawn:1164
Change-Id: Ib743afb1e86ef16740d49613f43f9e2f009232bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90583
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-05-18 13:28:21 +00:00
Kai Ninomiya 455f573d09 Reland "[chromium-style] Adding constructors and destructors."
This reverts commit 63cea3f8c0.

...except it skips adding the the constructor/destructor/copy
definitions for dawn::native::Format. Adding them triggers "constexpr
variable cannot have non-literal type" (or "declaration requires a
global constructor" if it's not marked constexpr), unless they're
explicitly marked as =default in the header - which just triggers a
different chromium-style warning, so there's no point.

A better solution to the chromium-style warning on Format may be to just
make the class physically smaller:
https://www.chromium.org/developers/coding-style/chromium-style-checker-errors/#constructordestructor-errors

Bug: dawn:1405
Change-Id: Ied6e9d0abff6bf1330131a40c6583bab18888b67
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90303
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2022-05-17 06:11:42 +00:00
Kai Ninomiya 63cea3f8c0 Revert "[chromium-style] Adding constructors and destructors."
This reverts commit efab8c894e.

Reason for revert: breaks check_static_initializers check in Chromium
https://chromium-review.googlesource.com/c/chromium/src/+/3636809/
due to the line `static Format kUnusedFormat;` in Texture.cpp.

Error: file "Texture.cpp" is not expected to have static initializers in binary "chrome"

# Static initializers in chrome:
# 000101 _Unwind_Resume@plt
# 000101 guard variable for std::__1::ios_base::Init::Init()::init_the_streams
# 000101 std::__1::DoIOSInit::DoIOSInit()
# 000101 std::__1::DoIOSInit::~DoIOSInit()
# 000101 std::__1::ios_base::Init::Init()::init_the_streams
# 000101 __cxa_atexit@plt [registers a dtor to run at exit]
# 000101 __cxa_guard_abort
# 000101 __cxa_guard_acquire
# 000101 __cxa_guard_release
# 000101 __dso_handle
# InstrProfilingRuntime.cpp __llvm_profile_initialize
# Texture.cpp dawn::native::Format::Format()
# Texture.cpp dawn::native::kUnusedFormat
# Texture.cpp __dtor__ZN4dawn6nativeL13kUnusedFormatE
# Texture.cpp atexit
# iostream.cpp: (empty initializer list)
# Found 15 static initializers in 4 files.


Original change's description:
> [chromium-style] Adding constructors and destructors.
>
> This CL adds missing constructors and destructors.
>
> Bug: dawn:1405
> Change-Id: I0a0ea7ca50643d48cfc4a4dcf4ce46ff37ed10ad
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89200
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>

TBR=enga@chromium.org,dsinclair@chromium.org,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I86daffc227c2411e8c2c69cc4683224320f4480c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1405
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89702
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-05-10 23:32:44 +00:00
dan sinclair efab8c894e [chromium-style] Adding constructors and destructors.
This CL adds missing constructors and destructors.

Bug: dawn:1405
Change-Id: I0a0ea7ca50643d48cfc4a4dcf4ce46ff37ed10ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89200
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-05-10 00:14:04 +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
Loko Kung 4091e0fa9c Factor out common cache testing code.
- To be used for pipeline cache testing.
- Plumbs overriding the platform to the adapters for testing.
- Restructures build a little bit so that the test infrastructure can have full access to dawn native internals. Also differentiates end2end and white_box a bit more to make it clear that end2end should not have access to dawn native internals.

Bug: dawn:549, dawn:1374
Change-Id: Ibcc6c44a116c7967ee2317c74409f613e896eb0a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86841
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-04-21 03:14:37 +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 012098a86b Add explicit in include/dawn
This CL adds some explicit notations to single argument constructors in
the include/dawn folder.

Bug: dawn:1339
Change-Id: Ie4e31bf68f920acfcfb27828a465e45fe0977af6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86443
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-04-12 17:43:21 +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
dan sinclair db9db31cab Fixup whitespace/comments issues.
This CL fixes a few tabs to be spaces which makes the whitespace/comments
lint check pass. The check is set to enabled.

Change-Id: I2a6c590aa3bfee888239adc89d1ce4c8c99f3e78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86083
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-04-08 19:23:36 +00:00
Shaobo 0a6c2b0f99 Wrap multiplanar iosurface in wgpuTexture
This CL supports wrapping multiplanar iosurface in wgpuTexture.
It also provides mechanism to create TextureView on each planes.

Bug:1307194

Change-Id: I5e82f47944fdea542abba097240c880628b1181f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81482
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2022-03-28 06:59:22 +00:00
Ben Clayton 9fb7a5146a tint->dawn: Move src/include -> include
Also simplify the target names.

Bug: dawn:1275
Change-Id: I2929b70897f64903b91b693b48c2e8dd7c11d07b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79102
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:18:18 +00:00