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 <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price 2023-02-27 22:31:35 +00:00 committed by Dawn LUCI CQ
parent 25e1f12228
commit 7680bc0a89
1 changed files with 8 additions and 9 deletions

View File

@ -309,19 +309,18 @@ class Field {
bool IsStorageBufferOnly() const { return mStorageBufferOnly; } 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 // 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 { void CheckData(DataMatcherCallback callback) const {
// Calls `callback` with the strided intervals of length mStrideDataBytes, skipping // Calls `callback` with the strided intervals of length mStrideDataBytes +
// mStridePaddingBytes. For example, for a field of mSize = 18, mStrideDataBytes = 2, // mStridePaddingBytes. For example, for a field of mSize = 18, mStrideDataBytes = 2, and
// and mStridePaddingBytes = 4, calls `callback` with the intervals: [0, 2), [6, 8), // mStridePaddingBytes = 4, calls `callback` with the intervals: [0, 6), [6, 12), [12, 18).
// [12, 14). If the data is continious, i.e. mStrideDataBytes = 18 and // If the data is continuous, i.e. mStrideDataBytes = 18 and mStridePaddingBytes = 0,
// mStridePaddingBytes = 0, `callback` would be called only once with the whole interval // `callback` would be called only once with the whole interval [0, 18).
// [0, 18).
size_t offset = 0; size_t offset = 0;
while (offset < mSize) { while (offset < mSize) {
callback(offset, mStrideDataBytes); callback(offset, mStrideDataBytes + mStridePaddingBytes);
offset += mStrideDataBytes + mStridePaddingBytes; offset += mStrideDataBytes + mStridePaddingBytes;
} }
} }