Commit f097e238 by Jamie Madill Committed by Commit Bot

D3D11: Fix 3D texture redefinition bug.

We would incorrectly check the storage type after we had redefined it. Thus we would allow old storages to persist for some cases of 3D texture. This bug did not affect 2D textures. See WebGL 2 test: conformance2/misc/views-with-offsets.html BUG=angleproject:1609 Change-Id: I7a04ff498740bb5d7daf2cee174c336f97a44c01 Reviewed-on: https://chromium-review.googlesource.com/408417Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 0350a64c
...@@ -2234,12 +2234,12 @@ void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, const gl:: ...@@ -2234,12 +2234,12 @@ void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, const gl::
const int storageWidth = std::max(1, getLevelZeroWidth() >> level); const int storageWidth = std::max(1, getLevelZeroWidth() >> level);
const int storageHeight = std::max(1, getLevelZeroHeight() >> level); const int storageHeight = std::max(1, getLevelZeroHeight() >> level);
const int storageDepth = std::max(1, getLevelZeroDepth() >> level); const int storageDepth = std::max(1, getLevelZeroDepth() >> level);
const GLenum storageFormat = getBaseLevelInternalFormat();
mImageArray[level]->redefine(GL_TEXTURE_3D, internalformat, size, false); mImageArray[level]->redefine(GL_TEXTURE_3D, internalformat, size, false);
if (mTexStorage) if (mTexStorage)
{ {
const GLenum storageFormat = getBaseLevelInternalFormat();
const int storageLevels = mTexStorage->getLevelCount(); const int storageLevels = mTexStorage->getLevelCount();
if ((level >= storageLevels && storageLevels != 0) || if ((level >= storageLevels && storageLevels != 0) ||
......
...@@ -3649,6 +3649,31 @@ TEST_P(Texture2DTestES3, StaleUnpackData) ...@@ -3649,6 +3649,31 @@ TEST_P(Texture2DTestES3, StaleUnpackData)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// This test covers a D3D format redefinition bug for 3D textures. The base level format was not
// being properly checked, and the texture storage of the previous texture format was persisting.
// This would result in an ASSERT in debug and incorrect rendering in release.
// See http://anglebug.com/1609 and WebGL 2 test conformance2/misc/views-with-offsets.html.
TEST_P(Texture3DTestES3, FormatRedefinitionBug)
{
GLTexture tex;
glBindTexture(GL_TEXTURE_3D, tex.get());
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex.get(), 0, 0);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
std::vector<uint8_t> pixelData(100, 0);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB565, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 1, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
pixelData.data());
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
// TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278. // TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278.
ANGLE_INSTANTIATE_TEST(Texture2DTest, ANGLE_INSTANTIATE_TEST(Texture2DTest,
......
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