Fix determining texture mipmap completeness
The code didn't previously take base level properly into account
when determining how many levels to check when checking for texture
completeness.
The code is refactored so that the "q" value in spec, that is the
maximum mipmap level for determining completeness, can be queried from
TextureState. This value is used now for checking completeness.
This requires moving ImageDescs under TextureState. Functions that
operate on the ImageDesc array are also moved from Texture to
TextureState. TextureState members are also renamed to start with the
"m" prefix and made private.
Also handle levels outside the base/max level range consistently in
eglCreateImageKHR validation. We interpret the spec so that if the
level used for the EGL image is not a part of the texture levels that
affect texture completeness, an error is generated.
BUG=angleproject:596
TEST=angle_end2end_tests
Change-Id: I038ef24aa83e0a6905ca3c0bbada5989eecb00d9
Reviewed-on: https://chromium-review.googlesource.com/344880
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp
index 742ffbd..b086461 100644
--- a/src/tests/gl_tests/TextureTest.cpp
+++ b/src/tests/gl_tests/TextureTest.cpp
@@ -1701,6 +1701,45 @@
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
+// Test that drawing works correctly when level 0 is undefined and base level is 1.
+TEST_P(Texture2DTestES3, DrawWithLevelZeroUndefined)
+{
+ if (IsAMD() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
+ {
+ // Observed crashing on AMD. Oddly the crash only happens with 2D textures, not 3D or array.
+ std::cout << "Test skipped on AMD OpenGL." << std::endl;
+ return;
+ }
+ if (IsOSX())
+ {
+ // Observed incorrect rendering on OSX.
+ std::cout << "Test skipped on OSX." << std::endl;
+ return;
+ }
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, mTexture2D);
+ std::vector<GLColor> texDataGreen(2u * 2u, GLColor::green);
+ glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ texDataGreen.data());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
+
+ EXPECT_GL_NO_ERROR();
+
+ // Texture is incomplete.
+ drawQuad(mProgram, "position", 0.5f);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
+
+ glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ texDataGreen.data());
+
+ // Texture is now complete.
+ drawQuad(mProgram, "position", 0.5f);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
+}
+
// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range have
// dimensions that don't fit the images inside the range.
// GLES 3.0.4 section 3.8.13 Texture completeness