Do simplifications assuming macOS 10.11 is the min version supported.
Bug: dawn:1397 Change-Id: I42a588b2a30e12eb7b6889a8954311b632547c58 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90243 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
5344184403
commit
142141cdf2
|
@ -1,4 +1,58 @@
|
||||||
Name: Dawn
|
Name: Dawn
|
||||||
|
![Dawn's logo: a sun rising behind a stylized mountain inspired by the WebGPU logo. The text "Dawn" is written below it.](docs/imgs/dawn_logo.png "Dawn's logo")
|
||||||
|
|
||||||
|
# Dawn, a WebGPU implementation
|
||||||
|
|
||||||
|
Dawn is an open-source and cross-platform implementation of the work-in-progress [WebGPU](https://webgpu.dev) standard.
|
||||||
|
More precisely it implements [`webgpu.h`](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h) that is a one-to-one mapping with the WebGPU IDL.
|
||||||
|
Dawn is meant to be integrated as part of a larger system and is the underlying implementation of WebGPU in Chromium.
|
||||||
|
|
||||||
|
Dawn provides several WebGPU building blocks:
|
||||||
|
- **WebGPU C/C++ headers** that applications and other building blocks use.
|
||||||
|
- The `webgpu.h` version that Dawn implements.
|
||||||
|
- A C++ wrapper for the `webgpu.h`.
|
||||||
|
- **A "native" implementation of WebGPU** using platforms' GPU APIs: D3D12, Metal, Vulkan and OpenGL. See [per API support](docs/support.md) for more details.
|
||||||
|
- **A client-server implementation of WebGPU** for applications that are in a sandbox without access to native drivers
|
||||||
|
- **Tint** is a compiler for the WebGPU Shader Language (WGSL) that can be used in standalone to convert shaders from and to WGSL.
|
||||||
|
|
||||||
|
Helpful links:
|
||||||
|
|
||||||
|
- [Dawn bug tracker](https://bugs.chromium.org/p/dawn/issues/entry) if you find issues with Dawn.
|
||||||
|
- [Tint bug tracker](https://bugs.chromium.org/p/tint/issues/entry) if you find issues with Tint.
|
||||||
|
- [Dawn's mailing list](https://groups.google.com/forum/#!members/dawn-graphics) for other discussions related to Dawn.
|
||||||
|
- [Dawn's source code](https://dawn.googlesource.com/dawn)
|
||||||
|
- [Dawn's Matrix chatroom](https://matrix.to/#/#webgpu-dawn:matrix.org) for live discussion around contributing or using Dawn.
|
||||||
|
- [WebGPU's Matrix chatroom](https://matrix.to/#/#WebGPU:matrix.org)
|
||||||
|
- [Tint mirror](https://dawn.googlesource.com/tint) for standalone usage.
|
||||||
|
|
||||||
|
## Documentation table of content
|
||||||
|
|
||||||
|
Developer documentation:
|
||||||
|
|
||||||
|
- [Dawn overview](docs/dawn/overview.md)
|
||||||
|
- [Building](docs/building.md)
|
||||||
|
- [Contributing](CONTRIBUTING.md)
|
||||||
|
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||||
|
- [Testing Dawn](docs/dawn/testing.md)
|
||||||
|
- [Debugging Dawn](docs/dawn/debugging.md)
|
||||||
|
- [Dawn's infrastructure](docs/dawn/infra.md)
|
||||||
|
- [Dawn errors](docs/dawn/errors.md)
|
||||||
|
- [Tint experimental extensions](docs/tint/experimental_extensions.md)
|
||||||
|
|
||||||
|
|
||||||
|
User documentation: (TODO, figure out what overlaps with the webgpu.h docs)
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
(TODO)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Apache 2.0 Public License, please see [LICENSE](/LICENSE).
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
This is not an officially supported Google product.
|
||||||
Short Name: dawn
|
Short Name: dawn
|
||||||
URL: https://dawn.googlesource.com/dawn
|
URL: https://dawn.googlesource.com/dawn
|
||||||
License: Apache 2.0
|
License: Apache 2.0
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Platform and API support for Dawn/Tint
|
||||||
|
|
||||||
|
## Khronos's Vulkan
|
||||||
|
|
||||||
|
Vulkan is supported with minimal features, limits and extensions being required (what's required has been measured to be wildly available).
|
||||||
|
Vulkan is the preferred target API on platforms that don't have other "modern" GPU APIs.
|
||||||
|
Vulkan is supported as best effort on other platforms (e.g. Windows and macOS).
|
||||||
|
|
||||||
|
**Required version**: Vulkan 1.0 is supported with some required extensions (`VK_KHR_maintenance1`), or Vulkan 1.1 and above without extensions.
|
||||||
|
|
||||||
|
**Required features**: `depthBiasClamp`, `fragmentStoresAndAtomics`, `fullDrawIndexUint32`, `imageCubeArray`, `independentBlend`, `sampleRateShading`, and either `textureCompressionBC` or both of `textureCompressionETC` and `textureCompressionASTC_LDR`.
|
||||||
|
|
||||||
|
**Required limites**: they are too detailed to describe here, but in general should be wildly supported.
|
||||||
|
See the [WebGPU limits](https://gpuweb.github.io/gpuweb/#limits) that mostly correspond to Vulkan limits.
|
||||||
|
|
||||||
|
**Operating system support**:
|
||||||
|
|
||||||
|
- Linux: Supported.
|
||||||
|
- ChromeOS: Supported.
|
||||||
|
- Android: Work in progress.
|
||||||
|
- Fuchsia: Work in progress.
|
||||||
|
|
||||||
|
## Microsoft's D3D12
|
||||||
|
|
||||||
|
D3D12 is supported with feature level 11.1, or feature level 11.0 with Resource Binding Tier 2.
|
||||||
|
This is the vast majority of D3D12 devices.
|
||||||
|
Supported shader models are 5.1 and above. It is the preferred target API when available.
|
||||||
|
|
||||||
|
**Windows flavor support**:
|
||||||
|
|
||||||
|
- Win32: Supported.
|
||||||
|
- UWP: Supported, best effort.
|
||||||
|
- Xbox: Not supported, contributions welcome.
|
||||||
|
|
||||||
|
## Apple's Metal
|
||||||
|
|
||||||
|
Metal is supported and is the preferred target API when available.
|
||||||
|
|
||||||
|
**Apple OS support:**
|
||||||
|
|
||||||
|
- macOS: supported.
|
||||||
|
- iOS: supported, best effort.
|
||||||
|
- tvOS/ipadOS/...: Not supported, contributions welcome.
|
||||||
|
|
||||||
|
## Khronos's OpenGL family
|
||||||
|
|
||||||
|
Support for OpenGL is in progress with the aim to make OpenGL ES 3.1 (with extensions and limits) supported through EGL.
|
||||||
|
Other flavors of OpenGL (desktop OpenGL) or binding APIs (GLX, WGL, EAGL, CGL) are supported as best effort with contributions welcome.
|
||||||
|
|
||||||
|
|
||||||
|
## Microsoft's D3D12
|
||||||
|
|
||||||
|
Dawn doesn't have a D3D11 backend at the moment, but D3D11 support can be achieved with the OpenGL ES backend through ANGLE's OpenGL ES to D3D11 translation.
|
||||||
|
There might be a D3D11 backend in the future.
|
|
@ -158,22 +158,14 @@ MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||||
return GetVendorIdFromVendors(device, ids);
|
return GetVendorIdFromVendors(device, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsMetalSupported() {
|
|
||||||
// Metal was first introduced in macOS 10.11
|
|
||||||
// WebGPU is targeted at macOS 10.12+
|
|
||||||
// TODO(dawn:1181): Dawn native should allow non-conformant WebGPU on macOS 10.11
|
|
||||||
return IsMacOSVersionAtLeast(10, 12);
|
|
||||||
}
|
|
||||||
#elif DAWN_PLATFORM_IS(IOS)
|
#elif DAWN_PLATFORM_IS(IOS)
|
||||||
|
|
||||||
MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||||
DAWN_UNUSED(device);
|
DAWN_UNUSED(device);
|
||||||
*ids = PCIIDs{0, 0};
|
*ids = PCIIDs{0, 0};
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsMetalSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
#error "Unsupported Apple platform."
|
#error "Unsupported Apple platform."
|
||||||
#endif
|
#endif
|
||||||
|
@ -467,11 +459,9 @@ class Adapter : public AdapterBase {
|
||||||
return MTLGPUFamily::Mac2;
|
return MTLGPUFamily::Mac2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (@available(macOS 10.11, *)) {
|
|
||||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
|
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
|
||||||
return MTLGPUFamily::Mac1;
|
return MTLGPUFamily::Mac1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#elif TARGET_OS_IOS
|
#elif TARGET_OS_IOS
|
||||||
if (@available(iOS 10.11, *)) {
|
if (@available(iOS 10.11, *)) {
|
||||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) {
|
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) {
|
||||||
|
@ -658,11 +648,7 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
ASSERT(optionsBase->backendType == WGPUBackendType_Metal);
|
ASSERT(optionsBase->backendType == WGPUBackendType_Metal);
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<AdapterBase>> adapters;
|
||||||
BOOL supportedVersion = NO;
|
|
||||||
#if DAWN_PLATFORM_IS(MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
if (@available(macOS 10.11, *)) {
|
|
||||||
supportedVersion = YES;
|
|
||||||
|
|
||||||
NSRef<NSArray<id<MTLDevice>>> devices = AcquireNSRef(MTLCopyAllDevices());
|
NSRef<NSArray<id<MTLDevice>>> devices = AcquireNSRef(MTLCopyAllDevices());
|
||||||
|
|
||||||
for (id<MTLDevice> device in devices.Get()) {
|
for (id<MTLDevice> device in devices.Get()) {
|
||||||
|
@ -671,30 +657,21 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
adapters.push_back(std::move(adapter));
|
adapters.push_back(std::move(adapter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DAWN_PLATFORM_IS(IOS)
|
|
||||||
if (@available(iOS 8.0, *)) {
|
|
||||||
supportedVersion = YES;
|
|
||||||
// iOS only has a single device so MTLCopyAllDevices doesn't exist there.
|
// iOS only has a single device so MTLCopyAllDevices doesn't exist there.
|
||||||
|
#if defined(DAWN_PLATFORM_IOS)
|
||||||
Ref<Adapter> adapter =
|
Ref<Adapter> adapter =
|
||||||
AcquireRef(new Adapter(GetInstance(), MTLCreateSystemDefaultDevice()));
|
AcquireRef(new Adapter(GetInstance(), MTLCreateSystemDefaultDevice()));
|
||||||
if (!GetInstance()->ConsumedError(adapter->Initialize())) {
|
if (!GetInstance()->ConsumedError(adapter->Initialize())) {
|
||||||
adapters.push_back(std::move(adapter));
|
adapters.push_back(std::move(adapter));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (!supportedVersion) {
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
return adapters;
|
return adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendConnection* Connect(InstanceBase* instance) {
|
BackendConnection* Connect(InstanceBase* instance) {
|
||||||
if (!IsMetalSupported()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return new Backend(instance);
|
return new Backend(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLFWwindow* window) {
|
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLFWwindow* window) {
|
||||||
if (@available(macOS 10.11, *)) {
|
|
||||||
NSWindow* nsWindow = glfwGetCocoaWindow(window);
|
NSWindow* nsWindow = glfwGetCocoaWindow(window);
|
||||||
NSView* view = [nsWindow contentView];
|
NSView* view = [nsWindow contentView];
|
||||||
|
|
||||||
|
@ -45,9 +44,6 @@ std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLF
|
||||||
std::make_unique<wgpu::SurfaceDescriptorFromMetalLayer>();
|
std::make_unique<wgpu::SurfaceDescriptorFromMetalLayer>();
|
||||||
desc->layer = [view layer];
|
desc->layer = [view layer];
|
||||||
return std::move(desc);
|
return std::move(desc);
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
Loading…
Reference in New Issue