DawnTest: try to more robustly handle device lost.

Deferred exepectations didn't handle device loss gracefully and would
crash, which meant all future tests were skipped. Instead of crashing,
skip the expectation, the test will fail anyway because the device was
lost.

Bug: None
Change-Id: If143f00a5ed9d2ddd5a923da7c771b1f40d80962
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Corentin Wallez 2023-01-12 11:25:25 +00:00 committed by Dawn LUCI CQ
parent 7a41bf1e2f
commit 961ad2358f
1 changed files with 17 additions and 5 deletions

View File

@ -1454,14 +1454,19 @@ void DawnTestBase::MapSlotsSynchronously() {
// static // static
void DawnTestBase::SlotMapCallback(WGPUBufferMapAsyncStatus status, void* userdata_) { void DawnTestBase::SlotMapCallback(WGPUBufferMapAsyncStatus status, void* userdata_) {
DAWN_ASSERT(status == WGPUBufferMapAsyncStatus_Success); DAWN_ASSERT(status == WGPUBufferMapAsyncStatus_Success ||
status == WGPUBufferMapAsyncStatus_DeviceLost);
std::unique_ptr<MapReadUserdata> userdata(static_cast<MapReadUserdata*>(userdata_)); std::unique_ptr<MapReadUserdata> userdata(static_cast<MapReadUserdata*>(userdata_));
DawnTestBase* test = userdata->test; DawnTestBase* test = userdata->test;
ReadbackSlot* slot = &test->mReadbackSlots[userdata->slot];
slot->mappedData = slot->buffer.GetConstMappedRange();
test->mNumPendingMapOperations--; test->mNumPendingMapOperations--;
ReadbackSlot* slot = &test->mReadbackSlots[userdata->slot];
if (status == WGPUBufferMapAsyncStatus_Success) {
slot->mappedData = slot->buffer.GetConstMappedRange();
ASSERT(slot->mappedData != nullptr);
} else {
slot->mappedData = nullptr;
}
} }
void DawnTestBase::ResolveExpectations() { void DawnTestBase::ResolveExpectations() {
@ -1471,6 +1476,13 @@ void DawnTestBase::ResolveExpectations() {
// Get a pointer to the mapped copy of the data for the expectation. // Get a pointer to the mapped copy of the data for the expectation.
const char* data = const char* data =
static_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData); static_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData);
// Handle the case where the device was lost so the expected data couldn't be read back.
if (data == nullptr) {
dawn::InfoLog() << "Skipping deferred expectation because the device was lost";
continue;
}
data += expectation.readbackOffset; data += expectation.readbackOffset;
uint32_t size; uint32_t size;