diff options
author | Rob Clark <robdclark@chromium.org> | 2020-09-02 09:16:25 -0700 |
---|---|---|
committer | Rob Clark <robdclark@chromium.org> | 2020-09-02 09:50:08 -0700 |
commit | 26326be53e30da9c101075fda081d38ea9ec758d (patch) | |
tree | f6f41f70df5ea5ebadc18e4856a2960ae08b341b /drm-legacy.c | |
parent | 31d162224b29d65715b70b307818c383be7b4f3c (diff) | |
download | kmscube-26326be53e30da9c101075fda081d38ea9ec758d.tar.gz |
surfaceless support
Diffstat (limited to 'drm-legacy.c')
-rw-r--r-- | drm-legacy.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/drm-legacy.c b/drm-legacy.c index 6c35904..8f773e8 100644 --- a/drm-legacy.c +++ b/drm-legacy.c @@ -54,8 +54,12 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) int64_t start_time, report_time, cur_time; int ret; - eglSwapBuffers(egl->display, egl->surface); - bo = gbm_surface_lock_front_buffer(gbm->surface); + if (gbm->surface) { + eglSwapBuffers(egl->display, egl->surface); + bo = gbm_surface_lock_front_buffer(gbm->surface); + } else { + bo = gbm->bos[0]; + } fb = drm_fb_get_from_bo(bo); if (!fb) { fprintf(stderr, "Failed to get a new framebuffer BO\n"); @@ -73,6 +77,7 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) start_time = report_time = get_time_ns(); while (i < drm.count) { + unsigned frame = i; struct gbm_bo *next_bo; int waiting_for_flip = 1; @@ -83,10 +88,19 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) start_time = report_time = get_time_ns(); } + if (!gbm->surface) { + glBindFramebuffer(GL_FRAMEBUFFER, egl->fbs[frame % NUM_BUFFERS].fb); + } + egl->draw(i++); - eglSwapBuffers(egl->display, egl->surface); - next_bo = gbm_surface_lock_front_buffer(gbm->surface); + if (gbm->surface) { + eglSwapBuffers(egl->display, egl->surface); + next_bo = gbm_surface_lock_front_buffer(gbm->surface); + } else { + glFinish(); + next_bo = gbm->bos[frame % NUM_BUFFERS]; + } fb = drm_fb_get_from_bo(next_bo); if (!fb) { fprintf(stderr, "Failed to get a new framebuffer BO\n"); @@ -135,7 +149,9 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) } /* release last buffer to render on again: */ - gbm_surface_release_buffer(gbm->surface, bo); + if (gbm->surface) { + gbm_surface_release_buffer(gbm->surface, bo); + } bo = next_bo; } |