This is helpful for debugging as you will bail early with an error message instead of a random SIGSEGV (or something more obscure). --- drm-atomic.c | 9 +++++++++ drm-legacy.c | 8 ++++++++ 2 files changed, 17 insertions(+)
diff --git a/drm-atomic.c b/drm-atomic.c index 27c6b1e..c06e52f 100644 --- a/drm-atomic.c +++ b/drm-atomic.c @@ -187,6 +187,11 @@ static int atomic_run(const struct gbm *gbm, const struct egl *egl) eglSwapBuffers(egl->display, egl->surface); bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(bo); + if (!fb) { + printf("Failed to get a new framebuffer BO\n"); + return -1; + } + drm.kms_in_fence_fd = -1; @@ -235,6 +240,10 @@ static int atomic_run(const struct gbm *gbm, const struct egl *egl) next_bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(next_bo); + if (!fb) { + printf("Failed to get a new framebuffer BO\n"); + return -1; + } /* * Here you could also update drm plane layers if you want diff --git a/drm-legacy.c b/drm-legacy.c index 3b407f8..a0b419a 100644 --- a/drm-legacy.c +++ b/drm-legacy.c @@ -60,6 +60,10 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) eglSwapBuffers(egl->display, egl->surface); bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(bo); + if (!fb) { + fprintf(stderr, "Failed to get a new framebuffer BO\n"); + return -1; + } /* set mode: */ ret = drmModeSetCrtc(drm.fd, drm.crtc_id, fb->fb_id, 0, 0, @@ -78,6 +82,10 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) eglSwapBuffers(egl->display, egl->surface); next_bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(next_bo); + if (!fb) { + fprintf(stderr, "Failed to get a new framebuffer BO\n"); + return -1; + } /* * Here you could also update drm plane layers if you want -- 2.12.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev