From 2f2ea8b465ed2c29d7a68edaada9e4914b0707e8 Mon Sep 17 00:00:00 2001 From: Geoff Lang Date: Wed, 18 Sep 2019 16:42:28 -0400 Subject: [PATCH] Fix depth pitch calculations for compressed textures. Depth pitch computations were not taking into account the block size and simply multiplying the row pitch with the pixel height. This caused our load functions to use a very high depth pitch, reading past the end of the user-supplied buffer. BUG=angleproject:3190 BUG=angleproject:3920 Change-Id: I4ef4763b542735993568c51ae4b5a235659b9094 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1811837 Reviewed-by: Tim Van Patten Reviewed-by: Ian Elliott Commit-Queue: Geoff Lang --- src/libANGLE/formatutils.cpp | 18 +++++++++++++++--- .../deqp_khr_gles2_test_expectations.txt | 5 ----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp index 88e3a5ee6..37f3ea5d8 100644 --- a/src/libANGLE/formatutils.cpp +++ b/src/libANGLE/formatutils.cpp @@ -1212,11 +1212,23 @@ bool InternalFormat::computeDepthPitch(GLsizei height, GLuint rowPitch, GLuint *resultOut) 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; + } + CheckedNumeric checkedRowPitch(rowPitch); - return CheckedMathResult(checkedRowPitch * rows, resultOut); + return CheckedMathResult(checkedRowPitch * rowCount, resultOut); } bool InternalFormat::computeDepthPitch(GLenum formatType, diff --git a/src/tests/deqp_support/deqp_khr_gles2_test_expectations.txt b/src/tests/deqp_support/deqp_khr_gles2_test_expectations.txt index 9efdc31fd..3b7a4a987 100644 --- a/src/tests/deqp_support/deqp_khr_gles2_test_expectations.txt +++ b/src/tests/deqp_support/deqp_khr_gles2_test_expectations.txt @@ -39,11 +39,6 @@ // GL_OES_rgb8_rgba8 only enables GL_RGBA8 for render buffers (not textures) 3797 VULKAN : KHR-GLES2.texture_3d.copy_sub_image.rgba8 = FAIL -// Compressed texture tests on Android -3190 VULKAN PIXEL2 : KHR-GLES2.texture_3d.compressed_texture.rgba_astc_* = SKIP -3190 VULKAN PIXEL2 : KHR-GLES2.texture_3d.compressed_texture.sgb8_alpha8_astc_* = SKIP -3190 VULKAN PIXEL2 : KHR-GLES2.texture_3d.compressed_texture.srgb8_alpha8_astc_* = SKIP - // Bug in dEQP uses an incorrect enum (GL_HALF_FLOAT instead of GL_HALF_FLOAT_OES) 3451 : KHR-GLES2.core.internalformat.texture2d.rgb_half_float_rgb16f = FAIL 3451 : KHR-GLES2.core.internalformat.texture2d.rgba_half_float_rgba16f = FAIL