Codebase list kmscube / 83d3394
atomic: Use normal rendering loop for modeset The initial pattern of: initial_modeset(); while (1) { pageflip(); } was relying on getting a buffer despite not having rendered anything. It would also show undefined content. Replace this with just using the pageflip loop for the initial modeset as well. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Daniel Stone 7 years ago
1 changed file(s) with 10 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
174174
175175 static int atomic_run(const struct gbm *gbm, const struct egl *egl)
176176 {
177 struct gbm_bo *bo;
177 struct gbm_bo *bo = NULL;
178178 struct drm_fb *fb;
179179 uint32_t i = 0;
180 uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK;
180181 int ret;
181182
182183 if (!egl->eglDupNativeFenceFDANDROID) {
184185 return -1;
185186 }
186187
187 eglSwapBuffers(egl->display, egl->surface);
188 bo = gbm_surface_lock_front_buffer(gbm->surface);
189 fb = drm_fb_get_from_bo(bo);
190 if (!fb) {
191 printf("Failed to get a new framebuffer BO\n");
192 return -1;
193 }
194
195
196 drm.kms_in_fence_fd = -1;
197
198 /* set mode: */
199 ret = drm_atomic_commit(fb->fb_id, DRM_MODE_ATOMIC_ALLOW_MODESET);
200 if (ret) {
201 printf("failed to commit modeset: %s\n", strerror(errno));
202 return ret;
203 }
188 /* Allow a modeset change for the first commit only. */
189 flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
204190
205191 while (1) {
206192 struct gbm_bo *next_bo;
268254 * Here you could also update drm plane layers if you want
269255 * hw composition
270256 */
271 ret = drm_atomic_commit(fb->fb_id, DRM_MODE_ATOMIC_NONBLOCK);
257 ret = drm_atomic_commit(fb->fb_id, flags);
272258 if (ret) {
273259 printf("failed to commit: %s\n", strerror(errno));
274260 return -1;
275261 }
276262
277263 /* release last buffer to render on again: */
278 gbm_surface_release_buffer(gbm->surface, bo);
264 if (bo)
265 gbm_surface_release_buffer(gbm->surface, bo);
279266 bo = next_bo;
267
268 /* Allow a modeset change for the first commit only. */
269 flags &= ~(DRM_MODE_ATOMIC_ALLOW_MODESET);
280270 }
281271
282272 return ret;