Commit b98f30e9 authored by Rob Clark's avatar Rob Clark

helper to check for egl entrypoints

Remove some boilerplate and check more specifically for all the entry-
points that different modules need.

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.
Signed-off-by: 's avatarRob Clark <robdclark@gmail.com>
Reviewed-by: 's avatarEric Engestrom <eric.engestrom@imgtec.com>
parent 4d322e94
......@@ -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);
......
......@@ -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;
......
......@@ -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, ","))) {
......
......@@ -181,10 +181,12 @@ static int atomic_run(const struct gbm *gbm, const struct egl *egl)
uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK;
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;
}
/* Allow a modeset change for the first commit only. */
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment