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:
parent
af09f74913
commit
2a232ba399
|
@ -1015,8 +1015,8 @@ void DawnTestBase::MapSlotsSynchronously() {
|
||||||
for (size_t i = 0; i < mReadbackSlots.size(); ++i) {
|
for (size_t i = 0; i < mReadbackSlots.size(); ++i) {
|
||||||
MapReadUserdata* userdata = new MapReadUserdata{this, i};
|
MapReadUserdata* userdata = new MapReadUserdata{this, i};
|
||||||
|
|
||||||
auto& slot = mReadbackSlots[i];
|
const ReadbackSlot& slot = mReadbackSlots[i];
|
||||||
slot.buffer.MapReadAsync(SlotMapReadCallback, userdata);
|
slot.buffer.MapAsync(wgpu::MapMode::Read, 0, 0, SlotMapCallback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Busy wait until all map operations are done.
|
// Busy wait until all map operations are done.
|
||||||
|
@ -1026,17 +1026,15 @@ void DawnTestBase::MapSlotsSynchronously() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void DawnTestBase::SlotMapReadCallback(WGPUBufferMapAsyncStatus status,
|
void DawnTestBase::SlotMapCallback(WGPUBufferMapAsyncStatus status, void* userdata_) {
|
||||||
const void* data,
|
|
||||||
uint64_t,
|
|
||||||
void* userdata_) {
|
|
||||||
DAWN_ASSERT(status == WGPUBufferMapAsyncStatus_Success);
|
DAWN_ASSERT(status == WGPUBufferMapAsyncStatus_Success);
|
||||||
|
|
||||||
auto userdata = static_cast<MapReadUserdata*>(userdata_);
|
std::unique_ptr<MapReadUserdata> userdata(static_cast<MapReadUserdata*>(userdata_));
|
||||||
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
|
DawnTestBase* test = userdata->test;
|
||||||
userdata->test->mNumPendingMapOperations--;
|
ReadbackSlot* slot = &test->mReadbackSlots[userdata->slot];
|
||||||
|
|
||||||
delete userdata;
|
slot->mappedData = slot->buffer.GetConstMappedRange();
|
||||||
|
test->mNumPendingMapOperations--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DawnTestBase::ResolveExpectations() {
|
void DawnTestBase::ResolveExpectations() {
|
||||||
|
|
|
@ -328,10 +328,7 @@ class DawnTestBase {
|
||||||
|
|
||||||
// Maps all the buffers and fill ReadbackSlot::mappedData
|
// Maps all the buffers and fill ReadbackSlot::mappedData
|
||||||
void MapSlotsSynchronously();
|
void MapSlotsSynchronously();
|
||||||
static void SlotMapReadCallback(WGPUBufferMapAsyncStatus status,
|
static void SlotMapCallback(WGPUBufferMapAsyncStatus status, void* userdata);
|
||||||
const void* data,
|
|
||||||
uint64_t dataLength,
|
|
||||||
void* userdata);
|
|
||||||
size_t mNumPendingMapOperations = 0;
|
size_t mNumPendingMapOperations = 0;
|
||||||
|
|
||||||
// Reserve space where the data for an expectation can be copied
|
// Reserve space where the data for an expectation can be copied
|
||||||
|
|
Loading…
Reference in New Issue