mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 14:46:08 +00:00
Fix double MapReadCallback trigger when Unmapping in it.
When calling unmap on a mapped buffer for which the callback hasn't fired yet, the callback should be called with UNKNOWN. The code marked the callback as called only after calling it, causing problems with re-entrancy where the callback would be called twice. This could also get triggered by destroying the buffer inside the callback. Fix this in backend::Buffer and the WireClient and add test for both.
This commit is contained in:
committed by
Corentin Wallez
parent
c25d376ac3
commit
2da19d5d6b
@@ -61,8 +61,11 @@ namespace backend {
|
||||
nxtBufferMapReadStatus status,
|
||||
const void* pointer) {
|
||||
if (mMapReadCallback && serial == mMapReadSerial) {
|
||||
mMapReadCallback(status, pointer, mMapReadUserdata);
|
||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
||||
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||
nxtBufferMapReadCallback callback = mMapReadCallback;
|
||||
mMapReadCallback = nullptr;
|
||||
callback(status, pointer, mMapReadUserdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user