Commit c5af8ba6 by Geoff Lang Committed by Commit Bot

D3D11: Make sure to resolve the storage for CopyTexImage3D.

TextureD3D_3D::copySubImage worked around missing functionality in D3D11 for copying a framebuffer directly to a texture storage but didn't handle the case of a texture storage already existing. This caused the image to have out-of-date data before the new data was copied into it. Simply copy the data from the storage back into the image before performing the copy from the framebuffer and then copy back to the storage afterwards. TEST=conformance2/textures/misc/copy-texture-image-webgl-specific.html BUG=angleproject:1815 Change-Id: I308d6a1d3ecbc738f7d0e232bece433e6b353638 Reviewed-on: https://chromium-review.googlesource.com/567199 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d90b214f
......@@ -2396,29 +2396,23 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context,
destOffset.y + clippedSourceArea.y - sourceArea.y,
destOffset.z);
// Currently, 3D single-layer blits are broken because we don't know how to make an SRV
// for a single layer of a 3D texture.
// TODO(jmadill): Investigate 3D blits in D3D11.
// gl::ImageIndex index = gl::ImageIndex::Make3D(level);
// Currently, copying directly to the storage is not possible because it's not possible to
// create an SRV from a single layer of a 3D texture. Instead, make sure the image is up to
// date before the copy and then copy back to the storage afterwards if needed.
// TODO: Investigate 3D blits in D3D11.
// if (!canCreateRenderTargetForImage(index))
bool syncTexStorage = mTexStorage && isLevelComplete(level);
if (syncTexStorage)
{
ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, clippedDestOffset,
clippedSourceArea, source));
mDirtyImages = true;
gl::ImageIndex index = gl::ImageIndex::Make3D(level);
mImageArray[level]->copyFromTexStorage(context, index, mTexStorage);
}
ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, clippedDestOffset, clippedSourceArea,
source));
if (syncTexStorage)
{
updateStorageLevel(context, level);
}
// else
//{
// ANGLE_TRY(ensureRenderTarget());
// if (isValidLevel(level))
// {
// ANGLE_TRY(updateStorageLevel(context, level));
// ANGLE_TRY(mRenderer->copyImage3D(
// source, sourceArea,
// gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
// destOffset, mTexStorage, level));
// }
//}
return gl::NoError();
}
......
......@@ -424,6 +424,53 @@ TEST_P(RobustResourceInitTest, ReadingUninitialized3DTexture)
EXPECT_GL_NO_ERROR();
}
// Copy of the copytexsubimage3d_texture_wrongly_initialized test that is part of the WebGL2
// conformance suite: copy-texture-image-webgl-specific.html
TEST_P(RobustResourceInitTest, CopyTexSubImage3DTextureWronglyInitialized)
{
if (!setup() || getClientMajorVersion() < 3)
{
return;
}
if (IsOpenGL())
{
std::cout << "Robust resource init is not yet fully implemented. (" << GetParam() << ")"
<< std::endl;
return;
}
constexpr GLint kLayer = 0;
constexpr GLint kWidth = 2;
constexpr GLint kHeight = 2;
constexpr GLint kDepth = 2;
constexpr size_t kDataSize = kWidth * kHeight * 4;
GLTexture texture2D;
glBindTexture(GL_TEXTURE_2D, texture2D);
constexpr std::array<uint8_t, kDataSize> data = {{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
0x0F, 0x10}};
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
data.data());
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture2D, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
GLTexture texture3D;
glBindTexture(GL_TEXTURE_3D, texture3D);
glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, kWidth, kHeight, kDepth);
glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, kLayer, 0, 0, kWidth, kHeight);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture3D, 0, kLayer);
std::array<uint8_t, kDataSize> pixels;
glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
ASSERT_GL_NO_ERROR();
EXPECT_EQ(data, pixels);
}
ANGLE_INSTANTIATE_TEST(RobustResourceInitTest,
ES2_D3D9(),
ES2_D3D11(),
......
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