From: Marek Olšák <[email protected]>

---
 tests/spec/ext_framebuffer_multisample/formats.cpp | 35 ++++++++++++++--------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/tests/spec/ext_framebuffer_multisample/formats.cpp 
b/tests/spec/ext_framebuffer_multisample/formats.cpp
index 3694302..8ade1dc 100644
--- a/tests/spec/ext_framebuffer_multisample/formats.cpp
+++ b/tests/spec/ext_framebuffer_multisample/formats.cpp
@@ -78,7 +78,7 @@ ColorGradientSunburst *test_pattern_uvec4;
 class PatternRenderer
 {
 public:
-       bool try_setup(GLenum internalformat);
+       enum piglit_result try_setup(GLenum internalformat);
        void set_piglit_tolerance();
        void set_color_clamping_mode();
        void draw();
@@ -137,7 +137,7 @@ public:
  * MSAA format.  Return false if one or more of the framebuffers is
  * incomplete.
  */
-bool
+enum piglit_result
 PatternRenderer::try_setup(GLenum internalformat)
 {
        FboConfig config_downsampled(0, pattern_width, pattern_height);
@@ -147,8 +147,10 @@ PatternRenderer::try_setup(GLenum internalformat)
        config_msaa.num_samples = num_samples;
 
        if (!(fbo_downsampled.try_setup(config_downsampled) &&
-             fbo_msaa.try_setup(config_msaa)))
-               return false;
+             fbo_msaa.try_setup(config_msaa))) {
+               printf("Unsupported framebuffer combination\n");
+               return PIGLIT_SKIP;
+       }
 
        glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_downsampled.handle);
        glGetFramebufferAttachmentParameteriv(
@@ -168,18 +170,26 @@ PatternRenderer::try_setup(GLenum internalformat)
                GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
                (GLint *) &component_type);
 
+       int num_bits = 0;
+       for (int i = 0; i < 4 && !num_bits; i++)
+               num_bits = color_bits[i];
+       if (!num_bits) {
+               printf("Red, green, blue, and alpha sizes are all zero.\n");
+               return PIGLIT_FAIL;
+       }
+
        color_clamping_mode = GL_FIXED_ONLY;
        switch (component_type) {
        case GL_INT:
                assert(test_pattern_ivec4);
                test_pattern = test_pattern_ivec4;
-               color_offset = 1.0 - pow(2.0, color_bits[0] - 1);
+               color_offset = 1.0 - pow(2.0, num_bits - 1);
                color_scale = -2.0 * color_offset;
                break;
        case GL_UNSIGNED_INT:
                assert(test_pattern_uvec4);
                test_pattern = test_pattern_uvec4;
-               color_scale = pow(2.0, color_bits[0]) - 1.0;
+               color_scale = pow(2.0, num_bits) - 1.0;
                color_offset = 0.0;
                break;
        case GL_UNSIGNED_NORMALIZED:
@@ -222,7 +232,7 @@ PatternRenderer::try_setup(GLenum internalformat)
                GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &color_encoding);
        is_srgb = color_encoding == GL_SRGB;
 
-       return true;
+       return PIGLIT_PASS;
 }
 
 
@@ -485,26 +495,25 @@ test_format(const struct format_desc *format)
         * supported, we might have received a GL error.  In either
         * case just skip to the next format.
         */
-       bool setup_success = test_renderer.try_setup(format->internalformat);
+       enum piglit_result setup_status = 
test_renderer.try_setup(format->internalformat);
        if (glGetError() != GL_NO_ERROR) {
                printf("Error setting up test renderbuffers\n");
                return PIGLIT_SKIP;
        }
-       if (!setup_success) {
-               printf("Unsupported framebuffer combination\n");
-               return PIGLIT_SKIP;
+       if (setup_status != PIGLIT_PASS) {
+               return setup_status;
        }
 
        /* Set up the framebuffers for rendering the reference image.
         * This shouldn't fail.
         */
-       setup_success = ref_renderer.try_setup(test_renderer.is_srgb ?
+       setup_status = ref_renderer.try_setup(test_renderer.is_srgb ?
                                               GL_SRGB8_ALPHA8 : GL_RGBA);
        if (!piglit_check_gl_error(GL_NO_ERROR)) {
                printf("Error setting up reference renderbuffers\n");
                return PIGLIT_FAIL;
        }
-       if (!setup_success) {
+       if (setup_status != PIGLIT_PASS) {
                printf("Reference framebuffer combination is unsupported\n");
                return PIGLIT_FAIL;
        }
-- 
1.8.3.2

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to