Capture/Replay: Don't access OOB in TexImage2D.

The last row of pixels is treated specially because we don't need
to round up to the unpack alignment. This fixes an ASAN error with
some 1x1 texture tests with small-sized formats.

Test: TextureUploadFormatTest
Bug: angleproject:5133
Change-Id: I4c56958b83406aff380bda56b90d3258020a1f99
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3104685
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill 2021-08-18 15:20:10 -04:00 коммит произвёл Angle LUCI CQ
Родитель e2485d60f5
Коммит f6b8db1d7c
1 изменённых файлов: 10 добавлений и 2 удалений

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

@ -704,8 +704,16 @@ void CaptureTexImage2D_pixels(const State &glState,
(void)internalFormatInfo.computeSkipBytes(type, srcRowPitch, srcDepthPitch, unpack, false,
&srcSkipBytes);
size_t captureSize = srcRowPitch * height + srcSkipBytes;
CaptureMemory(pixels, captureSize, paramCapture);
// For the last row of pixels, we don't round up to the unpack alignment. This often affects
// 1x1 sized textures because they may be 1 or 2 bytes wide with an alignment of 4 bytes.
size_t allRowSizeMinusLastRowSize = height == 0 ? 0 : (srcRowPitch * (height - 1));
size_t lastRowSize = width * internalFormatInfo.pixelBytes;
size_t captureSize = allRowSizeMinusLastRowSize + lastRowSize + srcSkipBytes;
if (captureSize > 0)
{
CaptureMemory(pixels, captureSize, paramCapture);
}
}
void CaptureTexParameterfv_params(const State &glState,