diff options
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 40 | ||||
-rw-r--r-- | src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c | 30 |
2 files changed, 42 insertions, 28 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 1c5ec714e25..2cd4bf70429 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -709,9 +709,24 @@ static void virgl_drm_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf) } +static struct pipe_fence_handle * +virgl_drm_fence_create(struct virgl_winsys *vws, int fd) +{ + struct virgl_hw_res *res; + + res = virgl_drm_winsys_resource_cache_create(vws, + PIPE_BUFFER, + PIPE_FORMAT_R8_UNORM, + VIRGL_BIND_CUSTOM, + 8, 1, 1, 0, 0, 0, 8); + + res->fence_fd = fd; + return (struct pipe_fence_handle *)res; +} + static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, struct virgl_cmd_buf *_cbuf, - int *out_fence_fd) + struct pipe_fence_handle **fence) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf); @@ -734,11 +749,10 @@ static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, eb.fence_fd = cbuf->in_fence_fd; } - if (out_fence_fd != NULL) + if (fence != NULL) eb.flags |= VIRTGPU_EXECBUF_FENCE_FD_OUT; } else { assert(cbuf->in_fence_fd < 0); - assert(out_fence_fd == NULL); } ret = drmIoctl(qdws->fd, DRM_IOCTL_VIRTGPU_EXECBUFFER, &eb); @@ -751,10 +765,13 @@ static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, close(cbuf->in_fence_fd); cbuf->in_fence_fd = -1; } - } - if (out_fence_fd != NULL) - *out_fence_fd = eb.fence_fd; + if (fence != NULL && ret == 0) + *fence = virgl_drm_fence_create(qws, eb.fence_fd); + } else { + if (fence != NULL && ret == 0) + *fence = virgl_drm_fence_create(qws, -1); + } virgl_drm_release_all_res(qdws, cbuf); @@ -809,16 +826,7 @@ static int handle_compare(void *key1, void *key2) static struct pipe_fence_handle * virgl_cs_create_fence(struct virgl_winsys *vws, int fd) { - struct virgl_hw_res *res; - - res = virgl_drm_winsys_resource_cache_create(vws, - PIPE_BUFFER, - PIPE_FORMAT_R8_UNORM, - VIRGL_BIND_CUSTOM, - 8, 1, 1, 0, 0, 0, 8); - - res->fence_fd = fd; - return (struct pipe_fence_handle *)res; + return virgl_drm_fence_create(vws, fd); } static bool virgl_fence_wait(struct virgl_winsys *vws, diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c index 2ea0187fec9..e3a38e00ec5 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c @@ -486,9 +486,23 @@ static void virgl_vtest_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf) FREE(cbuf); } +static struct pipe_fence_handle * +virgl_vtest_fence_create(struct virgl_winsys *vws) +{ + struct virgl_hw_res *res; + + res = virgl_vtest_winsys_resource_cache_create(vws, + PIPE_BUFFER, + PIPE_FORMAT_R8_UNORM, + VIRGL_BIND_CUSTOM, + 8, 1, 1, 0, 0, 0, 8); + + return (struct pipe_fence_handle *)res; +} + static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, struct virgl_cmd_buf *_cbuf, - int *out_fence_fd) + struct pipe_fence_handle **fence) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf); @@ -497,9 +511,9 @@ static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, if (cbuf->base.cdw == 0) return 0; - assert(out_fence_fd == NULL); - ret = virgl_vtest_submit_cmd(vtws, cbuf); + if (fence && ret == 0) + *fence = virgl_vtest_fence_create(vws); virgl_vtest_release_all_res(vtws, cbuf); memset(cbuf->is_handle_added, 0, sizeof(cbuf->is_handle_added)); @@ -543,15 +557,7 @@ static int virgl_vtest_get_caps(struct virgl_winsys *vws, static struct pipe_fence_handle * virgl_cs_create_fence(struct virgl_winsys *vws, int fd) { - struct virgl_hw_res *res; - - res = virgl_vtest_winsys_resource_cache_create(vws, - PIPE_BUFFER, - PIPE_FORMAT_R8_UNORM, - VIRGL_BIND_CUSTOM, - 8, 1, 1, 0, 0, 0, 8); - - return (struct pipe_fence_handle *)res; + return virgl_vtest_fence_create(vws); } static bool virgl_fence_wait(struct virgl_winsys *vws, |