Skip to content

Commit

Permalink
only report error from gbm_surface_create_with_modifiers if `gbm_su…
Browse files Browse the repository at this point in the history
…rface_create` fails too
  • Loading branch information
ardera committed Sep 16, 2024
1 parent 94e4540 commit 382ea68
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/egl_gbm_render_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static int egl_gbm_render_surface_init(
}
#endif

int with_modifiers_errno;
gbm_surface = NULL;
if (allowed_modifiers != NULL) {
gbm_surface = gbm_surface_create_with_modifiers(
Expand All @@ -157,11 +158,10 @@ static int egl_gbm_render_surface_init(
n_allowed_modifiers
);
if (gbm_surface == NULL) {
ok = errno;
LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create_with_modifiers: %s\n", strerror(ok));
LOG_ERROR("Will retry without modifiers\n");
with_modifiers_errno = errno;
}
}

if (gbm_surface == NULL) {
gbm_surface = gbm_surface_create(
gbm_device,
Expand All @@ -171,8 +171,17 @@ static int egl_gbm_render_surface_init(
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT
);
if (gbm_surface == NULL) {
ok = errno;
LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create: %s\n", strerror(ok));
ok = errno ? errno : EIO;
if (allowed_modifiers != NULL) {
LOG_ERROR(
"Couldn't create GBM surface for rendering. gbm_surface_create_with_modifiers: %s, gbm_surface_create: %s\n",
strerror(with_modifiers_errno),
strerror(ok)
);
} else {
LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create: %s\n", strerror(ok));
}

return ok;
}
}
Expand Down

0 comments on commit 382ea68

Please sign in to comment.