diff options
author | Chia-I Wu <[email protected]> | 2019-04-09 17:55:40 +0000 |
---|---|---|
committer | Gurchetan Singh <[email protected]> | 2019-04-15 23:25:47 +0000 |
commit | a23c091988f30fd432b5e1a68aedc95c307efa34 (patch) | |
tree | cd3dddd5930a34110259f18b005aa045821ad2ae /src/gallium/winsys/virgl | |
parent | 88e0bbf24aa82000195d10c7873f881d190b825b (diff) |
virgl: handle fence_server_sync in winsys
It does not need help from the driver. This also fixes one issue where
the fence is ignored when the transfer queue is full.
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/winsys/virgl')
-rw-r--r-- | src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 31 | ||||
-rw-r--r-- | src/gallium/winsys/virgl/drm/virgl_drm_winsys.h | 2 | ||||
-rw-r--r-- | src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c | 4 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 2cf8b4ba076..1c5ec714e25 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -692,8 +692,8 @@ static struct virgl_cmd_buf *virgl_drm_cmd_buf_create(struct virgl_winsys *qws, return NULL; } + cbuf->in_fence_fd = -1; cbuf->base.buf = cbuf->buf; - cbuf->base.in_fence_fd = -1; return &cbuf->base; } @@ -711,7 +711,7 @@ static void virgl_drm_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf) static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, struct virgl_cmd_buf *_cbuf, - int in_fence_fd, int *out_fence_fd) + int *out_fence_fd) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf); @@ -726,21 +726,33 @@ static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, eb.size = cbuf->base.cdw * 4; eb.num_bo_handles = cbuf->cres; eb.bo_handles = (unsigned long)(void *)cbuf->res_hlist; + eb.fence_fd = -1; + if (qws->supports_fences) { + if (cbuf->in_fence_fd >= 0) { + eb.flags |= VIRTGPU_EXECBUF_FENCE_FD_IN; + eb.fence_fd = cbuf->in_fence_fd; + } - if (in_fence_fd != -1) { - eb.flags |= VIRTGPU_EXECBUF_FENCE_FD_IN; - eb.fence_fd = in_fence_fd; + if (out_fence_fd != NULL) + eb.flags |= VIRTGPU_EXECBUF_FENCE_FD_OUT; + } else { + assert(cbuf->in_fence_fd < 0); + assert(out_fence_fd == NULL); } - if (out_fence_fd != NULL) - eb.flags |= VIRTGPU_EXECBUF_FENCE_FD_OUT; - ret = drmIoctl(qdws->fd, DRM_IOCTL_VIRTGPU_EXECBUFFER, &eb); if (ret == -1) fprintf(stderr,"got error from kernel - expect bad rendering %d\n", errno); cbuf->base.cdw = 0; + if (qws->supports_fences) { + if (cbuf->in_fence_fd >= 0) { + close(cbuf->in_fence_fd); + cbuf->in_fence_fd = -1; + } + } + if (out_fence_fd != NULL) *out_fence_fd = eb.fence_fd; @@ -849,9 +861,10 @@ static void virgl_fence_reference(struct virgl_winsys *vws, } static void virgl_fence_server_sync(struct virgl_winsys *vws, - struct virgl_cmd_buf *cbuf, + struct virgl_cmd_buf *_cbuf, struct pipe_fence_handle *fence) { + struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf); struct virgl_hw_res *hw_res = virgl_hw_res(fence); /* if not an external fence, then nothing more to do without preemption: */ diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h index 51fad9cf372..1fbbde2e7d2 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h @@ -73,6 +73,8 @@ struct virgl_drm_cmd_buf { uint32_t *buf; + int in_fence_fd; + unsigned nres; unsigned cres; struct virgl_hw_res **res_bo; diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c index 3ca15e6aed7..2ea0187fec9 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c @@ -474,7 +474,6 @@ static struct virgl_cmd_buf *virgl_vtest_cmd_buf_create(struct virgl_winsys *vws } cbuf->ws = vws; cbuf->base.buf = cbuf->buf; - cbuf->base.in_fence_fd = -1; return &cbuf->base; } @@ -489,7 +488,7 @@ static void virgl_vtest_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf) static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, struct virgl_cmd_buf *_cbuf, - int in_fence_fd, int *out_fence_fd) + int *out_fence_fd) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf); @@ -498,7 +497,6 @@ static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, if (cbuf->base.cdw == 0) return 0; - assert(in_fence_fd == -1); assert(out_fence_fd == NULL); ret = virgl_vtest_submit_cmd(vtws, cbuf); |