From bdc619f5efcbfdd06b9fe011922b9f63c6df3858 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 2 Aug 2022 16:46:25 +0000 Subject: [PATCH] dawn: Make adapter creation error less scary in stdout. Bug: chromium:1348664 Change-Id: Ieba886ccc6c0d8813cd175c648849c92b3820f2a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97840 Commit-Queue: Corentin Wallez Auto-Submit: Corentin Wallez Reviewed-by: Austin Eng Kokoro: Kokoro --- src/dawn/native/Instance.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/dawn/native/Instance.cpp b/src/dawn/native/Instance.cpp index 4b12b91087..afe9c1d7ff 100644 --- a/src/dawn/native/Instance.cpp +++ b/src/dawn/native/Instance.cpp @@ -180,7 +180,14 @@ ResultOrError> InstanceBase::RequestAdapterInternal( if (GetEnabledBackends()[wgpu::BackendType::Vulkan]) { dawn_native::vulkan::AdapterDiscoveryOptions vulkanOptions; vulkanOptions.forceSwiftShader = true; - DAWN_TRY(DiscoverAdaptersInternal(&vulkanOptions)); + + MaybeError result = DiscoverAdaptersInternal(&vulkanOptions); + if (result.IsError()) { + dawn::WarningLog() + << "Skipping Vulkan Swiftshader adapter because initialization failed: " + << result.AcquireError()->GetFormattedMessage(); + return Ref(nullptr); + } } #else return Ref(nullptr); @@ -276,7 +283,16 @@ void InstanceBase::DiscoverDefaultAdapters() { // This is just a wrapper around the real logic that uses Error.h error handling. bool InstanceBase::DiscoverAdapters(const AdapterDiscoveryOptionsBase* options) { - return !ConsumedError(DiscoverAdaptersInternal(options)); + MaybeError result = DiscoverAdaptersInternal(options); + + if (result.IsError()) { + dawn::WarningLog() << "Skipping " << options->backendType + << " adapter because initialization failed: " + << result.AcquireError()->GetFormattedMessage(); + return false; + } + + return true; } const ToggleInfo* InstanceBase::GetToggleInfo(const char* toggleName) {