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 <v...@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

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to