From 2a232ba3997cc16eadfb4fd74b5434f332e515ea Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 16 Jul 2020 16:35:40 +0000 Subject: [PATCH] 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 Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez --- src/tests/DawnTest.cpp | 18 ++++++++---------- src/tests/DawnTest.h | 5 +---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index 64e74555d3..d396e25b6a 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -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(userdata_); - userdata->test->mReadbackSlots[userdata->slot].mappedData = data; - userdata->test->mNumPendingMapOperations--; + std::unique_ptr userdata(static_cast(userdata_)); + DawnTestBase* test = userdata->test; + ReadbackSlot* slot = &test->mReadbackSlots[userdata->slot]; - delete userdata; + slot->mappedData = slot->buffer.GetConstMappedRange(); + test->mNumPendingMapOperations--; } void DawnTestBase::ResolveExpectations() { diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h index 7a29bc0e99..9e9f987041 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -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