On 16 July 2012 15:47, <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">
From: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>><br>
<br>
visualize_image function is utilized by multiple msaa test cases.<br>
<br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>><br>
---<br>
tests/spec/ext_framebuffer_multisample/common.cpp | 84 ++++++++++++++++++++<br>
tests/spec/ext_framebuffer_multisample/common.h | 5 +<br>
tests/spec/ext_framebuffer_multisample/formats.cpp | 77 +++----------------<br>
3 files changed, 99 insertions(+), 67 deletions(-)<br>
<br>
diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp<br>
index e1f6127..8bff701 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/common.cpp<br>
+++ b/tests/spec/ext_framebuffer_multisample/common.cpp<br>
@@ -1667,3 +1667,87 @@ create_test(test_type_enum test_type, int n_samples, bool small,<br>
pattern_height, supersample_factor);<br>
return test;<br>
}<br>
+<br>
+/**<br>
+ * Convert the image into a format that can be easily understood by<br>
+ * visual inspection, and display it on the screen.<br>
+ *<br>
+ * Luminance and intensity values are converted to a grayscale value.<br>
+ * Alpha values are visualized by blending the image with a grayscale<br>
+ * checkerboard.<br>
+ *<br>
+ * Pass image_count = 0 to disable drawing multiple images to window<br>
+ * system framebuffer.<br>
+ */<br>
+void<br>
+visualize_image(float *img, GLenum base_internal_format,<br>
+ int image_width, int image_height,<br>
+ int image_count, bool rhs)<br>
+{<br>
+ unsigned components = piglit_num_components(base_internal_format);<br>
+ float *visualization =<br>
+ (float *) malloc(sizeof(float)*3*image_width*image_height);<br>
+ for (int y = 0; y < image_height; ++y) {<br>
+ for (int x = 0; x < image_width; ++x) {<br>
+ float r = 0, g = 0, b = 0, a = 1;<br>
+ float *pixel =<br>
+ &img[(y * image_width + x) * components];<br>
+ switch (base_internal_format) {<br>
+ case GL_ALPHA:<br>
+ a = pixel[0];<br>
+ break;<br>
+ case GL_RGBA:<br>
+ a = pixel[3];<br>
+ /* Fall through */<br>
+ case GL_RGB:<br>
+ b = pixel[2];<br>
+ /* Fall through */<br>
+ case GL_RG:<br>
+ g = pixel[1];<br>
+ /* Fall through */<br>
+ case GL_RED:<br>
+ r = pixel[0];<br>
+ break;<br>
+ case GL_LUMINANCE_ALPHA:<br>
+ a = pixel[1];<br>
+ /* Fall through */<br>
+ case GL_INTENSITY:<br>
+ case GL_LUMINANCE:<br>
+ r = pixel[0];<br>
+ g = pixel[0];<br>
+ b = pixel[0];<br>
+ break;<br>
+ }<br>
+ float checker = ((x ^ y) & 0x10) ? 0.75 : 0.25;<br>
+ r = r * a + checker * (1 - a);<br>
+ g = g * a + checker * (1 - a);<br>
+ b = b * a + checker * (1 - a);<br>
+ visualization[(y * image_width + x) * 3] = r;<br>
+ visualization[(y * image_width + x) * 3 + 1] = g;<br>
+ visualization[(y * image_width + x) * 3 + 2] = b;<br>
+ }<br>
+ }<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ glUseProgram(0);<br>
+<br>
+ /* To simultaneously display multiple images on window system<br>
+ * framebuffer.<br>
+ */<br>
+ if(image_count) {<br>
+ glViewport(0, 0, image_width, image_height);<br>
+ /* Use glWindowPos to directly update x, y coordinates of<br>
+ * current raster position without getting transformed by<br>
+ * modelview projection matrix and viewport-to-window<br>
+ * transform.<br>
+ */<br>
+ glWindowPos2f(rhs ? image_width : 0,<br>
+ (image_count - 1) * image_height);<br>
+ }<br>
+ else {<br>
+ glViewport(0, 0, piglit_width, piglit_height);<br>
+ glRasterPos2f(rhs ? 0 : -1, -1);<br>
+ }<br>
+ glDrawPixels(image_width, image_height, GL_RGB, GL_FLOAT,<br>
+ visualization);<br>
+ free(visualization);<br>
+}<br></blockquote><div><br>I don't think the calls to glViewport() are necessary. I realize you copied this code from me, but I think I was confused when I wrote the function in the first place :)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h<br>
index d941e96..fda9f26 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/common.h<br>
+++ b/tests/spec/ext_framebuffer_multisample/common.h<br>
@@ -543,3 +543,8 @@ Test *<br>
create_test(test_type_enum test_type, int n_samples, bool small,<br>
bool combine_depth_stencil, int pattern_width,<br>
int pattern_height, int supersample_factor);<br>
+<br>
+void<br>
+visualize_image(float *img, GLenum base_internal_format,<br>
+ int image_width, int image_height,<br>
+ int draw_buffer_count, bool rhs);<br>
diff --git a/tests/spec/ext_framebuffer_multisample/formats.cpp b/tests/spec/ext_framebuffer_multisample/formats.cpp<br>
index 55542aa..ac2473a 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/formats.cpp<br>
+++ b/tests/spec/ext_framebuffer_multisample/formats.cpp<br>
@@ -350,70 +350,6 @@ PatternRenderer ref_renderer;<br>
<br>
<br>
/**<br>
- * Convert the image into a format that can be easily understood by<br>
- * visual inspection, and display it on the screen.<br>
- *<br>
- * Luminance and intensity values are converted to a grayscale value.<br>
- * Alpha values are visualized by blending the image with a grayscale<br>
- * checkerboard.<br>
- */<br>
-void<br>
-visualize_image(float *img, GLenum base_internal_format, bool rhs)<br>
-{<br>
- unsigned components = piglit_num_components(base_internal_format);<br>
- float *visualization =<br>
- (float *) malloc(sizeof(float)*3*pattern_width*pattern_height);<br>
- for (int y = 0; y < pattern_height; ++y) {<br>
- for (int x = 0; x < pattern_width; ++x) {<br>
- float r = 0, g = 0, b = 0, a = 1;<br>
- float *pixel =<br>
- &img[(y * pattern_width + x) * components];<br>
- switch (base_internal_format) {<br>
- case GL_ALPHA:<br>
- a = pixel[0];<br>
- break;<br>
- case GL_RGBA:<br>
- a = pixel[3];<br>
- /* Fall through */<br>
- case GL_RGB:<br>
- b = pixel[2];<br>
- /* Fall through */<br>
- case GL_RG:<br>
- g = pixel[1];<br>
- /* Fall through */<br>
- case GL_RED:<br>
- r = pixel[0];<br>
- break;<br>
- case GL_LUMINANCE_ALPHA:<br>
- a = pixel[1];<br>
- /* Fall through */<br>
- case GL_INTENSITY:<br>
- case GL_LUMINANCE:<br>
- r = pixel[0];<br>
- g = pixel[0];<br>
- b = pixel[0];<br>
- break;<br>
- }<br>
- float checker = ((x ^ y) & 0x10) ? 0.75 : 0.25;<br>
- r = r * a + checker * (1 - a);<br>
- g = g * a + checker * (1 - a);<br>
- b = b * a + checker * (1 - a);<br>
- visualization[(y * pattern_width + x) * 3] = r;<br>
- visualization[(y * pattern_width + x) * 3 + 1] = g;<br>
- visualization[(y * pattern_width + x) * 3 + 2] = b;<br>
- }<br>
- }<br>
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
- glViewport(0, 0, piglit_width, piglit_height);<br>
- glUseProgram(0);<br>
- glRasterPos2f(rhs ? 0 : -1, -1);<br>
- glDrawPixels(pattern_width, pattern_height, GL_RGB, GL_FLOAT,<br>
- visualization);<br>
- free(visualization);<br>
-}<br>
-<br>
-<br>
-/**<br>
* Transform the reference image (which is in GL_RGBA format) to an<br>
* expected image for a given base internal format, using the the<br>
* transformation described in the GL 3.0 spec, table 3.15 (Conversion<br>
@@ -537,10 +473,17 @@ test_format(const struct format_desc *format)<br>
expected_image, test_image);<br>
<br>
/* Show both the test and expected images on screen so that<br>
- * the user can diagnose problems.<br>
+ * the user can diagnose problems. Pass image_count = 0 to<br>
+ * display image without any offset applied to raster position.<br>
*/<br>
- visualize_image(test_image, format->base_internal_format, false);<br>
- visualize_image(expected_image, format->base_internal_format, true);<br>
+ visualize_image(test_image, format->base_internal_format,<br>
+ pattern_width, pattern_height,<br>
+ 0 /* image_count */,<br>
+ false /* rhs */);<br>
+ visualize_image(expected_image, format->base_internal_format,<br>
+ pattern_width, pattern_height,<br>
+ 0 /* image_count */,<br>
+ true /* rhs */);<br>
<br>
/* Finally, if any error occurred, count that as a failure. */<br>
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
<span><font color="#888888">--<br>
1.7.7.6<br>
<br>
</font></span></blockquote></div><br>Regardless, this is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>