Add descriptive error contexts to adapter initialization
To help diagnose issues where Dawn fails to create or initialize an adapter. Bug: none Change-Id: I0c757f99596e9b4ac0e559807654ffaf9cb03feb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/69420 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
1dc31428f1
commit
7065c21fbb
|
@ -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 =
|
||||
|
|
|
@ -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) \
|
||||
{ \
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue