On Mon, Apr 2, 2012 at 7:32 AM, Brian Paul <span dir="ltr">&lt;<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>&gt;</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">


<div><div>On 04/02/2012 01:06 AM, Anuj Phogat wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Signed-off-by: Anuj Phogat&lt;<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>&gt;<br>
---<br>
  tests/all.tests                   |    1 +<br>
  tests/texturing/CMakeLists.gl.<u></u>txt |    1 +<br>
  tests/texturing/draw-pixels.c     |  215 ++++++++++++++++++++++++++++++<u></u>+++++++<br>
  3 files changed, 217 insertions(+), 0 deletions(-)<br>
  create mode 100644 tests/texturing/draw-pixels.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 5b3dc6b..f6e1c71 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -661,6 +661,7 @@ add_plain_test(texturing, &#39;depth-tex-modes-glsl&#39;)<br>
  add_plain_test(texturing, &#39;depth-tex-modes-rg&#39;)<br>
  add_plain_test(texturing, &#39;depth-tex-compare&#39;)<br>
  add_plain_test(texturing, &#39;depth-cube-map&#39;)<br>
+add_plain_test(texturing, &#39;draw-pixels&#39;)<br></blockquote></div></div></blockquote><div>I think this test should be moved to tests/general</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  add_plain_test(texturing, &#39;fragment-and-vertex-<u></u>texturing&#39;)<br>
  add_plain_test(texturing, &#39;fxt1-teximage&#39;)<br>
  add_plain_test(texturing, &#39;gen-teximage&#39;)<br>
diff --git a/tests/texturing/CMakeLists.<u></u>gl.txt b/tests/texturing/CMakeLists.<u></u>gl.txt<br>
index 01fbe94..3c3c4b0 100644<br>
--- a/tests/texturing/CMakeLists.<u></u>gl.txt<br>
+++ b/tests/texturing/CMakeLists.<u></u>gl.txt<br>
@@ -24,6 +24,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES &quot;Linux&quot;)<br>
  ENDIF(${CMAKE_SYSTEM_NAME} MATCHES &quot;Linux&quot;)<br>
  add_executable (cubemap cubemap.c)<br>
  add_executable (depth-level-clamp depth-level-clamp.c)<br>
+add_executable (draw-pixels draw-pixels.c)<br>
  add_executable (gen-compressed-teximage gen-compressed-teximage.c)<br>
  add_executable (gen-nonzero-unit gen-nonzero-unit.c)<br>
  add_executable (gen-teximage gen-teximage.c)<br>
diff --git a/tests/texturing/draw-pixels.<u></u>c b/tests/texturing/draw-pixels.<u></u>c<br>
new file mode 100644<br>
index 0000000..ad628c8<br>
--- /dev/null<br>
+++ b/tests/texturing/draw-pixels.<u></u>c<br>
@@ -0,0 +1,215 @@<br>
+/*<br>
+ * Copyright 2011 VMware, Inc.<br>
</blockquote>
<br></div></div>
Copyright Intel?</blockquote><div><br></div><div> Yes. I&#39;ll change it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the &quot;Software&quot;),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * file drawpixels.c<br>
+ *<br>
+ * Test to verify glDrawPixels() with various pixel formats<br>
+ */<br>
+<br>
+#include &quot;piglit-util.h&quot;<br>
+#define TEX_SIZE 16<br>
</blockquote>
<br></div></div>
Maybe rename that to IMAGE_SIZE size you don&#39;t actually create any textures with this size.</blockquote><div>I agree.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA |<br>
+                        GLUT_DEPTH | GLUT_STENCIL;<br>
+int piglit_width = TEX_SIZE, piglit_height = TEX_SIZE;<br>
+<br>
+static const GLfloat fcolor[15][4] = {<br>
+       /* GL_RED */<br>
+       {0.7, 0.0, 0.0, 1.0},<br>
+       /* GL_GREEN */<br>
+       {0.0, 0.7, 0.0, 1.0},<br>
+       /* GL_BLUE */<br>
+       {0.0, 0.0, 0.7, 1.0},<br>
+       /* GL_ALPHA */<br>
+       {0.0, 0.0, 0.0, 0.7},<br>
+       /* GL_RG */<br>
+       {0.4, 0.5, 0.0, 1.0},<br>
+       /* GL_RGB */<br>
+       {0.4, 0.8, 0.2, 1.0},<br>
+       /* GL_BGR */<br>
+       {0.2, 0.8, 0.4, 1.0},<br>
+       /* GL_RGBA */<br>
+       {0.5, 0.2, 0.8, 0.4},<br>
+       /* GL_BGRA */<br>
+       {0.8, 0.2, 0.5, 0.4},<br>
+       /* GL_LUMINANCE */<br>
+       {0.7, 0.7, 0.7, 1},<br>
+       /* GL_LUMINANCE_ALPHA */<br>
+       {0.4, 0.4, 0.4, 0.5},<br>
+       /* GL_DEPTH_COMPONENT */<br>
+       {0.7, 0.0, 0.0, 0.0},<br>
+       /* GL_STENCIL_INDEX */<br>
+       {2.0, 0.0, 0.0, 0.0},<br>
+       {0.0, 0.0, 0.0, 1.0},<br>
+       {1.0, 0.0, 0.0, 1.0}};<br>
+<br>
+GLfloat buf_rgba_color[TEX_SIZE][TEX_<u></u>SIZE][4];<br>
+GLfloat buf_rgb_color[TEX_SIZE][TEX_<u></u>SIZE][3];<br>
+GLfloat buf_rg_color[TEX_SIZE][TEX_<u></u>SIZE][2];<br>
+GLfloat buf_color[TEX_SIZE][TEX_SIZE];<br>
+GLfloat buf_stencil[TEX_SIZE][TEX_<u></u>SIZE];<br>
+<br>
+static const struct {<br>
+       GLenum format;<br>
+       GLvoid *pixels;<br>
+       const GLfloat *expected;<br>
+} test_vectors[] = {<br>
+       { GL_RED,               buf_color,              fcolor[0] },<br>
+       { GL_GREEN,             buf_color,              fcolor[1] },<br>
+       { GL_BLUE,              buf_color,              fcolor[2] },<br>
+       { GL_ALPHA,             buf_color,              fcolor[3] },<br>
+       { GL_RG,                buf_rg_color,           fcolor[4] },<br>
+       { GL_RGB,               buf_rgb_color,          fcolor[5] },<br>
+       { GL_BGR,               buf_rgb_color,          fcolor[6] },<br>
+       { GL_RGBA,              buf_rgba_color,         fcolor[7] },<br>
+       { GL_BGRA,              buf_rgba_color,         fcolor[8] },<br>
+       { GL_LUMINANCE,         buf_color,              fcolor[9] },<br>
+       { GL_LUMINANCE_ALPHA,   buf_rg_color,           fcolor[10] },<br>
+       { GL_DEPTH_COMPONENT,   buf_color,              fcolor[11] },<br>
+       { GL_STENCIL_INDEX,     buf_stencil,            fcolor[12] }<br>
+};<br>
+#define NUM_FORMATS (sizeof(test_vectors) / sizeof(test_vectors[0]))<br>
</blockquote>
<br></div></div>
You can just use the ARRAY_SIZE() macro in the code below.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
+<br>
+/* Initialize pixel data */<br>
+static void<br>
+pixelsInit(void)<br>
+{<br>
+       int i, j;<br>
+       for (i = 0; i&lt;  TEX_SIZE; i++) {<br>
+               for (j = 0; j&lt;  TEX_SIZE; j++) {<br>
+                       buf_rgba_color[i][j][0] = 0.5;<br>
+                       buf_rgba_color[i][j][1] = 0.2;<br>
+                       buf_rgba_color[i][j][2] = 0.8;<br>
+                       buf_rgba_color[i][j][3] = 0.4;<br>
+<br>
+                       buf_rgb_color[i][j][0] = 0.4;<br>
+                       buf_rgb_color[i][j][1] = 0.8;<br>
+                       buf_rgb_color[i][j][2] = 0.2;<br>
+<br>
+                       buf_rg_color[i][j][0] = 0.4;<br>
+                       buf_rg_color[i][j][1] = 0.5;<br>
+<br>
+                       buf_color[i][j] = 0.7;<br>
+                       buf_stencil[i][j] = 2.0;<br>
+               }<br>
+       }<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       GLboolean pass = GL_TRUE;<br>
+       int j;<br>
+<br>
+       for (j = 0; j&lt;  NUM_FORMATS; j++) {<br>
+<br>
+               glClear(GL_COLOR_BUFFER_BIT);<br>
+               /* Draw a pixel rectangle with float color data. As per OpenGL 3.0<br>
+                * specification integer formats are not allowed in glDrawPixels<br>
+                */<br></div></div>
+               pass = piglit_check_gl_error(GL_NO_<u></u>ERROR)&amp;&amp;  pass;<div><br>
+<br>
+               switch(test_vectors[j].format) {<br>
+               case GL_RED:<br>
+               case GL_GREEN:<br>
+               case GL_BLUE:<br>
+               case GL_ALPHA:<br>
+               case GL_LUMINANCE:<br>
+               case GL_LUMINANCE_ALPHA:<br>
+               case GL_RG:<br>
+               case GL_RGB:<br>
+               case GL_BGR:<br>
+               case GL_RGBA:<br>
+               case GL_BGRA:<br>
</div></blockquote>
<br>
For the RG format you should check if GL_ARB_texture_rg is supported.</blockquote><div>right</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>



<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                       glDrawPixels(TEX_SIZE, TEX_SIZE, test_vectors[j].format,<br>
+                                    GL_FLOAT, test_vectors[j].pixels);<br>
+<br>
+                       pass = piglit_probe_rect_rgba(0, 0,<br>
+                              TEX_SIZE, TEX_SIZE,<br>
+                              test_vectors[j].expected)<br>
+                       &amp;&amp;  pass;<br>
+                       break;<br>
+<br>
+               case GL_DEPTH_COMPONENT:<br>
+                       glEnable(GL_DEPTH_TEST);<br>
+                       glClearDepth(0.0);<br>
+                       glDepthFunc(GL_ALWAYS);<br>
+                       glClear(GL_DEPTH_BUFFER_BIT);<br>
+                       glDrawPixels(TEX_SIZE, TEX_SIZE, test_vectors[j].format,<br>
+                                    GL_FLOAT, test_vectors[j].pixels);<br>
+<br>
+                       pass = piglit_probe_rect_depth(0, 0,<br>
+                              TEX_SIZE, TEX_SIZE,<br>
+                              test_vectors[j].expected[0])<br>
+                       &amp;&amp;  pass;<br>
+                       glDisable(GL_DEPTH_TEST);<br>
+                       break;<br>
+<br>
+               case GL_STENCIL_INDEX:<br>
+                       glClearStencil(0.0);<br>
+                       glClear(GL_STENCIL_BUFFER_BIT)<u></u>;<br>
+                       glDrawPixels(TEX_SIZE, TEX_SIZE, test_vectors[j].format,<br>
+                                    GL_FLOAT, test_vectors[j].pixels);<br>
+                       /* Probe stencil buffer */<br>
+                       pass = piglit_probe_rect_stencil(0, 0,<br>
+                                               TEX_SIZE, TEX_SIZE,<br>
+                                               test_vectors[j].expected[0])<br>
+                       &amp;&amp;  pass;<br>
+<br>
+                       glEnable(GL_STENCIL_TEST);<br>
+                       glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);<br>
+<br>
+                       glStencilFunc(GL_EQUAL, 1, ~0);<br>
+                       glColor4f(1.0, 0.0, 0.0, 1.0);<br>
+                       piglit_draw_rect(0, 0, piglit_width, piglit_height);<br>
+                       /* Probe color buffer. Color buffer will stay<br>
+                        * unaffected by piglit_draw_rect()<br>
+                        */<br>
+                       pass = piglit_probe_rect_rgba(0, 0,<br>
+                              TEX_SIZE, TEX_SIZE,<br>
+                              test_vectors[j].expected + 4)<br>
+                       &amp;&amp;  pass;<br>
+<br>
+                       glStencilFunc(GL_EQUAL, 2, ~0);<br>
+                       piglit_draw_rect(0, 0, piglit_width, piglit_height);<br>
+                       pass = piglit_probe_rect_rgba(0, 0,<br>
+                              TEX_SIZE, TEX_SIZE,<br>
+                              test_vectors[j].expected + 8)<br>
+                       &amp;&amp;  pass;<br>
+<br>
+                       glDisable(GL_STENCIL_TEST);<br>
+                       break;<br>
+               }<br>
+       }<br>
+       return (pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       glClearColor(0.0, 0.0, 0.0, 1.0);<br>
+       piglit_ortho_projection(<u></u>piglit_width, piglit_height, GL_TRUE);<br>
+       pixelsInit();<br>
+<br>
+}<br>
</blockquote>
<br></div></div>
Is the intention of this test to just do quick, basic glDrawPixels testing?  There are tons of format/type combinations for glDrawPixels that, ideally, should be tested.</blockquote><div>I want to make it a comprehensive test. I&#39;ll add the testing for other types in my next update.  </div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  Plus pixel transfer, etc.<span><font color="#888888"><br>
<br>
-Brian<br>
</font></span></blockquote></div><br>