1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

hwcontext_vulkan: create all images with concurrent sharing mode

As it turns out, we were already assuming and treating all images as if they had
concurrent access mode. This just changes the flag to CONCURRENT, which has less
restrictions than EXCLUSIVE, and fixed validation messages on machines with
multiple queues.
The validation layer didn't pick this up because the machine I was testing on
had only a single queue.
This commit is contained in:
Lynne 2020-05-10 21:53:39 +01:00
parent 7c080dc190
commit 875c1707e5
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 52 additions and 31 deletions

View File

@ -53,6 +53,10 @@ typedef struct VulkanDevicePriv {
VkPhysicalDeviceProperties props; VkPhysicalDeviceProperties props;
VkPhysicalDeviceMemoryProperties mprops; VkPhysicalDeviceMemoryProperties mprops;
/* Queues */
uint32_t qfs[3];
int num_qfs;
/* Debug callback */ /* Debug callback */
VkDebugUtilsMessengerEXT debug_ctx; VkDebugUtilsMessengerEXT debug_ctx;
@ -897,6 +901,14 @@ if (n >= queue_num) {
#undef CHECK_QUEUE #undef CHECK_QUEUE
p->qfs[p->num_qfs++] = hwctx->queue_family_index;
if ((hwctx->queue_family_tx_index != hwctx->queue_family_index) &&
(hwctx->queue_family_tx_index != hwctx->queue_family_comp_index))
p->qfs[p->num_qfs++] = hwctx->queue_family_tx_index;
if ((hwctx->queue_family_comp_index != hwctx->queue_family_index) &&
(hwctx->queue_family_comp_index != hwctx->queue_family_tx_index))
p->qfs[p->num_qfs++] = hwctx->queue_family_comp_index;
/* Create exec context - if there's something invalid this will error out */ /* Create exec context - if there's something invalid this will error out */
err = create_exec_ctx(ctx, &p->cmd, hwctx->queue_family_tx_index); err = create_exec_ctx(ctx, &p->cmd, hwctx->queue_family_tx_index);
if (err) if (err)
@ -1346,8 +1358,11 @@ static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame,
.tiling = tiling, .tiling = tiling,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.usage = usage, .usage = usage,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.samples = VK_SAMPLE_COUNT_1_BIT, .samples = VK_SAMPLE_COUNT_1_BIT,
.pQueueFamilyIndices = p->qfs,
.queueFamilyIndexCount = p->num_qfs,
.sharingMode = p->num_qfs > 1 ? VK_SHARING_MODE_CONCURRENT :
VK_SHARING_MODE_EXCLUSIVE,
}; };
ret = vkCreateImage(hwctx->act_dev, &image_create_info, ret = vkCreateImage(hwctx->act_dev, &image_create_info,
@ -1829,13 +1844,15 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
.extent.depth = 1, .extent.depth = 1,
.mipLevels = 1, .mipLevels = 1,
.arrayLayers = 1, .arrayLayers = 1,
.flags = VK_IMAGE_CREATE_ALIAS_BIT | .flags = VK_IMAGE_CREATE_ALIAS_BIT,
(signal_p ? VK_IMAGE_CREATE_DISJOINT_BIT : 0x0),
.tiling = f->tiling, .tiling = f->tiling,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */ .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
.usage = DEFAULT_USAGE_FLAGS, .usage = DEFAULT_USAGE_FLAGS,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.samples = VK_SAMPLE_COUNT_1_BIT, .samples = VK_SAMPLE_COUNT_1_BIT,
.pQueueFamilyIndices = p->qfs,
.queueFamilyIndexCount = p->num_qfs,
.sharingMode = p->num_qfs > 1 ? VK_SHARING_MODE_CONCURRENT :
VK_SHARING_MODE_EXCLUSIVE,
}; };
for (int j = 0; j < planes; j++) { for (int j = 0; j < planes; j++) {

View File

@ -119,6 +119,10 @@ typedef struct AVVulkanFramesContext {
* All frames, imported or allocated, will be created with the * All frames, imported or allocated, will be created with the
* VK_IMAGE_CREATE_ALIAS_BIT flag set, so the memory may be aliased if needed. * VK_IMAGE_CREATE_ALIAS_BIT flag set, so the memory may be aliased if needed.
* *
* If all three queue family indices in the device context are the same,
* images will be created with the EXCLUSIVE sharing mode. Otherwise, all images
* will be created using the CONCURRENT sharing mode.
*
* @note the size of this structure is not part of the ABI, to allocate * @note the size of this structure is not part of the ABI, to allocate
* you must use @av_vk_frame_alloc(). * you must use @av_vk_frame_alloc().
*/ */