Metal: Allow additional swapchain formats
Bug: 42241264
Change-Id: Idb9b11f3faa0eca2ab58faa814872a3fc70b78a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/187142
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/Surface.cpp b/src/dawn/native/Surface.cpp
index b1ea52c..013b535 100644
--- a/src/dawn/native/Surface.cpp
+++ b/src/dawn/native/Surface.cpp
@@ -206,18 +206,6 @@
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(config->format));
DAWN_ASSERT(format != nullptr);
- // TODO(crbug.com/dawn/160): Lift this restriction once
- // wgpu::Instance::GetPreferredSurfaceFormat is implemented.
- // TODO(dawn:286):
-#if DAWN_PLATFORM_IS(ANDROID)
- constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::RGBA8Unorm;
-#else
- constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::BGRA8Unorm;
-#endif // !DAWN_PLATFORM_IS(ANDROID)
- DAWN_INVALID_IF(config->format != kRequireSwapChainFormat,
- "Format (%s) is not %s, which is (currently) the only accepted format.",
- config->format, kRequireSwapChainFormat);
-
if (device->HasFeature(Feature::SurfaceCapabilities)) {
wgpu::TextureUsage validUsage;
DAWN_TRY_ASSIGN(validUsage, device->GetSupportedSurfaceUsage(surface));
diff --git a/src/dawn/native/metal/BackendMTL.mm b/src/dawn/native/metal/BackendMTL.mm
index 4d99129..5cbf306 100644
--- a/src/dawn/native/metal/BackendMTL.mm
+++ b/src/dawn/native/metal/BackendMTL.mm
@@ -306,8 +306,14 @@
// Formats
- // This is the only supported format in native mode (see crbug.com/dawn/160).
- capabilities.formats.push_back(wgpu::TextureFormat::BGRA8Unorm);
+ capabilities.formats = {
+ wgpu::TextureFormat::BGRA8Unorm,
+ wgpu::TextureFormat::BGRA8UnormSrgb,
+ wgpu::TextureFormat::RGBA16Float,
+ };
+#if DAWN_PLATFORM_IS(MACOS)
+ capabilities.formats.push_back(wgpu::TextureFormat::RGB10A2Unorm);
+#endif // DAWN_PLATFORM_IS(MACOS)
// Present Modes