diff options
author | Niklas Haas <git@haasn.xyz> | 2017-09-28 23:06:56 +0200 |
---|---|---|
committer | Martin Herkt <652892+lachs0r@users.noreply.github.com> | 2017-12-25 00:47:53 +0100 |
commit | 5feaaba0fd27af34ee1fef12545f1dd96ebefddd (patch) | |
tree | cd6278cc8f8de6e2f9f66a1d8ab6c06281ad77f5 /video/out/vulkan/ra_vk.c | |
parent | 885497a4456256a147d9e7e30daa3170e461d7d6 (diff) | |
download | mpv-5feaaba0fd27af34ee1fef12545f1dd96ebefddd.tar.bz2 mpv-5feaaba0fd27af34ee1fef12545f1dd96ebefddd.tar.xz |
vo_gpu: vulkan: refactor command submission
Instead of being submitted immediately, commands are appended into an
internal submission queue, and the actual submission is done once per
frame (at the same time as queue cycling). Again, the benefits are not
immediately obvious because nothing benefits from this yet, but it will
make more sense for an upcoming vk_signal mechanism.
This also cleans up the way the ra_vk submission interacts with the
synchronization/callbacks from the ra_vk_ctx. Although currently, the
way the dependency is signalled is a bit hacky: normally it would be
associated with the ra_tex itself and waited on in the appropriate stage
implicitly. But that code is just temporary, so I'm keeping it in there
for a better commit order.
Diffstat (limited to 'video/out/vulkan/ra_vk.c')
-rw-r--r-- | video/out/vulkan/ra_vk.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/video/out/vulkan/ra_vk.c b/video/out/vulkan/ra_vk.c index e0e13391af..d6063af4e0 100644 --- a/video/out/vulkan/ra_vk.c +++ b/video/out/vulkan/ra_vk.c @@ -34,18 +34,15 @@ static struct vk_cmd *vk_require_cmd(struct ra *ra) return p->cmd; } -static bool vk_flush(struct ra *ra) +static void vk_submit(struct ra *ra) { struct ra_vk *p = ra->priv; struct mpvk_ctx *vk = ra_vk_get(ra); if (p->cmd) { - if (!vk_cmd_submit(vk, p->cmd)) - return false; + vk_cmd_queue(vk, p->cmd); p->cmd = NULL; } - - return true; } // The callback's *priv will always be set to `ra` @@ -71,7 +68,8 @@ static void vk_destroy_ra(struct ra *ra) struct ra_vk *p = ra->priv; struct mpvk_ctx *vk = ra_vk_get(ra); - vk_flush(ra); + vk_submit(ra); + vk_flush_commands(vk); mpvk_dev_wait_cmds(vk, UINT64_MAX); ra_tex_free(ra, &p->clear_tex); @@ -1706,41 +1704,19 @@ static struct ra_fns ra_fns_vk = { .timer_stop = vk_timer_stop, }; -static void present_cb(void *priv, int *inflight) -{ - *inflight -= 1; -} - -bool ra_vk_submit(struct ra *ra, struct ra_tex *tex, VkSemaphore acquired, - VkSemaphore done, int *inflight) +struct vk_cmd *ra_vk_submit(struct ra *ra, struct ra_tex *tex) { + struct ra_vk *p = ra->priv; struct vk_cmd *cmd = vk_require_cmd(ra); if (!cmd) - goto error; - - if (inflight) { - *inflight += 1; - vk_cmd_callback(cmd, (vk_cb)present_cb, NULL, inflight); - } + return NULL; struct ra_tex_vk *tex_vk = tex->priv; assert(tex_vk->external_img); tex_barrier(cmd, tex_vk, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, false); - // These are the only two stages that we use/support for actually - // outputting to swapchain imagechain images, so just add a dependency - // on both of them. In theory, we could maybe come up with some more - // advanced mechanism of tracking dynamic dependencies, but that seems - // like overkill. - vk_cmd_dep(cmd, acquired, - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | - VK_PIPELINE_STAGE_TRANSFER_BIT); - - vk_cmd_sig(cmd, done); - - return vk_flush(ra); - -error: - return false; + // Return this directly instead of going through vk_submit + p->cmd = NULL; + return cmd; } |