From 7680bc0a8946dc67798e81d0325b04ae919f9853 Mon Sep 17 00:00:00 2001 From: James Price Date: Mon, 27 Feb 2023 22:31:35 +0000 Subject: [PATCH] dawn/test: Test padding byte preservation The Dawn E2E tests for memory layout now check that padding bytes are preserved, instead of skipping them. Bug: tint:1571 Change-Id: I02edbe140e7025937a3188106da5e43ff03ad078 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121602 Commit-Queue: James Price Reviewed-by: Ben Clayton Kokoro: Kokoro --- .../end2end/ComputeLayoutMemoryBufferTests.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp index b2289a8112..734d82c361 100644 --- a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp +++ b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp @@ -309,19 +309,18 @@ class Field { bool IsStorageBufferOnly() const { return mStorageBufferOnly; } - // Call the DataMatcherCallback `callback` for continious or strided data bytes, based on the + // Call the DataMatcherCallback `callback` for continuous or strided data bytes, based on the // strided information of this field. The callback may be called once or multiple times. Note - // that padding bytes introduced by @size attribute are not tested. + // that padding bytes are tested as well, as they must be preserved by the implementation. void CheckData(DataMatcherCallback callback) const { - // Calls `callback` with the strided intervals of length mStrideDataBytes, skipping - // mStridePaddingBytes. For example, for a field of mSize = 18, mStrideDataBytes = 2, - // and mStridePaddingBytes = 4, calls `callback` with the intervals: [0, 2), [6, 8), - // [12, 14). If the data is continious, i.e. mStrideDataBytes = 18 and - // mStridePaddingBytes = 0, `callback` would be called only once with the whole interval - // [0, 18). + // Calls `callback` with the strided intervals of length mStrideDataBytes + + // mStridePaddingBytes. For example, for a field of mSize = 18, mStrideDataBytes = 2, and + // mStridePaddingBytes = 4, calls `callback` with the intervals: [0, 6), [6, 12), [12, 18). + // If the data is continuous, i.e. mStrideDataBytes = 18 and mStridePaddingBytes = 0, + // `callback` would be called only once with the whole interval [0, 18). size_t offset = 0; while (offset < mSize) { - callback(offset, mStrideDataBytes); + callback(offset, mStrideDataBytes + mStridePaddingBytes); offset += mStrideDataBytes + mStridePaddingBytes; } }