[Piglit] [v2 1/3] framework: introduce interface for external buffers

Topi Pohjolainen topi.pohjolainen at intel.com
Fri Mar 8 01:29:20 PST 2013


In order to test the OES_EGL_image_external with planar formats such
as YUV420 or NV12, one needs a way for creating buffers that can be
passed to EGL and filling them with YUV-data for the GL-stack to
sample.
By the nature the extension in question deals with platform specific
buffers and hence the idea here is to push the details down into the
platform specific logic leaving the tests themselves platform
independent.

v2:
  - clarify _ext as referring to external instead of extension
  - if platform does not support external buffers, report PIGLIT_SKIP

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 tests/util/piglit-framework-gl.c                   |   42 ++++++++++++++++++++
 tests/util/piglit-framework-gl.h                   |   29 ++++++++++++++
 .../util/piglit-framework-gl/piglit_gl_framework.h |   23 +++++++++++
 3 files changed, 94 insertions(+)

diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c
index 441e271..36bf210 100644
--- a/tests/util/piglit-framework-gl.c
+++ b/tests/util/piglit-framework-gl.c
@@ -162,3 +162,45 @@ piglit_set_reshape_func(void (*func)(int w, int h))
 	if (!gl_fw->set_reshape_func)
 		gl_fw->set_reshape_func(gl_fw, func);
 }
+
+void
+piglit_create_ext_420_buf(unsigned w, unsigned h, bool swap_vu,
+			const void *y, const void *u, const void *v,
+			enum piglit_result *result, void **buf)
+{
+	*buf = NULL;
+
+	if (!gl_fw->create_external_420_buffer) {
+		*result = PIGLIT_SKIP;
+		return;
+	}
+
+	*buf = gl_fw->create_external_420_buffer(gl_fw, w, h, swap_vu, y, u, v);
+
+	*result = *buf ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_create_ext_nv12_buf(unsigned w, unsigned h, const void *y,
+			const void *uv, enum piglit_result *result, void **buf)
+{
+	*buf = NULL;
+
+	if (!gl_fw->create_external_nv12_buffer) {
+		*result = PIGLIT_SKIP;
+		return;
+	}
+
+	*buf = gl_fw->create_external_nv12_buffer(gl_fw, w, h, y, uv);
+
+	*result = *buf ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_destroy_ext_buf(void *buf)
+{
+	if (!gl_fw->destroy_external_buffer)
+		return;
+
+	gl_fw->destroy_external_buffer(gl_fw, buf);
+}
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index bc3a3cd..dddff19 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -254,4 +254,33 @@ void piglit_post_redisplay(void);
 void piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y));
 void piglit_set_reshape_func(void (*func)(int w, int h));
 
+/**
+ * Create external YUV420 or YV12 (YVU420) formatted buffer of the given size
+ * and set it contents according to the given planes. Here there is no
+ * padding in the planes y-plane having stride equaling the given width
+ * and u/v-planes having stride equaling half of the width. By setting
+ * the 'swap_vu' to true, the order of u/v planes is swapped
+ * corresponding to YV12 (YVU420) format.
+ *
+ * If the platform does not support this, 'result' is set to PIGLIT_SKIP.
+ * Otherwise depending on the success of the buffer creation one gets
+ * PIGLIT_PASS or PIGLIT_FAIL.
+ */
+void piglit_create_ext_420_buf(unsigned w, unsigned h, bool swap_vu,
+			       const void *y, const void *u, const void *v,
+			       enum piglit_result *result, void **buf);
+
+/**
+ * Create external NV12 formatted buffer of the given size and set it contents
+ * according to the given planes. Here there is no padding in the planes
+ * both y-plane and uv-plane having stride equaling the given width.
+ *
+ * Success is reported as for 'piglit_create_ext_420_buf()'.
+ */
+void piglit_create_ext_nv12_buf(unsigned w, unsigned h,
+				const void *y, const void *uv,
+				enum piglit_result *result, void **buf);
+
+void piglit_destroy_ext_buf(void *buf);
+
 #endif /* PIGLIT_FRAMEWORK_H */
diff --git a/tests/util/piglit-framework-gl/piglit_gl_framework.h b/tests/util/piglit-framework-gl/piglit_gl_framework.h
index 6dbdf94..a89f863 100644
--- a/tests/util/piglit-framework-gl/piglit_gl_framework.h
+++ b/tests/util/piglit-framework-gl/piglit_gl_framework.h
@@ -71,6 +71,29 @@ struct piglit_gl_framework {
 
 	void
 	(*destroy)(struct piglit_gl_framework *gl_fw);
+
+	/**
+	 * \see piglit_create_ext_420_buf()
+	 */
+	void *
+	(*create_external_420_buffer)(struct piglit_gl_framework *gl_fw,
+				      unsigned w, unsigned h, bool swap_vu,
+				      const void *y,
+				      const void *u,
+				      const void *v);
+
+	/**
+	 * \see piglit_create_ext_nv12_buf()
+	 */
+	void *
+	(*create_external_nv12_buffer)(struct piglit_gl_framework *gl_fw,
+				       unsigned w, unsigned h,
+				       const void *y,
+				       const void *uv);
+
+	void
+	(*destroy_external_buffer)(struct piglit_gl_framework *gl_fw,
+				   void *buf);
 };
 
 struct piglit_gl_framework*
-- 
1.7.9.5



More information about the Piglit mailing list