DawnTest: handle buffer readbacks not aligned to 4.
Bug: None
Change-Id: I69e8b9a9c0eae5d0287351cacbe21e550741cacc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87861
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index 1bbb615..cfc1b38 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -1085,12 +1085,13 @@
uint64_t offset,
uint64_t size,
detail::Expectation* expectation) {
- auto readback = ReserveReadback(size);
+ uint64_t alignedSize = Align(size, uint64_t(4));
+ auto readback = ReserveReadback(alignedSize);
// We need to enqueue the copy immediately because by the time we resolve the expectation,
// the buffer might have been modified.
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- encoder.CopyBufferToBuffer(buffer, offset, readback.buffer, readback.offset, size);
+ encoder.CopyBufferToBuffer(buffer, offset, readback.buffer, readback.offset, alignedSize);
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
@@ -1101,8 +1102,6 @@
deferred.readbackSlot = readback.slot;
deferred.readbackOffset = readback.offset;
deferred.size = size;
- deferred.rowBytes = size;
- deferred.bytesPerRow = size;
deferred.expectation.reset(expectation);
mDeferredExpectations.push_back(std::move(deferred));
diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h
index c3c8402..f171c68 100644
--- a/src/dawn/tests/DawnTest.h
+++ b/src/dawn/tests/DawnTest.h
@@ -586,8 +586,8 @@
size_t readbackSlot;
uint64_t readbackOffset;
uint64_t size;
- uint32_t rowBytes;
- uint32_t bytesPerRow;
+ uint32_t rowBytes = 0;
+ uint32_t bytesPerRow = 0;
std::unique_ptr<detail::Expectation> expectation;
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316
// Use unique_ptr because of missing move/copy constructors on std::basic_ostringstream