egl_util was hardcoded to use PIGLIT_DISPATCH_GL, now code makes decision based on config attribs set by the test.
Signed-off-by: Tapani Pälli <[email protected]> --- Chad noted that EGL_RENDERABLE_TYPE might not be present in attribs, these changes make sure that we gracefully detault to desktop GL if ES not chosen by user. tests/egl/egl-util.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c index 4ff91fd..5f4fffe 100644 --- a/tests/egl/egl-util.c +++ b/tests/egl/egl-util.c @@ -187,7 +187,13 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[]) struct egl_state state; EGLint count; enum piglit_result result; - int i; + int i, dispatch_api, api_bit = EGL_OPENGL_BIT; + + EGLint ctxAttribsES[] = { + EGL_CONTEXT_CLIENT_VERSION, 0, + EGL_NONE + }; + EGLint *ctxAttribs = NULL; for (i = 1; i < argc; ++i) { if (!strcmp(argv[i], "-auto")) @@ -202,13 +208,35 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[]) piglit_report_result(PIGLIT_FAIL); } + /* read api_bit if EGL_RENDERABLE_TYPE set in the attribs */ for (count = 0; test->config_attribs[count] != EGL_NONE; count += 2) { - if (test->config_attribs[count] == EGL_RENDERABLE_TYPE && - test->config_attribs[count+1] == EGL_OPENGL_BIT) { - eglBindAPI(EGL_OPENGL_API); + if (test->config_attribs[count] == EGL_RENDERABLE_TYPE) { + api_bit = test->config_attribs[count+1]; } } + /* bind chosen API and set ctxattribs if using ES */ + if (api_bit == EGL_OPENGL_BIT) + eglBindAPI(EGL_OPENGL_API); + else { + eglBindAPI(EGL_OPENGL_ES_API); + ctxAttribs = ctxAttribsES; + } + + /* choose dispatch_api and set ctx version to ctxAttribs if using ES */ + switch (api_bit) { + case EGL_OPENGL_ES_BIT: + dispatch_api = PIGLIT_DISPATCH_ES1; + ctxAttribsES[1] = 1; + break; + case EGL_OPENGL_ES2_BIT: + dispatch_api = PIGLIT_DISPATCH_ES2; + ctxAttribsES[1] = 2; + break; + default: + dispatch_api = PIGLIT_DISPATCH_GL; + } + state.egl_dpy = eglGetDisplay(state.dpy); if (state.egl_dpy == EGL_NO_DISPLAY) { @@ -230,7 +258,7 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[]) } state.ctx = eglCreateContext(state.egl_dpy, state.cfg, - EGL_NO_CONTEXT, NULL); + EGL_NO_CONTEXT, ctxAttribs); if (state.ctx == EGL_NO_CONTEXT) { fprintf(stderr, "eglCreateContext() failed\n"); piglit_report_result(PIGLIT_FAIL); @@ -253,7 +281,7 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[]) piglit_report_result(PIGLIT_FAIL); } - piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); + piglit_dispatch_default_init(dispatch_api); result = event_loop(&state, test); -- 1.8.5.3 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
