Commit Graph

112 Commits

Author SHA1 Message Date
Corentin Wallez a48ba981ea Remove dawn_wsi.h
Bug: dawn:269
Change-Id: Ie1fb1a8109ff646b880c3e27762300167776d050
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126424
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-07 13:33:26 +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
dan sinclair 39d4065653 Move BindingRemapper and MultiplanarExternalTexture to a backend transform.
In most backends, MultiplanarExternalTexture must run before the
BindingRemapper. The exception is the Vulkan SPIR-V backend where
it has to run before Multiplanar. This CL moves both of the transforms
to backend transforms and sets up the ordering as needed in the
generators.

Bug: tint:1855 chromium:1421379
Change-Id: I8223bce40babe901fe08bb1e8f033243837d7b18
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-15 13:41:46 +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
dan sinclair 1f6ce67ed2 Move `clamp_frag_depth` transformer to backend.
This CL moves the `clamp_frag_depth` transform to be controlled by the
SPIR-V backend.

Bug: tint:1855 chromium:1421379
Change-Id: Ia439d812d4baf35d4d4955595938a2bd5e647167
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123560
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-14 16:33:55 +00:00
dan sinclair eebbdef81a Split `BindingPoint` out of MultiplanarExternalTexture.
This CL moves the `using` statement for `BindingPoint` out to its own
file in `src/tint/writer/binding_point.h`. Usages of
`tint::transform::BindingPoint` have been updated to
`tint::writer::BindingPoint`.

Bug: tint:1855
Change-Id: Ife7d92807e0a65b93f21158d73a60d5068fc5da9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123000
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-08 02:48:42 +00:00
dan sinclair 64196ad60a Add array length options header to `tint.h`.
The `array_length_from_uniform_options.h` is being included directly by
Dawn. This CL moves the include to the `tint.h` file and has the dawn
usage include that instead.

Change-Id: Iaa77d76bc62fe5038f5b6b93d51478ceed85ac9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122781
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-07 16:51:01 +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
Ben Clayton f7910f5b95 tint.h: Remove 'libspirv.hpp' include
This does not belong in the public header - the spirv writer public header does not depend on it.

Change-Id: Id1b2107c3a2003632e1868c2d6a337ddbb0c8b48
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122382
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2023-03-03 14:20:53 +00:00
Ben Clayton 03de0e83ae Move tint::transform::Robustness to a santizier transform
There's no good reason for this to be public.
Move it into the writers, and expose a 'disable_robustness' option to
turn it off. This can be expanded to hold more fine-grain control in the
future.

Change-Id: I6ea6e54a27b2ae0fbcba5fdf45539063045cc15a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122203
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-02 20:48:48 +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
Corentin Wallez 40358fde0b Make EnumClassBitmask's BoolConvertible constructor explicit.
The implicit constructor seemed to confuse MSVC 14.29 when it tries to
find overloads of == or != with bitmasks. It didn't help fix compilation
but at least it's cleaner.

Bug: None
Change-Id: I40d9f831701113d021fc40862657a28f359d1ced
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117887
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Corentin Wallez <cwallez@chromium.org>
2023-01-30 13:51:32 +00:00
Jiawei Shao f7beb85fd1 Count the line pos, offset and size of compilation message in UTF-16
This patch counts the line position, offset and size of the compilation
message in UTF-16 and saves them to WGPUCompilationMessage to align the
latest WebGPU SPEC.

Bug: dawn:1357
Change-Id: If8f4026bd5b4a64a078e100762b6d1f61da50053
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115640
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-01-10 00:03:24 +00:00
Corentin Wallez 8e68a89cfb Vulkan: Clamp @builtin(frag_depth) with push constant values
Start using Tint's ClampFragDepth transform in the Vulkan backend when
needed in order to correctly clamp @builtin(frag_depth) on Vulkan. Do
this by always reserving 8 bytes of push constant space to contain the
f32 min and max values from the last viewport command.

Reenables relevant CTS tests that were suppressed on Vulkan.

Bug: dawn:1125, dawn:1576, dawn:1616
Change-Id: I38f4f6c3c51c99b5e591a780fea9859537529534
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105642
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-01-05 12:24:52 +00:00
dan sinclair 837b8042d3 Rename TypeManager to Manager.
With the move to the type:: hierarchy rename type::TypeManager to
type::Manager.

Bug: tint:1718
Change-Id: I1c8e2c2e469e20b959676232e9f3d62c9b3a789e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113429
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-12-09 05:00:07 +00:00
dan sinclair c9949ac59e Move type_manager to type/ folder
This CL moves the type_manager from sem to type and updates the
namespace as needed.

Bug: tint:1718
Change-Id: I1fe0c2be08146221e68a9d2e7450283d102afdfa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113280
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-12-08 12:03:53 +00:00
Austin Eng c982cd45c4 Use TINT_REFLECT for OverrideId
Adds tint_public_config to Dawn's internal config so Tint headers
can be included.

Fixed: dawn:1594
Change-Id: I4068fd95b6eae3138fbcc04f29f054c7cffdcf12
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111260
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
2022-11-22 22:23:55 +00:00
Ben Clayton 0d2aedf097 Run ./tools/format
Change-Id: I4a9f375f5c383d02917c2ade4c83c3d4fc458165
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110102
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-18 11:57:37 +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
Loko Kung a4314fabb4 Minor build/include fixes for google3 roll.
Change-Id: I2f9ba7f98acdf9441d80d3a1169b36bee44a2e0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108545
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-11-04 01:44:43 +00:00
Ben Clayton 8fa6c25b78 tint: Add Initialize() / Shutdown() public APIs
Have Initialize() bind the Program printer - which is helpful for debugging.
Call these from dawn/node.

This allows dawn/node to print programs when things go wrong.

Change-Id: I32d8805381d2939e82dc6ea383b9860fbb5fb69e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107684
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-11-03 19:16:26 +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
Antonio Maiorano e14a27bc7f tint: remove LoopToForLoop and FoldTrivialSingleUseLets transforms for HLSL and GLSL
Change-Id: I18c807b2449dc2842cb9dbfaeba98dae640d2355
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102621
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-09-19 14:05:21 +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
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
Ben Clayton 9a6acc419e tint: Add tint::OverrideId
This is a public API definition of a program-unique override identifier.

Bug: tint:1155
Change-Id: I6e55d43208e72a7a316557a89e2169d1b952f9bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97006
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-27 20:50:40 +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
dan sinclair 256f1116b8 Add transform to substitute overrides with const expressions.
This CL adds a SubstituteOverride transform which will convert
an `override` into a `const`. The transform is provided a map of
(string, double) which matches what the WebGPU API accepts as
data for overrides.

Bug: tint:1582
Change-Id: I6e6bf51b98ce4d4746f8de55128666c36735e585
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96760
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-22 16:05:06 +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
Ben Clayton 8ce7183e68 tint: Remove public include of ast include
ast::PipelineStage is private API. Duplicate the enum for the inspector.
Change-Id: Ib79600d2ef86cc13f409c7c800f98ea42bb3ace4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95943
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-11 17:17:23 +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
Corentin Wallez 3fa3e5667b dawn::wire::client: ReserveTexture: remove defaulting of descriptor
The usages in Chromium have been updated to pass a descriptor.

Bug: dawn:1451
Change-Id: I1f08141759dc7b8e0e805aa8efc9a8db51162876
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94941
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-06-28 15:55:16 +00:00
Loko Kung 7289bca018 Add dawn version hash to cache keys.
Motivation is to simplify cache evicting by reusing the LRU to evict stale entries from older Dawn versions since there isn't already a simple cache busting solution. The dawn version will just be pushed into the cache keys instead so old version entries will eventually be retired.

- Removes the fingerprint from the GetCachingInterface API on DawnNative.
- Adds the "fingerprint", which was just the hash, to the device;s cache key directly instead.

Bug: dawn:549
Change-Id: I573aa03a2bb96dfe044293b1176d3a7746725572
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2022-06-24 23:39:49 +00:00
Corentin Wallez 04f12142bd dawn::wire::client: Make object constructors less barebones.
This uses the variadic template arguments to Client::Make to
pass more data to object constructors and move the copying of data from
descriptors into the constructors.

This required adding a descriptor to the textures created in
ReserveTexture. The descriptor should come from the outside to give the
correct reflection data to textures (for example textures from
GPUCanvasContext). So a descriptor argument is added to ReserveTexture
that currently defaults to nullptr, but will be required once current
uses are updated.

Bug: dawn:1451
Change-Id: I44cbd5718b8d75fdde3ab1321d24f69a8e2486de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93142
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-06-19 20:13:01 +00:00
dan sinclair 369b0b4618 Remove old src/include folder
This CL removes the src/include folder which was used to forward old
header includes to the new include/ location. The various BUILD rules
which referred to these folders are also removed.

Bug: dawn:1275
Change-Id: Ic0bdc8cf900833af25199ee3e41708953c7c1eec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94026
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-18 16:16:11 +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
James Price a4666888a4 tint: Fix include layering violation
Headers exposing functionality from the core Tint library should be
included via include/tint/tint.h.

This fixes the google3 build.

Change-Id: I82a9d0105b3b44fb4c4c89b59e9282290dd49c61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
2022-06-08 15:04:12 +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 6a224fbd52 Remove custom serialization of device properties
Fixed: chromium:1315260
Change-Id: I1b4847289f34034a2a0bb5f5c8405ccf9d8e9c3b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92120
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
2022-05-31 20:07:39 +00:00