Skip to content

Commit

Permalink
hwcomposer: Correctly synchronize reused buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
aleasto committed Jan 29, 2023
1 parent 60e2e94 commit f53e314
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions hwcomposer/hwcomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static struct buffer *get_wl_buffer(struct waydroid_hwc_composer_device_1 *pdev,
int ret = 0;

buf = new struct buffer();
buf->timeline_fd = sw_sync_timeline_create();
if (pdev->display->gtype == GRALLOC_GBM) {
struct gralloc_handle_t *drm_handle = (struct gralloc_handle_t *)layer->handle;
if (pdev->display->dmabuf) {
Expand Down Expand Up @@ -767,12 +768,8 @@ static int hwc_set(struct hwc_composer_device_1* dev,size_t numDisplays,
if (fb_layer->compositionType != HWC_FRAMEBUFFER &&
fb_layer->compositionType != HWC_SIDEBAND)
{
int timeline_fd = sw_sync_timeline_create();
/* To be signaled when the compositor releases the buffer */
fb_layer->releaseFenceFd = sw_sync_fence_create(timeline_fd, "wayland_release", 1);
buf->timeline_fd = timeline_fd;
} else {
buf->timeline_fd = -1;
fb_layer->releaseFenceFd = sw_sync_fence_create(buf->timeline_fd, "wayland_release", ++buf->sync_point);
}

struct wl_surface *surface = get_surface(pdev, fb_layer, window, pdev->use_subsurface);
Expand Down
1 change: 1 addition & 0 deletions hwcomposer/wayland-hwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ void snapshot_inactive_app_window(struct display *display, struct window *window

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

Expand Down
1 change: 1 addition & 0 deletions hwcomposer/wayland-hwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct buffer {
uint32_t hal_format;

int timeline_fd;
int sync_point;
bool isShm;
void *shm_data;
int size;
Expand Down

0 comments on commit f53e314

Please sign in to comment.