Check if we can create high priority contexts, otherwise just fail the test immediately. There's no reason to test for preemption if we can't create high priority contexts. --- tests/egl/egl-context-preemption.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
diff --git a/tests/egl/egl-context-preemption.c b/tests/egl/egl-context-preemption.c index 82a698aa1..9d5aa42ee 100644 --- a/tests/egl/egl-context-preemption.c +++ b/tests/egl/egl-context-preemption.c @@ -58,6 +58,40 @@ struct test_profile { static bool small = false; static int total_objects = 0; +static EGLint +check_priority(EGLDisplay dpy, EGLContext ctx, EGLint *expected) +{ + EGLint value; + EGLBoolean status = + eglQueryContext(dpy, ctx, EGL_CONTEXT_PRIORITY_LEVEL_IMG, &value); + + if (status == EGL_FALSE) { + piglit_loge("eglQueryContext failed\n"); + piglit_report_result(PIGLIT_FAIL); + } + + if (expected && value != *expected) { + piglit_loge("%s fail: priority value 0x%x, expected 0x%x\n", + __func__, value, *expected); + piglit_loge("Can't create high priority context.\n"); + piglit_report_result(PIGLIT_FAIL); + } + return value; +} + +static EGLContext +create_context(EGLDisplay dpy, EGLint *attr) +{ + EGLContext ctx = + eglCreateContext(dpy, EGL_NO_CONFIG_MESA, EGL_NO_CONTEXT, attr); + + if (ctx == EGL_NO_CONTEXT) { + piglit_loge("could not create EGL context, attr 0x%x\n", attr[1]); + piglit_report_result(PIGLIT_FAIL); + } + return ctx; +} + static const char *vs_text = "#version 330 core\n" "layout (location = 0) in vec3 aPos;\n" @@ -304,6 +338,27 @@ piglit_display(void) return result; } +static void +check_high_context_priority_creation(EGLDisplay dpy) +{ + EGLint attr[] = { + EGL_CONTEXT_PRIORITY_LEVEL_IMG, + EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE + }; + EGLContext ctx = create_context(dpy, attr); + if (ctx == EGL_NO_CONTEXT) { + piglit_loge("failed to create context"); + piglit_check_egl_error(EGL_SUCCESS); + piglit_report_result(PIGLIT_FAIL); + } + + EGLint expected = EGL_CONTEXT_PRIORITY_HIGH_IMG; + check_priority(dpy, ctx, &expected); + + eglDestroyContext(dpy, ctx); +} + void piglit_init(int argc, char **argv) { @@ -312,6 +367,8 @@ piglit_init(int argc, char **argv) dpy = eglGetCurrentDisplay(); piglit_require_egl_extension(dpy, "EGL_IMG_context_priority"); + check_high_context_priority_creation(dpy); + if (piglit_strip_arg(&argc, argv, "small")) small = true; -- 2.19.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit