[Piglit] [v8 02/13] framework: hardware independent interface for dma buffers
Topi Pohjolainen
topi.pohjolainen at intel.com
Wed Jul 10 01:24:01 PDT 2013
In order to test the EXT_image_dma_buf_import, one needs a way for
creating dma buffers that can be imported to EGL and filling them
with data for the GL-stack to sample.
While dma buffer themselves are only defined for linux, the actual
writing of the buffers using CPU differs from hardware to another,
and possibly from window system to another. The intention here is
to push these details into the framework leaving the actual tests
environment independent.
v2 (Chad):
- replace 'void*' buffer type by 'struct piglit_dma_buf *'
v3 (Chan, Ken):
- document passing NULL pointers to buffer desctruction
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
Reviewed-by: Chad Versace <chad.versace at linux.intel.com> (v2)
Reviewed-by: Eric Anholt <eric at anholt.net>
---
tests/util/piglit-framework-gl.c | 24 +++++++++++++++++++++
tests/util/piglit-framework-gl.h | 25 ++++++++++++++++++++++
.../util/piglit-framework-gl/piglit_gl_framework.h | 9 ++++++++
3 files changed, 58 insertions(+)
diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c
index ece5968..5d4f5c2 100644
--- a/tests/util/piglit-framework-gl.c
+++ b/tests/util/piglit-framework-gl.c
@@ -172,3 +172,27 @@ piglit_set_reshape_func(void (*func)(int w, int h))
if (!gl_fw->set_reshape_func)
gl_fw->set_reshape_func(gl_fw, func);
}
+
+enum piglit_result
+piglit_create_dma_buf(unsigned w, unsigned h, unsigned cpp,
+ const void *src_data, unsigned src_stride,
+ struct piglit_dma_buf **buf, int *fd,
+ unsigned *stride, unsigned *offset)
+{
+ *fd = 0;
+ *stride = 0;
+ *offset = 0;
+
+ if (!gl_fw->create_dma_buf)
+ return PIGLIT_SKIP;
+
+ return gl_fw->create_dma_buf(w, h, cpp, src_data, src_stride, buf, fd,
+ stride, offset);
+}
+
+void
+piglit_destroy_dma_buf(struct piglit_dma_buf *buf)
+{
+ if (gl_fw->destroy_dma_buf)
+ gl_fw->destroy_dma_buf(buf);
+}
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index 3cc1cac..31b6883 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -243,4 +243,29 @@ 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));
+struct piglit_dma_buf;
+
+/**
+ * Create buffer suitable for dma_buf importing and set its contents to the
+ * given data (src_data). Different hardware may have different alignment
+ * constraints and hence one can specify one stride for the source and get
+ * another for the final buffer to be given further to EGL.
+ * An opaque handle, file descriptor, stride and offset for the buffer are only
+ * returned upon success indicated by the return value PIGLIT_PASS, otherwise
+ * no buffer is created. In case the framework simply does not support dma
+ * buffers, the return value is PIGLIT_SKIP instead of PIGLIT_FAIL.
+ */
+enum piglit_result
+piglit_create_dma_buf(unsigned w, unsigned h, unsigned cpp,
+ const void *src_data, unsigned src_stride,
+ struct piglit_dma_buf **buf, int *fd,
+ unsigned *stride, unsigned *offset);
+
+/**
+ * Release all the resources allocated for the designated buffer. If the given
+ * pointer (buf) is NULL no action is taken.
+ */
+void
+piglit_destroy_dma_buf(struct piglit_dma_buf *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..97fecca 100644
--- a/tests/util/piglit-framework-gl/piglit_gl_framework.h
+++ b/tests/util/piglit-framework-gl/piglit_gl_framework.h
@@ -71,6 +71,15 @@ struct piglit_gl_framework {
void
(*destroy)(struct piglit_gl_framework *gl_fw);
+
+ enum piglit_result
+ (*create_dma_buf)(unsigned w, unsigned h, unsigned cpp,
+ const void *src_data, unsigned src_stride,
+ struct piglit_dma_buf **buf, int *fd,
+ unsigned *stride, unsigned *offset);
+
+ void
+ (*destroy_dma_buf)(struct piglit_dma_buf *buf);
};
struct piglit_gl_framework*
--
1.8.1.2
More information about the Piglit
mailing list