Move all the validations on imageHeight to one function
This patch moves all the validations on imageHeight to one function so that we no longer have two versions of ValidateImageHeight(). BUG=dawn:42 Change-Id: Ieadca2a1010b67252adb7e4f2452d9e53aebdf8b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8480 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
773a551d1a
commit
521003fd4e
|
@ -107,11 +107,18 @@ namespace dawn_native {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateImageHeight(uint32_t imageHeight, uint32_t copyHeight) {
|
MaybeError ValidateImageHeight(const Format& format,
|
||||||
|
uint32_t imageHeight,
|
||||||
|
uint32_t copyHeight) {
|
||||||
if (imageHeight < copyHeight) {
|
if (imageHeight < copyHeight) {
|
||||||
return DAWN_VALIDATION_ERROR("Image height must not be less than the copy height.");
|
return DAWN_VALIDATION_ERROR("Image height must not be less than the copy height.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imageHeight % format.blockHeight != 0) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Image height must be a multiple of compressed texture format block width");
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +203,7 @@ namespace dawn_native {
|
||||||
uint32_t rowPitch,
|
uint32_t rowPitch,
|
||||||
uint32_t imageHeight,
|
uint32_t imageHeight,
|
||||||
uint32_t* bufferSize) {
|
uint32_t* bufferSize) {
|
||||||
DAWN_TRY(ValidateImageHeight(imageHeight, copySize.height));
|
ASSERT(imageHeight >= copySize.height);
|
||||||
|
|
||||||
uint32_t blockByteSize = textureFormat.blockByteSize;
|
uint32_t blockByteSize = textureFormat.blockByteSize;
|
||||||
uint32_t blockWidth = textureFormat.blockWidth;
|
uint32_t blockWidth = textureFormat.blockWidth;
|
||||||
uint32_t blockHeight = textureFormat.blockHeight;
|
uint32_t blockHeight = textureFormat.blockHeight;
|
||||||
|
@ -230,15 +236,6 @@ namespace dawn_native {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateImageHeight(const Format& format, uint32_t imageHeight) {
|
|
||||||
if (imageHeight % format.blockHeight != 0) {
|
|
||||||
return DAWN_VALIDATION_ERROR(
|
|
||||||
"Image height must be a multiple of compressed texture format block width");
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
MaybeError ValidateImageOrigin(const Format& format, const Origin3D& offset) {
|
MaybeError ValidateImageOrigin(const Format& format, const Origin3D& offset) {
|
||||||
if (offset.x % format.blockWidth != 0) {
|
if (offset.x % format.blockWidth != 0) {
|
||||||
return DAWN_VALIDATION_ERROR(
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
@ -952,7 +949,7 @@ namespace dawn_native {
|
||||||
ValidateTextureSampleCountInCopyCommands(copy->destination.texture.Get()));
|
ValidateTextureSampleCountInCopyCommands(copy->destination.texture.Get()));
|
||||||
|
|
||||||
DAWN_TRY(ValidateImageHeight(copy->destination.texture->GetFormat(),
|
DAWN_TRY(ValidateImageHeight(copy->destination.texture->GetFormat(),
|
||||||
copy->source.imageHeight));
|
copy->source.imageHeight, copy->copySize.height));
|
||||||
DAWN_TRY(ValidateImageOrigin(copy->destination.texture->GetFormat(),
|
DAWN_TRY(ValidateImageOrigin(copy->destination.texture->GetFormat(),
|
||||||
copy->destination.origin));
|
copy->destination.origin));
|
||||||
DAWN_TRY(ValidateImageCopySize(copy->destination.texture->GetFormat(),
|
DAWN_TRY(ValidateImageCopySize(copy->destination.texture->GetFormat(),
|
||||||
|
@ -986,7 +983,8 @@ namespace dawn_native {
|
||||||
DAWN_TRY(ValidateTextureSampleCountInCopyCommands(copy->source.texture.Get()));
|
DAWN_TRY(ValidateTextureSampleCountInCopyCommands(copy->source.texture.Get()));
|
||||||
|
|
||||||
DAWN_TRY(ValidateImageHeight(copy->source.texture->GetFormat(),
|
DAWN_TRY(ValidateImageHeight(copy->source.texture->GetFormat(),
|
||||||
copy->destination.imageHeight));
|
copy->destination.imageHeight,
|
||||||
|
copy->copySize.height));
|
||||||
DAWN_TRY(ValidateImageOrigin(copy->source.texture->GetFormat(),
|
DAWN_TRY(ValidateImageOrigin(copy->source.texture->GetFormat(),
|
||||||
copy->source.origin));
|
copy->source.origin));
|
||||||
DAWN_TRY(
|
DAWN_TRY(
|
||||||
|
|
Loading…
Reference in New Issue