mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-02 04:31:26 +00:00
EncodingContext: Forward the backtrace of stored errors.
This makes error messages from command buffers more useful because they keep the whole stack trace instead of just showing that the error was created in the CommandBuffer::Finish call. Bug: dawn:632 Change-Id: I23e66045c3caa1ad086003a04eed78c40aefc562 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/49885 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
c8f0b6d633
commit
d98b3076f5
@ -815,7 +815,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
void CommandEncoder::APIInjectValidationError(const char* message) {
|
void CommandEncoder::APIInjectValidationError(const char* message) {
|
||||||
if (mEncodingContext.CheckCurrentEncoder(this)) {
|
if (mEncodingContext.CheckCurrentEncoder(this)) {
|
||||||
mEncodingContext.HandleError(InternalErrorType::Validation, message);
|
mEncodingContext.HandleError(DAWN_VALIDATION_ERROR(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,18 +53,17 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodingContext::HandleError(InternalErrorType type, const char* message) {
|
void EncodingContext::HandleError(std::unique_ptr<ErrorData> error) {
|
||||||
if (!IsFinished()) {
|
if (!IsFinished()) {
|
||||||
// Encoding should only generate validation errors.
|
// Encoding should only generate validation errors.
|
||||||
ASSERT(type == InternalErrorType::Validation);
|
ASSERT(error->GetType() == InternalErrorType::Validation);
|
||||||
// If the encoding context is not finished, errors are deferred until
|
// If the encoding context is not finished, errors are deferred until
|
||||||
// Finish() is called.
|
// Finish() is called.
|
||||||
if (!mGotError) {
|
if (mError == nullptr) {
|
||||||
mGotError = true;
|
mError = std::move(error);
|
||||||
mErrorMessage = message;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mDevice->HandleError(type, message);
|
mDevice->HandleError(error->GetType(), error->GetMessage().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,8 +128,8 @@ namespace dawn_native {
|
|||||||
mCurrentEncoder = nullptr;
|
mCurrentEncoder = nullptr;
|
||||||
mTopLevelEncoder = nullptr;
|
mTopLevelEncoder = nullptr;
|
||||||
|
|
||||||
if (mGotError) {
|
if (mError != nullptr) {
|
||||||
return DAWN_VALIDATION_ERROR(mErrorMessage);
|
return std::move(mError);
|
||||||
}
|
}
|
||||||
if (currentEncoder != topLevelEncoder) {
|
if (currentEncoder != topLevelEncoder) {
|
||||||
return DAWN_VALIDATION_ERROR("Command buffer recording ended mid-pass");
|
return DAWN_VALIDATION_ERROR("Command buffer recording ended mid-pass");
|
||||||
|
@ -39,15 +39,11 @@ namespace dawn_native {
|
|||||||
CommandIterator* GetIterator();
|
CommandIterator* GetIterator();
|
||||||
|
|
||||||
// Functions to handle encoder errors
|
// Functions to handle encoder errors
|
||||||
void HandleError(InternalErrorType type, const char* message);
|
void HandleError(std::unique_ptr<ErrorData> error);
|
||||||
|
|
||||||
inline void ConsumeError(std::unique_ptr<ErrorData> error) {
|
|
||||||
HandleError(error->GetType(), error->GetMessage().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool ConsumedError(MaybeError maybeError) {
|
inline bool ConsumedError(MaybeError maybeError) {
|
||||||
if (DAWN_UNLIKELY(maybeError.IsError())) {
|
if (DAWN_UNLIKELY(maybeError.IsError())) {
|
||||||
ConsumeError(maybeError.AcquireError());
|
HandleError(maybeError.AcquireError());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -57,11 +53,10 @@ namespace dawn_native {
|
|||||||
if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) {
|
if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) {
|
||||||
if (mCurrentEncoder != mTopLevelEncoder) {
|
if (mCurrentEncoder != mTopLevelEncoder) {
|
||||||
// The top level encoder was used when a pass encoder was current.
|
// The top level encoder was used when a pass encoder was current.
|
||||||
HandleError(InternalErrorType::Validation,
|
HandleError(DAWN_VALIDATION_ERROR("Command cannot be recorded inside a pass"));
|
||||||
"Command cannot be recorded inside a pass");
|
|
||||||
} else {
|
} else {
|
||||||
HandleError(InternalErrorType::Validation,
|
HandleError(DAWN_VALIDATION_ERROR(
|
||||||
"Recording in an error or already ended pass encoder");
|
"Recording in an error or already ended pass encoder"));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -113,8 +108,7 @@ namespace dawn_native {
|
|||||||
bool mWasMovedToIterator = false;
|
bool mWasMovedToIterator = false;
|
||||||
bool mWereCommandsAcquired = false;
|
bool mWereCommandsAcquired = false;
|
||||||
|
|
||||||
bool mGotError = false;
|
std::unique_ptr<ErrorData> mError;
|
||||||
std::string mErrorMessage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
Loading…
x
Reference in New Issue
Block a user