From 08903c0c9c5983a5f9bb48b25dc59085033a4bdb Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 5 Feb 2021 18:40:41 +0000 Subject: [angle] Cherry-pick compressed tex depth stride fix. --- gfx/angle/src/libANGLE/formatutils.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'gfx') diff --git a/gfx/angle/src/libANGLE/formatutils.cpp b/gfx/angle/src/libANGLE/formatutils.cpp index 9a8c1b790..caeaf6c6e 100755 --- a/gfx/angle/src/libANGLE/formatutils.cpp +++ b/gfx/angle/src/libANGLE/formatutils.cpp @@ -863,13 +863,22 @@ gl::ErrorOrResult InternalFormat::computeDepthPitch(GLenum formatType, GLint rowLength, GLint imageHeight) const { - GLuint rows = - (imageHeight > 0 ? static_cast(imageHeight) : static_cast(height)); + CheckedNumeric pixelsHeight(imageHeight > 0 ? static_cast(imageHeight) + : static_cast(height)); + + CheckedNumeric rowCount; + if (compressed) { + CheckedNumeric checkedBlockHeight(compressedBlockHeight); + rowCount = (pixelsHeight + checkedBlockHeight - 1u) / checkedBlockHeight; + } else { + rowCount = pixelsHeight; + } + GLuint rowPitch = 0; ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch); CheckedNumeric checkedRowPitch(rowPitch); - auto depthPitch = checkedRowPitch * rows; + auto depthPitch = checkedRowPitch * rowCount; ANGLE_TRY_CHECKED_MATH(depthPitch); return depthPitch.ValueOrDie(); } -- cgit v1.2.3