zink: prepare for multiple cmdbufs
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 25 Mar 2019 14:21:30 +0000 (15:21 +0100)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:44 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_cmdbuf.c
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_context.h

index df55b2377f544e1fb003345cbcbc9a265c7b4037..ab07069128ddf2765b6fc7b188791c2e077af431 100644 (file)
@@ -20,7 +20,7 @@ reset_cmdbuf(struct zink_screen *screen, struct zink_cmdbuf *cmdbuf)
 struct zink_cmdbuf *
 zink_start_cmdbuf(struct zink_context *ctx)
 {
-   struct zink_cmdbuf *cmdbuf = &ctx->cmdbuf;
+   struct zink_cmdbuf *cmdbuf = &ctx->cmdbufs[0];
    reset_cmdbuf(zink_screen(ctx->base.screen), cmdbuf);
 
    VkCommandBufferBeginInfo cbbi = {};
index b437bd3269ddc4660a4f38a6f5a5fff48fc0d7aa..4b31557cda94ae305c06ab9b7bf6059624780653 100644 (file)
@@ -53,7 +53,8 @@ zink_context_destroy(struct pipe_context *pctx)
 {
    struct zink_context *ctx = zink_context(pctx);
    struct zink_screen *screen = zink_screen(pctx->screen);
-   vkFreeCommandBuffers(screen->dev, ctx->cmdpool, 1, &ctx->cmdbuf.cmdbuf);
+   for (int i = 0; i < ARRAY_SIZE(ctx->cmdbufs); ++i)
+      vkFreeCommandBuffers(screen->dev, ctx->cmdpool, 1, &ctx->cmdbufs[i].cmdbuf);
    vkDestroyCommandPool(screen->dev, ctx->cmdpool, NULL);
 
    util_primconvert_destroy(ctx->primconvert);
@@ -1197,8 +1198,9 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    cbai.commandPool = ctx->cmdpool;
    cbai.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
    cbai.commandBufferCount = 1;
-   if (vkAllocateCommandBuffers(screen->dev, &cbai, &ctx->cmdbuf.cmdbuf) != VK_SUCCESS)
-      goto fail;
+   for (int i = 0; i < ARRAY_SIZE(ctx->cmdbufs); ++i)
+      if (vkAllocateCommandBuffers(screen->dev, &cbai, &ctx->cmdbufs[i].cmdbuf) != VK_SUCCESS)
+         goto fail;
 
    VkDescriptorPoolSize sizes[] = {
       {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000}
index fdf6ed665f604b772e01e145ae946c2a3686fcce..81aeb337e7f20d3626f2d4322385471d54d33144 100644 (file)
@@ -60,7 +60,7 @@ struct zink_context {
    struct blitter_context *blitter;
 
    VkCommandPool cmdpool;
-   struct zink_cmdbuf cmdbuf;
+   struct zink_cmdbuf cmdbufs[1];
 
    VkQueue queue;