--- tests/egl/CMakeLists.gl.txt | 2 + tests/egl/egl-create-drm-image.c | 145 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 0 deletions(-) create mode 100755 tests/egl/egl-create-drm-image.c
diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt index ddfbbef..1e8865c 100644 --- a/tests/egl/CMakeLists.gl.txt +++ b/tests/egl/CMakeLists.gl.txt @@ -20,6 +20,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(egl-create-surface pthread ${X11_X11_LIB}) piglit_add_executable (egl-query-surface egl-util.c egl-query-surface.c) target_link_libraries(egl-query-surface pthread ${X11_X11_LIB}) + piglit_add_executable (egl-create-drm-image egl-util.c egl-create-drm-image.c) + target_link_libraries(egl-create-drm-image pthread ${X11_X11_LIB}) ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # vim: ft=cmake: diff --git a/tests/egl/egl-create-drm-image.c b/tests/egl/egl-create-drm-image.c new file mode 100755 index 0000000..d20d27e --- /dev/null +++ b/tests/egl/egl-create-drm-image.c @@ -0,0 +1,145 @@ +/* + * Copyright © 2012 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: Halley Zhao <halley.z...@intel.com> + */ + +/** @file egl-create-drm-image.c + * + * Test EGL_MESA_drm_image. + */ + +#include "piglit-util.h" +#include "egl-util.h" + +#ifdef EGL_MESA_drm_image + +const char *extensions[] = { "EGL_MESA_drm_image", NULL }; + +static enum piglit_result +draw(struct egl_state *state) +{ + PFNEGLCREATEDRMIMAGEMESAPROC create_drm_image; + PFNEGLEXPORTDRMIMAGEMESAPROC export_drm_image; + PFNEGLCREATEIMAGEKHRPROC create_image; + PFNEGLDESTROYIMAGEKHRPROC destroy_image; + + EGLImageKHR image1 = EGL_NO_IMAGE_KHR; + EGLImageKHR image2 = EGL_NO_IMAGE_KHR; + + EGLint attr_list1[] = { + EGL_WIDTH, 256, EGL_HEIGHT, 256, + EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_YUYV_MESA, + // EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, + EGL_NONE + }; + + EGLint name, handle, stride; + EGLint attr_list2[] = { + EGL_DRM_BUFFER_STRIDE_MESA, 0, + EGL_WIDTH, 256, EGL_HEIGHT, 256, + EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_YUYV_MESA, + // EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, + EGL_NONE + }; + #define STRIDE_INDEX 1 + + create_drm_image = (PFNEGLCREATEDRMIMAGEMESAPROC)eglGetProcAddress("eglCreateDRMImageMESA"); + if (create_drm_image == NULL ) { + fprintf(stderr, "could not getproc eglCreateDRMImageMESA"); + piglit_report_result(PIGLIT_PASS); + } + + export_drm_image = (PFNEGLEXPORTDRMIMAGEMESAPROC)eglGetProcAddress("eglExportDRMImageMESA"); + if (export_drm_image == NULL ) { + fprintf(stderr, "could not getproc eglExportDRMImageMESA"); + piglit_report_result(PIGLIT_PASS); + } + + create_image = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + if (create_image == NULL ) { + fprintf(stderr, "could not getproc eglCreateImageKHR"); + piglit_report_result(PIGLIT_PASS); + } + + destroy_image = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + if (destroy_image == NULL ) { + fprintf(stderr, "could not getproc eglDestroyImageKHR"); + piglit_report_result(PIGLIT_PASS); + } + + image1 = create_drm_image(state->egl_dpy, attr_list1); + if(image1 == EGL_NO_IMAGE_KHR) { + fprintf(stderr, "fail to create YUYV EGLImageKHR from eglCreateDRMImageMESA"); + piglit_report_result(PIGLIT_FAIL); + } + + if (export_drm_image(state->egl_dpy, image1, &name, &handle, &stride) == EGL_FALSE) { + fprintf(stderr, "fail to create export YUYV EGLImageKHR from eglExportDRMImageMESA"); + piglit_report_result(PIGLIT_FAIL); + + } + attr_list2[STRIDE_INDEX] = stride; + + image2 = eglCreateImageKHR(state->egl_dpy, state->ctx, EGL_DRM_BUFFER_MESA, + name, attr_list2); + if(image2 == EGL_NO_IMAGE_KHR) { + fprintf(stderr, "fail to create YUYV EGLImageKHR from eglCreateDRMImageMESA"); + piglit_report_result(PIGLIT_FAIL); + } + + if(eglDestroyImageKHR(state->egl_dpy, image1) == EGL_FALSE) { + fprintf(stderr, "fail to destroy EGLImageKHR from eglDestroyImageKHR"); + piglit_report_result(PIGLIT_FAIL); + } + + if(eglDestroyImageKHR(state->egl_dpy, image2) == EGL_FALSE) { + fprintf(stderr, "fail to destroy EGLImageKHR from eglDestroyImageKHR"); + piglit_report_result(PIGLIT_FAIL); + } + + return PIGLIT_PASS; +} + +int +main(int argc, char *argv[]) +{ + struct egl_test test; + + egl_init_test(&test); + test.extensions = extensions; + test.draw = draw; + + return egl_util_run(&test, argc, argv); +} + +#else + +int +main(int argc, char *argv[]) +{ + piglit_report_result(PIGLIT_SKIP); + + return 0; +} + +#endif -- 1.7.5.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev