On 23 July 2012 15:27, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

These changes are required to enable no-draw-buffer-zero test case to use the<br>
shared code.<br>
<br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>><br>
---<br>
 .../draw-buffers-common.cpp                        |   24 +++++++++++++++----<br>
 1 files changed, 19 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp<br>
index 2829405..9158a0b 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp<br>
+++ b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp<br>
@@ -88,6 +88,7 @@ static int pattern_width;<br>
 static int pattern_height;<br>
<br>
 static bool is_buffer_zero_integer_format = false;<br>
+static GLenum draw_buffer_zero_format;<br>
<br>
 static const int num_components = 4; /* for RGBA formats */<br>
 static const int num_color_bits = 8; /* for GL_RGBA & GL_RGBA8I formats */<br>
@@ -440,10 +441,16 @@ compute_expected(bool sample_alpha_to_coverage,<br>
                        coverage[i] = 1.0;<br>
        }<br>
<br>
-       if (buffer_to_test == GL_COLOR_BUFFER_BIT)<br>
-               compute_expected_color(sample_alpha_to_coverage,<br>
-                                      sample_alpha_to_one,<br>
-                                      draw_buffer_count);<br>
+       if (buffer_to_test == GL_COLOR_BUFFER_BIT) {<br>
+               /* Don't compute expected color for color buffer zero<br>
+                * if no renderbuffer is attached to it.<br>
+                */<br>
+               if(draw_buffer_count ||<br>
+                  draw_buffer_zero_format != GL_NONE)<br>
+                       compute_expected_color(sample_alpha_to_coverage,<br>
+                                              sample_alpha_to_one,<br>
+                                              draw_buffer_count);<br>
+       }<br>
        else if (buffer_to_test == GL_DEPTH_BUFFER_BIT)<br>
                compute_expected_depth();<br></blockquote><div><br>I realize this isn't part of your patch, but it took me a while to understand that "draw_buffer_count" means "index of the draw buffer we are computing expected values for" and not "count of how many draw buffers there are".  You might want to consider a follow-up patch that changes the name of the variable to "draw_buffer_index".<br>

<br>Two other things that made it difficult for me to follow this change:<br>- Treating draw_buffer_count as a boolean in order to implicitly compare it with zero.<br>- The if statement computes when the expected color *should* be computed, and the comment says when the expected color *should not* be computed.<br>

<br>You might want to consider an alternative like this:<br><br>/* Don't compute expected color for color buffer zero<br> * if no renderbuffer is attached to it.<br> */<br>if (draw_buffer_count == 0 && draw_buffer_zero_format == GL_NONE)<br>

    return;<br>compute_expected_color(...);<br><br>As an added benefit, this would make the similarity more evident between this if test and the one below.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
@@ -461,6 +468,11 @@ probe_framebuffer_color(void)<br>
        int rect_height = pattern_height / num_rects;<br>
<br>
        for (int i = 0; i < num_draw_buffers; i++) {<br>
+               /* Don't probe color buffer zero if no renderbuffer is<br>
+                * attached to it.<br>
+                */<br>
+               if( i == 0 && draw_buffer_zero_format == GL_NONE)<br>
+                       continue;<br>
                bool is_integer_operation = is_buffer_zero_integer_format && !i;<br>
<br>
                if(is_integer_operation) {<br>
@@ -730,6 +742,7 @@ ms_fbo_and_draw_buffers_setup(int samples,<br>
<br>
        pattern_width = width;<br>
        pattern_height = height;<br>
+       draw_buffer_zero_format = color_buffer_zero_format;<br>
<br>
        /* Setup frame buffer objects with required configuration */<br>
        FboConfig ms_config(samples, pattern_width, pattern_height);<br>
@@ -752,7 +765,8 @@ ms_fbo_and_draw_buffers_setup(int samples,<br>
                resolve_int_fbo.setup(resolve_config);<br>
                is_buffer_zero_integer_format = true;<br>
        }<br>
-       else if (color_buffer_zero_format != GL_RGBA){<br>
+       else if (color_buffer_zero_format != GL_RGBA &&<br>
+                color_buffer_zero_format != GL_NONE) {<br>
                printf("Draw buffer zero format is not"<br>
                       " supported by test functions.\n");<br>
                piglit_report_result(PIGLIT_FAIL);<br>
<span><font color="#888888">--<br>
1.7.7.6<br>
<br>
</font></span></blockquote></div><br>My suggested changes are minor, so regardless of whether you decide to make them, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>><br>