Changing validation order for linear texture data
Changed the order of validation blocks in ValidateLinearTextureData.
It doesn't match the order in spec now, but for the algorithm to
compute required bytes in copy we need the conditions which come
after the ones relating to it. Also switched the order of
ValidateLinearTextureData and ValidateTextureCopyRange for similar
reasons.
Bug: dawn:483
Change-Id: If00ae769d170ea12494258721916ec55d79e2880
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25041
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp
index da99bbd..1a387b7 100644
--- a/src/dawn_native/CommandEncoder.cpp
+++ b/src/dawn_native/CommandEncoder.cpp
@@ -656,9 +656,13 @@
DAWN_TRY(ValidateCanUseAs(destination->texture, wgpu::TextureUsage::CopyDst));
DAWN_TRY(ValidateTextureSampleCountInCopyCommands(destination->texture));
+ // We validate texture copy range before validating linear texture data,
+ // because in the latter we divide copyExtent.width by blockWidth and
+ // copyExtent.height by blockHeight while the divisibility conditions are
+ // checked in validating texture copy range.
+ DAWN_TRY(ValidateTextureCopyRange(*destination, *copySize));
DAWN_TRY(ValidateLinearTextureData(source->layout, source->buffer->GetSize(),
destination->texture->GetFormat(), *copySize));
- DAWN_TRY(ValidateTextureCopyRange(*destination, *copySize));
mTopLevelBuffers.insert(source->buffer);
mTopLevelTextures.insert(destination->texture);
@@ -709,10 +713,14 @@
DAWN_TRY(ValidateBufferCopyView(GetDevice(), *destination));
DAWN_TRY(ValidateCanUseAs(destination->buffer, wgpu::BufferUsage::CopyDst));
+ // We validate texture copy range before validating linear texture data,
+ // because in the latter we divide copyExtent.width by blockWidth and
+ // copyExtent.height by blockHeight while the divisibility conditions are
+ // checked in validating texture copy range.
+ DAWN_TRY(ValidateTextureCopyRange(*source, *copySize));
DAWN_TRY(ValidateLinearTextureData(destination->layout,
destination->buffer->GetSize(),
source->texture->GetFormat(), *copySize));
- DAWN_TRY(ValidateTextureCopyRange(*source, *copySize));
mTopLevelTextures.insert(source->texture);
mTopLevelBuffers.insert(destination->buffer);