The patch was applied by mistake in an unfinished form. This fixes the build and lets the code run.
Unified · Split
| @@ -2830,14 +2830,13 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) · 2829 unmodified lines | |||
| 2830 | 2830 | ||
| 2831 | /* Image usage flags */ | 2831 | /* Image usage flags */ |
| 2832 | if (!hwctx->usage) { | 2832 | if (!hwctx->usage) { |
| 2833 | hwctx->usage = supported_usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | | 2833 | hwctx->usage = supported_usage & (VK_IMAGE_USAGE_TRANSFER_DST_BIT | |
| 2834 | VK_IMAGE_USAGE_STORAGE_BIT | | 2834 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | |
| 2835 | VK_IMAGE_USAGE_STORAGE_BIT | | ||
| 2835 | VK_IMAGE_USAGE_SAMPLED_BIT); | 2836 | VK_IMAGE_USAGE_SAMPLED_BIT); |
| 2836 | 2837 | ||
| 2837 | if (p->vkctx.extensions & FF_VK_EXT_HOST_IMAGE_COPY) | 2838 | if (p->vkctx.extensions & FF_VK_EXT_HOST_IMAGE_COPY) |
| 2838 | hwctx->usage |= supported_usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT; | 2839 | hwctx->usage |= supported_usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT; |
| 2839 | else | ||
| 2840 | hwctx->usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||
| 2841 | 2840 | ||
| 2842 | /* Enables encoding of images, if supported by format and extensions */ | 2841 | /* Enables encoding of images, if supported by format and extensions */ |
| 2843 | if ((supported_usage & VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR) && | 2842 | if ((supported_usage & VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR) && |
| @@ -4160,8 +4159,9 @@ fail: · 1316 unmodified lines | |||
| 4160 | static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf, | 4159 | static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf, |
| 4161 | AVFrame *swf, int upload) | 4160 | AVFrame *swf, int upload) |
| 4162 | { | 4161 | { |
| 4162 | VulkanFramesPriv *fp = hwfc->hwctx; | ||
| 4163 | AVVulkanFramesContext *hwfc_vk = &fp->p; | ||
| 4163 | VulkanDevicePriv *p = hwfc->device_ctx->hwctx; | 4164 | VulkanDevicePriv *p = hwfc->device_ctx->hwctx; |
| 4164 | AVVulkanFramesContext *hwfc_vk = hwfc->hwctx; | ||
| 4165 | AVVulkanDeviceContext *hwctx = &p->p; | 4165 | AVVulkanDeviceContext *hwctx = &p->p; |
| 4166 | FFVulkanFunctions *vk = &p->vkctx.vkfn; | 4166 | FFVulkanFunctions *vk = &p->vkctx.vkfn; |
| 4167 | 4167 | ||
| @@ -4170,16 +4170,23 @@ static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf, · 2 unmodified lines | |||
| 4170 | const int nb_images = ff_vk_count_images(hwf_vk); | 4170 | const int nb_images = ff_vk_count_images(hwf_vk); |
| 4171 | 4171 | ||
| 4172 | VkSemaphoreWaitInfo sem_wait; | 4172 | VkSemaphoreWaitInfo sem_wait; |
| 4173 | VkHostImageLayoutTransitionInfo layout_ch_info[]; | 4173 | VkHostImageLayoutTransitionInfo layout_ch_info[AV_NUM_DATA_POINTERS]; |
| 4174 | int nb_layout_ch = 0; | 4174 | int nb_layout_ch = 0; |
| 4175 | 4175 | ||
| 4176 | hwfc_vk->lock_frame(hwfc, hwf_vk); | 4176 | hwfc_vk->lock_frame(hwfc, hwf_vk); |
| 4177 | 4177 | ||
| 4178 | for (int i = 0; i < nb_images; i++) { | 4178 | for (int i = 0; i < nb_images; i++) { |
| 4179 | if (hwf_vk->layout[i]) | 4179 | int compat = 0; |
| 4180 | for (int j = 0; j < p->vkctx.host_image_props.copySrcLayoutCount; j++) { | ||
| 4181 | if (hwf_vk->layout[i] == p->vkctx.host_image_props.pCopySrcLayouts[j]) { | ||
| 4182 | compat = 1; | ||
| 4183 | break; | ||
| 4184 | } | ||
| 4185 | } | ||
| 4186 | if (compat) | ||
| 4180 | continue; | 4187 | continue; |
| 4181 | 4188 | ||
| 4182 | layout_ch_info[nb_layout_ch++] = (VkHostImageLayoutTransitionInfo) { | 4189 | layout_ch_info[nb_layout_ch] = (VkHostImageLayoutTransitionInfo) { |
| 4183 | .sType = VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO, | 4190 | .sType = VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO, |
| 4184 | .image = hwf_vk->img[i], | 4191 | .image = hwf_vk->img[i], |
| 4185 | .oldLayout = hwf_vk->layout[i], | 4192 | .oldLayout = hwf_vk->layout[i], |
| @@ -4188,13 +4195,12 @@ static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf, · 2 unmodified lines | |||
| 4188 | .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, | 4195 | .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, |
| 4189 | .levelCount = 1, | 4196 | .levelCount = 1, |
| 4190 | .layerCount = 1, | 4197 | .layerCount = 1, |
| 4191 | }; | 4198 | }, |
| 4192 | }; | 4199 | }; |
| 4193 | } | ||
| 4194 | 4200 | ||
| 4195 | if (nb_layout_ch) | 4201 | hwf_vk->layout[i] = layout_ch_info[nb_layout_ch].newLayout; |
| 4196 | vk->TransitionImageLayoutEXT(hwctx->act_dev, | 4202 | nb_layout_ch++; |
| 4197 | nb_layout_ch, layout_ch_info); | 4203 | } |
| 4198 | 4204 | ||
| 4199 | sem_wait = (VkSemaphoreWaitInfo) { | 4205 | sem_wait = (VkSemaphoreWaitInfo) { |
| 4200 | .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO, | 4206 | .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO, |
| @@ -4205,6 +4211,10 @@ static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf, · 4 unmodified lines | |||
| 4205 | 4211 | ||
| 4206 | vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX); | 4212 | vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX); |
| 4207 | 4213 | ||
| 4214 | if (nb_layout_ch) | ||
| 4215 | vk->TransitionImageLayoutEXT(hwctx->act_dev, | ||
| 4216 | nb_layout_ch, layout_ch_info); | ||
| 4217 | |||
| 4208 | if (upload) { | 4218 | if (upload) { |
| 4209 | VkMemoryToImageCopy region_info = { | 4219 | VkMemoryToImageCopy region_info = { |
| 4210 | .sType = VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY, | 4220 | .sType = VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY, |
| @@ -4270,6 +4280,7 @@ static int vulkan_transfer_frame(AVHWFramesContext *hwfc, · 59 unmodified lines | |||
| 4270 | { | 4280 | { |
| 4271 | int err; | 4281 | int err; |
| 4272 | VulkanFramesPriv *fp = hwfc->hwctx; | 4282 | VulkanFramesPriv *fp = hwfc->hwctx; |
| 4283 | AVVulkanFramesContext *hwctx = &fp->p; | ||
| 4273 | VulkanDevicePriv *p = hwfc->device_ctx->hwctx; | 4284 | VulkanDevicePriv *p = hwfc->device_ctx->hwctx; |
| 4274 | FFVulkanFunctions *vk = &p->vkctx.vkfn; | 4285 | FFVulkanFunctions *vk = &p->vkctx.vkfn; |
| 4275 | 4286 | ||
| @@ -4300,7 +4311,7 @@ static int vulkan_transfer_frame(AVHWFramesContext *hwfc, · 24 unmodified lines | |||
| 4300 | if (swf->width > hwfc->width || swf->height > hwfc->height) | 4311 | if (swf->width > hwfc->width || swf->height > hwfc->height) |
| 4301 | return AVERROR(EINVAL); | 4312 | return AVERROR(EINVAL); |
| 4302 | 4313 | ||
| 4303 | if (p->vkctx.extensions & FF_VK_EXT_HOST_IMAGE_COPY) | 4314 | if (hwctx->usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT) |
| 4304 | return vulkan_transfer_host(hwfc, hwf, swf, upload); | 4315 | return vulkan_transfer_host(hwfc, hwf, swf, upload); |
| 4305 | 4316 | ||
| 4306 | for (int i = 0; i < av_pix_fmt_count_planes(swf->format); i++) { | 4317 | for (int i = 0; i < av_pix_fmt_count_planes(swf->format); i++) { |
| @@ -107,6 +107,8 @@ const char *ff_vk_ret2str(VkResult res) · 106 unmodified lines | |||
| 107 | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR); \ | 107 | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR); \ |
| 108 | MAP_TO(VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR, \ | 108 | MAP_TO(VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR, \ |
| 109 | VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR); \ | 109 | VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR); \ |
| 110 | MAP_TO(VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT, \ | ||
| 111 | VK_IMAGE_USAGE_HOST_TRANSFER_BIT); \ | ||
| 110 | return dst; \ | 112 | return dst; \ |
| 111 | } | 113 | } |
| 112 | 114 | ||
| @@ -191,7 +193,7 @@ int ff_vk_load_props(FFVulkanContext *s) · 78 unmodified lines | |||
| 191 | s->host_image_props.pCopySrcLayouts = | 193 | s->host_image_props.pCopySrcLayouts = |
| 192 | s->host_image_props.pCopyDstLayouts = NULL; | 194 | s->host_image_props.pCopyDstLayouts = NULL; |
| 193 | s->host_image_props.copySrcLayoutCount = | 195 | s->host_image_props.copySrcLayoutCount = |
| 194 | s->host_image_props.copyDstLayoutCount = NULL; | 196 | s->host_image_props.copyDstLayoutCount = 0; |
| 195 | vk->GetPhysicalDeviceProperties2(s->hwctx->phys_dev, &s->props); | 197 | vk->GetPhysicalDeviceProperties2(s->hwctx->phys_dev, &s->props); |
| 196 | 198 | ||
| 197 | new_size = s->host_image_props.copySrcLayoutCount + | 199 | new_size = s->host_image_props.copySrcLayoutCount + |