Compute row pitch using the size of the input pixel, not the format pixel.
For formats that can be loaded with data that has a different size pixel than
the internal format (UNSIGNED_INT -> GL_DEPTH_COMPONENT_24) the row length
would be computed as rowLength * 3 which is incorrect.
BUG=angleproject:1095
Change-Id: I0f60a3bb9bb387d475ddda1389a3b4b6f4973922
Reviewed-on: https://chromium-review.googlesource.com/360214
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index 3fd42d3..c78f76e 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -712,21 +712,11 @@
return computeCompressedImageSize(formatType, gl::Extents(width, 1, 1));
}
- CheckedNumeric<GLuint> checkedRowBytes(0);
- if (rowLength > 0)
- {
- CheckedNumeric<GLuint> checkePixelBytes(pixelBytes);
- checkedRowBytes = checkePixelBytes * rowLength;
- }
- else
- {
- CheckedNumeric<GLuint> checkedWidth(width);
- const auto &typeInfo = GetTypeInfo(formatType);
- CheckedNumeric<GLuint> checkedComponents(typeInfo.specialInterpretation ? 1u
- : componentCount);
- CheckedNumeric<GLuint> checkedTypeBytes(typeInfo.bytes);
- checkedRowBytes = checkedWidth * checkedComponents * checkedTypeBytes;
- }
+ const auto &typeInfo = GetTypeInfo(formatType);
+ CheckedNumeric<GLuint> checkedComponents(typeInfo.specialInterpretation ? 1u : componentCount);
+ CheckedNumeric<GLuint> checkedTypeBytes(typeInfo.bytes);
+ CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width);
+ CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * checkedComponents * checkedTypeBytes;
ASSERT(alignment > 0 && isPow2(alignment));
CheckedNumeric<GLuint> checkedAlignment(alignment);