Don't use ConsumedError on device initialization errors

If there's an error during device initialization, it's too early to use
ConsumedError (SetErrorCallback can't possibly have been called).
In this case, manually handle the error from initialization.

This will help us diagnose issue chromium:917555, where device
initialization is failing but the error is not printed.

TBR: cwallez@chromium.org
Bug: chromium:917555
Change-Id: I63ba3983688f508550afe2815ca1dda36130fed1
Reviewed-on: https://dawn-review.googlesource.com/c/3520
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Kai Ninomiya 2018-12-22 05:40:11 +00:00 committed by Commit Bot service account
parent 300eec0f82
commit cb71ba7b3a
1 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@
#include "common/Platform.h"
#include "common/SwapChainUtils.h"
#include "dawn_native/Commands.h"
#include "dawn_native/ErrorData.h"
#include "dawn_native/VulkanBackend.h"
#include "dawn_native/vulkan/BindGroupLayoutVk.h"
#include "dawn_native/vulkan/BindGroupVk.h"
@ -83,7 +84,14 @@ namespace dawn_native { namespace vulkan {
// Device
Device::Device(const std::vector<const char*>& requiredInstanceExtensions) {
if (ConsumedError(Initialize(requiredInstanceExtensions))) {
MaybeError maybeError = Initialize(requiredInstanceExtensions);
// In device initialization, the error callback can't have been set yet.
// So it's too early to use ConsumedError - consume the error manually.
if (DAWN_UNLIKELY(maybeError.IsError())) {
ErrorData* error = maybeError.AcquireError();
printf("Device initialization error: %s\n", error->GetMessage().c_str());
delete error;
ASSERT(false);
return;
}