summaryrefslogtreecommitdiff
path: root/chromium/third_party/dawn/include
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/third_party/dawn/include
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
downloadqtwebengine-chromium-33fc33aa94d4add0878ec30dc818e34e1dd3cc2a.tar.gz
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/dawn/include')
-rw-r--r--chromium/third_party/dawn/include/dawn/CPPLINT.cfg1
-rw-r--r--chromium/third_party/dawn/include/dawn/EnumClassBitmasks.h231
-rw-r--r--chromium/third_party/dawn/include/dawn/dawn_wsi.h4
-rw-r--r--chromium/third_party/dawn/include/dawn/native/D3D12Backend.h151
-rw-r--r--chromium/third_party/dawn/include/dawn/native/DawnNative.h448
-rw-r--r--chromium/third_party/dawn/include/dawn/native/MetalBackend.h44
-rw-r--r--chromium/third_party/dawn/include/dawn/native/NullBackend.h6
-rw-r--r--chromium/third_party/dawn/include/dawn/native/OpenGLBackend.h45
-rw-r--r--chromium/third_party/dawn/include/dawn/native/VulkanBackend.h204
-rw-r--r--chromium/third_party/dawn/include/dawn/native/dawn_native_export.h30
-rw-r--r--chromium/third_party/dawn/include/dawn/platform/DawnPlatform.h167
-rw-r--r--chromium/third_party/dawn/include/dawn/platform/dawn_platform_export.h30
-rw-r--r--chromium/third_party/dawn/include/dawn/wire/Wire.h73
-rw-r--r--chromium/third_party/dawn/include/dawn/wire/WireClient.h282
-rw-r--r--chromium/third_party/dawn/include/dawn/wire/WireServer.h231
-rw-r--r--chromium/third_party/dawn/include/dawn/wire/dawn_wire_export.h30
-rw-r--r--chromium/third_party/dawn/include/tint/.clang-format2
-rw-r--r--chromium/third_party/dawn/include/tint/tint.h1
-rw-r--r--chromium/third_party/dawn/include/webgpu/webgpu_cpp.h2
19 files changed, 979 insertions, 1003 deletions
diff --git a/chromium/third_party/dawn/include/dawn/CPPLINT.cfg b/chromium/third_party/dawn/include/dawn/CPPLINT.cfg
deleted file mode 100644
index f5c9c6dfc49..00000000000
--- a/chromium/third_party/dawn/include/dawn/CPPLINT.cfg
+++ /dev/null
@@ -1 +0,0 @@
-filter=-runtime/indentation_namespace
diff --git a/chromium/third_party/dawn/include/dawn/EnumClassBitmasks.h b/chromium/third_party/dawn/include/dawn/EnumClassBitmasks.h
index 7bfe4ecc5cb..0dbe09031b9 100644
--- a/chromium/third_party/dawn/include/dawn/EnumClassBitmasks.h
+++ b/chromium/third_party/dawn/include/dawn/EnumClassBitmasks.h
@@ -31,126 +31,117 @@
namespace dawn {
- template <typename T>
- struct IsDawnBitmask {
- static constexpr bool enable = false;
- };
-
- template <typename T, typename Enable = void>
- struct LowerBitmask {
- static constexpr bool enable = false;
- };
-
- template <typename T>
- struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
- static constexpr bool enable = true;
- using type = T;
- constexpr static T Lower(T t) {
- return t;
- }
- };
-
- template <typename T>
- struct BoolConvertible {
- using Integral = typename std::underlying_type<T>::type;
-
- // NOLINTNEXTLINE(runtime/explicit)
- constexpr BoolConvertible(Integral value) : value(value) {
- }
- constexpr operator bool() const {
- return value != 0;
- }
- constexpr operator T() const {
- return static_cast<T>(value);
- }
-
- Integral value;
- };
-
- template <typename T>
- struct LowerBitmask<BoolConvertible<T>> {
- static constexpr bool enable = true;
- using type = T;
- static constexpr type Lower(BoolConvertible<T> t) {
- return t;
- }
- };
-
- template <typename T1,
- typename T2,
- typename = typename std::enable_if<LowerBitmask<T1>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
- static_cast<Integral>(LowerBitmask<T2>::Lower(right));
- }
-
- template <typename T1,
- typename T2,
- typename = typename std::enable_if<LowerBitmask<T1>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
- static_cast<Integral>(LowerBitmask<T2>::Lower(right));
- }
-
- template <typename T1,
- typename T2,
- typename = typename std::enable_if<LowerBitmask<T1>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
- static_cast<Integral>(LowerBitmask<T2>::Lower(right));
- }
-
- template <typename T1>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
- }
-
- template <typename T,
- typename T2,
- typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr T& operator&=(T& l, T2 right) {
- T r = LowerBitmask<T2>::Lower(right);
- l = l & r;
- return l;
- }
-
- template <typename T,
- typename T2,
- typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr T& operator|=(T& l, T2 right) {
- T r = LowerBitmask<T2>::Lower(right);
- l = l | r;
- return l;
- }
-
- template <typename T,
- typename T2,
- typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr T& operator^=(T& l, T2 right) {
- T r = LowerBitmask<T2>::Lower(right);
- l = l ^ r;
- return l;
- }
-
- template <typename T>
- constexpr bool HasZeroOrOneBits(T value) {
- using Integral = typename std::underlying_type<T>::type;
- return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
- }
+template <typename T>
+struct IsDawnBitmask {
+ static constexpr bool enable = false;
+};
+
+template <typename T, typename Enable = void>
+struct LowerBitmask {
+ static constexpr bool enable = false;
+};
+
+template <typename T>
+struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
+ static constexpr bool enable = true;
+ using type = T;
+ constexpr static T Lower(T t) { return t; }
+};
+
+template <typename T>
+struct BoolConvertible {
+ using Integral = typename std::underlying_type<T>::type;
+
+ // NOLINTNEXTLINE(runtime/explicit)
+ constexpr BoolConvertible(Integral value) : value(value) {}
+ constexpr operator bool() const { return value != 0; }
+ constexpr operator T() const { return static_cast<T>(value); }
+
+ Integral value;
+};
+
+template <typename T>
+struct LowerBitmask<BoolConvertible<T>> {
+ static constexpr bool enable = true;
+ using type = T;
+ static constexpr type Lower(BoolConvertible<T> t) { return t; }
+};
+
+template <
+ typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
+constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+}
+
+template <
+ typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
+constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+}
+
+template <
+ typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
+constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+}
+
+template <typename T1>
+constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
+}
+
+template <
+ typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
+constexpr T& operator&=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l & r;
+ return l;
+}
+
+template <
+ typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
+constexpr T& operator|=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l | r;
+ return l;
+}
+
+template <
+ typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
+constexpr T& operator^=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l ^ r;
+ return l;
+}
+
+template <typename T>
+constexpr bool HasZeroOrOneBits(T value) {
+ using Integral = typename std::underlying_type<T>::type;
+ return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
+}
} // namespace dawn
diff --git a/chromium/third_party/dawn/include/dawn/dawn_wsi.h b/chromium/third_party/dawn/include/dawn/dawn_wsi.h
index cf30dffa883..aecb252893f 100644
--- a/chromium/third_party/dawn/include/dawn/dawn_wsi.h
+++ b/chromium/third_party/dawn/include/dawn/dawn_wsi.h
@@ -15,7 +15,7 @@
#ifndef INCLUDE_DAWN_DAWN_WSI_H_
#define INCLUDE_DAWN_DAWN_WSI_H_
-#include <dawn/webgpu.h>
+#include "dawn/webgpu.h"
// Error message (or nullptr if there was no error)
typedef const char* DawnSwapChainError;
@@ -65,7 +65,7 @@ struct DawnWSIContextD3D12 {
#endif
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
-# import <Metal/Metal.h>
+#import <Metal/Metal.h>
struct DawnWSIContextMetal {
id<MTLDevice> device = nil;
diff --git a/chromium/third_party/dawn/include/dawn/native/D3D12Backend.h b/chromium/third_party/dawn/include/dawn/native/D3D12Backend.h
index 99a6c62702c..9f00ff4ce82 100644
--- a/chromium/third_party/dawn/include/dawn/native/D3D12Backend.h
+++ b/chromium/third_party/dawn/include/dawn/native/D3D12Backend.h
@@ -15,9 +15,6 @@
#ifndef INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
#define INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
-#include <dawn/dawn_wsi.h>
-#include <dawn/native/DawnNative.h>
-
#include <DXGI1_4.h>
#include <d3d12.h>
#include <windows.h>
@@ -25,86 +22,84 @@
#include <memory>
+#include "dawn/dawn_wsi.h"
+#include "dawn/native/DawnNative.h"
+
struct ID3D12Device;
struct ID3D12Resource;
namespace dawn::native::d3d12 {
- class D3D11on12ResourceCache;
-
- DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
- DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
- HWND window);
- DAWN_NATIVE_EXPORT WGPUTextureFormat
- GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
-
- enum MemorySegment {
- Local,
- NonLocal,
- };
-
- DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
- uint64_t requestedReservationSize,
- MemorySegment memorySegment);
-
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor {
- public:
- ExternalImageDescriptorDXGISharedHandle();
-
- // Note: SharedHandle must be a handle to a texture object.
- HANDLE sharedHandle;
- };
-
- // Keyed mutex acquire/release uses a fixed key of 0 to match Chromium behavior.
- constexpr UINT64 kDXGIKeyedMutexAcquireReleaseKey = 0;
-
- struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGIKeyedMutex
- : ExternalImageAccessDescriptor {
- public:
- // TODO(chromium:1241533): Remove deprecated keyed mutex params after removing associated
- // code from Chromium - we use a fixed key of 0 for acquire and release everywhere now.
- uint64_t acquireMutexKey;
- uint64_t releaseMutexKey;
- bool isSwapChainTexture = false;
- };
-
- class DAWN_NATIVE_EXPORT ExternalImageDXGI {
- public:
- ~ExternalImageDXGI();
-
- // Note: SharedHandle must be a handle to a texture object.
- static std::unique_ptr<ExternalImageDXGI> Create(
- WGPUDevice device,
- const ExternalImageDescriptorDXGISharedHandle* descriptor);
-
- WGPUTexture ProduceTexture(WGPUDevice device,
- const ExternalImageAccessDescriptorDXGIKeyedMutex* descriptor);
-
- private:
- ExternalImageDXGI(Microsoft::WRL::ComPtr<ID3D12Resource> d3d12Resource,
- const WGPUTextureDescriptor* descriptor);
-
- Microsoft::WRL::ComPtr<ID3D12Resource> mD3D12Resource;
-
- // Contents of WGPUTextureDescriptor are stored individually since the descriptor
- // could outlive this image.
- WGPUTextureUsageFlags mUsage;
- WGPUTextureUsageFlags mUsageInternal = WGPUTextureUsage_None;
- WGPUTextureDimension mDimension;
- WGPUExtent3D mSize;
- WGPUTextureFormat mFormat;
- uint32_t mMipLevelCount;
- uint32_t mSampleCount;
-
- std::unique_ptr<D3D11on12ResourceCache> mD3D11on12ResourceCache;
- };
-
- struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
- AdapterDiscoveryOptions();
- explicit AdapterDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
-
- Microsoft::WRL::ComPtr<IDXGIAdapter> dxgiAdapter;
- };
+class D3D11on12ResourceCache;
+class Device;
+class ExternalImageDXGIImpl;
+
+DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
+DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
+ HWND window);
+DAWN_NATIVE_EXPORT WGPUTextureFormat
+GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
+
+enum MemorySegment {
+ Local,
+ NonLocal,
+};
+
+DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
+ uint64_t requestedReservationSize,
+ MemorySegment memorySegment);
+
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor {
+ public:
+ ExternalImageDescriptorDXGISharedHandle();
+
+ // Note: SharedHandle must be a handle to a texture object.
+ HANDLE sharedHandle;
+};
+
+// Keyed mutex acquire/release uses a fixed key of 0 to match Chromium behavior.
+constexpr UINT64 kDXGIKeyedMutexAcquireReleaseKey = 0;
+
+struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGIKeyedMutex
+ : ExternalImageAccessDescriptor {
+ public:
+ // TODO(chromium:1241533): Remove deprecated keyed mutex params after removing associated
+ // code from Chromium - we use a fixed key of 0 for acquire and release everywhere now.
+ uint64_t acquireMutexKey;
+ uint64_t releaseMutexKey;
+ bool isSwapChainTexture = false;
+};
+
+class DAWN_NATIVE_EXPORT ExternalImageDXGI {
+ public:
+ ~ExternalImageDXGI();
+
+ static std::unique_ptr<ExternalImageDXGI> Create(
+ WGPUDevice device,
+ const ExternalImageDescriptorDXGISharedHandle* descriptor);
+
+ // Returns true if the external image resources are still valid, otherwise ProduceTexture() is
+ // guaranteed to fail e.g. after device destruction.
+ bool IsValid() const;
+
+ // TODO(sunnyps): |device| is ignored - remove after Chromium migrates to single parameter call.
+ WGPUTexture ProduceTexture(WGPUDevice device,
+ const ExternalImageAccessDescriptorDXGIKeyedMutex* descriptor);
+
+ WGPUTexture ProduceTexture(const ExternalImageAccessDescriptorDXGIKeyedMutex* descriptor);
+
+ private:
+ explicit ExternalImageDXGI(std::unique_ptr<ExternalImageDXGIImpl> impl);
+
+ std::unique_ptr<ExternalImageDXGIImpl> mImpl;
+};
+
+struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
+ AdapterDiscoveryOptions();
+ explicit AdapterDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
+
+ Microsoft::WRL::ComPtr<IDXGIAdapter> dxgiAdapter;
+};
} // namespace dawn::native::d3d12
diff --git a/chromium/third_party/dawn/include/dawn/native/DawnNative.h b/chromium/third_party/dawn/include/dawn/native/DawnNative.h
index dc54dedac21..ee01ff245a0 100644
--- a/chromium/third_party/dawn/include/dawn/native/DawnNative.h
+++ b/chromium/third_party/dawn/include/dawn/native/DawnNative.h
@@ -15,244 +15,252 @@
#ifndef INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
#define INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
-#include <dawn/dawn_proc_table.h>
-#include <dawn/native/dawn_native_export.h>
-#include <dawn/webgpu.h>
-
#include <string>
#include <vector>
+#include "dawn/dawn_proc_table.h"
+#include "dawn/native/dawn_native_export.h"
+#include "dawn/webgpu.h"
+
namespace dawn::platform {
- class Platform;
+class Platform;
} // namespace dawn::platform
namespace wgpu {
- struct AdapterProperties;
- struct DeviceDescriptor;
+struct AdapterProperties;
+struct DeviceDescriptor;
} // namespace wgpu
namespace dawn::native {
- class InstanceBase;
- class AdapterBase;
-
- // An optional parameter of Adapter::CreateDevice() to send additional information when creating
- // a Device. For example, we can use it to enable a workaround, optimization or feature.
- struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
- std::vector<const char*> requiredFeatures;
- std::vector<const char*> forceEnabledToggles;
- std::vector<const char*> forceDisabledToggles;
-
- const WGPURequiredLimits* requiredLimits = nullptr;
- };
-
- // A struct to record the information of a toggle. A toggle is a code path in Dawn device that
- // can be manually configured to run or not outside Dawn, including workarounds, special
- // features and optimizations.
- struct ToggleInfo {
- const char* name;
- const char* description;
- const char* url;
- };
-
- // A struct to record the information of a feature. A feature is a GPU feature that is not
- // required to be supported by all Dawn backends and can only be used when it is enabled on the
- // creation of device.
- using FeatureInfo = ToggleInfo;
-
- // An adapter is an object that represent on possibility of creating devices in the system.
- // Most of the time it will represent a combination of a physical GPU and an API. Not that the
- // same GPU can be represented by multiple adapters but on different APIs.
- //
- // The underlying Dawn adapter is owned by the Dawn instance so this class is not RAII but just
- // a reference to an underlying adapter.
- class DAWN_NATIVE_EXPORT Adapter {
- public:
- Adapter();
- // NOLINTNEXTLINE(runtime/explicit)
- Adapter(AdapterBase* impl);
- ~Adapter();
-
- Adapter(const Adapter& other);
- Adapter& operator=(const Adapter& other);
-
- // Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in
- // dawn.json
- void GetProperties(wgpu::AdapterProperties* properties) const;
- void GetProperties(WGPUAdapterProperties* properties) const;
-
- std::vector<const char*> GetSupportedExtensions() const;
- std::vector<const char*> GetSupportedFeatures() const;
- WGPUDeviceProperties GetAdapterProperties() const;
- bool GetLimits(WGPUSupportedLimits* limits) const;
-
- void SetUseTieredLimits(bool useTieredLimits);
-
- // Check that the Adapter is able to support importing external images. This is necessary
- // to implement the swapchain and interop APIs in Chromium.
- bool SupportsExternalImages() const;
-
- explicit operator bool() const;
-
- // Create a device on this adapter. On an error, nullptr is returned.
- WGPUDevice CreateDevice(const DawnDeviceDescriptor* deviceDescriptor);
- WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
- WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
-
- void RequestDevice(const DawnDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
- void RequestDevice(const wgpu::DeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
- void RequestDevice(const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
-
- // Returns the underlying WGPUAdapter object.
- WGPUAdapter Get() const;
-
- // Reset the backend device object for testing purposes.
- void ResetInternalDeviceForTesting();
-
- private:
- AdapterBase* mImpl = nullptr;
- };
-
- // Base class for options passed to Instance::DiscoverAdapters.
- struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase {
- public:
- const WGPUBackendType backendType;
-
- protected:
- explicit AdapterDiscoveryOptionsBase(WGPUBackendType type);
- };
-
- enum BackendValidationLevel { Full, Partial, Disabled };
-
- // Represents a connection to dawn_native and is used for dependency injection, discovering
- // system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
- //
- // This is an RAII class for Dawn instances and also controls the lifetime of all adapters
- // for this instance.
- class DAWN_NATIVE_EXPORT Instance {
- public:
- explicit Instance(const WGPUInstanceDescriptor* desc = nullptr);
- ~Instance();
-
- Instance(const Instance& other) = delete;
- Instance& operator=(const Instance& other) = delete;
-
- // Gather all adapters in the system that can be accessed with no special options. These
- // adapters will later be returned by GetAdapters.
- void DiscoverDefaultAdapters();
-
- // Adds adapters that can be discovered with the options provided (like a getProcAddress).
- // The backend is chosen based on the type of the options used. Returns true on success.
- bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options);
-
- // Returns all the adapters that the instance knows about.
- std::vector<Adapter> GetAdapters() const;
-
- const ToggleInfo* GetToggleInfo(const char* toggleName);
- const FeatureInfo* GetFeatureInfo(WGPUFeatureName feature);
-
- // Enables backend validation layers
- void EnableBackendValidation(bool enableBackendValidation);
- void SetBackendValidationLevel(BackendValidationLevel validationLevel);
-
- // Enable debug capture on Dawn startup
- void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup);
-
- void SetPlatform(dawn::platform::Platform* platform);
-
- // Returns the underlying WGPUInstance object.
- WGPUInstance Get() const;
-
- private:
- InstanceBase* mImpl = nullptr;
- };
-
- // Backend-agnostic API for dawn_native
- DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs();
-
- // Query the names of all the toggles that are enabled in device
- DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
-
- // Backdoor to get the number of lazy clears for testing
- DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
-
- // Backdoor to get the number of deprecation warnings for testing
- DAWN_NATIVE_EXPORT size_t GetDeprecationWarningCountForTesting(WGPUDevice device);
-
- // Query if texture has been initialized
- DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
- WGPUTexture texture,
- uint32_t baseMipLevel,
- uint32_t levelCount,
- uint32_t baseArrayLayer,
- uint32_t layerCount,
- WGPUTextureAspect aspect = WGPUTextureAspect_All);
-
- // Backdoor to get the order of the ProcMap for testing
- DAWN_NATIVE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
-
- DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device);
-
- // ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp
- DAWN_NATIVE_EXPORT void EnableErrorInjector();
- DAWN_NATIVE_EXPORT void DisableErrorInjector();
- DAWN_NATIVE_EXPORT void ClearErrorInjector();
- DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount();
- DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index);
-
- // The different types of external images
- enum ExternalImageType {
- OpaqueFD,
- DmaBuf,
- IOSurface,
- DXGISharedHandle,
- EGLImage,
- };
+class InstanceBase;
+class AdapterBase;
+
+// An optional parameter of Adapter::CreateDevice() to send additional information when creating
+// a Device. For example, we can use it to enable a workaround, optimization or feature.
+struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
+ DawnDeviceDescriptor();
+ ~DawnDeviceDescriptor();
+
+ std::vector<const char*> requiredFeatures;
+ std::vector<const char*> forceEnabledToggles;
+ std::vector<const char*> forceDisabledToggles;
+
+ const WGPURequiredLimits* requiredLimits = nullptr;
+};
+
+// A struct to record the information of a toggle. A toggle is a code path in Dawn device that
+// can be manually configured to run or not outside Dawn, including workarounds, special
+// features and optimizations.
+struct ToggleInfo {
+ const char* name;
+ const char* description;
+ const char* url;
+};
+
+// A struct to record the information of a feature. A feature is a GPU feature that is not
+// required to be supported by all Dawn backends and can only be used when it is enabled on the
+// creation of device.
+using FeatureInfo = ToggleInfo;
+
+// An adapter is an object that represent on possibility of creating devices in the system.
+// Most of the time it will represent a combination of a physical GPU and an API. Not that the
+// same GPU can be represented by multiple adapters but on different APIs.
+//
+// The underlying Dawn adapter is owned by the Dawn instance so this class is not RAII but just
+// a reference to an underlying adapter.
+class DAWN_NATIVE_EXPORT Adapter {
+ public:
+ Adapter();
+ // NOLINTNEXTLINE(runtime/explicit)
+ Adapter(AdapterBase* impl);
+ ~Adapter();
+
+ Adapter(const Adapter& other);
+ Adapter& operator=(const Adapter& other);
+
+ // Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in
+ // dawn.json
+ void GetProperties(wgpu::AdapterProperties* properties) const;
+ void GetProperties(WGPUAdapterProperties* properties) const;
+
+ std::vector<const char*> GetSupportedExtensions() const;
+ std::vector<const char*> GetSupportedFeatures() const;
+ WGPUDeviceProperties GetAdapterProperties() const;
+ bool GetLimits(WGPUSupportedLimits* limits) const;
+
+ void SetUseTieredLimits(bool useTieredLimits);
+
+ // Check that the Adapter is able to support importing external images. This is necessary
+ // to implement the swapchain and interop APIs in Chromium.
+ bool SupportsExternalImages() const;
+
+ explicit operator bool() const;
+
+ // Create a device on this adapter. On an error, nullptr is returned.
+ WGPUDevice CreateDevice(const DawnDeviceDescriptor* deviceDescriptor);
+ WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
+ WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
+
+ void RequestDevice(const DawnDeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata);
+ void RequestDevice(const wgpu::DeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata);
+ void RequestDevice(const WGPUDeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata);
+
+ // Returns the underlying WGPUAdapter object.
+ WGPUAdapter Get() const;
+
+ // Reset the backend device object for testing purposes.
+ void ResetInternalDeviceForTesting();
+
+ private:
+ AdapterBase* mImpl = nullptr;
+};
+
+// Base class for options passed to Instance::DiscoverAdapters.
+struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase {
+ public:
+ const WGPUBackendType backendType;
+
+ protected:
+ explicit AdapterDiscoveryOptionsBase(WGPUBackendType type);
+};
+
+enum BackendValidationLevel { Full, Partial, Disabled };
+
+// Represents a connection to dawn_native and is used for dependency injection, discovering
+// system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
+//
+// This is an RAII class for Dawn instances and also controls the lifetime of all adapters
+// for this instance.
+class DAWN_NATIVE_EXPORT Instance {
+ public:
+ explicit Instance(const WGPUInstanceDescriptor* desc = nullptr);
+ ~Instance();
+
+ Instance(const Instance& other) = delete;
+ Instance& operator=(const Instance& other) = delete;
+
+ // Gather all adapters in the system that can be accessed with no special options. These
+ // adapters will later be returned by GetAdapters.
+ void DiscoverDefaultAdapters();
+
+ // Adds adapters that can be discovered with the options provided (like a getProcAddress).
+ // The backend is chosen based on the type of the options used. Returns true on success.
+ bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options);
+
+ // Returns all the adapters that the instance knows about.
+ std::vector<Adapter> GetAdapters() const;
+
+ const ToggleInfo* GetToggleInfo(const char* toggleName);
+ const FeatureInfo* GetFeatureInfo(WGPUFeatureName feature);
+
+ // Enables backend validation layers
+ void EnableBackendValidation(bool enableBackendValidation);
+ void SetBackendValidationLevel(BackendValidationLevel validationLevel);
+
+ // Enable debug capture on Dawn startup
+ void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup);
+
+ // TODO(dawn:1374) Deprecate this once it is passed via the descriptor.
+ void SetPlatform(dawn::platform::Platform* platform);
+
+ uint64_t GetDeviceCountForTesting() const;
+
+ // Returns the underlying WGPUInstance object.
+ WGPUInstance Get() const;
+
+ private:
+ InstanceBase* mImpl = nullptr;
+};
+
+// Backend-agnostic API for dawn_native
+DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs();
+
+// Query the names of all the toggles that are enabled in device
+DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
+
+// Backdoor to get the number of lazy clears for testing
+DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
+
+// Backdoor to get the number of deprecation warnings for testing
+DAWN_NATIVE_EXPORT size_t GetDeprecationWarningCountForTesting(WGPUDevice device);
+
+// Query if texture has been initialized
+DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
+ WGPUTexture texture,
+ uint32_t baseMipLevel,
+ uint32_t levelCount,
+ uint32_t baseArrayLayer,
+ uint32_t layerCount,
+ WGPUTextureAspect aspect = WGPUTextureAspect_All);
+
+// Backdoor to get the order of the ProcMap for testing
+DAWN_NATIVE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
+
+DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device);
+
+// ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp
+DAWN_NATIVE_EXPORT void EnableErrorInjector();
+DAWN_NATIVE_EXPORT void DisableErrorInjector();
+DAWN_NATIVE_EXPORT void ClearErrorInjector();
+DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount();
+DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index);
+
+// The different types of external images
+enum ExternalImageType {
+ OpaqueFD,
+ DmaBuf,
+ IOSurface,
+ DXGISharedHandle,
+ EGLImage,
+};
+
+// Common properties of external images
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
+ public:
+ const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params
+ bool isInitialized; // Whether the texture is initialized on import
+ ExternalImageType GetType() const;
+
+ protected:
+ explicit ExternalImageDescriptor(ExternalImageType type);
+
+ private:
+ ExternalImageType mType;
+};
+
+struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptor {
+ public:
+ bool isInitialized; // Whether the texture is initialized on import
+ WGPUTextureUsageFlags usage;
+};
- // Common properties of external images
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
- public:
- const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params
- bool isInitialized; // Whether the texture is initialized on import
- ExternalImageType GetType() const;
-
- protected:
- explicit ExternalImageDescriptor(ExternalImageType type);
-
- private:
- ExternalImageType mType;
- };
-
- struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptor {
- public:
- bool isInitialized; // Whether the texture is initialized on import
- WGPUTextureUsageFlags usage;
- };
+struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
+ public:
+ bool isInitialized; // Whether the texture is initialized after export
+ ExternalImageType GetType() const;
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
- public:
- bool isInitialized; // Whether the texture is initialized after export
- ExternalImageType GetType() const;
+ protected:
+ explicit ExternalImageExportInfo(ExternalImageType type);
- protected:
- explicit ExternalImageExportInfo(ExternalImageType type);
+ private:
+ ExternalImageType mType;
+};
- private:
- ExternalImageType mType;
- };
+DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle);
- DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle);
+DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle);
- DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);
+DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);
- DAWN_NATIVE_EXPORT bool BindGroupLayoutBindingsEqualForTesting(WGPUBindGroupLayout a,
- WGPUBindGroupLayout b);
+DAWN_NATIVE_EXPORT bool BindGroupLayoutBindingsEqualForTesting(WGPUBindGroupLayout a,
+ WGPUBindGroupLayout b);
} // namespace dawn::native
diff --git a/chromium/third_party/dawn/include/dawn/native/MetalBackend.h b/chromium/third_party/dawn/include/dawn/native/MetalBackend.h
index dfe71148fc2..20c80484fd6 100644
--- a/chromium/third_party/dawn/include/dawn/native/MetalBackend.h
+++ b/chromium/third_party/dawn/include/dawn/native/MetalBackend.h
@@ -15,8 +15,8 @@
#ifndef INCLUDE_DAWN_NATIVE_METALBACKEND_H_
#define INCLUDE_DAWN_NATIVE_METALBACKEND_H_
-#include <dawn/dawn_wsi.h>
-#include <dawn/native/DawnNative.h>
+#include "dawn/dawn_wsi.h"
+#include "dawn/native/DawnNative.h"
// The specifics of the Metal backend expose types in function signatures that might not be
// available in dependent's minimum supported SDK version. Suppress all availability errors using
@@ -29,41 +29,41 @@ struct __IOSurface;
typedef __IOSurface* IOSurfaceRef;
#ifdef __OBJC__
-# import <Metal/Metal.h>
+#import <Metal/Metal.h>
#endif // __OBJC__
namespace dawn::native::metal {
- struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
- AdapterDiscoveryOptions();
- };
+struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
+ AdapterDiscoveryOptions();
+};
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorIOSurface : ExternalImageDescriptor {
- public:
- ExternalImageDescriptorIOSurface();
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorIOSurface : ExternalImageDescriptor {
+ public:
+ ExternalImageDescriptorIOSurface();
- IOSurfaceRef ioSurface;
+ IOSurfaceRef ioSurface;
- // This has been deprecated.
- uint32_t plane;
- };
+ // This has been deprecated.
+ uint32_t plane;
+};
- DAWN_NATIVE_EXPORT WGPUTexture
- WrapIOSurface(WGPUDevice device, const ExternalImageDescriptorIOSurface* descriptor);
+DAWN_NATIVE_EXPORT WGPUTexture WrapIOSurface(WGPUDevice device,
+ const ExternalImageDescriptorIOSurface* descriptor);
- // When making Metal interop with other APIs, we need to be careful that QueueSubmit doesn't
- // mean that the operations will be visible to other APIs/Metal devices right away. macOS
- // does have a global queue of graphics operations, but the command buffers are inserted there
- // when they are "scheduled". Submitting other operations before the command buffer is
- // scheduled could lead to races in who gets scheduled first and incorrect rendering.
- DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
+// When making Metal interop with other APIs, we need to be careful that QueueSubmit doesn't
+// mean that the operations will be visible to other APIs/Metal devices right away. macOS
+// does have a global queue of graphics operations, but the command buffers are inserted there
+// when they are "scheduled". Submitting other operations before the command buffer is
+// scheduled could lead to races in who gets scheduled first and incorrect rendering.
+DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
} // namespace dawn::native::metal
#ifdef __OBJC__
namespace dawn::native::metal {
- DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(WGPUDevice device);
+DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(WGPUDevice device);
} // namespace dawn::native::metal
#endif // __OBJC__
diff --git a/chromium/third_party/dawn/include/dawn/native/NullBackend.h b/chromium/third_party/dawn/include/dawn/native/NullBackend.h
index 5df866456fa..bfa8a630458 100644
--- a/chromium/third_party/dawn/include/dawn/native/NullBackend.h
+++ b/chromium/third_party/dawn/include/dawn/native/NullBackend.h
@@ -15,11 +15,11 @@
#ifndef INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
#define INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
-#include <dawn/dawn_wsi.h>
-#include <dawn/native/DawnNative.h>
+#include "dawn/dawn_wsi.h"
+#include "dawn/native/DawnNative.h"
namespace dawn::native::null {
- DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl();
+DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl();
} // namespace dawn::native::null
#endif // INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
diff --git a/chromium/third_party/dawn/include/dawn/native/OpenGLBackend.h b/chromium/third_party/dawn/include/dawn/native/OpenGLBackend.h
index 5077a5209ea..bee9daeae94 100644
--- a/chromium/third_party/dawn/include/dawn/native/OpenGLBackend.h
+++ b/chromium/third_party/dawn/include/dawn/native/OpenGLBackend.h
@@ -17,38 +17,39 @@
typedef void* EGLImage;
-#include <dawn/dawn_wsi.h>
-#include <dawn/native/DawnNative.h>
+#include "dawn/dawn_wsi.h"
+#include "dawn/native/DawnNative.h"
namespace dawn::native::opengl {
- struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
- AdapterDiscoveryOptions();
+struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
+ AdapterDiscoveryOptions();
- void* (*getProc)(const char*);
- };
+ void* (*getProc)(const char*);
+};
- struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public AdapterDiscoveryOptionsBase {
- AdapterDiscoveryOptionsES();
+struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public AdapterDiscoveryOptionsBase {
+ AdapterDiscoveryOptionsES();
- void* (*getProc)(const char*);
- };
+ void* (*getProc)(const char*);
+};
- using PresentCallback = void (*)(void*);
- DAWN_NATIVE_EXPORT DawnSwapChainImplementation
- CreateNativeSwapChainImpl(WGPUDevice device, PresentCallback present, void* presentUserdata);
- DAWN_NATIVE_EXPORT WGPUTextureFormat
- GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
+using PresentCallback = void (*)(void*);
+DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
+ PresentCallback present,
+ void* presentUserdata);
+DAWN_NATIVE_EXPORT WGPUTextureFormat
+GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor {
- public:
- ExternalImageDescriptorEGLImage();
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor {
+ public:
+ ExternalImageDescriptorEGLImage();
- ::EGLImage image;
- };
+ ::EGLImage image;
+};
- DAWN_NATIVE_EXPORT WGPUTexture
- WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor);
+DAWN_NATIVE_EXPORT WGPUTexture
+WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor);
} // namespace dawn::native::opengl
diff --git a/chromium/third_party/dawn/include/dawn/native/VulkanBackend.h b/chromium/third_party/dawn/include/dawn/native/VulkanBackend.h
index 5bbc00e35e3..9ee41258095 100644
--- a/chromium/third_party/dawn/include/dawn/native/VulkanBackend.h
+++ b/chromium/third_party/dawn/include/dawn/native/VulkanBackend.h
@@ -15,125 +15,133 @@
#ifndef INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_
#define INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_
-#include <dawn/dawn_wsi.h>
-#include <dawn/native/DawnNative.h>
-
#include <vulkan/vulkan.h>
+#include <array>
#include <vector>
+#include "dawn/dawn_wsi.h"
+#include "dawn/native/DawnNative.h"
+
namespace dawn::native::vulkan {
- DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device);
+DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device);
- DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
+DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
- DAWN_NATIVE_EXPORT DawnSwapChainImplementation
- CreateNativeSwapChainImpl(WGPUDevice device, ::VkSurfaceKHR surface);
- DAWN_NATIVE_EXPORT WGPUTextureFormat
- GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
+DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
+ ::VkSurfaceKHR surface);
+DAWN_NATIVE_EXPORT WGPUTextureFormat
+GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
- struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
- AdapterDiscoveryOptions();
+struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
+ AdapterDiscoveryOptions();
- bool forceSwiftShader = false;
- };
+ bool forceSwiftShader = false;
+};
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorVk : ExternalImageDescriptor {
- public:
- // The following members may be ignored if |ExternalImageDescriptor::isInitialized| is false
- // since the import does not need to preserve texture contents.
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorVk : ExternalImageDescriptor {
+ public:
+ // The following members may be ignored if |ExternalImageDescriptor::isInitialized| is false
+ // since the import does not need to preserve texture contents.
- // See https://www.khronos.org/registry/vulkan/specs/1.1/html/chap7.html. The acquire
- // operation old/new layouts must match exactly the layouts in the release operation. So
- // we may need to issue two barriers releasedOldLayout -> releasedNewLayout ->
- // cTextureDescriptor.usage if the new layout is not compatible with the desired usage.
- // The first barrier is the queue transfer, the second is the layout transition to our
- // desired usage.
- VkImageLayout releasedOldLayout = VK_IMAGE_LAYOUT_GENERAL;
- VkImageLayout releasedNewLayout = VK_IMAGE_LAYOUT_GENERAL;
+ // See https://www.khronos.org/registry/vulkan/specs/1.1/html/chap7.html. The acquire
+ // operation old/new layouts must match exactly the layouts in the release operation. So
+ // we may need to issue two barriers releasedOldLayout -> releasedNewLayout ->
+ // cTextureDescriptor.usage if the new layout is not compatible with the desired usage.
+ // The first barrier is the queue transfer, the second is the layout transition to our
+ // desired usage.
+ VkImageLayout releasedOldLayout = VK_IMAGE_LAYOUT_GENERAL;
+ VkImageLayout releasedNewLayout = VK_IMAGE_LAYOUT_GENERAL;
- protected:
- using ExternalImageDescriptor::ExternalImageDescriptor;
- };
+ protected:
+ using ExternalImageDescriptor::ExternalImageDescriptor;
+};
- struct ExternalImageExportInfoVk : ExternalImageExportInfo {
- public:
- // See comments in |ExternalImageDescriptorVk|
- // Contains the old/new layouts used in the queue release operation.
- VkImageLayout releasedOldLayout;
- VkImageLayout releasedNewLayout;
+struct ExternalImageExportInfoVk : ExternalImageExportInfo {
+ public:
+ // See comments in |ExternalImageDescriptorVk|
+ // Contains the old/new layouts used in the queue release operation.
+ VkImageLayout releasedOldLayout;
+ VkImageLayout releasedNewLayout;
- protected:
- using ExternalImageExportInfo::ExternalImageExportInfo;
- };
+ protected:
+ using ExternalImageExportInfo::ExternalImageExportInfo;
+};
-// Can't use DAWN_PLATFORM_LINUX since header included in both Dawn and Chrome
+// Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
#ifdef __linux__
- // Common properties of external images represented by FDs. On successful import the file
- // descriptor's ownership is transferred to the Dawn implementation and they shouldn't be
- // used outside of Dawn again. TODO(enga): Also transfer ownership in the error case so the
- // caller can assume the FD is always consumed.
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorFD : ExternalImageDescriptorVk {
- public:
- int memoryFD; // A file descriptor from an export of the memory of the image
- std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
-
- protected:
- using ExternalImageDescriptorVk::ExternalImageDescriptorVk;
- };
-
- // Descriptor for opaque file descriptor image import
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescriptorFD {
- ExternalImageDescriptorOpaqueFD();
-
- VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation
- uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation
- };
-
- // Descriptor for dma-buf file descriptor image import
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD {
- ExternalImageDescriptorDmaBuf();
-
- uint32_t stride; // Stride of the buffer in bytes
- uint64_t drmModifier; // DRM modifier of the buffer
- };
-
- // Info struct that is written to in |ExportVulkanImage|.
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoFD : ExternalImageExportInfoVk {
- public:
- // Contains the exported semaphore handles.
- std::vector<int> semaphoreHandles;
-
- protected:
- using ExternalImageExportInfoVk::ExternalImageExportInfoVk;
- };
-
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoOpaqueFD : ExternalImageExportInfoFD {
- ExternalImageExportInfoOpaqueFD();
- };
-
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoDmaBuf : ExternalImageExportInfoFD {
- ExternalImageExportInfoDmaBuf();
- };
+// Common properties of external images represented by FDs. On successful import the file
+// descriptor's ownership is transferred to the Dawn implementation and they shouldn't be
+// used outside of Dawn again. TODO(enga): Also transfer ownership in the error case so the
+// caller can assume the FD is always consumed.
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorFD : ExternalImageDescriptorVk {
+ public:
+ int memoryFD; // A file descriptor from an export of the memory of the image
+ std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
+
+ protected:
+ using ExternalImageDescriptorVk::ExternalImageDescriptorVk;
+};
+
+// Descriptor for opaque file descriptor image import
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescriptorFD {
+ ExternalImageDescriptorOpaqueFD();
+
+ VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation
+ uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation
+};
+
+// The plane-wise offset and stride.
+struct DAWN_NATIVE_EXPORT PlaneLayout {
+ uint64_t offset;
+ uint32_t stride;
+};
+
+// Descriptor for dma-buf file descriptor image import
+struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD {
+ ExternalImageDescriptorDmaBuf();
+
+ static constexpr uint32_t kMaxPlanes = 3;
+ std::array<PlaneLayout, kMaxPlanes> planeLayouts;
+ uint64_t drmModifier; // DRM modifier of the buffer
+};
+
+// Info struct that is written to in |ExportVulkanImage|.
+struct DAWN_NATIVE_EXPORT ExternalImageExportInfoFD : ExternalImageExportInfoVk {
+ public:
+ // Contains the exported semaphore handles.
+ std::vector<int> semaphoreHandles;
+
+ protected:
+ using ExternalImageExportInfoVk::ExternalImageExportInfoVk;
+};
+
+struct DAWN_NATIVE_EXPORT ExternalImageExportInfoOpaqueFD : ExternalImageExportInfoFD {
+ ExternalImageExportInfoOpaqueFD();
+};
+
+struct DAWN_NATIVE_EXPORT ExternalImageExportInfoDmaBuf : ExternalImageExportInfoFD {
+ ExternalImageExportInfoDmaBuf();
+};
#endif // __linux__
- // Imports external memory into a Vulkan image. Internally, this uses external memory /
- // semaphore extensions to import the image and wait on the provided synchronizaton
- // primitives before the texture can be used.
- // On failure, returns a nullptr.
- DAWN_NATIVE_EXPORT WGPUTexture WrapVulkanImage(WGPUDevice device,
- const ExternalImageDescriptorVk* descriptor);
-
- // Exports external memory from a Vulkan image. This must be called on wrapped textures
- // before they are destroyed. It writes the semaphore to wait on and the old/new image
- // layouts to |info|. Pass VK_IMAGE_LAYOUT_UNDEFINED as |desiredLayout| if you don't want to
- // perform a layout transition.
- DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture,
- VkImageLayout desiredLayout,
- ExternalImageExportInfoVk* info);
+// Imports external memory into a Vulkan image. Internally, this uses external memory /
+// semaphore extensions to import the image and wait on the provided synchronizaton
+// primitives before the texture can be used.
+// On failure, returns a nullptr.
+DAWN_NATIVE_EXPORT WGPUTexture WrapVulkanImage(WGPUDevice device,
+ const ExternalImageDescriptorVk* descriptor);
+
+// Exports external memory from a Vulkan image. This must be called on wrapped textures
+// before they are destroyed. It writes the semaphore to wait on and the old/new image
+// layouts to |info|. Pass VK_IMAGE_LAYOUT_UNDEFINED as |desiredLayout| if you don't want to
+// perform a layout transition.
+DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture,
+ VkImageLayout desiredLayout,
+ ExternalImageExportInfoVk* info);
} // namespace dawn::native::vulkan
diff --git a/chromium/third_party/dawn/include/dawn/native/dawn_native_export.h b/chromium/third_party/dawn/include/dawn/native/dawn_native_export.h
index 329b1a1d8bd..c23772010b1 100644
--- a/chromium/third_party/dawn/include/dawn/native/dawn_native_export.h
+++ b/chromium/third_party/dawn/include/dawn/native/dawn_native_export.h
@@ -16,21 +16,21 @@
#define INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
#if defined(DAWN_NATIVE_SHARED_LIBRARY)
-# if defined(_WIN32)
-# if defined(DAWN_NATIVE_IMPLEMENTATION)
-# define DAWN_NATIVE_EXPORT __declspec(dllexport)
-# else
-# define DAWN_NATIVE_EXPORT __declspec(dllimport)
-# endif
-# else // defined(_WIN32)
-# if defined(DAWN_NATIVE_IMPLEMENTATION)
-# define DAWN_NATIVE_EXPORT __attribute__((visibility("default")))
-# else
-# define DAWN_NATIVE_EXPORT
-# endif
-# endif // defined(_WIN32)
-#else // defined(DAWN_NATIVE_SHARED_LIBRARY)
-# define DAWN_NATIVE_EXPORT
+#if defined(_WIN32)
+#if defined(DAWN_NATIVE_IMPLEMENTATION)
+#define DAWN_NATIVE_EXPORT __declspec(dllexport)
+#else
+#define DAWN_NATIVE_EXPORT __declspec(dllimport)
+#endif
+#else // defined(_WIN32)
+#if defined(DAWN_NATIVE_IMPLEMENTATION)
+#define DAWN_NATIVE_EXPORT __attribute__((visibility("default")))
+#else
+#define DAWN_NATIVE_EXPORT
+#endif
+#endif // defined(_WIN32)
+#else // defined(DAWN_NATIVE_SHARED_LIBRARY)
+#define DAWN_NATIVE_EXPORT
#endif // defined(DAWN_NATIVE_SHARED_LIBRARY)
#endif // INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
diff --git a/chromium/third_party/dawn/include/dawn/platform/DawnPlatform.h b/chromium/third_party/dawn/include/dawn/platform/DawnPlatform.h
index 1112a88b327..5c616d1bbc2 100644
--- a/chromium/third_party/dawn/include/dawn/platform/DawnPlatform.h
+++ b/chromium/third_party/dawn/include/dawn/platform/DawnPlatform.h
@@ -15,101 +15,94 @@
#ifndef INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
#define INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
-#include <dawn/webgpu.h>
-
#include <cstddef>
#include <cstdint>
#include <memory>
#include "dawn/platform/dawn_platform_export.h"
+#include "dawn/webgpu.h"
namespace dawn::platform {
- enum class TraceCategory {
- General, // General trace events
- Validation, // Dawn validation
- Recording, // Native command recording
- GPUWork, // Actual GPU work
- };
-
- class DAWN_PLATFORM_EXPORT CachingInterface {
- public:
- CachingInterface();
- virtual ~CachingInterface();
-
- // LoadData has two modes. The first mode is used to get a value which
- // corresponds to the |key|. The |valueOut| is a caller provided buffer
- // allocated to the size |valueSize| which is loaded with data of the
- // size returned. The second mode is used to query for the existence of
- // the |key| where |valueOut| is nullptr and |valueSize| must be 0.
- // The return size is non-zero if the |key| exists.
- virtual size_t LoadData(const WGPUDevice device,
- const void* key,
- size_t keySize,
- void* valueOut,
- size_t valueSize) = 0;
-
- // StoreData puts a |value| in the cache which corresponds to the |key|.
- virtual void StoreData(const WGPUDevice device,
- const void* key,
- size_t keySize,
- const void* value,
- size_t valueSize) = 0;
-
- private:
- CachingInterface(const CachingInterface&) = delete;
- CachingInterface& operator=(const CachingInterface&) = delete;
- };
-
- class DAWN_PLATFORM_EXPORT WaitableEvent {
- public:
- WaitableEvent() = default;
- virtual ~WaitableEvent() = default;
- virtual void Wait() = 0; // Wait for completion
- virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
- };
-
- using PostWorkerTaskCallback = void (*)(void* userdata);
-
- class DAWN_PLATFORM_EXPORT WorkerTaskPool {
- public:
- WorkerTaskPool() = default;
- virtual ~WorkerTaskPool() = default;
- virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
- void* userdata) = 0;
- };
-
- class DAWN_PLATFORM_EXPORT Platform {
- public:
- Platform();
- virtual ~Platform();
-
- virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
-
- virtual double MonotonicallyIncreasingTime();
-
- virtual uint64_t AddTraceEvent(char phase,
- const unsigned char* categoryGroupEnabled,
- const char* name,
- uint64_t id,
- double timestamp,
- int numArgs,
- const char** argNames,
- const unsigned char* argTypes,
- const uint64_t* argValues,
- unsigned char flags);
-
- // The |fingerprint| is provided by Dawn to inform the client to discard the Dawn caches
- // when the fingerprint changes. The returned CachingInterface is expected to outlive the
- // device which uses it to persistently cache objects.
- virtual CachingInterface* GetCachingInterface(const void* fingerprint,
- size_t fingerprintSize);
- virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
-
- private:
- Platform(const Platform&) = delete;
- Platform& operator=(const Platform&) = delete;
- };
+enum class TraceCategory {
+ General, // General trace events
+ Validation, // Dawn validation
+ Recording, // Native command recording
+ GPUWork, // Actual GPU work
+};
+
+class DAWN_PLATFORM_EXPORT CachingInterface {
+ public:
+ CachingInterface();
+ virtual ~CachingInterface();
+
+ // LoadData has two modes. The first mode is used to get a value which
+ // corresponds to the |key|. The |valueOut| is a caller provided buffer
+ // allocated to the size |valueSize| which is loaded with data of the
+ // size returned. The second mode is used to query for the existence of
+ // the |key| where |valueOut| is nullptr and |valueSize| must be 0.
+ // The return size is non-zero if the |key| exists.
+ virtual size_t LoadData(const void* key, size_t keySize, void* valueOut, size_t valueSize) = 0;
+
+ // StoreData puts a |value| in the cache which corresponds to the |key|.
+ virtual void StoreData(const void* key,
+ size_t keySize,
+ const void* value,
+ size_t valueSize) = 0;
+
+ private:
+ CachingInterface(const CachingInterface&) = delete;
+ CachingInterface& operator=(const CachingInterface&) = delete;
+};
+
+class DAWN_PLATFORM_EXPORT WaitableEvent {
+ public:
+ WaitableEvent() = default;
+ virtual ~WaitableEvent() = default;
+ virtual void Wait() = 0; // Wait for completion
+ virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
+};
+
+using PostWorkerTaskCallback = void (*)(void* userdata);
+
+class DAWN_PLATFORM_EXPORT WorkerTaskPool {
+ public:
+ WorkerTaskPool() = default;
+ virtual ~WorkerTaskPool() = default;
+ virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
+ void* userdata) = 0;
+};
+
+class DAWN_PLATFORM_EXPORT Platform {
+ public:
+ Platform();
+ virtual ~Platform();
+
+ virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
+
+ virtual double MonotonicallyIncreasingTime();
+
+ virtual uint64_t AddTraceEvent(char phase,
+ const unsigned char* categoryGroupEnabled,
+ const char* name,
+ uint64_t id,
+ double timestamp,
+ int numArgs,
+ const char** argNames,
+ const unsigned char* argTypes,
+ const uint64_t* argValues,
+ unsigned char flags);
+
+ // The |fingerprint| is provided by Dawn to inform the client to discard the Dawn caches
+ // when the fingerprint changes. The returned CachingInterface is expected to outlive the
+ // device which uses it to persistently cache objects.
+ virtual CachingInterface* GetCachingInterface(const void* fingerprint, size_t fingerprintSize);
+ virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
+
+ private:
+ Platform(const Platform&) = delete;
+ Platform& operator=(const Platform&) = delete;
+};
} // namespace dawn::platform
diff --git a/chromium/third_party/dawn/include/dawn/platform/dawn_platform_export.h b/chromium/third_party/dawn/include/dawn/platform/dawn_platform_export.h
index e8d22e37aa1..fbdb33c64e0 100644
--- a/chromium/third_party/dawn/include/dawn/platform/dawn_platform_export.h
+++ b/chromium/third_party/dawn/include/dawn/platform/dawn_platform_export.h
@@ -16,21 +16,21 @@
#define INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
#if defined(DAWN_PLATFORM_SHARED_LIBRARY)
-# if defined(_WIN32)
-# if defined(DAWN_PLATFORM_IMPLEMENTATION)
-# define DAWN_PLATFORM_EXPORT __declspec(dllexport)
-# else
-# define DAWN_PLATFORM_EXPORT __declspec(dllimport)
-# endif
-# else // defined(_WIN32)
-# if defined(DAWN_PLATFORM_IMPLEMENTATION)
-# define DAWN_PLATFORM_EXPORT __attribute__((visibility("default")))
-# else
-# define DAWN_PLATFORM_EXPORT
-# endif
-# endif // defined(_WIN32)
-#else // defined(DAWN_PLATFORM_SHARED_LIBRARY)
-# define DAWN_PLATFORM_EXPORT
+#if defined(_WIN32)
+#if defined(DAWN_PLATFORM_IMPLEMENTATION)
+#define DAWN_PLATFORM_EXPORT __declspec(dllexport)
+#else
+#define DAWN_PLATFORM_EXPORT __declspec(dllimport)
+#endif
+#else // defined(_WIN32)
+#if defined(DAWN_PLATFORM_IMPLEMENTATION)
+#define DAWN_PLATFORM_EXPORT __attribute__((visibility("default")))
+#else
+#define DAWN_PLATFORM_EXPORT
+#endif
+#endif // defined(_WIN32)
+#else // defined(DAWN_PLATFORM_SHARED_LIBRARY)
+#define DAWN_PLATFORM_EXPORT
#endif // defined(DAWN_PLATFORM_SHARED_LIBRARY)
#endif // INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
diff --git a/chromium/third_party/dawn/include/dawn/wire/Wire.h b/chromium/third_party/dawn/include/dawn/wire/Wire.h
index 10028e05b72..e866db3dd82 100644
--- a/chromium/third_party/dawn/include/dawn/wire/Wire.h
+++ b/chromium/third_party/dawn/include/dawn/wire/Wire.h
@@ -23,53 +23,32 @@
namespace dawn::wire {
- class DAWN_WIRE_EXPORT CommandSerializer {
- public:
- CommandSerializer();
- virtual ~CommandSerializer();
- CommandSerializer(const CommandSerializer& rhs) = delete;
- CommandSerializer& operator=(const CommandSerializer& rhs) = delete;
-
- // Get space for serializing commands.
- // GetCmdSpace will never be called with a value larger than
- // what GetMaximumAllocationSize returns. Return nullptr to indicate
- // a fatal error.
- virtual void* GetCmdSpace(size_t size) = 0;
- virtual bool Flush() = 0;
- virtual size_t GetMaximumAllocationSize() const = 0;
- virtual void OnSerializeError();
- };
-
- class DAWN_WIRE_EXPORT CommandHandler {
- public:
- CommandHandler();
- virtual ~CommandHandler();
- CommandHandler(const CommandHandler& rhs) = delete;
- CommandHandler& operator=(const CommandHandler& rhs) = delete;
-
- virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0;
- };
-
- DAWN_WIRE_EXPORT size_t
- SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties);
-
- DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(
- const WGPUDeviceProperties* deviceProperties,
- char* serializeBuffer);
-
- DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
- const volatile char* deserializeBuffer,
- size_t deserializeBufferSize);
-
- DAWN_WIRE_EXPORT size_t
- SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits);
-
- DAWN_WIRE_EXPORT void SerializeWGPUSupportedLimits(const WGPUSupportedLimits* supportedLimits,
- char* serializeBuffer);
-
- DAWN_WIRE_EXPORT bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits,
- const volatile char* deserializeBuffer,
- size_t deserializeBufferSize);
+class DAWN_WIRE_EXPORT CommandSerializer {
+ public:
+ CommandSerializer();
+ virtual ~CommandSerializer();
+ CommandSerializer(const CommandSerializer& rhs) = delete;
+ CommandSerializer& operator=(const CommandSerializer& rhs) = delete;
+
+ // Get space for serializing commands.
+ // GetCmdSpace will never be called with a value larger than
+ // what GetMaximumAllocationSize returns. Return nullptr to indicate
+ // a fatal error.
+ virtual void* GetCmdSpace(size_t size) = 0;
+ virtual bool Flush() = 0;
+ virtual size_t GetMaximumAllocationSize() const = 0;
+ virtual void OnSerializeError();
+};
+
+class DAWN_WIRE_EXPORT CommandHandler {
+ public:
+ CommandHandler();
+ virtual ~CommandHandler();
+ CommandHandler(const CommandHandler& rhs) = delete;
+ CommandHandler& operator=(const CommandHandler& rhs) = delete;
+
+ virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0;
+};
} // namespace dawn::wire
diff --git a/chromium/third_party/dawn/include/dawn/wire/WireClient.h b/chromium/third_party/dawn/include/dawn/wire/WireClient.h
index d8b50a33a81..c1adfb13372 100644
--- a/chromium/third_party/dawn/include/dawn/wire/WireClient.h
+++ b/chromium/third_party/dawn/include/dawn/wire/WireClient.h
@@ -23,160 +23,158 @@
namespace dawn::wire {
- namespace client {
- class Client;
- class MemoryTransferService;
-
- DAWN_WIRE_EXPORT const DawnProcTable& GetProcs();
- } // namespace client
-
- struct ReservedTexture {
- WGPUTexture texture;
- uint32_t id;
- uint32_t generation;
- uint32_t deviceId;
- uint32_t deviceGeneration;
- };
-
- struct ReservedSwapChain {
- WGPUSwapChain swapchain;
- uint32_t id;
- uint32_t generation;
- uint32_t deviceId;
- uint32_t deviceGeneration;
- };
-
- struct ReservedDevice {
- WGPUDevice device;
- uint32_t id;
- uint32_t generation;
- };
-
- struct ReservedInstance {
- WGPUInstance instance;
- uint32_t id;
- uint32_t generation;
- };
+namespace client {
+class Client;
+class MemoryTransferService;
+
+DAWN_WIRE_EXPORT const DawnProcTable& GetProcs();
+} // namespace client
+
+struct ReservedTexture {
+ WGPUTexture texture;
+ uint32_t id;
+ uint32_t generation;
+ uint32_t deviceId;
+ uint32_t deviceGeneration;
+};
+
+struct ReservedSwapChain {
+ WGPUSwapChain swapchain;
+ uint32_t id;
+ uint32_t generation;
+ uint32_t deviceId;
+ uint32_t deviceGeneration;
+};
+
+struct ReservedDevice {
+ WGPUDevice device;
+ uint32_t id;
+ uint32_t generation;
+};
+
+struct ReservedInstance {
+ WGPUInstance instance;
+ uint32_t id;
+ uint32_t generation;
+};
+
+struct DAWN_WIRE_EXPORT WireClientDescriptor {
+ CommandSerializer* serializer;
+ client::MemoryTransferService* memoryTransferService = nullptr;
+};
+
+class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
+ public:
+ explicit WireClient(const WireClientDescriptor& descriptor);
+ ~WireClient() override;
+
+ const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
+
+ ReservedTexture ReserveTexture(WGPUDevice device);
+ ReservedSwapChain ReserveSwapChain(WGPUDevice device);
+ ReservedDevice ReserveDevice();
+ ReservedInstance ReserveInstance();
+
+ void ReclaimTextureReservation(const ReservedTexture& reservation);
+ void ReclaimSwapChainReservation(const ReservedSwapChain& reservation);
+ void ReclaimDeviceReservation(const ReservedDevice& reservation);
+ void ReclaimInstanceReservation(const ReservedInstance& reservation);
+
+ // Disconnects the client.
+ // Commands allocated after this point will not be sent.
+ void Disconnect();
+
+ private:
+ std::unique_ptr<client::Client> mImpl;
+};
+
+namespace client {
+class DAWN_WIRE_EXPORT MemoryTransferService {
+ public:
+ MemoryTransferService();
+ virtual ~MemoryTransferService();
+
+ class ReadHandle;
+ class WriteHandle;
+
+ // Create a handle for reading server data.
+ // This may fail and return nullptr.
+ virtual ReadHandle* CreateReadHandle(size_t) = 0;
+
+ // Create a handle for writing server data.
+ // This may fail and return nullptr.
+ virtual WriteHandle* CreateWriteHandle(size_t) = 0;
+
+ class DAWN_WIRE_EXPORT ReadHandle {
+ public:
+ ReadHandle();
+ virtual ~ReadHandle();
+
+ // Get the required serialization size for SerializeCreate
+ virtual size_t SerializeCreateSize() = 0;
+
+ // Serialize the handle into |serializePointer| so it can be received by the server.
+ virtual void SerializeCreate(void* serializePointer) = 0;
+
+ // Simply return the base address of the allocation (without applying any offset)
+ // Returns nullptr if the allocation failed.
+ // The data must live at least until the ReadHandle is destructued
+ virtual const void* GetData() = 0;
+
+ // Gets called when a MapReadCallback resolves.
+ // deserialize the data update and apply
+ // it to the range (offset, offset + size) of allocation
+ // There could be nothing to be deserialized (if using shared memory)
+ // Needs to check potential offset/size OOB and overflow
+ virtual bool DeserializeDataUpdate(const void* deserializePointer,
+ size_t deserializeSize,
+ size_t offset,
+ size_t size) = 0;
- struct DAWN_WIRE_EXPORT WireClientDescriptor {
- CommandSerializer* serializer;
- client::MemoryTransferService* memoryTransferService = nullptr;
+ private:
+ ReadHandle(const ReadHandle&) = delete;
+ ReadHandle& operator=(const ReadHandle&) = delete;
};
- class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
+ class DAWN_WIRE_EXPORT WriteHandle {
public:
- explicit WireClient(const WireClientDescriptor& descriptor);
- ~WireClient() override;
+ WriteHandle();
+ virtual ~WriteHandle();
- const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
+ // Get the required serialization size for SerializeCreate
+ virtual size_t SerializeCreateSize() = 0;
- ReservedTexture ReserveTexture(WGPUDevice device);
- ReservedSwapChain ReserveSwapChain(WGPUDevice device);
- ReservedDevice ReserveDevice();
- ReservedInstance ReserveInstance();
+ // Serialize the handle into |serializePointer| so it can be received by the server.
+ virtual void SerializeCreate(void* serializePointer) = 0;
- void ReclaimTextureReservation(const ReservedTexture& reservation);
- void ReclaimSwapChainReservation(const ReservedSwapChain& reservation);
- void ReclaimDeviceReservation(const ReservedDevice& reservation);
- void ReclaimInstanceReservation(const ReservedInstance& reservation);
+ // Simply return the base address of the allocation (without applying any offset)
+ // The data returned should be zero-initialized.
+ // The data returned must live at least until the WriteHandle is destructed.
+ // On failure, the pointer returned should be null.
+ virtual void* GetData() = 0;
- // Disconnects the client.
- // Commands allocated after this point will not be sent.
- void Disconnect();
+ // Get the required serialization size for SerializeDataUpdate
+ virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
+
+ // Serialize a command to send the modified contents of
+ // the subrange (offset, offset + size) of the allocation at buffer unmap
+ // This subrange is always the whole mapped region for now
+ // There could be nothing to be serialized (if using shared memory)
+ virtual void SerializeDataUpdate(void* serializePointer, size_t offset, size_t size) = 0;
private:
- std::unique_ptr<client::Client> mImpl;
+ WriteHandle(const WriteHandle&) = delete;
+ WriteHandle& operator=(const WriteHandle&) = delete;
};
- namespace client {
- class DAWN_WIRE_EXPORT MemoryTransferService {
- public:
- MemoryTransferService();
- virtual ~MemoryTransferService();
-
- class ReadHandle;
- class WriteHandle;
-
- // Create a handle for reading server data.
- // This may fail and return nullptr.
- virtual ReadHandle* CreateReadHandle(size_t) = 0;
-
- // Create a handle for writing server data.
- // This may fail and return nullptr.
- virtual WriteHandle* CreateWriteHandle(size_t) = 0;
-
- class DAWN_WIRE_EXPORT ReadHandle {
- public:
- ReadHandle();
- virtual ~ReadHandle();
-
- // Get the required serialization size for SerializeCreate
- virtual size_t SerializeCreateSize() = 0;
-
- // Serialize the handle into |serializePointer| so it can be received by the server.
- virtual void SerializeCreate(void* serializePointer) = 0;
-
- // Simply return the base address of the allocation (without applying any offset)
- // Returns nullptr if the allocation failed.
- // The data must live at least until the ReadHandle is destructued
- virtual const void* GetData() = 0;
-
- // Gets called when a MapReadCallback resolves.
- // deserialize the data update and apply
- // it to the range (offset, offset + size) of allocation
- // There could be nothing to be deserialized (if using shared memory)
- // Needs to check potential offset/size OOB and overflow
- virtual bool DeserializeDataUpdate(const void* deserializePointer,
- size_t deserializeSize,
- size_t offset,
- size_t size) = 0;
-
- private:
- ReadHandle(const ReadHandle&) = delete;
- ReadHandle& operator=(const ReadHandle&) = delete;
- };
-
- class DAWN_WIRE_EXPORT WriteHandle {
- public:
- WriteHandle();
- virtual ~WriteHandle();
-
- // Get the required serialization size for SerializeCreate
- virtual size_t SerializeCreateSize() = 0;
-
- // Serialize the handle into |serializePointer| so it can be received by the server.
- virtual void SerializeCreate(void* serializePointer) = 0;
-
- // Simply return the base address of the allocation (without applying any offset)
- // The data returned should be zero-initialized.
- // The data returned must live at least until the WriteHandle is destructed.
- // On failure, the pointer returned should be null.
- virtual void* GetData() = 0;
-
- // Get the required serialization size for SerializeDataUpdate
- virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
-
- // Serialize a command to send the modified contents of
- // the subrange (offset, offset + size) of the allocation at buffer unmap
- // This subrange is always the whole mapped region for now
- // There could be nothing to be serialized (if using shared memory)
- virtual void SerializeDataUpdate(void* serializePointer,
- size_t offset,
- size_t size) = 0;
-
- private:
- WriteHandle(const WriteHandle&) = delete;
- WriteHandle& operator=(const WriteHandle&) = delete;
- };
-
- private:
- MemoryTransferService(const MemoryTransferService&) = delete;
- MemoryTransferService& operator=(const MemoryTransferService&) = delete;
- };
-
- // Backdoor to get the order of the ProcMap for testing
- DAWN_WIRE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
- } // namespace client
+ private:
+ MemoryTransferService(const MemoryTransferService&) = delete;
+ MemoryTransferService& operator=(const MemoryTransferService&) = delete;
+};
+
+// Backdoor to get the order of the ProcMap for testing
+DAWN_WIRE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
+} // namespace client
} // namespace dawn::wire
#endif // INCLUDE_DAWN_WIRE_WIRECLIENT_H_
diff --git a/chromium/third_party/dawn/include/dawn/wire/WireServer.h b/chromium/third_party/dawn/include/dawn/wire/WireServer.h
index 1957de03567..9fc2ab39739 100644
--- a/chromium/third_party/dawn/include/dawn/wire/WireServer.h
+++ b/chromium/third_party/dawn/include/dawn/wire/WireServer.h
@@ -23,126 +23,131 @@ struct DawnProcTable;
namespace dawn::wire {
- namespace server {
- class Server;
- class MemoryTransferService;
- } // namespace server
-
- struct DAWN_WIRE_EXPORT WireServerDescriptor {
- const DawnProcTable* procs;
- CommandSerializer* serializer;
- server::MemoryTransferService* memoryTransferService = nullptr;
+namespace server {
+class Server;
+class MemoryTransferService;
+} // namespace server
+
+struct DAWN_WIRE_EXPORT WireServerDescriptor {
+ const DawnProcTable* procs;
+ CommandSerializer* serializer;
+ server::MemoryTransferService* memoryTransferService = nullptr;
+};
+
+class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
+ public:
+ explicit WireServer(const WireServerDescriptor& descriptor);
+ ~WireServer() override;
+
+ const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
+
+ bool InjectTexture(WGPUTexture texture,
+ uint32_t id,
+ uint32_t generation,
+ uint32_t deviceId,
+ uint32_t deviceGeneration);
+ bool InjectSwapChain(WGPUSwapChain swapchain,
+ uint32_t id,
+ uint32_t generation,
+ uint32_t deviceId,
+ uint32_t deviceGeneration);
+
+ bool InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation);
+
+ bool InjectInstance(WGPUInstance instance, uint32_t id, uint32_t generation);
+
+ // Look up a device by (id, generation) pair. Returns nullptr if the generation
+ // has expired or the id is not found.
+ // The Wire does not have destroy hooks to allow an embedder to observe when an object
+ // has been destroyed, but in Chrome, we need to know the list of live devices so we
+ // can call device.Tick() on all of them periodically to ensure progress on asynchronous
+ // work is made. Getting this list can be done by tracking the (id, generation) of
+ // previously injected devices, and observing if GetDevice(id, generation) returns non-null.
+ WGPUDevice GetDevice(uint32_t id, uint32_t generation);
+
+ // Check if a device handle is known by the wire.
+ // In Chrome, we need to know the list of live devices so we can call device.Tick() on all of
+ // them periodically to ensure progress on asynchronous work is made.
+ bool IsDeviceKnown(WGPUDevice device) const;
+
+ private:
+ std::unique_ptr<server::Server> mImpl;
+};
+
+namespace server {
+class DAWN_WIRE_EXPORT MemoryTransferService {
+ public:
+ MemoryTransferService();
+ virtual ~MemoryTransferService();
+
+ class ReadHandle;
+ class WriteHandle;
+
+ // Deserialize data to create Read/Write handles. These handles are for the client
+ // to Read/Write data.
+ virtual bool DeserializeReadHandle(const void* deserializePointer,
+ size_t deserializeSize,
+ ReadHandle** readHandle) = 0;
+ virtual bool DeserializeWriteHandle(const void* deserializePointer,
+ size_t deserializeSize,
+ WriteHandle** writeHandle) = 0;
+
+ class DAWN_WIRE_EXPORT ReadHandle {
+ public:
+ ReadHandle();
+ virtual ~ReadHandle();
+
+ // Return the size of the command serialized if
+ // SerializeDataUpdate is called with the same offset/size args
+ virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
+
+ // Gets called when a MapReadCallback resolves.
+ // Serialize the data update for the range (offset, offset + size) into
+ // |serializePointer| to the client There could be nothing to be serialized (if
+ // using shared memory)
+ virtual void SerializeDataUpdate(const void* data,
+ size_t offset,
+ size_t size,
+ void* serializePointer) = 0;
+
+ private:
+ ReadHandle(const ReadHandle&) = delete;
+ ReadHandle& operator=(const ReadHandle&) = delete;
};
- class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
+ class DAWN_WIRE_EXPORT WriteHandle {
public:
- explicit WireServer(const WireServerDescriptor& descriptor);
- ~WireServer() override;
-
- const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
-
- bool InjectTexture(WGPUTexture texture,
- uint32_t id,
- uint32_t generation,
- uint32_t deviceId,
- uint32_t deviceGeneration);
- bool InjectSwapChain(WGPUSwapChain swapchain,
- uint32_t id,
- uint32_t generation,
- uint32_t deviceId,
- uint32_t deviceGeneration);
-
- bool InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation);
-
- bool InjectInstance(WGPUInstance instance, uint32_t id, uint32_t generation);
-
- // Look up a device by (id, generation) pair. Returns nullptr if the generation
- // has expired or the id is not found.
- // The Wire does not have destroy hooks to allow an embedder to observe when an object
- // has been destroyed, but in Chrome, we need to know the list of live devices so we
- // can call device.Tick() on all of them periodically to ensure progress on asynchronous
- // work is made. Getting this list can be done by tracking the (id, generation) of
- // previously injected devices, and observing if GetDevice(id, generation) returns non-null.
- WGPUDevice GetDevice(uint32_t id, uint32_t generation);
+ WriteHandle();
+ virtual ~WriteHandle();
+
+ // Set the target for writes from the client. DeserializeFlush should copy data
+ // into the target.
+ void SetTarget(void* data);
+ // Set Staging data length for OOB check
+ void SetDataLength(size_t dataLength);
+
+ // This function takes in the serialized result of
+ // client::MemoryTransferService::WriteHandle::SerializeDataUpdate.
+ // Needs to check potential offset/size OOB and overflow
+ virtual bool DeserializeDataUpdate(const void* deserializePointer,
+ size_t deserializeSize,
+ size_t offset,
+ size_t size) = 0;
+
+ protected:
+ void* mTargetData = nullptr;
+ size_t mDataLength = 0;
private:
- std::unique_ptr<server::Server> mImpl;
+ WriteHandle(const WriteHandle&) = delete;
+ WriteHandle& operator=(const WriteHandle&) = delete;
};
- namespace server {
- class DAWN_WIRE_EXPORT MemoryTransferService {
- public:
- MemoryTransferService();
- virtual ~MemoryTransferService();
-
- class ReadHandle;
- class WriteHandle;
-
- // Deserialize data to create Read/Write handles. These handles are for the client
- // to Read/Write data.
- virtual bool DeserializeReadHandle(const void* deserializePointer,
- size_t deserializeSize,
- ReadHandle** readHandle) = 0;
- virtual bool DeserializeWriteHandle(const void* deserializePointer,
- size_t deserializeSize,
- WriteHandle** writeHandle) = 0;
-
- class DAWN_WIRE_EXPORT ReadHandle {
- public:
- ReadHandle();
- virtual ~ReadHandle();
-
- // Return the size of the command serialized if
- // SerializeDataUpdate is called with the same offset/size args
- virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
-
- // Gets called when a MapReadCallback resolves.
- // Serialize the data update for the range (offset, offset + size) into
- // |serializePointer| to the client There could be nothing to be serialized (if
- // using shared memory)
- virtual void SerializeDataUpdate(const void* data,
- size_t offset,
- size_t size,
- void* serializePointer) = 0;
-
- private:
- ReadHandle(const ReadHandle&) = delete;
- ReadHandle& operator=(const ReadHandle&) = delete;
- };
-
- class DAWN_WIRE_EXPORT WriteHandle {
- public:
- WriteHandle();
- virtual ~WriteHandle();
-
- // Set the target for writes from the client. DeserializeFlush should copy data
- // into the target.
- void SetTarget(void* data);
- // Set Staging data length for OOB check
- void SetDataLength(size_t dataLength);
-
- // This function takes in the serialized result of
- // client::MemoryTransferService::WriteHandle::SerializeDataUpdate.
- // Needs to check potential offset/size OOB and overflow
- virtual bool DeserializeDataUpdate(const void* deserializePointer,
- size_t deserializeSize,
- size_t offset,
- size_t size) = 0;
-
- protected:
- void* mTargetData = nullptr;
- size_t mDataLength = 0;
-
- private:
- WriteHandle(const WriteHandle&) = delete;
- WriteHandle& operator=(const WriteHandle&) = delete;
- };
-
- private:
- MemoryTransferService(const MemoryTransferService&) = delete;
- MemoryTransferService& operator=(const MemoryTransferService&) = delete;
- };
- } // namespace server
+ private:
+ MemoryTransferService(const MemoryTransferService&) = delete;
+ MemoryTransferService& operator=(const MemoryTransferService&) = delete;
+};
+} // namespace server
} // namespace dawn::wire
diff --git a/chromium/third_party/dawn/include/dawn/wire/dawn_wire_export.h b/chromium/third_party/dawn/include/dawn/wire/dawn_wire_export.h
index 285d5db0029..e5b211387ce 100644
--- a/chromium/third_party/dawn/include/dawn/wire/dawn_wire_export.h
+++ b/chromium/third_party/dawn/include/dawn/wire/dawn_wire_export.h
@@ -16,21 +16,21 @@
#define INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_
#if defined(DAWN_WIRE_SHARED_LIBRARY)
-# if defined(_WIN32)
-# if defined(DAWN_WIRE_IMPLEMENTATION)
-# define DAWN_WIRE_EXPORT __declspec(dllexport)
-# else
-# define DAWN_WIRE_EXPORT __declspec(dllimport)
-# endif
-# else // defined(_WIN32)
-# if defined(DAWN_WIRE_IMPLEMENTATION)
-# define DAWN_WIRE_EXPORT __attribute__((visibility("default")))
-# else
-# define DAWN_WIRE_EXPORT
-# endif
-# endif // defined(_WIN32)
-#else // defined(DAWN_WIRE_SHARED_LIBRARY)
-# define DAWN_WIRE_EXPORT
+#if defined(_WIN32)
+#if defined(DAWN_WIRE_IMPLEMENTATION)
+#define DAWN_WIRE_EXPORT __declspec(dllexport)
+#else
+#define DAWN_WIRE_EXPORT __declspec(dllimport)
+#endif
+#else // defined(_WIN32)
+#if defined(DAWN_WIRE_IMPLEMENTATION)
+#define DAWN_WIRE_EXPORT __attribute__((visibility("default")))
+#else
+#define DAWN_WIRE_EXPORT
+#endif
+#endif // defined(_WIN32)
+#else // defined(DAWN_WIRE_SHARED_LIBRARY)
+#define DAWN_WIRE_EXPORT
#endif // defined(DAWN_WIRE_SHARED_LIBRARY)
#endif // INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_
diff --git a/chromium/third_party/dawn/include/tint/.clang-format b/chromium/third_party/dawn/include/tint/.clang-format
deleted file mode 100644
index 2fb833a5df1..00000000000
--- a/chromium/third_party/dawn/include/tint/.clang-format
+++ /dev/null
@@ -1,2 +0,0 @@
-# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
-BasedOnStyle: Chromium
diff --git a/chromium/third_party/dawn/include/tint/tint.h b/chromium/third_party/dawn/include/tint/tint.h
index 2b8430e01d8..c397cdcba83 100644
--- a/chromium/third_party/dawn/include/tint/tint.h
+++ b/chromium/third_party/dawn/include/tint/tint.h
@@ -33,6 +33,7 @@
#include "src/tint/transform/robustness.h"
#include "src/tint/transform/single_entry_point.h"
#include "src/tint/transform/vertex_pulling.h"
+#include "src/tint/writer/flatten_bindings.h"
#include "src/tint/writer/writer.h"
#if TINT_BUILD_SPV_READER
diff --git a/chromium/third_party/dawn/include/webgpu/webgpu_cpp.h b/chromium/third_party/dawn/include/webgpu/webgpu_cpp.h
index c8928cc7b35..f1a633356f3 100644
--- a/chromium/third_party/dawn/include/webgpu/webgpu_cpp.h
+++ b/chromium/third_party/dawn/include/webgpu/webgpu_cpp.h
@@ -15,6 +15,6 @@
#ifndef INCLUDE_WEBGPU_WEBGPU_CPP_H_
#define INCLUDE_WEBGPU_WEBGPU_CPP_H_
-#include <dawn/webgpu_cpp.h>
+#include "dawn/webgpu_cpp.h"
#endif // INCLUDE_WEBGPU_WEBGPU_CPP_H_