On Monday, 2018-10-29 10:16:30 -0700, Rafael Antognolli wrote: > 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. > > v2: Require configless context (Tapani) > --- > tests/egl/egl-context-preemption.c | 58 ++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/tests/egl/egl-context-preemption.c > b/tests/egl/egl-context-preemption.c > index 82a698aa1..5265bccc4 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) > { > @@ -311,6 +366,9 @@ piglit_init(int argc, char **argv) > > dpy = eglGetCurrentDisplay(); > piglit_require_egl_extension(dpy, "EGL_IMG_context_priority"); > + piglit_require_egl_extension(dpy, "EGL_MESA_configless_context");
FYI this extension was uptreamed as EGL_KHR_no_config_context, so we should require either one of them if we want piglit to work with non-Mesa drivers. Similarly, the EGL_NO_CONFIG_MESA token was renamed EGL_NO_CONFIG_KHR in the process, since the former only exists in Mesa's EGL headers. > + > + check_high_context_priority_creation(dpy); > > if (piglit_strip_arg(&argc, argv, "small")) > small = true; > -- > 2.19.1 > > _______________________________________________ > Piglit mailing list > Piglit@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/piglit _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit