Remove some boilerplate and check more specifically for all the entry- points that different modules need.
Signed-off-by: Rob Clark <robdcl...@gmail.com> --- Ok, I guess it isn't likely for a driver to expose eglCreateImageKHR but not eglDeleteImageKHR.. but otoh kmscube is useful for bringing up drivers. common.h | 11 +++++++++++ cube-tex.c | 6 +++--- cube-video.c | 4 +--- drm-atomic.c | 8 +++++--- gst-decoder.c | 4 ++++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/common.h b/common.h index 0acf4c0..11ec26e 100644 --- a/common.h +++ b/common.h @@ -85,6 +85,17 @@ struct egl { void (*draw)(unsigned i); }; +static inline int __egl_check(void *ptr, const char *name) +{ + if (!ptr) { + printf("no %s\n", name); + return -1; + } + return 0; +} + +#define egl_check(egl, name) __egl_check((egl)->name, #name) + int init_egl(struct egl *egl, const struct gbm *gbm); int create_program(const char *vs_src, const char *fs_src); int link_program(unsigned program); diff --git a/cube-tex.c b/cube-tex.c index 9316ffb..9e38ae8 100644 --- a/cube-tex.c +++ b/cube-tex.c @@ -507,10 +507,10 @@ const struct egl * init_cube_tex(const struct gbm *gbm, enum mode mode) if (ret) return NULL; - if (!gl.egl.eglCreateImageKHR) { - printf("no eglCreateImageKHR\n"); + if (egl_check(&gl.egl, eglCreateImageKHR) || + egl_check(&gl.egl, glEGLImageTargetTexture2DOES) || + egl_check(&gl.egl, eglDestroyImageKHR)) return NULL; - } gl.aspect = (GLfloat)(gbm->height) / (GLfloat)(gbm->width); gl.mode = mode; diff --git a/cube-video.c b/cube-video.c index 6ce20da..095544d 100644 --- a/cube-video.c +++ b/cube-video.c @@ -300,10 +300,8 @@ const struct egl * init_cube_video(const struct gbm *gbm, const char *filenames) if (ret) return NULL; - if (!gl.egl.eglCreateImageKHR) { - printf("no eglCreateImageKHR\n"); + if (egl_check(&gl.egl, glEGLImageTargetTexture2DOES)) return NULL; - } fnames = strdup(filenames); while ((s = strstr(fnames, ","))) { diff --git a/drm-atomic.c b/drm-atomic.c index 65caacd..dd91bbb 100644 --- a/drm-atomic.c +++ b/drm-atomic.c @@ -180,10 +180,12 @@ static int atomic_run(const struct gbm *gbm, const struct egl *egl) uint32_t i = 0; int ret; - if (!egl->eglDupNativeFenceFDANDROID) { - printf("no eglDupNativeFenceFDANDROID\n"); + if (egl_check(egl, eglDupNativeFenceFDANDROID) || + egl_check(egl, eglCreateSyncKHR) || + egl_check(egl, eglDestroySyncKHR) || + egl_check(egl, eglWaitSyncKHR) || + egl_check(egl, eglClientWaitSyncKHR)) return -1; - } eglSwapBuffers(egl->display, egl->surface); bo = gbm_surface_lock_front_buffer(gbm->surface); diff --git a/gst-decoder.c b/gst-decoder.c index deffad5..2d6d581 100644 --- a/gst-decoder.c +++ b/gst-decoder.c @@ -260,6 +260,10 @@ video_init(const struct egl *egl, const struct gbm *gbm, const char *filename) GstPad *pad; GstBus *bus; + if (egl_check(egl, eglCreateImageKHR) || + egl_check(egl, eglDestroyImageKHR)) + return NULL; + dec = calloc(1, sizeof(*dec)); dec->loop = g_main_loop_new(NULL, FALSE); dec->gbm = gbm; -- 2.9.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev