Buffer: Validate the offset is aligned to 8 This is to match the upstream WebGPU spec. Bug: dawn:445 Change-Id: I1a511ed9a2a04c7b95368ce724d69c128158f097 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29360 Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp index 3b2b750..519b0e7 100644 --- a/src/dawn_native/Buffer.cpp +++ b/src/dawn_native/Buffer.cpp
@@ -403,8 +403,8 @@ *status = WGPUBufferMapAsyncStatus_Error; DAWN_TRY(GetDevice()->ValidateObject(this)); - if (offset % 4 != 0) { - return DAWN_VALIDATION_ERROR("offset must be a multiple of 4"); + if (offset % 8 != 0) { + return DAWN_VALIDATION_ERROR("offset must be a multiple of 8"); } if (size % 4 != 0) { @@ -448,6 +448,10 @@ } bool BufferBase::CanGetMappedRange(bool writable, size_t offset, size_t size) const { + if (offset % 8 != 0 || size % 4 != 0) { + return false; + } + if (size > mMapSize || offset < mMapOffset) { return false; }