From c279e0c794ec032ab258d620f3f640adecee83ec Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 15 Dec 2021 20:53:20 -0700 Subject: [PATCH] gpu: update to latest Dawn revision as of Dec 15, 2021 See hexops/dawn#4 Signed-off-by: Stephen Gutekanst --- gpu/libs/dawn | 2 +- gpu/src/dawn/dawn_native_mach.cpp | 185 ++++------------------ gpu/src/dawn/dawn_native_mach.h | 6 +- gpu/src/dawn/sources/dawn_wire_gen.cpp | 6 + gpu/src/dawn/sources/tint_core_all_src.cc | 3 + 5 files changed, 41 insertions(+), 161 deletions(-) diff --git a/gpu/libs/dawn b/gpu/libs/dawn index 2606c6a7..0bae4b53 160000 --- a/gpu/libs/dawn +++ b/gpu/libs/dawn @@ -1 +1 @@ -Subproject commit 2606c6a7b2bcb502637f108189450221ae9d1a2a +Subproject commit 0bae4b5373f7d3b117bd11837d1005350eb10f0c diff --git a/gpu/src/dawn/dawn_native_mach.cpp b/gpu/src/dawn/dawn_native_mach.cpp index 4dd7292a..4757df36 100644 --- a/gpu/src/dawn/dawn_native_mach.cpp +++ b/gpu/src/dawn/dawn_native_mach.cpp @@ -70,7 +70,23 @@ MACH_EXPORT MachDawnNativeAdapterProperties machDawnNativeAdapter_getProperties( // // to implement the swapchain and interop APIs in Chromium. // bool SupportsExternalImages() const; // explicit operator bool() const; -MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter adapter, MachDawnNativeDeviceDescriptor* deviceDescriptor) { + +// TODO(dawn-native-mach): These API* methods correlate to the new API (which is unified between Dawn +// and wgpu-native?), e.g. dawn_native::Instance::APIRequestAdapter corresponds to wgpuInstanceRequestAdapter +// These are not implemented in Dawn yet according to austineng, but we should switch to this API once they do: +// +// "fyi, the requestAdapter/requestedDevice stuff isn't implemented right now. We just added the interface for it, but still working on the implementation. Today, it'll always fail the callback." +// +// +// bool APIGetLimits(SupportedLimits* limits) const; +// void APIGetProperties(AdapterProperties* properties) const; +// bool APIHasFeature(wgpu::FeatureName feature) const; +// uint32_t APIEnumerateFeatures(wgpu::FeatureName* features) const; +// void APIRequestDevice(const DeviceDescriptor* descriptor, +// WGPURequestDeviceCallback callback, +// void* userdata); +// +MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter adapter, MachDawnNativeDawnDeviceDescriptor* deviceDescriptor) { auto self = reinterpret_cast(adapter); if (deviceDescriptor == nullptr) { @@ -89,7 +105,7 @@ MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter for (int i = 0; i < deviceDescriptor->forceDisabledTogglesLength; i++) cppForceDisabledToggles.push_back(deviceDescriptor->forceDisabledToggles[i]); - auto cppDeviceDescriptor = dawn_native::DeviceDescriptor{ + auto cppDeviceDescriptor = dawn_native::DawnDeviceDescriptor{ .requiredFeatures = cppRequiredExtensions, .forceEnabledToggles = cppForceEnabledToggles, .forceDisabledToggles = cppForceDisabledToggles, @@ -131,6 +147,15 @@ MACH_EXPORT MachDawnNativeInstance machDawnNativeInstance_init(void) { MACH_EXPORT void machDawnNativeInstance_deinit(MachDawnNativeInstance instance) { delete reinterpret_cast(instance); } +// TODO(dawn-native-mach): These API* methods correlate to the new API (which is unified between Dawn +// and wgpu-native?), e.g. dawn_native::Instance::APIRequestAdapter corresponds to wgpuInstanceRequestAdapter +// These are not implemented in Dawn yet according to austineng, but we should switch to this API once they do: +// +// "fyi, the requestAdapter/requestedDevice stuff isn't implemented right now. We just added the interface for it, but still working on the implementation. Today, it'll always fail the callback." +// +// void APIRequestAdapter(const RequestAdapterOptions* options, +// WGPURequestAdapterCallback callback, +// void* userdata); MACH_EXPORT void machDawnNativeInstance_discoverDefaultAdapters(MachDawnNativeInstance instance) { dawn_native::Instance* self = reinterpret_cast(instance); self->DiscoverDefaultAdapters(); @@ -246,158 +271,4 @@ MACH_EXPORT WGPUTextureFormat machUtilsBackendBinding_getPreferredSwapChainTextu #ifdef __cplusplus } // extern "C" -#endif - -// TODO(dawn-native-mach): everything below here is not wrapped - -// #ifndef DAWNNATIVE_DAWNNATIVE_H_ -// #define DAWNNATIVE_DAWNNATIVE_H_ - -// #include -// #include -// #include - -// #include -// #include - -// namespace dawn_platform { -// class Platform; -// } // namespace dawn_platform - -// namespace wgpu { -// struct AdapterProperties; -// } - -// namespace dawn_native { - -// // DEPRECATED: use WGPUAdapterProperties instead. -// struct PCIInfo { -// uint32_t deviceId = 0; -// uint32_t vendorId = 0; -// std::string name; -// }; - -// // DEPRECATED: use WGPUBackendType instead. -// enum class BackendType { -// D3D12, -// Metal, -// Null, -// OpenGL, -// OpenGLES, -// Vulkan, -// }; - -// // DEPRECATED: use WGPUAdapterType instead. -// enum class DeviceType { -// DiscreteGPU, -// IntegratedGPU, -// CPU, -// Unknown, -// }; - -// class InstanceBase; -// class AdapterBase; - -// // 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 an extension. An extension 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 ExtensionInfo = ToggleInfo; - -// // Base class for options passed to Instance::DiscoverAdapters. -// struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase { -// public: -// const WGPUBackendType backendType; - -// protected: -// AdapterDiscoveryOptionsBase(WGPUBackendType type); -// }; - -// enum BackendValidationLevel { Full, Partial, Disabled }; - -// class DAWN_NATIVE_EXPORT Instance { -// }; - -// // Query the names of all the toggles that are enabled in device -// DAWN_NATIVE_EXPORT std::vector 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 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 ExternalImageType type; -// const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params -// bool isInitialized; // Whether the texture is initialized on import - -// protected: -// ExternalImageDescriptor(ExternalImageType type); -// }; - -// struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptor { -// public: -// bool isInitialized; // Whether the texture is initialized on import -// WGPUTextureUsageFlags usage; -// }; - -// struct DAWN_NATIVE_EXPORT ExternalImageExportInfo { -// public: -// const ExternalImageType type; -// bool isInitialized; // Whether the texture is initialized after export - -// protected: -// ExternalImageExportInfo(ExternalImageType type); -// }; - -// DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle); - -// DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer); - -// DAWN_NATIVE_EXPORT bool BindGroupLayoutBindingsEqualForTesting(WGPUBindGroupLayout a, -// WGPUBindGroupLayout b); - -// } // namespace dawn_native - -// #endif // DAWNNATIVE_DAWNNATIVE_H_ +#endif \ No newline at end of file diff --git a/gpu/src/dawn/dawn_native_mach.h b/gpu/src/dawn/dawn_native_mach.h index ffcc900e..91e1340e 100644 --- a/gpu/src/dawn/dawn_native_mach.h +++ b/gpu/src/dawn/dawn_native_mach.h @@ -51,7 +51,7 @@ MACH_EXPORT MachDawnNativeAdapterProperties machDawnNativeAdapter_getProperties( // 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. -typedef struct MachDawnNativeDeviceDescriptor { +typedef struct MachDawnNativeDawnDeviceDescriptor { char** requiredFeatures; uintptr_t requiredFeaturesLength; @@ -63,8 +63,8 @@ typedef struct MachDawnNativeDeviceDescriptor { // default null WGPURequiredLimits* requiredLimits; -} MachDawnNativeDeviceDescriptor; -MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter adapter, MachDawnNativeDeviceDescriptor* deviceDescriptor); +} MachDawnNativeDawnDeviceDescriptor; +MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter adapter, MachDawnNativeDawnDeviceDescriptor* deviceDescriptor); typedef struct MachDawnNativeAdaptersImpl* MachDawnNativeAdapters; MACH_EXPORT MachDawnNativeAdapter machDawnNativeAdapters_index(MachDawnNativeAdapters adapters, uintptr_t index); diff --git a/gpu/src/dawn/sources/dawn_wire_gen.cpp b/gpu/src/dawn/sources/dawn_wire_gen.cpp index 0f8bf990..748ba234 100644 --- a/gpu/src/dawn/sources/dawn_wire_gen.cpp +++ b/gpu/src/dawn/sources/dawn_wire_gen.cpp @@ -6,20 +6,26 @@ #include "src/dawn_wire/ChunkedCommandHandler.cpp" #include "src/dawn_wire/ChunkedCommandSerializer.cpp" +#include "src/dawn_wire/SupportedFeatures.cpp" #include "src/dawn_wire/Wire.cpp" #include "src/dawn_wire/WireClient.cpp" #include "src/dawn_wire/WireDeserializeAllocator.cpp" #include "src/dawn_wire/WireServer.cpp" +#include "src/dawn_wire/client/Adapter.cpp" #include "src/dawn_wire/client/Buffer.cpp" #include "src/dawn_wire/client/Client.cpp" #include "src/dawn_wire/client/ClientDoers.cpp" #include "src/dawn_wire/client/ClientInlineMemoryTransferService.cpp" #include "src/dawn_wire/client/Device.cpp" +#include "src/dawn_wire/client/Instance.cpp" +#include "src/dawn_wire/client/LimitsAndFeatures.cpp" #include "src/dawn_wire/client/Queue.cpp" #include "src/dawn_wire/client/ShaderModule.cpp" #include "src/dawn_wire/server/Server.cpp" +#include "src/dawn_wire/server/ServerAdapter.cpp" #include "src/dawn_wire/server/ServerBuffer.cpp" #include "src/dawn_wire/server/ServerDevice.cpp" #include "src/dawn_wire/server/ServerInlineMemoryTransferService.cpp" +#include "src/dawn_wire/server/ServerInstance.cpp" #include "src/dawn_wire/server/ServerQueue.cpp" #include "src/dawn_wire/server/ServerShaderModule.cpp" diff --git a/gpu/src/dawn/sources/tint_core_all_src.cc b/gpu/src/dawn/sources/tint_core_all_src.cc index 34a5f318..0945462b 100644 --- a/gpu/src/dawn/sources/tint_core_all_src.cc +++ b/gpu/src/dawn/sources/tint_core_all_src.cc @@ -93,6 +93,7 @@ #include "third_party/tint/src/symbol.cc" #include "third_party/tint/src/symbol_table.cc" #include "third_party/tint/src/transform/add_empty_entry_point.cc" +#include "third_party/tint/src/transform/add_spirv_block_decoration.cc" #include "third_party/tint/src/transform/array_length_from_uniform.cc" #include "third_party/tint/src/transform/binding_remapper.cc" #include "third_party/tint/src/transform/calculate_array_length.cc" @@ -104,6 +105,7 @@ #include "third_party/tint/src/transform/fold_constants.cc" #include "third_party/tint/src/transform/fold_trivial_single_use_lets.cc" #include "third_party/tint/src/transform/for_loop_to_loop.cc" +#include "third_party/tint/src/transform/localize_struct_array_assignment.cc" #include "third_party/tint/src/transform/loop_to_for_loop.cc" #include "third_party/tint/src/transform/manager.cc" #include "third_party/tint/src/transform/module_scope_var_to_entry_point_param.cc" @@ -112,6 +114,7 @@ #include "third_party/tint/src/transform/pad_array_elements.cc" #include "third_party/tint/src/transform/promote_initializers_to_const_var.cc" #include "third_party/tint/src/transform/remove_phonies.cc" +#include "third_party/tint/src/transform/remove_unreachable_statements.cc" #include "third_party/tint/src/transform/renamer.cc" #include "third_party/tint/src/transform/robustness.cc" #include "third_party/tint/src/transform/simplify_pointers.cc"