[Piglit] [PATCH 2/2] arb_texture_view: check the initial value of GL_TEXTURE_MAX_LEVEL
Nicolai Hähnle
nhaehnle at gmail.com
Thu Oct 22 04:47:01 PDT 2015
This test is a bit pedantic and the required behavior is perhaps
surprising, but it's what the spec says and it's compatible with
the clamping that Mesa does when you try to explicitly set a large
MAX_LEVEL via glTexParameteri.
---
tests/spec/arb_texture_view/max-level.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tests/spec/arb_texture_view/max-level.c b/tests/spec/arb_texture_view/max-level.c
index ee25adf..b6dd326 100644
--- a/tests/spec/arb_texture_view/max-level.c
+++ b/tests/spec/arb_texture_view/max-level.c
@@ -77,6 +77,7 @@ test_max_level(void)
const unsigned int numPixels = WIDTH * HEIGHT;
GLuint texData[WIDTH * HEIGHT];
GLuint i, texFbo, tex, view, fbo, vertexArray, vertexBuf, l;
+ GLint level;
for (i = 0; i < numPixels; ++i) {
texData[i] = white;
@@ -119,6 +120,32 @@ test_max_level(void)
glTextureView(view, GL_TEXTURE_2D, tex, GL_RGBA8,
VIEW_LEVEL, 1, 0, 1);
glBindTexture(GL_TEXTURE_2D, view);
+
+ /*
+ * OpenGL 4.4 spec, section 8.14.3 says:
+ *
+ * For immutable-format textures (see section 8.19), [...] level_max
+ * is then clamped to the range [level_base , level_immut − 1], [...]
+ * where level_immut is the levels parameter passed to TexStorage*
+ * for the texture object (the value of TEXTURE_IMMUTABLE_LEVELS;
+ * see section 8.19).
+ *
+ * and section 8.18 says this about glTextureView:
+ *
+ * If the command is successful, the texture parameters in texture
+ * are updated as follows:
+ * [...]
+ * * TEXTURE_IMMUTABLE_LEVELS is set to the value of TEXTURE_-
+ * IMMUTABLE_LEVELS for origtexture.
+ *
+ */
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &level);
+ if (level != LEVELS - 1) {
+ printf("GL_TEXTURE_MAX_LEVEL is %d instead of %d after "
+ "glTextureView\n", level, LEVELS - 1);
+ return false;
+ }
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
--
2.1.4
More information about the Piglit
mailing list