Commit Graph

27 Commits

Author SHA1 Message Date
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 c9a1f6a595 Fix copyright issues in src/include forwarding headers.
This CL adds the missing copyrights in the forwarding headers.

Bug: tint:1339
Change-Id: I9806d7ef8124a8e0e9a1fbc3452e1946f75d3fb7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86363
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-04-12 06:59:11 +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
Ben Clayton 818001d32e tint->dawn: Move src/dawn_native -> src/dawn/native
Bug: dawn:1275
Change-Id: Ic60a00107a015bc677ff929c492f1085ffc38482
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79083
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-04 17:07:46 +00:00
Corentin Wallez ec9cf2a85c Rename namespace dawn_native to dawn::native.
But keep a namespace alias to avoid breaking project that depend on the
previous namespace name while they get updated.

Done with through the following steps:

 - git grep -l dawn_native:: | xargs sed -i "" "s/dawn_native::/dawn::native::/g"
 - git grep -l "namespace dawn_native" | xargs sed -i "" "s/namespace dawn_native/namespace dawn::native/g"
 - git cl format
 - Manual fixups in generator/templates (and the addition of
   namespace_case in dawn_json_generator.py).
 - The addition of the namespace alias in DawnNative.h

Bug: dawn:824
Change-Id: I676cc4e3ced2e0e4bab32a0d66d7eaf9537e3f09
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75982
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-01-12 09:17:35 +00:00
Corentin Wallez 7f8fa04edc Use C++17 nested namespaces instead of manually nesting them.
This was done with these two commands and a couple manual fixups for
namespaces that had more than one space in the comment in the closing
brace, as well as vulkan_platform.h

git grep -l "namespace .* { namespace " | xargs sed -i "" "s/namespace \(.*\) { namespace /namespace \1::/"
git grep -l "}}  // namespace" | xargs sed -i "" "s%}}  // namespace%}  // namespace%"

Bug: dawn:824
Change-Id: I6f448b820c12fc1004ea5270bf8e1f466b0c0aab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75400
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-06 09:22:17 +00:00
Austin Eng 58c655b6b3 Complete per-backend AdapterDiscoveryOptions
D3D12, OpenGL, and OpenGLES have their own backend-specific
AdapterDiscoveryOptions. Add the same for Vulkan and Metal so we can
selectively discover just Vulkan or Metal adapters.

The Vulkan options include a boolean forceSwiftShader to force
Dawn to discover only SwiftShader on the Vulkan backend.

Also, refactor D3D12's DiscoverDefaultAdapters to simply call
DiscoverAdapters to match the other backends.

Bug: chromium:1266550
Change-Id: I137f94b40084b2d0ddeda39b6b7ef20f033d8a4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/69522
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2021-12-06 20:58:56 +00:00
Corentin Wallez c6d3a840da Replace reinterpret_cast with FromAPI/ToAPI where possible
This brings more type safety to the code and is marginally more
readable.

Bug: None
Change-Id: I0330a8a8e95cd9b8b531af266acd8fdc50c50460
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71606
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-12-03 16:47:18 +00:00
Corentin Wallez bd04e15890 Remove deprecated APIs
Bug: None
Change-Id: I77ac6660318bef1f9a245b3aee06a8e89a67e518
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64540
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-09-17 16:05:40 +00:00
Austin Eng 0b29732cd8 Pass the old/new VkImageLayouts to Vulkan image import/export
Returning the layouts from an export operation and then using
them in a subsequent import operation allows the import to preserve
the texture contents.

This fixes Vukan image wrapping on some AMD/NVIDIA devices.

Bug: dawn:200
Change-Id: Icbb6e759856d410bb69724b9f439bc3088756d19
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28380
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-09-22 20:10:46 +00:00
Kai Ninomiya 6328356129 Autoformat everything except tests/examples
Done by:
- Appending an extra newline at the end of src/**/*.{cpp,h,mm,gn}
  except src/tests/*
- Running git cl format --full to format the full contents of every
  changed file

Bug: none
Change-Id: Id88fc5ed0c5efbbc93b2c6a305c2f98465fe646d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-10 18:19:38 +00:00
Austin Eng 65ee6497d6 Fix VulkanImageWrappingUsageTests.ClearImageAcrossDevicesAliased
In Vulkan, importing memory by file descriptor takes ownership of
the file descriptor. It is necessary to dup it in
ClearImageAcrossDevicesAliased because the texture is imported
twice. This fixes these tests on SwiftShader.

Bug: dawn:417
Change-Id: I08b6464c4b8bd31f738037678e29fd6d066e7888
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22020
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-05-22 00:23:39 +00:00
Natasha Lee 6f92b9160b Also use ExternalImageDescriptor in D3D12 and Metal Backends
Bug: chromium:1036080
Change-Id: I358b0441c168ca075b09ab028c2f6d9df2a44d59
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16240
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2020-03-02 22:27:46 +00:00
Kai Ninomiya f44a809f9a Remove VK_DEFINE_NON_DISPATCHABLE_HANDLE magic, use explicit VkHandle wrapper
Overriding VK_DEFINE_NON_DISPATCHABLE_HANDLE changes the function
signatures of Vulkan functions, changing their ABI and making us
incompatible with real drivers. This removes that magic, and replaces it
with an explicit wrapper, VkHandle, which has much of the same
functionality as the original VkNonDispatchableHandle.

It adds definitions for dawn_native::vulkan::VkBuffer et al, which
shadow the native ::VkBuffer et al. This retains type safety throughout
the Vulkan backend without changing every single usage.

Notably, the following things had to change:
- An explicit conversion from VkBuffer* to ::VkBuffer* is needed for
  arrays. This is implemented as a reinterpret_cast, which is still
  safe as the new VkHandle still has the same memory layout properties
  as VkNonDispatchableHandle did.
- When pointing to a VkHandle as an output pointer, it's now necessary
  to explicitly get the native ::VkBuffer (via operator*) and point to
  it.

Previously reviewed on:
https://dawn-review.googlesource.com/c/dawn/+/15580

Bug: chromium:1046362
Change-Id: I7d34ec38a805025f92165ea9a7ee07ae5c182076
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15641
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-01-31 04:04:16 +00:00
Kai Ninomiya f28d0ae614 Revert "Remove VK_DEFINE_NON_DISPATCHABLE_HANDLE magic, use explicit VkHandle wrapper"
This reverts commit 4e17d5c248.

Reason for revert: broken on chromeos

Original change's description:
> Remove VK_DEFINE_NON_DISPATCHABLE_HANDLE magic, use explicit VkHandle wrapper
> 
> Overriding VK_DEFINE_NON_DISPATCHABLE_HANDLE changes the function
> signatures of Vulkan functions, changing their ABI and making us
> incompatible with real drivers. This removes that magic, and replaces it
> with an explicit wrapper, VkHandle, which has much of the same
> functionality as the original VkNonDispatchableHandle.
> 
> It adds definitions for dawn_native::vulkan::VkBuffer et al, which
> shadow the native ::VkBuffer et al. This retains type safety throughout
> the Vulkan backend without changing every single usage.
> 
> Notably, the following things had to change:
> - An explicit conversion from VkBuffer* to ::VkBuffer* is needed for
>   arrays. This is implemented as a reinterpret_cast, which is still
>   safe as the new VkHandle still has the same memory layout properties
>   as VkNonDispatchableHandle did.
> - When pointing to a VkHandle as an output pointer, it's now necessary
>   to explicitly get the native ::VkBuffer (via operator*) and point to it.
> 
> Bug: chromium:1046362
> Change-Id: I9c5691b6e295aca1b46d4e3d0203956e4d570285
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15580
> Reviewed-by: Austin Eng <enga@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Commit-Queue: Kai Ninomiya <kainino@chromium.org>

TBR=cwallez@chromium.org,kainino@chromium.org,enga@chromium.org

Change-Id: I500df2e34fd0f245ad04c517ff028ddd7bb5a2bf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1046362
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15620
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-01-31 02:09:06 +00:00
Kai Ninomiya 4e17d5c248 Remove VK_DEFINE_NON_DISPATCHABLE_HANDLE magic, use explicit VkHandle wrapper
Overriding VK_DEFINE_NON_DISPATCHABLE_HANDLE changes the function
signatures of Vulkan functions, changing their ABI and making us
incompatible with real drivers. This removes that magic, and replaces it
with an explicit wrapper, VkHandle, which has much of the same
functionality as the original VkNonDispatchableHandle.

It adds definitions for dawn_native::vulkan::VkBuffer et al, which
shadow the native ::VkBuffer et al. This retains type safety throughout
the Vulkan backend without changing every single usage.

Notably, the following things had to change:
- An explicit conversion from VkBuffer* to ::VkBuffer* is needed for
  arrays. This is implemented as a reinterpret_cast, which is still
  safe as the new VkHandle still has the same memory layout properties
  as VkNonDispatchableHandle did.
- When pointing to a VkHandle as an output pointer, it's now necessary
  to explicitly get the native ::VkBuffer (via operator*) and point to it.

Bug: chromium:1046362
Change-Id: I9c5691b6e295aca1b46d4e3d0203956e4d570285
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15580
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-01-31 01:30:56 +00:00
Brian Ho e568fe138e Remove WrapVulkanImageOpaqueFD
This CL removes the deprecated WrapVulkanImageOpaqueFD now that it
no longer being called in Chromium [1].

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1931145

BUG=chromium:996470

Change-Id: I19a7ff36e39b5ed07c68f422cd053f480a7c177e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
2019-11-22 21:00:43 +00:00
Corentin Wallez 3f195e7d42 Fix link in standalone on Linux
There were some missing DAWN_NATIVE_EXPORT arributes for new structures
in VulkanBackend.h which resulted in linking errors.

BUG=chromium:996470

Change-Id: I45deb56faf5fd77ecfa96ebda99d31d0109d98ec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13900
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-21 18:54:42 +00:00
Brian Ho 98ba76af00 Define an interface to import dma-bufs
This CL adds an API to import a dma-buf into Dawn as a WGPUTexture.

We also add a descriptor type enum to the base
ExternalImageDescriptor struct. This is because all memory import
code (e.g. MemoryService, Texture::CreateFromExternal) takes the
a base ExternalImageDescriptor as a parameter. The dma-buf external
memory and image services, however, will need to downcast to
ExternalImageDescriptorDmaBuf to access import parameters like
stride. Explicitly adding a type enum will let us more safely verify
the type before downcasting.

BUG=chromium:996470

Change-Id: I2d9883a15e9059a91f2c7bdb7a96d74373e18c56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13782
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
2019-11-20 23:57:03 +00:00
Austin Eng fb03935bed Add a GetInstanceProcAddr helper for the native Vulkan backend.
This is a helper to allow a Dawn embedder to look up the Vulkan device
functions.  Possibly remove when we design a cleaner way to share function
pointers.

Change-Id: I3ed92568e543c1aad9e0e64d72ad0990824640cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12980
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-01 01:10:09 +00:00
Corentin Wallez 9f90c8d3ca Make dawn_native public headers and dawn_wsi use webgpu.h
BUG=dawn:22

Change-Id: I112d71323c9305fa0997d251556fe0a41dafed29
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12701
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-24 23:55:37 +00:00
Idan Raiter 74e4834d3d Add wrapping for using external vulkan images as textures
This change adds platform-dependent services that handle creating
semaphores and importing image memory. Then, we use them to wrap a
texture from an outside source, and release a signal semaphore back
when we're done with it. This will be used to allow chrome to render
dawn on Vulkan platforms.

Bug: chromium:976495
Change-Id: I9f07eaf436e10aa6bd88cffdc74fd23834d62ee0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8340
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-10 03:17:52 +00:00
Austin Eng 45f9730855 Capitalize C types dawn -> Dawn
This is to match Chromium style.

Change-Id: Ic97cc03e2291c653ade9662ba3d5e629872b10ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5482
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-03-11 16:52:42 +00:00
Corentin Wallez d1be0e7077 Vulkan: Implement the backend connection and adapter.
This also changes VulkanInfo to gather info on backends / adapters
instead of the device, because all the info gathering can happen before
the device is created.

BUG=dawn:29

Change-Id: I9dc4412f494428f1ae589544d3adf76fe8b9a3a3
Reviewed-on: https://dawn-review.googlesource.com/c/3941
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-04 09:31:09 +00:00
Corentin Wallez 7c0f0fbf91 Vulkan: Always request all VkSurfaceKHR-related extensions
The backend had a "requiredInstanceExtensions" parameter to device
creation so that we could request the right instance extensions to
support swapchains. When we have dawn_native::Instance we don't want to
require this information before we can use the Vulkan backend. Instead
we make the backend always require all VkSurfaceKHR extensions. This
should be safe because these extensions basically enable copying a
struct into an opaque VkSurfaceKHR object and not much else.

BUG=dawn:29

Change-Id: I7fc5426f5770b65bb35f02793a1319eb0653782c
Reviewed-on: https://dawn-review.googlesource.com/c/3662
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-07 12:04:46 +00:00
Corentin Wallez dcb71a131c dawn_native: Factor getting procs into a single function.
Now the backends only expose the creation of devices. Getting the procs
is moved to DawnNative that will over time more backend-agnostic APIs.
2018-08-06 16:38:33 +02:00
Corentin Wallez 196ade667f Make libdawn_native a shared library.
The interface exposed by libdawn_native is declared in the new headers
living in src/include/dawn_native so that they both the users and the
libraries use the DAWN_NATIVE_EXPORT macros.
2018-07-27 12:56:26 +02:00