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
174 | 174 | |
175 | 175 | static int atomic_run(const struct gbm *gbm, const struct egl *egl) |
176 | 176 | { |
177 | struct gbm_bo *bo; | |
177 | struct gbm_bo *bo = NULL; | |
178 | 178 | struct drm_fb *fb; |
179 | 179 | uint32_t i = 0; |
180 | uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK; | |
180 | 181 | int ret; |
181 | 182 | |
182 | 183 | if (!egl->eglDupNativeFenceFDANDROID) { |
184 | 185 | return -1; |
185 | 186 | } |
186 | 187 | |
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; | |
204 | 190 | |
205 | 191 | while (1) { |
206 | 192 | struct gbm_bo *next_bo; |
268 | 254 | * Here you could also update drm plane layers if you want |
269 | 255 | * hw composition |
270 | 256 | */ |
271 | ret = drm_atomic_commit(fb->fb_id, DRM_MODE_ATOMIC_NONBLOCK); | |
257 | ret = drm_atomic_commit(fb->fb_id, flags); | |
272 | 258 | if (ret) { |
273 | 259 | printf("failed to commit: %s\n", strerror(errno)); |
274 | 260 | return -1; |
275 | 261 | } |
276 | 262 | |
277 | 263 | /* 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); | |
279 | 266 | bo = next_bo; |
267 | ||
268 | /* Allow a modeset change for the first commit only. */ | |
269 | flags &= ~(DRM_MODE_ATOMIC_ALLOW_MODESET); | |
280 | 270 | } |
281 | 271 | |
282 | 272 | return ret; |