Skip to content

Commit 460c8a6

Browse files
committed
hwcomposer: Correctly synchronize reused buffers
1 parent ae6f275 commit 460c8a6

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

hwcomposer/hwcomposer.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static struct buffer *get_wl_buffer(struct waydroid_hwc_composer_device_1 *pdev,
206206
int ret = 0;
207207

208208
buf = new struct buffer();
209+
buf->timeline_fd = sw_sync_timeline_create();
209210
if (pdev->display->gtype == GRALLOC_GBM) {
210211
struct gralloc_handle_t *drm_handle = (struct gralloc_handle_t *)layer->handle;
211212
if (pdev->display->dmabuf) {
@@ -767,12 +768,8 @@ static int hwc_set(struct hwc_composer_device_1* dev,size_t numDisplays,
767768
if (fb_layer->compositionType != HWC_FRAMEBUFFER &&
768769
fb_layer->compositionType != HWC_SIDEBAND)
769770
{
770-
int timeline_fd = sw_sync_timeline_create();
771771
/* To be signaled when the compositor releases the buffer */
772-
fb_layer->releaseFenceFd = sw_sync_fence_create(timeline_fd, "wayland_release", 1);
773-
buf->timeline_fd = timeline_fd;
774-
} else {
775-
buf->timeline_fd = -1;
772+
fb_layer->releaseFenceFd = sw_sync_fence_create(buf->timeline_fd, "wayland_release", ++buf->sync_point);
776773
}
777774

778775
struct wl_surface *surface = get_surface(pdev, fb_layer, window, pdev->use_subsurface);

hwcomposer/wayland-hwc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ void snapshot_inactive_app_window(struct display *display, struct window *window
302302

303303
struct buffer *old_buf = window->last_layer_buffer;
304304
struct buffer *new_buf = new struct buffer();
305+
new_buf->timeline_fd = -1;
305306
// FIXME won't work as expected if there are multiple surfaces
306307
struct wl_surface *surface = window->surface;
307308

hwcomposer/wayland-hwc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ struct buffer {
174174
uint32_t hal_format;
175175

176176
int timeline_fd;
177+
int sync_point;
177178
bool isShm;
178179
void *shm_data;
179180
int size;

0 commit comments

Comments
 (0)