struct pipe_fence_handle **fence)
{
struct virgl_screen *rs = virgl_screen(ctx->base.screen);
- int out_fence_fd = -1;
if (ctx->num_draws)
u_upload_unmap(ctx->uploader);
ctx->num_transfers = ctx->num_draws = ctx->num_compute = 0;
virgl_transfer_queue_clear(&ctx->queue, ctx->cbuf);
- rs->vws->submit_cmd(rs->vws, ctx->cbuf,
- ctx->cbuf->needs_out_fence_fd ? &out_fence_fd : NULL);
-
- if (fence)
- *fence = rs->vws->cs_create_fence(rs->vws, out_fence_fd);
+ rs->vws->submit_cmd(rs->vws, ctx->cbuf, fence);
/* Reserve some space for transfers. */
if (ctx->encoded_transfers)
{
struct virgl_context *vctx = virgl_context(ctx);
- if (flags & PIPE_FLUSH_FENCE_FD)
- vctx->cbuf->needs_out_fence_fd = true;
-
virgl_flush_eq(vctx, vctx, fence);
-
- vctx->cbuf->needs_out_fence_fd = false;
}
static struct pipe_sampler_view *virgl_create_sampler_view(struct pipe_context *ctx,
struct virgl_cmd_buf {
unsigned cdw;
uint32_t *buf;
- bool needs_out_fence_fd;
};
struct virgl_winsys {
void (*emit_res)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf, struct virgl_hw_res *res, boolean write_buffer);
int (*submit_cmd)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf,
- int32_t *out_fence_fd);
+ struct pipe_fence_handle **fence);
boolean (*res_is_referenced)(struct virgl_winsys *vws,
struct virgl_cmd_buf *buf,
}
+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);
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);
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);
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,
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);
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));
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,