Use typed integers for the Buffer MapRequestID
This will prevent mixing it up with other serial types in the future.
Bug: dawn:442
Change-Id: Ie655d57722fcd79c82acc5aac429aed2c2741c3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28920
Commit-Queue: 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 aa9af0a..9ec821e 100644
--- a/src/dawn_native/Buffer.cpp
+++ b/src/dawn_native/Buffer.cpp
@@ -138,7 +138,7 @@
BufferBase::~BufferBase() {
if (mState == BufferState::Mapped) {
ASSERT(!IsError());
- CallMapCallback(mMapSerial, WGPUBufferMapAsyncStatus_DestroyedBeforeCallback);
+ CallMapCallback(mLastMapID, WGPUBufferMapAsyncStatus_DestroyedBeforeCallback);
}
}
@@ -212,9 +212,9 @@
}
}
- void BufferBase::CallMapCallback(uint32_t serial, WGPUBufferMapAsyncStatus status) {
+ void BufferBase::CallMapCallback(MapRequestID mapID, WGPUBufferMapAsyncStatus status) {
ASSERT(!IsError());
- if (mMapCallback != nullptr && serial == mMapSerial) {
+ if (mMapCallback != nullptr && mapID == mLastMapID) {
// 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.
WGPUBufferMapCallback callback = mMapCallback;
@@ -249,8 +249,7 @@
}
ASSERT(!IsError());
- // TODO(cwallez@chromium.org): what to do on wraparound? Could cause crashes.
- mMapSerial++;
+ mLastMapID++;
mMapMode = mode;
mMapOffset = offset;
mMapSize = size;
@@ -259,12 +258,12 @@
mState = BufferState::Mapped;
if (GetDevice()->ConsumedError(MapAsyncImpl(mode, offset, size))) {
- CallMapCallback(mMapSerial, WGPUBufferMapAsyncStatus_DeviceLost);
+ CallMapCallback(mLastMapID, WGPUBufferMapAsyncStatus_DeviceLost);
return;
}
MapRequestTracker* tracker = GetDevice()->GetMapRequestTracker();
- tracker->Track(this, mMapSerial);
+ tracker->Track(this, mLastMapID);
}
void* BufferBase::GetMappedRange(size_t offset, size_t size) {
@@ -350,7 +349,7 @@
// completed before the Unmap.
// Callbacks are not fired if there is no callback registered, so this is correct for
// mappedAtCreation = true.
- CallMapCallback(mMapSerial, callbackStatus);
+ CallMapCallback(mLastMapID, callbackStatus);
UnmapImpl();
mMapCallback = nullptr;
@@ -514,8 +513,8 @@
mState = BufferState::Destroyed;
}
- void BufferBase::OnMapCommandSerialFinished(uint32_t mapSerial) {
- CallMapCallback(mapSerial, WGPUBufferMapAsyncStatus_Success);
+ void BufferBase::OnMapRequestCompleted(MapRequestID mapID) {
+ CallMapCallback(mapID, WGPUBufferMapAsyncStatus_Success);
}
bool BufferBase::IsDataInitialized() const {