diff --git a/src/dawn_native/Adapter.cpp b/src/dawn_native/Adapter.cpp index bdbfc2cdbf..a0ee2c7a1e 100644 --- a/src/dawn_native/Adapter.cpp +++ b/src/dawn_native/Adapter.cpp @@ -25,9 +25,19 @@ namespace dawn_native { } MaybeError AdapterBase::Initialize() { - DAWN_TRY(InitializeImpl()); - DAWN_TRY(InitializeSupportedFeaturesImpl()); - DAWN_TRY(InitializeSupportedLimitsImpl(&mLimits)); + DAWN_TRY_CONTEXT(InitializeImpl(), "initializing adapter (backend=%s)", mBackend); + DAWN_TRY_CONTEXT( + InitializeSupportedFeaturesImpl(), + "gathering supported features for \"%s\" - \"%s\" (vendorId=%#06x deviceId=%#06x " + "backend=%s type=%s)", + mPCIInfo.name, mDriverDescription, mPCIInfo.vendorId, mPCIInfo.deviceId, mBackend, + mAdapterType); + DAWN_TRY_CONTEXT( + InitializeSupportedLimitsImpl(&mLimits), + "gathering supported limits for \"%s\" - \"%s\" (vendorId=%#06x deviceId=%#06x " + "backend=%s type=%s)", + mPCIInfo.name, mDriverDescription, mPCIInfo.vendorId, mPCIInfo.deviceId, mBackend, + mAdapterType); // Enforce internal Dawn constants. mLimits.v1.maxVertexBufferArrayStride = diff --git a/src/dawn_native/Error.h b/src/dawn_native/Error.h index 7e6726ed94..da093de09c 100644 --- a/src/dawn_native/Error.h +++ b/src/dawn_native/Error.h @@ -113,12 +113,8 @@ namespace dawn_native { // the current function. #define DAWN_TRY(EXPR) DAWN_TRY_WITH_CLEANUP(EXPR, {}) -#define DAWN_TRY_CONTEXT(EXPR, ...) \ - DAWN_TRY_WITH_CLEANUP(EXPR, { \ - if (error->GetType() == InternalErrorType::Validation) { \ - error->AppendContext(absl::StrFormat(__VA_ARGS__)); \ - } \ - }) +#define DAWN_TRY_CONTEXT(EXPR, ...) \ + DAWN_TRY_WITH_CLEANUP(EXPR, { error->AppendContext(absl::StrFormat(__VA_ARGS__)); }) #define DAWN_TRY_WITH_CLEANUP(EXPR, BODY) \ { \ diff --git a/src/dawn_native/ErrorData.cpp b/src/dawn_native/ErrorData.cpp index 93ef6be68f..6e28161985 100644 --- a/src/dawn_native/ErrorData.cpp +++ b/src/dawn_native/ErrorData.cpp @@ -79,7 +79,11 @@ namespace dawn_native { for (auto context : mContexts) { ss << " - While " << context << "\n"; } - } else { + } + + // For non-validation errors, or erros that lack a context include the + // stack trace for debugging purposes. + if (mContexts.empty() || mType != InternalErrorType::Validation) { for (const auto& callsite : mBacktrace) { ss << " at " << callsite.function << " (" << callsite.file << ":" << callsite.line << ")\n";