virgl: make winsys modifications for encoded transfers
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 3 Jan 2019 21:33:12 +0000 (13:33 -0800)
committerGert Wollny <gert.wollny@collabora.com>
Fri, 15 Feb 2019 10:19:05 +0000 (11:19 +0100)
The idea is to have two command buffers:

1) One for transfers
2) One for commands, which can include transfers

At flush time, (2) will be filled.  Otherwise, (1) will be
used to submit transfers if there are enough of them.

v2: Pass size directly to cmd_buf_create (@gerddie)
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_winsys.h
src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c

index a4d4ab704ebda52eb7cfccc1db6d211423bce780..afc9fe883f7725f9c605a1e8a654d60741cfd705 100644 (file)
@@ -1242,7 +1242,7 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
    vctx = CALLOC_STRUCT(virgl_context);
    const char *host_debug_flagstring;
 
-   vctx->cbuf = rs->vws->cmd_buf_create(rs->vws);
+   vctx->cbuf = rs->vws->cmd_buf_create(rs->vws, VIRGL_MAX_CMDBUF_DWORDS);
    if (!vctx->cbuf) {
       FREE(vctx);
       return NULL;
index 96726b409d9ccee07d02a95e0ec9dcf572255a11..face3f0243ff6c271a9c76a7ee29c430a5484e90 100644 (file)
@@ -31,7 +31,8 @@ struct pipe_fence_handle;
 struct winsys_handle;
 struct virgl_hw_res;
 
-#define VIRGL_MAX_CMDBUF_DWORDS (64 * 1024)
+#define VIRGL_MAX_TBUF_DWORDS 1024
+#define VIRGL_MAX_CMDBUF_DWORDS ((64 * 1024) + VIRGL_MAX_TBUF_DWORDS)
 
 struct virgl_drm_caps {
    union virgl_caps caps;
@@ -47,6 +48,7 @@ struct virgl_cmd_buf {
 struct virgl_winsys {
    unsigned pci_id;
    int supports_fences; /* In/Out fences are supported */
+   int supports_encoded_transfers; /* Encoded transfers are supported */
 
    void (*destroy)(struct virgl_winsys *vws);
 
@@ -82,7 +84,7 @@ struct virgl_winsys {
                                   uint32_t stride,
                                   struct winsys_handle *whandle);
 
-   struct virgl_cmd_buf *(*cmd_buf_create)(struct virgl_winsys *ws);
+   struct virgl_cmd_buf *(*cmd_buf_create)(struct virgl_winsys *ws, uint32_t size);
    void (*cmd_buf_destroy)(struct virgl_cmd_buf *buf);
 
    void (*emit_res)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf, struct virgl_hw_res *res, boolean write_buffer);
index 26de8c702df70aaebfbc145b2f2228c345aef122..7759c87f9cfbb9f910c91aad5fee285627bf51bd 100644 (file)
@@ -564,7 +564,8 @@ static void virgl_drm_resource_wait(struct virgl_winsys *qws,
       goto again;
 }
 
-static struct virgl_cmd_buf *virgl_drm_cmd_buf_create(struct virgl_winsys *qws)
+static struct virgl_cmd_buf *virgl_drm_cmd_buf_create(struct virgl_winsys *qws,
+                                                      uint32_t size)
 {
    struct virgl_drm_cmd_buf *cbuf;
 
@@ -587,6 +588,14 @@ static struct virgl_cmd_buf *virgl_drm_cmd_buf_create(struct virgl_winsys *qws)
       return NULL;
    }
 
+   cbuf->buf = CALLOC(size, sizeof(uint32_t));
+   if (!cbuf->buf) {
+      FREE(cbuf->res_hlist);
+      FREE(cbuf->res_bo);
+      FREE(cbuf);
+      return NULL;
+   }
+
    cbuf->base.buf = cbuf->buf;
    cbuf->base.in_fence_fd = -1;
    return &cbuf->base;
@@ -598,6 +607,7 @@ static void virgl_drm_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf)
 
    FREE(cbuf->res_hlist);
    FREE(cbuf->res_bo);
+   FREE(cbuf->buf);
    FREE(cbuf);
 
 }
@@ -930,6 +940,7 @@ virgl_drm_winsys_create(int drmFD)
    qdws->base.fence_server_sync = virgl_fence_server_sync;
    qdws->base.fence_get_fd = virgl_fence_get_fd;
    qdws->base.supports_fences =  drm_version >= VIRGL_DRM_VERSION_FENCE_FD;
+   qdws->base.supports_encoded_transfers = 1;
 
    qdws->base.get_caps = virgl_drm_get_caps;
 
index 659c2d775681547457b42b61622ec7574ed46e22..51fad9cf372587a95d5a71cd6b59091969cea031 100644 (file)
@@ -71,7 +71,7 @@ struct virgl_drm_winsys
 struct virgl_drm_cmd_buf {
    struct virgl_cmd_buf base;
 
-   uint32_t buf[VIRGL_MAX_CMDBUF_DWORDS];
+   uint32_t *buf;
 
    unsigned nres;
    unsigned cres;
index 5422b29e55a5be18710256198e7fb448e4581b61..479a98fe499a66b36217b1289f029436e6663855 100644 (file)
@@ -411,7 +411,8 @@ alloc:
    return res;
 }
 
-static struct virgl_cmd_buf *virgl_vtest_cmd_buf_create(struct virgl_winsys *vws)
+static struct virgl_cmd_buf *virgl_vtest_cmd_buf_create(struct virgl_winsys *vws,
+                                                        uint32_t size)
 {
    struct virgl_vtest_cmd_buf *cbuf;
 
@@ -700,6 +701,7 @@ virgl_vtest_winsys_wrap(struct sw_winsys *sws)
    vtws->base.fence_wait = virgl_fence_wait;
    vtws->base.fence_reference = virgl_fence_reference;
    vtws->base.supports_fences =  0;
+   vtws->base.supports_encoded_transfers = 0;
 
    vtws->base.flush_frontbuffer = virgl_vtest_flush_frontbuffer;