MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vulkan_transfer_host

Function vulkan_transfer_host

libavutil/hwcontext_vulkan.c:4441–4558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4439}
4440
4441static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf,
4442 AVFrame *swf, int upload)
4443{
4444 VulkanFramesPriv *fp = hwfc->hwctx;
4445 AVVulkanFramesContext *hwfc_vk = &fp->p;
4446 VulkanDevicePriv *p = hwfc->device_ctx->hwctx;
4447 AVVulkanDeviceContext *hwctx = &p->p;
4448 FFVulkanFunctions *vk = &p->vkctx.vkfn;
4449
4450 AVVkFrame *hwf_vk = (AVVkFrame *)hwf->data[0];
4451 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(swf->format);
4452 const int planes = av_pix_fmt_count_planes(swf->format);
4453 const int nb_images = ff_vk_count_images(hwf_vk);
4454
4455 VkSemaphoreWaitInfo sem_wait;
4456 VkHostImageLayoutTransitionInfoEXT layout_ch_info[AV_NUM_DATA_POINTERS];
4457 int nb_layout_ch = 0;
4458
4459 hwfc_vk->lock_frame(hwfc, hwf_vk);
4460
4461 for (int i = 0; i < nb_images; i++) {
4462 int compat = 0;
4463 for (int j = 0; j < p->vkctx.host_image_props.copySrcLayoutCount; j++) {
4464 if (hwf_vk->layout[i] == p->vkctx.host_image_props.pCopySrcLayouts[j]) {
4465 compat = 1;
4466 break;
4467 }
4468 }
4469 if (compat)
4470 continue;
4471
4472 layout_ch_info[nb_layout_ch] = (VkHostImageLayoutTransitionInfoEXT) {
4473 .sType = VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO_EXT,
4474 .image = hwf_vk->img[i],
4475 .oldLayout = hwf_vk->layout[i],
4476 .newLayout = VK_IMAGE_LAYOUT_GENERAL,
4477 .subresourceRange = {
4478 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
4479 .levelCount = 1,
4480 .layerCount = 1,
4481 },
4482 };
4483
4484 hwf_vk->layout[i] = layout_ch_info[nb_layout_ch].newLayout;
4485 nb_layout_ch++;
4486 }
4487
4488 sem_wait = (VkSemaphoreWaitInfo) {
4489 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
4490 .pSemaphores = hwf_vk->sem,
4491 .pValues = hwf_vk->sem_value,
4492 .semaphoreCount = nb_images,
4493 };
4494
4495 vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX);
4496
4497 if (nb_layout_ch)
4498 vk->TransitionImageLayoutEXT(hwctx->act_dev,

Callers 1

vulkan_transfer_frameFunction · 0.85

Calls 5

av_pix_fmt_desc_getFunction · 0.85
av_pix_fmt_count_planesFunction · 0.85
ff_vk_count_imagesFunction · 0.85
get_plane_whFunction · 0.85
ff_vk_aspect_flagFunction · 0.85

Tested by

no test coverage detected