mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
vulkan: fix use of atomics for the current context index
The code used to use atomic, but over time, this got broken. This commit also remmoves the is-the-last-submission-ready shortcut, which rarely did anything. There's also value in relying on the fact that contexts always carry their frames in a strictly incremental order with no gaps.
This commit is contained in:
parent
41f65b7326
commit
187fd52864
@ -317,6 +317,8 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
|
||||
|
||||
const VkQueryPoolVideoEncodeFeedbackCreateInfoKHR *ef = NULL;
|
||||
|
||||
atomic_init(&pool->idx, 0);
|
||||
|
||||
if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) {
|
||||
ef = ff_vk_find_struct(query_create_pnext,
|
||||
VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR);
|
||||
@ -490,17 +492,7 @@ VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e,
|
||||
|
||||
FFVkExecContext *ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
|
||||
{
|
||||
FFVulkanFunctions *vk = &s->vkfn;
|
||||
FFVkExecContext *e = &pool->contexts[pool->idx];
|
||||
|
||||
/* Check if last submission has already finished.
|
||||
* If so, don't waste resources and reuse the same buffer. */
|
||||
if (e->had_submission &&
|
||||
vk->GetFenceStatus(s->hwctx->act_dev, e->fence) == VK_SUCCESS)
|
||||
return e;
|
||||
|
||||
pool->idx = (pool->idx + 1) % pool->pool_size;
|
||||
return &pool->contexts[pool->idx];
|
||||
return &pool->contexts[atomic_fetch_add(&pool->idx, 1) % pool->pool_size];
|
||||
}
|
||||
|
||||
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
|
||||
|
@ -248,7 +248,7 @@ typedef struct FFVulkanShaderData {
|
||||
|
||||
typedef struct FFVkExecPool {
|
||||
FFVkExecContext *contexts;
|
||||
atomic_int_least64_t idx;
|
||||
atomic_uint_least64_t idx;
|
||||
|
||||
VkCommandPool cmd_buf_pool;
|
||||
VkCommandBuffer *cmd_bufs;
|
||||
|
Loading…
Reference in New Issue
Block a user