Commit eba008ad by Ian Elliott Committed by Commit Bot

Add end2end test for changing MAX_LEVEL with compressed texture

This is a follow-on to https://chromium-review.googlesource.com/c/angle/angle/+/2180881. This adds a comment explaining part of that solution, and an end2end test that creates a compressed texture and then renders after decreasing MAX_LEVEL and then again after increasing MAX_LEVEL. Bug: b/155499736 Change-Id: I04bb0dc9ead2807f7121e4c6b95ffd3594d5dcc0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2182174Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent a5829b2a
...@@ -1216,6 +1216,9 @@ angle::Result TextureVk::copyAndStageImageSubresource(ContextVk *contextVk, ...@@ -1216,6 +1216,9 @@ angle::Result TextureVk::copyAndStageImageSubresource(ContextVk *contextVk,
uint32_t bufferImageHeight = updatedExtents.height; uint32_t bufferImageHeight = updatedExtents.height;
if (desc.format.info->compressed) if (desc.format.info->compressed)
{ {
// In the case of a compressed texture, bufferRowLength can never be smaller than the
// compressed format's compressed block width, and bufferImageHeight can never be smaller
// than the compressed block height.
bufferRowLength = std::max(bufferRowLength, desc.format.info->compressedBlockWidth); bufferRowLength = std::max(bufferRowLength, desc.format.info->compressedBlockWidth);
bufferImageHeight = std::max(bufferImageHeight, desc.format.info->compressedBlockHeight); bufferImageHeight = std::max(bufferImageHeight, desc.format.info->compressedBlockHeight);
} }
......
...@@ -6145,6 +6145,70 @@ TEST_P(ETC1CompressedTextureTest, ETC1CompressedSubImage) ...@@ -6145,6 +6145,70 @@ TEST_P(ETC1CompressedTextureTest, ETC1CompressedSubImage)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Fully-define a compressed texture and draw; then decrease MAX_LEVEL and draw; then increase
// MAX_LEVEL and draw. This used to cause Vulkan validation errors.
TEST_P(ETC1CompressedTextureTest, ETC1ShrinkThenGrowMaxLevels)
{
// ETC texture formats are not supported on Mac OpenGL. http://anglebug.com/3853
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_compressed_ETC1_RGB8_sub_texture"));
const GLuint width = 4u;
const GLuint height = 4u;
setWindowWidth(width);
setWindowHeight(height);
// Setup primary Texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
if (getClientMajorVersion() < 3)
{
glTexStorage2DEXT(GL_TEXTURE_2D, 3, GL_ETC1_RGB8_OES, width, height);
}
else
{
glTexStorage2D(GL_TEXTURE_2D, 3, GL_ETC1_RGB8_OES, width, height);
}
ASSERT_GL_NO_ERROR();
// Populate a subimage of the texture
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_ETC1_RGB8_OES,
width * height / 2u, kCompressedImageETC2);
glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, width / 2, height / 2, GL_ETC1_RGB8_OES,
width * height / 2u, kCompressedImageETC2);
glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, width / 4, height / 4, GL_ETC1_RGB8_OES,
width * height / 2u, kCompressedImageETC2);
ASSERT_GL_NO_ERROR();
// Set MAX_LEVEL to 2 (the highest level)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
// Render and ensure we get red
glUseProgram(mProgram);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::red);
ASSERT_GL_NO_ERROR();
// Decrease MAX_LEVEL to 0, render, and ensure we still get red
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::red);
ASSERT_GL_NO_ERROR();
// Increase MAX_LEVEL back to 2, render, and ensure we still get red
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::red);
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST_ES2(Texture2DTest); ANGLE_INSTANTIATE_TEST_ES2(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