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 <timvp@google.com>
Reviewed-by: Ian Elliott <ianelliott@google.com>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Geoff Lang 2019-09-18 16:42:28 -04:00 коммит произвёл Commit Bot
Родитель 197005d8a8
Коммит 2f2ea8b465
2 изменённых файлов: 15 добавлений и 8 удалений

Просмотреть файл

@ -1212,11 +1212,23 @@ bool InternalFormat::computeDepthPitch(GLsizei height,
GLuint rowPitch,
GLuint *resultOut) const
{
GLuint rows =
(imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
CheckedNumeric<GLuint> pixelsHeight(imageHeight > 0 ? static_cast<GLuint>(imageHeight)
: static_cast<GLuint>(height));
CheckedNumeric<GLuint> rowCount;
if (compressed)
{
CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
rowCount = (pixelsHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
}
else
{
rowCount = pixelsHeight;
}
CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
return CheckedMathResult(checkedRowPitch * rows, resultOut);
return CheckedMathResult(checkedRowPitch * rowCount, resultOut);
}
bool InternalFormat::computeDepthPitch(GLenum formatType,

Просмотреть файл

@ -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