[Piglit] [PATCH 5/5] egl: add eglCopyBuffers test

Tapani Pälli tapani.palli at intel.com
Wed Dec 13 06:10:59 UTC 2017


Hi;

On 11.12.2017 22:15, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Current Mesa implementation was overly cautious, flagging an error
> where it shouldn't - patch for Mesa is on the list.
> 
> See the test for details.
> 
> Cc: Ian Romanick <ian.d.romanick at intel.com>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
> Nitpicks:
>   - suggestions for test name and category?
>   - should we bother at all with piglit_egl_get_default_display(EGL_NONE)
>   - yay X11+DRI3 crashes somewhere in the xshmfence code... DRI2 works
> fine.
> ---
>   tests/all.py                 |   1 +
>   tests/egl/CMakeLists.gl.txt  |   2 +
>   tests/egl/egl-copy-buffers.c | 110 +++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 113 insertions(+)
>   create mode 100644 tests/egl/egl-copy-buffers.c
> 
> diff --git a/tests/all.py b/tests/all.py
> index c4cbe0bd9..2b6979b4c 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4542,6 +4542,7 @@ with profile.test_list.group_manager(
>           exclude_platforms=['glx']) as g:
>       g(['egl-nok-texture-from-pixmap'], 'basic', run_concurrent=False)
>   
> +# XXX: where to add the eglCopyBuffers test?
>   with profile.test_list.group_manager(
>           PiglitGLTest,
>           grouptools.join('spec', 'egl_khr_create_context'),
> diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
> index 6ba88427d..3691c56a9 100644
> --- a/tests/egl/CMakeLists.gl.txt
> +++ b/tests/egl/CMakeLists.gl.txt
> @@ -27,6 +27,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
>   	target_link_libraries(egl-create-largest-pbuffer-surface pthread ${X11_X11_LIB})
>   	piglit_add_executable (egl-configless-context egl-configless-context.c)
>   	target_link_libraries(egl-configless-context pthread ${X11_X11_LIB})
> +	piglit_add_executable (egl-copy-buffers egl-util.c egl-copy-buffers.c)
> +	target_link_libraries(egl-copy-buffers pthread ${X11_X11_LIB})
>   	piglit_add_executable (egl-gl-colorspace egl-util.c egl-gl-colorspace.c)
>   	target_link_libraries(egl-gl-colorspace pthread ${X11_X11_LIB})
>   	piglit_add_executable (egl-invalid-attr egl-invalid-attr.c)
> diff --git a/tests/egl/egl-copy-buffers.c b/tests/egl/egl-copy-buffers.c
> new file mode 100644
> index 000000000..fa6508f69
> --- /dev/null
> +++ b/tests/egl/egl-copy-buffers.c
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright © 2017 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.
> + */
> +
> +#include "piglit-util.h"
> +#include "piglit-util-egl.h"
> +#include "piglit-util-gl.h"
> +#include "egl-util.h"
> +
> +/*
> + * For legacy reasons, eglGetDisplay uses a detection heuristics to establish
> + * the underlying platform.
> + *
> + * Yet there is another API eglCopyBuffers that invokes the detection, a seeming
> + * remainder from the days perior to the EGL platform extensions.
> + *
> + * With the EGL extensions, the platform specified by the user may differ from
> + * the detected one. which will result in eglCopyBuffers failure.
> + *
> + * The check should be dropped.
> + */
> +
> +static void
> +test_setup(void)
> +{
> +	/* Set the env. variable to force the platform 'detection' to use
> +	 * different platform (than X11).
> +	 *
> +	 * NOTE: This is not perfect, since driver may ignore the variable, yet
> +	 * we aim to provide a consistent experience across test runs, build
> +	 * permutation and/or driver used.
> +	 */
> +//	setenv("EGL_PLATFORM", "drm", true);
> +
> +	/* XXX: test should flag regardless of the following call - testing
> +	 * has confirmed it.
> +	 *
> +	 * NOTE: We cannot do the test twice - with and W/o the call; the
> +	 * detection result is stored in static variable :-\
> +	 */
> +	piglit_egl_get_default_display(EGL_NONE);
> +
> +	/* Use X11 since it's the only platform that has EGL pixmap surfaces */
> +	piglit_require_egl_extension(EGL_NO_DISPLAY, "EGL_EXT_platform_x11");
> +}
> +
> +static enum piglit_result
> +draw(struct egl_state *state)
> +{
> +	EGLNativePixmapType pixmap;
> +	enum piglit_result result = PIGLIT_PASS;
> +
> +	/* Green for a pass */
> +	glClearColor(0.0, 1.0, 0.0, 1.0);
> +	glClear(GL_COLOR_BUFFER_BIT);
> +
> +	pixmap = egl_util_create_native_pixmap(state, egl_default_window_width,
> +					       egl_default_window_height);

Should we call XFlush(dpy) here or is it ok to go and use pixmap right away?

> +	eglCopyBuffers(state->egl_dpy, state->surf, pixmap);

I think we could also read from pixmap and verify that it has green (in 
every pixel)?

There might be need some additional synchronization if doing that, at 
least dEQP issues eglWaitClient() before reading pixmap contents.


> +	if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +		fprintf(stderr, "eglCopyBuffers() failed\n");
> +
> +		/* Red for a fail */
> +		glClearColor(1.0, 0.0, 0.0, 1.0);
> +		glClear(GL_COLOR_BUFFER_BIT);
> +
> +		result = PIGLIT_FAIL;
> +	}
> +	eglSwapBuffers(state->egl_dpy, state->surf);
> +	return result;
> +}
> +
> +int
> +main(int argc, char *argv[])
> +{
> +	static const EGLint test_attribs[] = {
> +		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
> +		EGL_NONE
> +	};
> +	struct egl_test test;
> +
> +	egl_init_test(&test);
> +	test.draw = draw;
> +	test.config_attribs = test_attribs;
> +
> +	test_setup();
> +
> +	if (egl_util_run(&test, argc, argv) != PIGLIT_PASS)
> +		return EXIT_FAILURE;
> +	return EXIT_SUCCESS;
> +}
> 


More information about the Piglit mailing list