Round up for UV plane sizes
Bug: chromium:409576884
Change-Id: I01299fdd4092acbd232a27808869c44a1846479c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/236395
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp
index 891270b..47cc9f2 100644
--- a/src/dawn/native/Texture.cpp
+++ b/src/dawn/native/Texture.cpp
@@ -1063,17 +1063,12 @@
auto planeSize = mBaseSize;
switch (GetFormat().subSampling) {
case TextureSubsampling::e420:
- if (planeSize.width > 1) {
- planeSize.width >>= 1;
- }
- if (planeSize.height > 1) {
- planeSize.height >>= 1;
- }
+ // Divide by 2, rounding odd dimensions up.
+ planeSize.width = (planeSize.width + 1) >> 1;
+ planeSize.height = (planeSize.height + 1) >> 1;
break;
case TextureSubsampling::e422:
- if (planeSize.width > 1) {
- planeSize.width >>= 1;
- }
+ planeSize.width = (planeSize.width + 1) >> 1;
break;
case TextureSubsampling::e444:
break;