Commit 936ea325 by Frank Henigman Committed by Commit Bot

Clip to framebuffer when copying to cube map.

In D3D cube map textures use different code paths than regular 2D textures. Add outside-the-framebuffer handling to those paths, same as was added the other paths earlier. Change-Id: I51896a07f73ae8d761cd9d7b18c68076f38d32a3 Reviewed-on: https://chromium-review.googlesource.com/603050 Commit-Queue: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c2157a09
...@@ -1619,7 +1619,7 @@ gl::Error TextureD3D_Cube::setCompressedSubImage(const gl::Context *context, ...@@ -1619,7 +1619,7 @@ gl::Error TextureD3D_Cube::setCompressedSubImage(const gl::Context *context,
gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
GLenum target, GLenum target,
size_t imageLevel, size_t imageLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &origSourceArea,
GLenum internalFormat, GLenum internalFormat,
const gl::Framebuffer *source) const gl::Framebuffer *source)
{ {
...@@ -1629,13 +1629,43 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1629,13 +1629,43 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
GLint level = static_cast<GLint>(imageLevel); GLint level = static_cast<GLint>(imageLevel);
gl::Extents size(sourceArea.width, sourceArea.height, 1); gl::Extents size(origSourceArea.width, origSourceArea.height, 1);
ANGLE_TRY(redefineImage(context, static_cast<int>(faceIndex), level, ANGLE_TRY(redefineImage(context, static_cast<int>(faceIndex), level,
internalFormatInfo.sizedInternalFormat, size, internalFormatInfo.sizedInternalFormat, size,
mRenderer->isRobustResourceInitEnabled())); mRenderer->isRobustResourceInitEnabled()));
gl::Extents fbSize = source->getReadColorbuffer()->getSize();
// Does the read area extend beyond the framebuffer?
bool outside = origSourceArea.x < 0 || origSourceArea.y < 0 ||
origSourceArea.x + origSourceArea.width > fbSize.width ||
origSourceArea.y + origSourceArea.height > fbSize.height;
// In WebGL mode we need to zero the texture outside the framebuffer.
// If we have robust resource init, it was already zeroed by redefineImage() above, otherwise
// zero it explicitly.
// TODO(fjhenigman): When robust resource is fully implemented look into making it a
// prerequisite for WebGL and deleting this code.
if (outside && context->getExtensions().webglCompatibility &&
!mRenderer->isRobustResourceInitEnabled())
{
angle::MemoryBuffer *zero;
ANGLE_TRY(context->getZeroFilledBuffer(
origSourceArea.width * origSourceArea.height * internalFormatInfo.pixelBytes, &zero));
setImage(context, target, imageLevel, internalFormat, size, internalFormatInfo.format,
internalFormatInfo.type, gl::PixelUnpackState(1, 0), zero->data());
}
gl::Rectangle sourceArea;
if (!ClipRectangle(origSourceArea, gl::Rectangle(0, 0, fbSize.width, fbSize.height),
&sourceArea))
{
// Empty source area, nothing to do.
return gl::NoError();
}
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level); gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
gl::Offset destOffset(0, 0, 0); gl::Offset destOffset(sourceArea.x - origSourceArea.x, sourceArea.y - origSourceArea.y, 0);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path. // so we should use the non-rendering copy path.
...@@ -1665,10 +1695,20 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1665,10 +1695,20 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context, gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context,
GLenum target, GLenum target,
size_t imageLevel, size_t imageLevel,
const gl::Offset &destOffset, const gl::Offset &origDestOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &origSourceArea,
const gl::Framebuffer *source) const gl::Framebuffer *source)
{ {
gl::Extents fbSize = source->getReadColorbuffer()->getSize();
gl::Rectangle sourceArea;
if (!ClipRectangle(origSourceArea, gl::Rectangle(0, 0, fbSize.width, fbSize.height),
&sourceArea))
{
return gl::NoError();
}
const gl::Offset destOffset(origDestOffset.x + sourceArea.x - origSourceArea.x,
origDestOffset.y + sourceArea.y - origSourceArea.y, 0);
int faceIndex = static_cast<int>(gl::CubeMapTextureTargetToLayerIndex(target)); int faceIndex = static_cast<int>(gl::CubeMapTextureTargetToLayerIndex(target));
GLint level = static_cast<GLint>(imageLevel); GLint level = static_cast<GLint>(imageLevel);
......
...@@ -368,8 +368,16 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexSubImage2D) ...@@ -368,8 +368,16 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexSubImage2D)
Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage2D, false); Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage2D, false);
// TODO(fjhenigman): Enable this test as part of a CL that lets the test pass. #ifdef _WIN64
//Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImageCube, false); // TODO(fjhenigman): Figure out this failure.
if (GetParam() == ES2_D3D11_FL9_3())
{
std::cout << "Cube map skipped on 64-bit " << GetParam() << "." << std::endl;
return;
}
#endif
Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImageCube, false);
} }
// Check that copyTexImage2D sets (0,0,0,0) for pixels outside the framebuffer. // Check that copyTexImage2D sets (0,0,0,0) for pixels outside the framebuffer.
...@@ -384,8 +392,16 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexImage2D) ...@@ -384,8 +392,16 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexImage2D)
Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexImage2D, true); Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexImage2D, true);
// TODO(fjhenigman): Enable this test as part of a CL that lets the test pass. #ifdef _WIN64
//Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexImageCube, true); // TODO(fjhenigman): Figure out this failure.
if (GetParam() == ES2_D3D11_FL9_3())
{
std::cout << "Cube map skipped on 64-bit " << GetParam() << "." << std::endl;
return;
}
#endif
Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexImageCube, true);
} }
// Check that copyTexSubImage3D does not set a destination pixel when // Check that copyTexSubImage3D does not set a destination pixel when
......
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