Add WGPU_STRIDE_UNDEFINED and update bytesPerRow/rowsPerImage validation
This makes a nearly one-to-one mapping between the JS and C APIs, which
benefits projects like Blink and Emscripten.
- JavaScript's `undefined` is equivalent to C `WGPU_STRIDE_UNDEFINED`.
- JavaScript's `0` is equivalent to C `0`.
- To implement the API correctly, Blink must special-case an actual
value coming in from JS that is equal to WGPU_STRIDE_UNDEFINED
(0xFFFF'FFFF), and inject an error.
Keeps but deprecates a reasonable approximation of the old behavior.
Bug: dawn:520
Change-Id: Ie9c992ffab82830090d0dfc3120731e89cd9691c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31140
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/CommandValidation.h b/src/dawn_native/CommandValidation.h
index 0eb04f5..3e46774 100644
--- a/src/dawn_native/CommandValidation.h
+++ b/src/dawn_native/CommandValidation.h
@@ -51,7 +51,15 @@
uint32_t bytesPerRow,
uint32_t rowsPerImage);
- MaybeError ValidateLinearTextureData(TextureDataLayout layout,
+ TextureDataLayout FixUpDeprecatedTextureDataLayoutOptions(
+ DeviceBase* device,
+ const TextureDataLayout& originalLayout,
+ const TexelBlockInfo& blockInfo,
+ const Extent3D& copyExtent);
+ void ApplyDefaultTextureDataLayoutOptions(TextureDataLayout* layout,
+ const TexelBlockInfo& blockInfo,
+ const Extent3D& copyExtent);
+ MaybeError ValidateLinearTextureData(const TextureDataLayout& layout,
uint64_t byteSize,
const TexelBlockInfo& blockInfo,
const Extent3D& copyExtent);