1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +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;
VkPhysicalDeviceMemoryProperties mprops;
/* Queues */
uint32_t qfs[3];
int num_qfs;
/* Debug callback */
VkDebugUtilsMessengerEXT debug_ctx;
@ -897,6 +901,14 @@ if (n >= queue_num) {
#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 */
err = create_exec_ctx(ctx, &p->cmd, hwctx->queue_family_tx_index);
if (err)
@ -1333,21 +1345,24 @@ static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame,
const int p_h = i > 0 ? AV_CEIL_RSHIFT(h, desc->log2_chroma_h) : h;
VkImageCreateInfo image_create_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = create_pnext,
.imageType = VK_IMAGE_TYPE_2D,
.format = img_fmts[i],
.extent.width = p_w,
.extent.height = p_h,
.extent.depth = 1,
.mipLevels = 1,
.arrayLayers = 1,
.flags = VK_IMAGE_CREATE_ALIAS_BIT,
.tiling = tiling,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.usage = usage,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.samples = VK_SAMPLE_COUNT_1_BIT,
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = create_pnext,
.imageType = VK_IMAGE_TYPE_2D,
.format = img_fmts[i],
.extent.width = p_w,
.extent.height = p_h,
.extent.depth = 1,
.mipLevels = 1,
.arrayLayers = 1,
.flags = VK_IMAGE_CREATE_ALIAS_BIT,
.tiling = tiling,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.usage = usage,
.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,
@ -1820,22 +1835,24 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
const int p_h = i > 0 ? AV_CEIL_RSHIFT(hwfc->height, fmt_desc->log2_chroma_h) : hwfc->height;
VkImageCreateInfo image_create_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = &einfo,
.imageType = VK_IMAGE_TYPE_2D,
.format = drm_to_vulkan_fmt(desc->layers[i].format),
.extent.width = p_w,
.extent.height = p_h,
.extent.depth = 1,
.mipLevels = 1,
.arrayLayers = 1,
.flags = VK_IMAGE_CREATE_ALIAS_BIT |
(signal_p ? VK_IMAGE_CREATE_DISJOINT_BIT : 0x0),
.tiling = f->tiling,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
.usage = DEFAULT_USAGE_FLAGS,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.samples = VK_SAMPLE_COUNT_1_BIT,
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = &einfo,
.imageType = VK_IMAGE_TYPE_2D,
.format = drm_to_vulkan_fmt(desc->layers[i].format),
.extent.width = p_w,
.extent.height = p_h,
.extent.depth = 1,
.mipLevels = 1,
.arrayLayers = 1,
.flags = VK_IMAGE_CREATE_ALIAS_BIT,
.tiling = f->tiling,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
.usage = DEFAULT_USAGE_FLAGS,
.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++) {

View File

@ -119,6 +119,10 @@ typedef struct AVVulkanFramesContext {
* 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.
*
* 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
* you must use @av_vk_frame_alloc().
*/