formatutils: allow reusing rowPitch computation for depthPitch
This should fix a null D3D11 backend draw call performance regression.
BUG=651101
Change-Id: I2eb10cddd15f0e7b25b886c89eccd2906e988c72
Reviewed-on: https://chromium-review.googlesource.com/392227
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index b9c5b4e..67977bc 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -880,6 +880,19 @@
return aligned.ValueOrDie();
}
+ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei height,
+ GLint imageHeight,
+ GLuint rowPitch) const
+{
+ GLuint rows =
+ (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
+ CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
+
+ auto depthPitch = checkedRowPitch * rows;
+ ANGLE_TRY_CHECKED_MATH(depthPitch);
+ return depthPitch.ValueOrDie();
+}
+
ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType,
GLsizei width,
GLsizei height,
@@ -887,15 +900,9 @@
GLint rowLength,
GLint imageHeight) const
{
- GLuint rows =
- (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch);
-
- CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
- auto depthPitch = checkedRowPitch * rows;
- ANGLE_TRY_CHECKED_MATH(depthPitch);
- return depthPitch.ValueOrDie();
+ return computeDepthPitch(height, imageHeight, rowPitch);
}
ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(GLenum formatType,
@@ -943,18 +950,16 @@
const PixelStoreStateBase &state,
bool is3D) const
{
- GLuint depthPitch = 0;
- if (is3D)
- {
- ANGLE_TRY_RESULT(computeDepthPitch(formatType, size.width, size.height, state.alignment,
- state.rowLength, state.imageHeight),
- depthPitch);
- }
-
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength),
rowPitch);
+ GLuint depthPitch = 0;
+ if (is3D)
+ {
+ ANGLE_TRY_RESULT(computeDepthPitch(size.height, state.imageHeight, rowPitch), depthPitch);
+ }
+
CheckedNumeric<GLuint> checkedCopyBytes = 0;
if (compressed)
{