Immediately call fence and map callbacks on device loss.
This is more in line with what happens in dawn_wire and Blink's WebGPU
implementation. It also allows fixing the Fence-related DeviceLost tests
to destroy the mock fence callback on destruction, which in turns fixes
a crash on dawn_end2end_tests exit on MSVC x64 debug.
Bug: dawn:602
Change-Id: I277e7fa284a573854ed46576602d5f6819db1357
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38526
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp
index 74d74eb..4f89724 100644
--- a/src/dawn_native/Buffer.cpp
+++ b/src/dawn_native/Buffer.cpp
@@ -35,7 +35,10 @@
: buffer(std::move(buffer)), id(id) {
}
void Finish() override {
- buffer->OnMapRequestCompleted(id);
+ buffer->OnMapRequestCompleted(id, WGPUBufferMapAsyncStatus_Success);
+ }
+ void HandleDeviceLoss() override {
+ buffer->OnMapRequestCompleted(id, WGPUBufferMapAsyncStatus_DeviceLost);
}
~MapRequestTask() override = default;
@@ -537,8 +540,8 @@
mState = BufferState::Destroyed;
}
- void BufferBase::OnMapRequestCompleted(MapRequestID mapID) {
- CallMapCallback(mapID, WGPUBufferMapAsyncStatus_Success);
+ void BufferBase::OnMapRequestCompleted(MapRequestID mapID, WGPUBufferMapAsyncStatus status) {
+ CallMapCallback(mapID, status);
}
bool BufferBase::IsDataInitialized() const {