Commit d0d523f4 by Alexis Hetu Committed by Commit Bot

Make copyTexImage2D robust when source area is out of bounds

Whenever the source area of the texture being copied is out of bounds and robust resource init is enabled, it is necessary to clear the invalid portion of the source area to 0 in the copy operation, EXCEPT if the source and the destination are the same, in which case clearing the destination would also clear the source. Bug: angleproject:3930 Change-Id: Ie9e0c52fff86b5626c82a511319688392b7b073b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2391281Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Alexis Hétu <sugoi@chromium.org>
parent d701eae2
......@@ -1188,9 +1188,17 @@ angle::Result Texture::copyImage(Context *context,
// the copy lies entirely off the source framebuffer, initialize as though a zero-size box is
// going to be set during the copy operation.
Box destBox;
bool forceCopySubImage = false;
if (context->isRobustResourceInitEnabled())
{
Extents fbSize = source->getReadColorAttachment()->getSize();
const FramebufferAttachment *sourceReadAttachment = source->getReadColorAttachment();
Extents fbSize = sourceReadAttachment->getSize();
// Force using copySubImage when the source area is out of bounds AND
// we're not copying to and from the same texture
forceCopySubImage = ((sourceArea.x < 0) || (sourceArea.y < 0) ||
((sourceArea.x + sourceArea.width) > fbSize.width) ||
((sourceArea.y + sourceArea.height) > fbSize.height)) &&
(sourceReadAttachment->getTexture() != this);
Rectangle clippedArea;
if (ClipRectangle(sourceArea, Rectangle(0, 0, fbSize.width, fbSize.height), &clippedArea))
{
......@@ -1205,7 +1213,7 @@ angle::Result Texture::copyImage(Context *context,
// an initializeContents call, and then a copySubImage call. This ensures the destination
// texture exists before we try to clear it.
Extents size(sourceArea.width, sourceArea.height, 1);
if (doesSubImageNeedInit(context, index, destBox))
if (forceCopySubImage || doesSubImageNeedInit(context, index, destBox))
{
ANGLE_TRY(mTexture->setImage(context, index, internalFormat, size,
internalFormatInfo.format, internalFormatInfo.type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment