[Piglit] [PATCH] fast-clear: Skip formats that are not color renderable

Neil Roberts neil at linux.intel.com
Thu Nov 19 03:23:15 PST 2015


fbo-formats.h contains some formats that are not marked as color
renderable in the spec, eg, the non-sized formats such as RG_INTEGER.
The spec disallows these formats in glTexImage2DMultisample and it
generates an error. Previously this didn't matter because it would end
up making the FBO incomplete and the format would be skipped. However,
since 1f172a09ea2 there is an assert if it can't find any components
with bits in the texture and this gets hit for these invalid formats.
This patch makes it check for the GL_INVALID_ENUM error upfront after
calling glTexImage2DMultisample so that it skips the format earlier.

It could be nice to use GL_ARB_internalformat_query2 to check whether
the format is color renderable and avoid generating the error
entirely, but that extension isn't implemented yet on i965.

Cc: Vinson Lee <vlee at freedesktop.org>
---
 .../spec/ext_framebuffer_multisample/fast-clear.c  | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/spec/ext_framebuffer_multisample/fast-clear.c b/tests/spec/ext_framebuffer_multisample/fast-clear.c
index ad9d170..b3b57bf 100644
--- a/tests/spec/ext_framebuffer_multisample/fast-clear.c
+++ b/tests/spec/ext_framebuffer_multisample/fast-clear.c
@@ -230,6 +230,7 @@ test_format(const struct format_desc *format)
 	enum piglit_result color_result;
 	GLint l_size, i_size, r_size, g_size, b_size, a_size;
 	GLenum type_param;
+	GLenum tex_error;
 	GLint type;
 	GLuint tex;
 	GLuint fbo;
@@ -246,12 +247,34 @@ test_format(const struct format_desc *format)
 
 	glGenTextures(1, &tex);
 	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
+
+	piglit_reset_gl_error();
+
 	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,
 				1, /* samples */
 				format->internalformat,
 				1, 1, /* width/height */
 				GL_FALSE /* fixed sample locations */);
 
+	tex_error = glGetError();
+
+	if (tex_error != GL_NO_ERROR) {
+		glDeleteTextures(1, &tex);
+
+		if (tex_error == GL_INVALID_ENUM) {
+			/* You're only supposed to pass color renderable
+			 * formats to glTexImage2DMultisample.
+			 */
+			printf("Format is not color renderable\n");
+			return PIGLIT_SKIP;
+		} else {
+			printf("Unexpected GL error: %s 0x%x\n",
+			       piglit_get_gl_error_name(tex_error),
+			       tex_error);
+			return PIGLIT_FAIL;
+		}
+	}
+
 	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
 				 GL_TEXTURE_LUMINANCE_SIZE, &l_size);
 	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
-- 
1.9.3



More information about the Piglit mailing list