mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 00:47:13 +00:00
Vulkan: Print the VkResult value on device creation failure.
This adds a CheckVkSuccess utility function that adds the VkResult value to the context lost error message. Also adds a small fix to dawn_native/Error.h interoperability between MaybeError and ResultOrError<NonPointer> with tests. BUG=chromium:917555 BUG=dawn:79 Change-Id: Icc01122d62d83693fc0ea3f26b272f2372fd3087 Reviewed-on: https://dawn-review.googlesource.com/c/3623 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
1e37db5350
commit
e9212dfe30
@@ -246,6 +246,29 @@ TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
||||
delete errorData;
|
||||
}
|
||||
|
||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||
// Version without Result<E*, T*>
|
||||
TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
||||
auto ReturnError = []() -> ResultOrError<int> {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
||||
auto Try = [ReturnError]() -> MaybeError {
|
||||
int result = 0;
|
||||
DAWN_TRY_ASSIGN(result, ReturnError());
|
||||
DAWN_UNUSED(result);
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
MaybeError result = Try();
|
||||
ASSERT_TRUE(result.IsError());
|
||||
|
||||
ErrorData* errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
delete errorData;
|
||||
}
|
||||
|
||||
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
|
||||
// Check DAWN_TRY handles errors correctly.
|
||||
TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
|
||||
@@ -266,4 +289,24 @@ TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
|
||||
delete errorData;
|
||||
}
|
||||
|
||||
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
|
||||
// Check DAWN_TRY handles errors correctly. Version without Result<E*, T*>
|
||||
TEST(ErrorTests, TRY_ConversionToErrorOrResultNonPointer) {
|
||||
auto ReturnError = []() -> MaybeError {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
||||
auto Try = [ReturnError]() -> ResultOrError<int>{
|
||||
DAWN_TRY(ReturnError());
|
||||
return 42;
|
||||
};
|
||||
|
||||
ResultOrError<int> result = Try();
|
||||
ASSERT_TRUE(result.IsError());
|
||||
|
||||
ErrorData* errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
delete errorData;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Reference in New Issue
Block a user