[Piglit] [PATCH v3 4/8] egl_khr_fence_sync: Add test to create fence from fd.

Eric Anholt eric at anholt.net
Wed Jun 21 21:34:14 UTC 2017


Rafael Antognolli <rafael.antognolli at intel.com> writes:

> Add a test that creates a sync file using sw_sync, and then creates an
> EGL fence sync from that sync file. It also verify that the fence sync
> EGL_SYNC_CONDITION_KHR is set to EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID,
> and that EGL_SYNC_STATUS_KHR changes to EGL_SIGNALED_KHR once the fence
> is signaled.
>
> Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
> ---
>  .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 145 +++++++++++++++++++++
>  1 file changed, 145 insertions(+)
>
> diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
> index d5353f2..f6ebc0b 100644
> --- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
> +++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
> @@ -55,6 +55,7 @@
>  
>  #include "piglit-util-egl.h"
>  #include "piglit-util-gl.h"
> +#include "sw_sync.h"
>  
>  /* Extension function pointers.
>   *
> @@ -1347,6 +1348,144 @@ static struct test_profile fence_android_native = {
>  	.extension = "EGL_ANDROID_native_fence_sync",
>  };
>  
> +static EGLSyncKHR
> +test_create_fence_from_fd(int fd)
> +{
> +	EGLint attrib_list[] = {
> +		EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
> +		EGL_NONE,
> +	};
> +
> +	return peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
> +}
> +
> +static enum piglit_result
> +test_eglCreateSyncKHR_native_from_fd(void *test_data)
> +{
> +	enum piglit_result result = PIGLIT_PASS;
> +	EGLSyncKHR sync = 0;
> +	EGLint sync_type = canary,
> +	       sync_status = canary,
> +	       sync_condition = canary;
> +	int sync_fd = canary;
> +	int timeline = canary;
> +	bool ok = false;
> +	struct test_profile *profile = test_data;
> +
> +	result = test_setup(profile);
> +	if (result != PIGLIT_PASS) {
> +		return result;
> +	}
> +
> +	if (!sw_sync_is_supported()) {
> +		result = PIGLIT_SKIP;
> +		goto cleanup;
> +	}
> +
> +	/* Create timeline and sw_sync */
> +	timeline = sw_sync_timeline_create();
> +	if (timeline < 0) {
> +		piglit_loge("sw_sync_timeline_create() failed");
> +		result = PIGLIT_FAIL;
> +		goto cleanup;
> +	}
> +
> +	sync_fd = sw_sync_fence_create(timeline, 1);
> +	if (sync_fd < 0) {
> +		piglit_loge("sw_sync_fence_create() failed");
> +		result = PIGLIT_FAIL;
> +		goto cleanup_timeline;
> +	}
> +
> +	sync = test_create_fence_from_fd(sync_fd);
> +	if (sync == EGL_NO_SYNC_KHR) {
> +		piglit_loge("eglCreateSyncKHR(%s) failed", profile->sync_str);
> +		result = PIGLIT_FAIL;
> +		sw_sync_fence_destroy(sync_fd);
> +		goto cleanup_timeline;
> +	}
> +
> +	ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_TYPE_KHR, &sync_type);
> +	if (!ok) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) failed");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) emitted "
> +			    "an error");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (sync_type != profile->sync_type) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) returned "
> +			    "0x%x but expected %s(0x%x)",
> +			    sync_type, profile->sync_str, profile->sync_type);
> +		result = PIGLIT_FAIL;
> +	}
> +
> +	ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_STATUS_KHR, &sync_status);
> +	if (!ok) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) failed");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) emitted "
> +			    "an error");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (sync_status != EGL_UNSIGNALED_KHR) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) "
> +			    "returned 0x%x but expected "
> +			    "EGL_UNSIGNALED_KHR(0x%x)",
> +			    sync_status, EGL_UNSIGNALED_KHR);
> +		result = PIGLIT_FAIL;
> +	}
> +
> +	ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_CONDITION_KHR, &sync_condition);
> +	if (!ok) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_CONDITION_KHR) failed");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_CONDITION_KHR) "
> +			    "emitted an error");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (sync_condition != EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_CONDITION_KHR) "
> +			    "returned 0x%x but expected "
> +			    "EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID(0x%x)",
> +			    sync_condition, EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID);
> +		result = PIGLIT_FAIL;
> +	}
> +
> +	sw_sync_timeline_inc(timeline, 1);
> +
> +	ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_STATUS_KHR, &sync_status);
> +	if (!ok) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) failed");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) emitted "
> +			    "an error");
> +		result = PIGLIT_FAIL;
> +	}
> +	if (sync_status != EGL_SIGNALED_KHR) {
> +		piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) "
> +			    "returned 0x%x but expected "
> +			    "EGL_SIGNALED_KHR(0x%x)",
> +			    sync_status, EGL_SIGNALED_KHR);
> +		result = PIGLIT_FAIL;
> +	}
> +
> +cleanup_timeline:
> +	sw_sync_timeline_destroy(timeline);
> +
> +cleanup:
> +	test_cleanup(sync, &result);
> +	return result;
> +}
> +
>  static const struct piglit_subtest fence_android_native_subtests[] = {
>  	{
>  		"eglCreateSyncKHR_default_attributes",
> @@ -1390,6 +1529,12 @@ static const struct piglit_subtest fence_android_native_subtests[] = {
>  		test_eglClientWaitSyncKHR_nonzero_timeout,
>  		&fence_android_native,
>  	},
> +	{
> +		"eglCreateSyncKHR_native_from_fd",
> +		"eglCreateSyncKHR_native_from_fd",
> +		test_eglClientWaitSyncKHR_nonzero_timeout,

Looks like the wrong test being called here.

> +		&fence_android_native,
> +	},
>  	{0},
>  };
>  
> -- 
> 2.9.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20170621/dff7f725/attachment.sig>


More information about the Piglit mailing list