DawnTest: Use MapAsync for expectations.

Bug: dawn:445
Change-Id: I1ef0e0f2eef03565254fb07a1ffca51cddeb0a97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25040
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-07-16 16:35:40 +00:00 committed by Commit Bot service account
parent af09f74913
commit 2a232ba399
2 changed files with 9 additions and 14 deletions

View File

@ -1015,8 +1015,8 @@ void DawnTestBase::MapSlotsSynchronously() {
for (size_t i = 0; i < mReadbackSlots.size(); ++i) {
MapReadUserdata* userdata = new MapReadUserdata{this, i};
auto& slot = mReadbackSlots[i];
slot.buffer.MapReadAsync(SlotMapReadCallback, userdata);
const ReadbackSlot& slot = mReadbackSlots[i];
slot.buffer.MapAsync(wgpu::MapMode::Read, 0, 0, SlotMapCallback, userdata);
}
// Busy wait until all map operations are done.
@ -1026,17 +1026,15 @@ void DawnTestBase::MapSlotsSynchronously() {
}
// static
void DawnTestBase::SlotMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* data,
uint64_t,
void* userdata_) {
void DawnTestBase::SlotMapCallback(WGPUBufferMapAsyncStatus status, void* userdata_) {
DAWN_ASSERT(status == WGPUBufferMapAsyncStatus_Success);
auto userdata = static_cast<MapReadUserdata*>(userdata_);
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
userdata->test->mNumPendingMapOperations--;
std::unique_ptr<MapReadUserdata> userdata(static_cast<MapReadUserdata*>(userdata_));
DawnTestBase* test = userdata->test;
ReadbackSlot* slot = &test->mReadbackSlots[userdata->slot];
delete userdata;
slot->mappedData = slot->buffer.GetConstMappedRange();
test->mNumPendingMapOperations--;
}
void DawnTestBase::ResolveExpectations() {

View File

@ -328,10 +328,7 @@ class DawnTestBase {
// Maps all the buffers and fill ReadbackSlot::mappedData
void MapSlotsSynchronously();
static void SlotMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* data,
uint64_t dataLength,
void* userdata);
static void SlotMapCallback(WGPUBufferMapAsyncStatus status, void* userdata);
size_t mNumPendingMapOperations = 0;
// Reserve space where the data for an expectation can be copied