aboutsummaryrefslogtreecommitdiff
path: root/src/egl.c
diff options
context:
space:
mode:
authorSteam Deck User <deck@arch.steamdeck>2023-03-16 13:36:19 +0100
committerdec05eba <dec05eba@protonmail.com>2023-03-17 11:44:51 +0100
commit8cbdb596ebf79587a432ed40583630b6cd39ed88 (patch)
tree82c60558aaaa7a1fc1eb9ffc388f1dd84a9529d2 /src/egl.c
parent689419a78238626aba887e974cbfcf5dff99de81 (diff)
vaapi wip
Diffstat (limited to 'src/egl.c')
-rw-r--r--src/egl.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/src/egl.c b/src/egl.c
index dbc8928..325a06f 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -57,7 +57,10 @@ static bool gsr_egl_create_window(gsr_egl *self) {
goto fail;
}
- self->eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
+ if(!self->eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)) {
+ fprintf(stderr, "gsr error: gsr_egl_create_window failed: failed to make context current\n");
+ goto fail;
+ }
self->egl_display = egl_display;
self->egl_surface = egl_surface;
@@ -79,6 +82,7 @@ static bool gsr_egl_create_window(gsr_egl *self) {
static bool gsr_egl_load_egl(gsr_egl *self, void *library) {
dlsym_assign required_dlsym[] = {
+ { (void**)&self->eglGetError, "eglGetError" },
{ (void**)&self->eglGetDisplay, "eglGetDisplay" },
{ (void**)&self->eglInitialize, "eglInitialize" },
{ (void**)&self->eglTerminate, "eglTerminate" },
@@ -182,52 +186,45 @@ bool gsr_egl_load(gsr_egl *self, Display *dpy) {
memset(self, 0, sizeof(gsr_egl));
self->dpy = dpy;
+ void *egl_lib = NULL;
+ void *gl_lib = NULL;
+
dlerror(); /* clear */
- void *egl_lib = dlopen("libEGL.so.1", RTLD_LAZY);
+ egl_lib = dlopen("libEGL.so.1", RTLD_LAZY);
if(!egl_lib) {
fprintf(stderr, "gsr error: gsr_egl_load: failed to load libEGL.so.1, error: %s\n", dlerror());
- return false;
+ goto fail;
}
- void *gl_lib = dlopen("libGL.so.1", RTLD_LAZY);
+ gl_lib = dlopen("libGL.so.1", RTLD_LAZY);
if(!egl_lib) {
fprintf(stderr, "gsr error: gsr_egl_load: failed to load libGL.so.1, error: %s\n", dlerror());
- dlclose(egl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
+ goto fail;
}
- if(!gsr_egl_load_egl(self, egl_lib)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_load_egl(self, egl_lib))
+ goto fail;
- if(!gsr_egl_load_gl(self, gl_lib)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_load_gl(self, gl_lib))
+ goto fail;
- if(!gsr_egl_proc_load_egl(self)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_proc_load_egl(self))
+ goto fail;
- if(!gsr_egl_create_window(self)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_create_window(self))
+ goto fail;
self->egl_library = egl_lib;
self->gl_library = gl_lib;
return true;
+
+ fail:
+ if(egl_lib)
+ dlclose(egl_lib);
+ if(gl_lib)
+ dlclose(gl_lib);
+ memset(self, 0, sizeof(gsr_egl));
+ return false;
}
void gsr_egl_unload(gsr_egl *self) {