Re: [Mesa-dev] [PATCH] Add a draw-pixel-with-texture testcase

2011-11-23 Thread Eric Anholt
On Mon, 21 Nov 2011 16:27:57 +0800, Yuanhan Liu yuanhan@linux.intel.com 
wrote:
 Add a draw-pixel-with-texture testcase to check if texture
 sampling is happened while drawing pixels by glDrawPixels.
 
 v2: use piglit_probe_rect_rgba instead of just sampling a
 set of pixels(comments from Eric)
 
 Signed-off-by: Yuanhan Liu yuanhan@linux.intel.com
 ---
  tests/all.tests |1 +
  tests/general/CMakeLists.gl.txt |1 +
  tests/general/draw-pixel-with-texture.c |   77 
 +++
  3 files changed, 79 insertions(+), 0 deletions(-)
  create mode 100644 tests/general/draw-pixel-with-texture.c
 
 diff --git a/tests/all.tests b/tests/all.tests
 index 48ce2cb..851db11 100644
 --- a/tests/all.tests
 +++ b/tests/all.tests
 @@ -242,6 +242,7 @@ general['draw-elements-user'] = 
 PlainExecTest(['draw-elements', '-auto', 'user']
  add_plain_test(general, 'draw-elements-vs-inputs')
  add_plain_test(general, 'draw-instanced')
  add_plain_test(general, 'draw-instanced-divisor')
 +add_plain_test(general, 'draw-pixel-with-texture')
  add_plain_test(general, 'draw-vertices')
  general['draw-vertices-user'] = PlainExecTest(['draw-vertices', '-auto', 
 'user'])
  add_plain_test(general, 'draw-vertices-half-float')

 diff --git a/tests/general/draw-pixel-with-texture.c 
 b/tests/general/draw-pixel-with-texture.c
 new file mode 100644
 index 000..73e04c5
 --- /dev/null
 +++ b/tests/general/draw-pixel-with-texture.c

 + glutSwapBuffers();

Similarly to the other test, I think with a piglit_present_results()
here, you could make this an add_concurrent_test instead of
add_plain_test.  Other than that, looks great!

Reviewed-by: Eric Anholt e...@anholt.net


pgpCr7tH4EmFX.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Add a draw-pixel-with-texture testcase

2011-11-21 Thread Yuanhan Liu
Add a draw-pixel-with-texture testcase to check if texture
sampling is happened while drawing pixels by glDrawPixels.

v2: use piglit_probe_rect_rgba instead of just sampling a
set of pixels(comments from Eric)

Signed-off-by: Yuanhan Liu yuanhan@linux.intel.com
---
 tests/all.tests |1 +
 tests/general/CMakeLists.gl.txt |1 +
 tests/general/draw-pixel-with-texture.c |   77 +++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 tests/general/draw-pixel-with-texture.c

diff --git a/tests/all.tests b/tests/all.tests
index 48ce2cb..851db11 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -242,6 +242,7 @@ general['draw-elements-user'] = 
PlainExecTest(['draw-elements', '-auto', 'user']
 add_plain_test(general, 'draw-elements-vs-inputs')
 add_plain_test(general, 'draw-instanced')
 add_plain_test(general, 'draw-instanced-divisor')
+add_plain_test(general, 'draw-pixel-with-texture')
 add_plain_test(general, 'draw-vertices')
 general['draw-vertices-user'] = PlainExecTest(['draw-vertices', '-auto', 
'user'])
 add_plain_test(general, 'draw-vertices-half-float')
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 2cfc7be..58cbaa1 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -42,6 +42,7 @@ ENDIF (UNIX)
 add_executable (draw-elements-vs-inputs draw-elements-vs-inputs.c)
 add_executable (draw-instanced draw-instanced.c)
 add_executable (draw-instanced-divisor draw-instanced-divisor.c)
+add_executable (draw-pixel-with-texture draw-pixel-with-texture.c)
 add_executable (draw-sync draw-sync.c)
 add_executable (draw-vertices draw-vertices.c)
 add_executable (draw-vertices-half-float draw-vertices-half-float.c)
diff --git a/tests/general/draw-pixel-with-texture.c 
b/tests/general/draw-pixel-with-texture.c
new file mode 100644
index 000..73e04c5
--- /dev/null
+++ b/tests/general/draw-pixel-with-texture.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Yuanhan Liu yuanhan@linux.intel.com
+ */
+
+#include piglit-util.h
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+#define SCREEN_SIZE_IN_PIXELS  (piglit_width * piglit_height * 4)
+
+
+enum piglit_result
+piglit_display(void)
+{
+   GLboolean pass = GL_TRUE;
+   GLfloat tex_data[2 * 2 * 4] = {
+   1, 0, 0, 1, 1, 0, 0, 1,
+   1, 0, 0, 1, 1, 0, 0, 1,
+   };
+   GLfloat pixels[SCREEN_SIZE_IN_PIXELS];
+   GLfloat expected[4] = {0.2, 0, 0, 1};
+   int i;
+
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_FLOAT, 
tex_data);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+   glTexCoord2f(0.5, 0.5);
+   glEnable(GL_TEXTURE_2D);
+
+   for (i = 0; i  SCREEN_SIZE_IN_PIXELS; i += 4) {
+   pixels[i + 0] = 0.2;
+   pixels[i + 1] = 1;
+   pixels[i + 2] = 0;
+   pixels[i + 3] = 1;
+   }
+
+   glClear(GL_COLOR_BUFFER_BIT);
+   glDrawPixels(piglit_width, piglit_height, GL_RGBA, GL_FLOAT, pixels);
+
+   pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, 
expected);
+
+   glutSwapBuffers();
+
+   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+   glClearColor(0.0, 0.0, 0.0, 1.0);
+}
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev