Re: [Piglit] [RFC 3/3] tests/spec: add tests for oes image external

2013-03-01 Thread Chad Versace
On 02/26/2013 05:15 AM, Topi Pohjolainen wrote:
 This consists of tests adapted from Khronos conformance suite and
 Android surface flinger. While the former deals with getters/setters,
 enumrations and simple sampling of texture based images, the latter
 addresses bilinear sampling of non-GPU written subsampled UV-planes
 and conversion from YUV to RGB.
 
 The original Android test consist of two YV12 formatted textures,
 one of size 64x64 and another of size 64x66. Both represent checker
 board pattern each YUV component having value 63 or 191. Here I have
 only the first but I'm planning to adopt the latter also if the approach
 I have taken is reasonable. Instead of filling in the entire pattern I
 have only written those YUV-components that are actually checked (a
 dozen odd pixels) while the rest are initialised to zero. In addition
 I used calculated floating point values instead of the hardcoded found
 in the original. There, however, I ended up in deviations and I would
 appreciate if people understanding the domain of YUV to RGB conversion
 better could take a good look.
 
 In the implementation that I have written for mesa/i965 I have also
 support for NV12 format. Whereas YV12 (YVU420) has separate U- and
 V-planes, NV12 has them combined into one. Hence I would like to have
 the same tests for NV12 as for YV12 if acceptable.
 
 The tests are written only for ES2 contexts, I haven't looked into
 how I would separate the tests not dealing with external sampler
 (samplerExternalOES is only defined for ES 2.x).
 
 Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
 ---
  tests/spec/CMakeLists.txt  |1 +
  .../oes_egl_image_external/CMakeLists.gles2.txt|   16 +
  tests/spec/oes_egl_image_external/CMakeLists.txt   |3 +
  .../oes_egl_image_external.c   |  776 
 
  4 files changed, 796 insertions(+)
  create mode 100644 tests/spec/oes_egl_image_external/CMakeLists.gles2.txt
  create mode 100644 tests/spec/oes_egl_image_external/CMakeLists.txt
  create mode 100644 tests/spec/oes_egl_image_external/oes_egl_image_external.c





 +static bool
 +test_64x64_yv12(void)
 +{
 + bool pass;
 + unsigned char y[64 * 64];
 + unsigned char u[32 * 32];
 + unsigned char v[32 * 32];
 + EGLImageKHR img;
 + void *buf;
 +
 + write_64x64_420(y, u, v);
 + /* Reversing the order of UV-planes gives YVU420 a.k.a. YV12 */
 + buf = piglit_create_ext_420_buf(64, 64, true, y, u, v);
 + if (!buf) {
 + printf(failed to create external buffer\n);
 + return false;

As I mentioned in patch 1, this is one of the places where the test
should skip if the platform is incapable of creating a yuv420 buffer.
If the the platform *is* capable of creating a yuv420, but fails to
do so, only then does it make sense to fail here.

 + }



 +/**
 + * INVALID_ENUM should be generated for TexImage2D, TexSubImage2D,
 + * CompressedTexImager2D and CompressedTexSubImage2D with
 + * TEXTURE_EXTERNAL_OES.
 + */
 +static bool
 +test_disallow_image_2d(void)
 +{
 + GLushort pixel_2x2_565[] = { 0, 0, 0, 0 };
 + GLuint tex;
 +
 + glGenTextures(1, tex);
 + glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
 +
 + glTexImage2D(GL_TEXTURE_EXTERNAL_OES, 0, GL_RGB, 2, 2, 0, GL_RGB,
 + GL_UNSIGNED_SHORT_5_6_5, pixel_2x2_565);
 + if (glGetError() != GL_INVALID_ENUM) {
 + printf(TexImage2D() cannot be invoked for EXTERNAL_OES\n);
 + glDeleteTextures(1, tex);
 + return false;
 + }

Piglit has a useful utility for checking GL errors: piglit_check_gl_error().
It prints good diagnostic information, so please use it here and in similar
places in your test. A quick grep should show you how to use it.



I tried reviewing the whole test, but quickly realized that I don't know
enough about color formats to do so.

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [RFC 3/3] tests/spec: add tests for oes image external

2013-02-26 Thread Topi Pohjolainen
This consists of tests adapted from Khronos conformance suite and
Android surface flinger. While the former deals with getters/setters,
enumrations and simple sampling of texture based images, the latter
addresses bilinear sampling of non-GPU written subsampled UV-planes
and conversion from YUV to RGB.

The original Android test consist of two YV12 formatted textures,
one of size 64x64 and another of size 64x66. Both represent checker
board pattern each YUV component having value 63 or 191. Here I have
only the first but I'm planning to adopt the latter also if the approach
I have taken is reasonable. Instead of filling in the entire pattern I
have only written those YUV-components that are actually checked (a
dozen odd pixels) while the rest are initialised to zero. In addition
I used calculated floating point values instead of the hardcoded found
in the original. There, however, I ended up in deviations and I would
appreciate if people understanding the domain of YUV to RGB conversion
better could take a good look.

In the implementation that I have written for mesa/i965 I have also
support for NV12 format. Whereas YV12 (YVU420) has separate U- and
V-planes, NV12 has them combined into one. Hence I would like to have
the same tests for NV12 as for YV12 if acceptable.

The tests are written only for ES2 contexts, I haven't looked into
how I would separate the tests not dealing with external sampler
(samplerExternalOES is only defined for ES 2.x).

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
 tests/spec/CMakeLists.txt  |1 +
 .../oes_egl_image_external/CMakeLists.gles2.txt|   16 +
 tests/spec/oes_egl_image_external/CMakeLists.txt   |3 +
 .../oes_egl_image_external.c   |  776 
 4 files changed, 796 insertions(+)
 create mode 100644 tests/spec/oes_egl_image_external/CMakeLists.gles2.txt
 create mode 100644 tests/spec/oes_egl_image_external/CMakeLists.txt
 create mode 100644 tests/spec/oes_egl_image_external/oes_egl_image_external.c

diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 96b5a61..485cf5e 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -66,6 +66,7 @@ add_subdirectory (ext_texture_array)
 add_subdirectory (ext_texture_integer)
 add_subdirectory (arb_draw_buffers)
 add_subdirectory (oes_draw_texture)
+add_subdirectory (oes_egl_image_external)
 add_subdirectory (arb_blend_func_extended)
 add_subdirectory (ext_unpack_subimage)
 add_subdirectory (arb_vertex_array_object)
diff --git a/tests/spec/oes_egl_image_external/CMakeLists.gles2.txt 
b/tests/spec/oes_egl_image_external/CMakeLists.gles2.txt
new file mode 100644
index 000..1ae1792
--- /dev/null
+++ b/tests/spec/oes_egl_image_external/CMakeLists.gles2.txt
@@ -0,0 +1,16 @@
+#add_definitions(-DSOURCE_DIR=${piglit_SOURCE_DIR}/)
+
+include_directories(
+   ${OPENGL_INCLUDE_PATH}
+   )
+
+link_libraries(
+   ${OPENGL_egl_LIBRARY}
+   piglitutil_gles2
+   )
+
+piglit_add_executable(oes_egl_image_external_gles2
+   oes_egl_image_external.c
+   )
+
+# vim: ft=cmake:
diff --git a/tests/spec/oes_egl_image_external/CMakeLists.txt 
b/tests/spec/oes_egl_image_external/CMakeLists.txt
new file mode 100644
index 000..d9d41f2
--- /dev/null
+++ b/tests/spec/oes_egl_image_external/CMakeLists.txt
@@ -0,0 +1,3 @@
+if(OPENGL_egl_LIBRARY)
+   piglit_include_target_api()
+endif(OPENGL_egl_LIBRARY)
diff --git a/tests/spec/oes_egl_image_external/oes_egl_image_external.c 
b/tests/spec/oes_egl_image_external/oes_egl_image_external.c
new file mode 100644
index 000..b04c72c
--- /dev/null
+++ b/tests/spec/oes_egl_image_external/oes_egl_image_external.c
@@ -0,0 +1,776 @@
+/*
+ * Copyright © 2013 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.
+ *
+ * Author: Topi Pohjolainen topi.pohjolai...@intel.com
+ */
+
+/** @file