We recently introduced a public field which was a superset of the queue context we used to have. Switch to using it entirely. This also allows us to get rid of the NIH function which was valid only for video queues.
Unified · Split
| @@ -58,10 +58,10 @@ typedef struct VulkanEncodeFFv1Context { · 57 unmodified lines | |||
| 58 | AVFrame *frame; | 58 | AVFrame *frame; |
| 59 | 59 | ||
| 60 | FFVulkanContext s; | 60 | FFVulkanContext s; |
| 61 | FFVkQueueFamilyCtx qf; | 61 | AVVulkanDeviceQueueFamily *qf; |
| 62 | FFVkExecPool exec_pool; | 62 | FFVkExecPool exec_pool; |
| 63 | 63 | ||
| 64 | FFVkQueueFamilyCtx transfer_qf; | 64 | AVVulkanDeviceQueueFamily *transfer_qf; |
| 65 | FFVkExecPool transfer_exec_pool; | 65 | FFVkExecPool transfer_exec_pool; |
| 66 | 66 | ||
| 67 | VkBufferCopy *buf_regions; | 67 | VkBufferCopy *buf_regions; |
| @@ -1586,8 +1586,8 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) · 1518 unmodified lines | |||
| 1586 | if (err < 0) | 1586 | if (err < 0) |
| 1587 | return err; | 1587 | return err; |
| 1588 | 1588 | ||
| 1589 | err = ff_vk_qf_init(&fv->s, &fv->qf, VK_QUEUE_COMPUTE_BIT); | 1589 | fv->qf = ff_vk_qf_find(&fv->s, VK_QUEUE_COMPUTE_BIT, 0); |
| 1590 | if (err < 0) { | 1590 | if (!fv->qf) { |
| 1591 | av_log(avctx, AV_LOG_ERROR, "Device has no compute queues!\n"); | 1591 | av_log(avctx, AV_LOG_ERROR, "Device has no compute queues!\n"); |
| 1592 | return err; | 1592 | return err; |
| 1593 | } | 1593 | } |
| @@ -1626,7 +1626,7 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) · 32 unmodified lines | |||
| 1626 | } | 1626 | } |
| 1627 | 1627 | ||
| 1628 | if (!fv->async_depth) { | 1628 | if (!fv->async_depth) { |
| 1629 | fv->async_depth = FFMIN(fv->qf.nb_queues, FFMAX(max_heap_size / maxsize, 1)); | 1629 | fv->async_depth = FFMIN(fv->qf->num, FFMAX(max_heap_size / maxsize, 1)); |
| 1630 | fv->async_depth = FFMAX(fv->async_depth, 1); | 1630 | fv->async_depth = FFMAX(fv->async_depth, 1); |
| 1631 | } | 1631 | } |
| 1632 | 1632 | ||
| @@ -1635,19 +1635,19 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) · 2 unmodified lines | |||
| 1635 | (fv->async_depth * maxsize) / (1024*1024), | 1635 | (fv->async_depth * maxsize) / (1024*1024), |
| 1636 | fv->async_depth); | 1636 | fv->async_depth); |
| 1637 | 1637 | ||
| 1638 | err = ff_vk_exec_pool_init(&fv->s, &fv->qf, &fv->exec_pool, | 1638 | err = ff_vk_exec_pool_init(&fv->s, fv->qf, &fv->exec_pool, |
| 1639 | fv->async_depth, | 1639 | fv->async_depth, |
| 1640 | 0, 0, 0, NULL); | 1640 | 0, 0, 0, NULL); |
| 1641 | if (err < 0) | 1641 | if (err < 0) |
| 1642 | return err; | 1642 | return err; |
| 1643 | 1643 | ||
| 1644 | err = ff_vk_qf_init(&fv->s, &fv->transfer_qf, VK_QUEUE_TRANSFER_BIT); | 1644 | fv->transfer_qf = ff_vk_qf_find(&fv->s, VK_QUEUE_TRANSFER_BIT, 0); |
| 1645 | if (err < 0) { | 1645 | if (!fv->transfer_qf) { |
| 1646 | av_log(avctx, AV_LOG_ERROR, "Device has no transfer queues!\n"); | 1646 | av_log(avctx, AV_LOG_ERROR, "Device has no transfer queues!\n"); |
| 1647 | return err; | 1647 | return err; |
| 1648 | } | 1648 | } |
| 1649 | 1649 | ||
| 1650 | err = ff_vk_exec_pool_init(&fv->s, &fv->transfer_qf, &fv->transfer_exec_pool, | 1650 | err = ff_vk_exec_pool_init(&fv->s, fv->transfer_qf, &fv->transfer_exec_pool, |
| 1651 | 1, | 1651 | 1, |
| 1652 | 0, 0, 0, NULL); | 1652 | 0, 0, 0, NULL); |
| 1653 | if (err < 0) | 1653 | if (err < 0) |
| @@ -1116,21 +1116,19 @@ int ff_vk_decode_init(AVCodecContext *avctx) · 1115 unmodified lines | |||
| 1116 | 1116 | ||
| 1117 | /* Create queue context */ | 1117 | /* Create queue context */ |
| 1118 | vk_desc = get_codecdesc(avctx->codec_id); | 1118 | vk_desc = get_codecdesc(avctx->codec_id); |
| 1119 | err = ff_vk_video_qf_init(s, &ctx->qf, | 1119 | ctx->qf = ff_vk_qf_find(s, VK_QUEUE_VIDEO_DECODE_BIT_KHR, vk_desc->decode_op); |
| 1120 | VK_QUEUE_VIDEO_DECODE_BIT_KHR, | 1120 | if (!ctx->qf) { |
| 1121 | vk_desc->decode_op); | ||
| 1122 | if (err < 0) { | ||
| 1123 | av_log(avctx, AV_LOG_ERROR, "Decoding of %s is not supported by this device\n", | 1121 | av_log(avctx, AV_LOG_ERROR, "Decoding of %s is not supported by this device\n", |
| 1124 | avcodec_get_name(avctx->codec_id)); | 1122 | avcodec_get_name(avctx->codec_id)); |
| 1125 | return err; | 1123 | return err; |
| 1126 | } | 1124 | } |
| 1127 | 1125 | ||
| 1128 | /* Enable queries if supported */ | 1126 | /* Enable queries if supported and usable */ |
| 1129 | if (s->query_props[ctx->qf.queue_family].queryResultStatusSupport) | 1127 | if (s->query_props[ctx->qf->idx].queryResultStatusSupport) |
| 1130 | nb_q = 1; | 1128 | nb_q = 1; |
| 1131 | 1129 | ||
| 1132 | session_create.flags = 0x0; | 1130 | session_create.flags = 0x0; |
| 1133 | session_create.queueFamilyIndex = ctx->qf.queue_family; | 1131 | session_create.queueFamilyIndex = ctx->qf->idx; |
| 1134 | session_create.maxCodedExtent = ctx->caps.maxCodedExtent; | 1132 | session_create.maxCodedExtent = ctx->caps.maxCodedExtent; |
| 1135 | session_create.maxDpbSlots = ctx->caps.maxDpbSlots; | 1133 | session_create.maxDpbSlots = ctx->caps.maxDpbSlots; |
| 1136 | session_create.maxActiveReferencePictures = ctx->caps.maxActiveReferencePictures; | 1134 | session_create.maxActiveReferencePictures = ctx->caps.maxActiveReferencePictures; |
| @@ -1142,8 +1140,8 @@ int ff_vk_decode_init(AVCodecContext *avctx) · 5 unmodified lines | |||
| 1142 | /* Create decode exec context for this specific main thread. | 1140 | /* Create decode exec context for this specific main thread. |
| 1143 | * 2 async contexts per thread was experimentally determined to be optimal | 1141 | * 2 async contexts per thread was experimentally determined to be optimal |
| 1144 | * for a majority of streams. */ | 1142 | * for a majority of streams. */ |
| 1145 | err = ff_vk_exec_pool_init(s, &ctx->qf, &ctx->exec_pool, | 1143 | err = ff_vk_exec_pool_init(s, ctx->qf, &ctx->exec_pool, |
| 1146 | FFMAX(2*ctx->qf.nb_queues, avctx->thread_count), | 1144 | FFMAX(2*ctx->qf->num, avctx->thread_count), |
| 1147 | nb_q, VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR, 0, | 1145 | nb_q, VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR, 0, |
| 1148 | profile); | 1146 | profile); |
| 1149 | if (err < 0) | 1147 | if (err < 0) |
| @@ -46,7 +46,7 @@ typedef struct FFVulkanDecodeProfileData { · 45 unmodified lines | |||
| 46 | typedef struct FFVulkanDecodeShared { | 46 | typedef struct FFVulkanDecodeShared { |
| 47 | FFVulkanContext s; | 47 | FFVulkanContext s; |
| 48 | FFVkVideoCommon common; | 48 | FFVkVideoCommon common; |
| 49 | FFVkQueueFamilyCtx qf; | 49 | AVVulkanDeviceQueueFamily *qf; |
| 50 | FFVkExecPool exec_pool; | 50 | FFVkExecPool exec_pool; |
| 51 | 51 | ||
| 52 | AVBufferPool *buf_pool; | 52 | AVBufferPool *buf_pool; |
| @@ -769,10 +769,8 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext * · 768 unmodified lines | |||
| 769 | return err; | 769 | return err; |
| 770 | 770 | ||
| 771 | /* Create queue context */ | 771 | /* Create queue context */ |
| 772 | err = ff_vk_video_qf_init(s, &ctx->qf_enc, | 772 | ctx->qf_enc = ff_vk_qf_find(s, VK_QUEUE_VIDEO_ENCODE_BIT_KHR, vk_desc->encode_op); |
| 773 | VK_QUEUE_VIDEO_ENCODE_BIT_KHR, | 773 | if (!ctx->qf_enc) { |
| 774 | vk_desc->encode_op); | ||
| 775 | if (err < 0) { | ||
| 776 | av_log(avctx, AV_LOG_ERROR, "Encoding of %s is not supported by this device\n", | 774 | av_log(avctx, AV_LOG_ERROR, "Encoding of %s is not supported by this device\n", |
| 777 | avcodec_get_name(avctx->codec_id)); | 775 | avcodec_get_name(avctx->codec_id)); |
| 778 | return err; | 776 | return err; |
| @@ -846,7 +844,7 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext * · 67 unmodified lines | |||
| 846 | .encodeFeedbackFlags = ctx->enc_caps.supportedEncodeFeedbackFlags & | 844 | .encodeFeedbackFlags = ctx->enc_caps.supportedEncodeFeedbackFlags & |
| 847 | (~VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_HAS_OVERRIDES_BIT_KHR), | 845 | (~VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_HAS_OVERRIDES_BIT_KHR), |
| 848 | }; | 846 | }; |
| 849 | err = ff_vk_exec_pool_init(s, &ctx->qf_enc, &ctx->enc_pool, base_ctx->async_depth, | 847 | err = ff_vk_exec_pool_init(s, ctx->qf_enc, &ctx->enc_pool, base_ctx->async_depth, |
| 850 | 1, VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR, 0, | 848 | 1, VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR, 0, |
| 851 | &query_create); | 849 | &query_create); |
| 852 | if (err < 0) | 850 | if (err < 0) |
| @@ -994,7 +992,7 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext * · 141 unmodified lines | |||
| 994 | /* Create session */ | 992 | /* Create session */ |
| 995 | session_create.pVideoProfile = &ctx->profile; | 993 | session_create.pVideoProfile = &ctx->profile; |
| 996 | session_create.flags = 0x0; | 994 | session_create.flags = 0x0; |
| 997 | session_create.queueFamilyIndex = ctx->qf_enc.queue_family; | 995 | session_create.queueFamilyIndex = ctx->qf_enc->idx; |
| 998 | session_create.maxCodedExtent = ctx->caps.maxCodedExtent; | 996 | session_create.maxCodedExtent = ctx->caps.maxCodedExtent; |
| 999 | session_create.maxDpbSlots = ctx->caps.maxDpbSlots; | 997 | session_create.maxDpbSlots = ctx->caps.maxDpbSlots; |
| 1000 | session_create.maxActiveReferencePictures = ctx->caps.maxActiveReferencePictures; | 998 | session_create.maxActiveReferencePictures = ctx->caps.maxActiveReferencePictures; |
| @@ -188,7 +188,7 @@ typedef struct FFVulkanEncodeContext { · 187 unmodified lines | |||
| 188 | VkVideoEncodeCapabilitiesKHR enc_caps; | 188 | VkVideoEncodeCapabilitiesKHR enc_caps; |
| 189 | VkVideoEncodeUsageInfoKHR usage_info; | 189 | VkVideoEncodeUsageInfoKHR usage_info; |
| 190 | 190 | ||
| 191 | FFVkQueueFamilyCtx qf_enc; | 191 | AVVulkanDeviceQueueFamily *qf_enc; |
| 192 | FFVkExecPool enc_pool; | 192 | FFVkExecPool enc_pool; |
| 193 | 193 | ||
| 194 | FFHWBaseEncodePicture *slots[32]; | 194 | FFHWBaseEncodePicture *slots[32]; |
| @@ -268,20 +268,6 @@ int ff_vk_h265_profile_to_av(StdVideoH264ProfileIdc profile) · 267 unmodified lines | |||
| 268 | } | 268 | } |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, | ||
| 272 | VkQueueFlagBits family, VkVideoCodecOperationFlagBitsKHR caps) | ||
| 273 | { | ||
| 274 | for (int i = 0; i < s->hwctx->nb_qf; i++) { | ||
| 275 | if ((s->hwctx->qf[i].flags & family) && | ||
| 276 | (s->hwctx->qf[i].video_caps & caps)) { | ||
| 277 | qf->queue_family = s->hwctx->qf[i].idx; | ||
| 278 | qf->nb_queues = s->hwctx->qf[i].num; | ||
| 279 | return 0; | ||
| 280 | } | ||
| 281 | } | ||
| 282 | return AVERROR(ENOTSUP); | ||
| 283 | } | ||
| 284 | |||
| 285 | int ff_vk_create_view(FFVulkanContext *s, FFVkVideoCommon *common, | 271 | int ff_vk_create_view(FFVulkanContext *s, FFVkVideoCommon *common, |
| 286 | VkImageView *view, VkImageAspectFlags *aspect, | 272 | VkImageView *view, VkImageAspectFlags *aspect, |
| 287 | AVVkFrame *src, VkFormat vkf, int is_dpb) | 273 | AVVkFrame *src, VkFormat vkf, int is_dpb) |
| @@ -63,12 +63,6 @@ VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFm · 62 unmodified lines | |||
| 63 | */ | 63 | */ |
| 64 | VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth); | 64 | VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth); |
| 65 | 65 | ||
| 66 | /** | ||
| 67 | * Chooses a QF and loads it into a context. | ||
| 68 | */ | ||
| 69 | int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, | ||
| 70 | VkQueueFlagBits family, VkVideoCodecOperationFlagBitsKHR caps); | ||
| 71 | |||
| 72 | /** | 66 | /** |
| 73 | * Convert level from Vulkan to AV. | 67 | * Convert level from Vulkan to AV. |
| 74 | */ | 68 | */ |
| @@ -31,7 +31,7 @@ typedef struct AvgBlurVulkanContext { · 30 unmodified lines | |||
| 31 | 31 | ||
| 32 | int initialized; | 32 | int initialized; |
| 33 | FFVkExecPool e; | 33 | FFVkExecPool e; |
| 34 | FFVkQueueFamilyCtx qf; | 34 | AVVulkanDeviceQueueFamily *qf; |
| 35 | VkSampler sampler; | 35 | VkSampler sampler; |
| 36 | FFVulkanShader shd; | 36 | FFVulkanShader shd; |
| 37 | 37 | ||
| @@ -77,8 +77,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 39 unmodified lines | |||
| 77 | return AVERROR_EXTERNAL; | 77 | return AVERROR_EXTERNAL; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 80 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 81 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 81 | if (!s->qf) { |
| 82 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 83 | err = AVERROR(ENOTSUP); | ||
| 84 | goto fail; | ||
| 85 | } | ||
| 86 | |||
| 87 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 82 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); | 88 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); |
| 83 | RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur", | 89 | RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur", |
| 84 | VK_SHADER_STAGE_COMPUTE_BIT, | 90 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -47,7 +47,7 @@ typedef struct BlendVulkanContext { · 46 unmodified lines | |||
| 47 | 47 | ||
| 48 | int initialized; | 48 | int initialized; |
| 49 | FFVkExecPool e; | 49 | FFVkExecPool e; |
| 50 | FFVkQueueFamilyCtx qf; | 50 | AVVulkanDeviceQueueFamily *qf; |
| 51 | FFVulkanShader shd; | 51 | FFVulkanShader shd; |
| 52 | VkSampler sampler; | 52 | VkSampler sampler; |
| 53 | 53 | ||
| @@ -141,8 +141,14 @@ static av_cold int init_filter(AVFilterContext *avctx) · 87 unmodified lines | |||
| 141 | return AVERROR_EXTERNAL; | 141 | return AVERROR_EXTERNAL; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 144 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 145 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 145 | if (!s->qf) { |
| 146 | av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 147 | err = AVERROR(ENOTSUP); | ||
| 148 | goto fail; | ||
| 149 | } | ||
| 150 | |||
| 151 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 146 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); | 152 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); |
| 147 | RET(ff_vk_shader_init(vkctx, &s->shd, "blend", | 153 | RET(ff_vk_shader_init(vkctx, &s->shd, "blend", |
| 148 | VK_SHADER_STAGE_COMPUTE_BIT, | 154 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -33,7 +33,7 @@ typedef struct BWDIFVulkanContext { · 32 unmodified lines | |||
| 33 | 33 | ||
| 34 | int initialized; | 34 | int initialized; |
| 35 | FFVkExecPool e; | 35 | FFVkExecPool e; |
| 36 | FFVkQueueFamilyCtx qf; | 36 | AVVulkanDeviceQueueFamily *qf; |
| 37 | VkSampler sampler; | 37 | VkSampler sampler; |
| 38 | FFVulkanShader shd; | 38 | FFVulkanShader shd; |
| 39 | } BWDIFVulkanContext; | 39 | } BWDIFVulkanContext; |
| @@ -65,8 +65,14 @@ static av_cold int init_filter(AVFilterContext *ctx) · 25 unmodified lines | |||
| 65 | return AVERROR_EXTERNAL; | 65 | return AVERROR_EXTERNAL; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 68 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 69 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 69 | if (!s->qf) { |
| 70 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 71 | err = AVERROR(ENOTSUP); | ||
| 72 | goto fail; | ||
| 73 | } | ||
| 74 | |||
| 75 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 70 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); | 76 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); |
| 71 | 77 | ||
| 72 | RET(ff_vk_shader_init(vkctx, &s->shd, "bwdif", | 78 | RET(ff_vk_shader_init(vkctx, &s->shd, "bwdif", |
| @@ -31,7 +31,7 @@ typedef struct ChromaticAberrationVulkanContext { · 30 unmodified lines | |||
| 31 | 31 | ||
| 32 | int initialized; | 32 | int initialized; |
| 33 | FFVkExecPool e; | 33 | FFVkExecPool e; |
| 34 | FFVkQueueFamilyCtx qf; | 34 | AVVulkanDeviceQueueFamily *qf; |
| 35 | FFVulkanShader shd; | 35 | FFVulkanShader shd; |
| 36 | VkSampler sampler; | 36 | VkSampler sampler; |
| 37 | 37 | ||
| @@ -88,8 +88,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 50 unmodified lines | |||
| 88 | return AVERROR_EXTERNAL; | 88 | return AVERROR_EXTERNAL; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 91 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 92 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 92 | if (!s->qf) { |
| 93 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 94 | err = AVERROR(ENOTSUP); | ||
| 95 | goto fail; | ||
| 96 | } | ||
| 97 | |||
| 98 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 93 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 0, VK_FILTER_LINEAR)); | 99 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 0, VK_FILTER_LINEAR)); |
| 94 | RET(ff_vk_shader_init(vkctx, &s->shd, "chromatic_abberation", | 100 | RET(ff_vk_shader_init(vkctx, &s->shd, "chromatic_abberation", |
| 95 | VK_SHADER_STAGE_COMPUTE_BIT, | 101 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -38,7 +38,7 @@ typedef struct FlipVulkanContext { · 37 unmodified lines | |||
| 38 | 38 | ||
| 39 | int initialized; | 39 | int initialized; |
| 40 | FFVkExecPool e; | 40 | FFVkExecPool e; |
| 41 | FFVkQueueFamilyCtx qf; | 41 | AVVulkanDeviceQueueFamily *qf; |
| 42 | FFVulkanShader shd; | 42 | FFVulkanShader shd; |
| 43 | VkSampler sampler; | 43 | VkSampler sampler; |
| 44 | } FlipVulkanContext; | 44 | } FlipVulkanContext; |
| @@ -62,8 +62,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType · 17 unmodified lines | |||
| 62 | return AVERROR_EXTERNAL; | 62 | return AVERROR_EXTERNAL; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 65 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 66 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 66 | if (!s->qf) { |
| 67 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 68 | err = AVERROR(ENOTSUP); | ||
| 69 | goto fail; | ||
| 70 | } | ||
| 71 | |||
| 72 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 67 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); | 73 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); |
| 68 | RET(ff_vk_shader_init(vkctx, &s->shd, "flip", | 74 | RET(ff_vk_shader_init(vkctx, &s->shd, "flip", |
| 69 | VK_SHADER_STAGE_COMPUTE_BIT, | 75 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -36,7 +36,7 @@ typedef struct GBlurVulkanContext { · 35 unmodified lines | |||
| 36 | 36 | ||
| 37 | int initialized; | 37 | int initialized; |
| 38 | FFVkExecPool e; | 38 | FFVkExecPool e; |
| 39 | FFVkQueueFamilyCtx qf; | 39 | AVVulkanDeviceQueueFamily *qf; |
| 40 | VkSampler sampler; | 40 | VkSampler sampler; |
| 41 | FFVulkanShader shd_hor; | 41 | FFVulkanShader shd_hor; |
| 42 | FFVkBuffer params_hor; | 42 | FFVkBuffer params_hor; |
| @@ -212,8 +212,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 169 unmodified lines | |||
| 212 | return AVERROR_EXTERNAL; | 212 | return AVERROR_EXTERNAL; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 215 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 216 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 216 | if (!s->qf) { |
| 217 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 218 | err = AVERROR(ENOTSUP); | ||
| 219 | goto fail; | ||
| 220 | } | ||
| 221 | |||
| 222 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 217 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); | 223 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); |
| 218 | 224 | ||
| 219 | desc = (FFVulkanDescriptorSetBinding []) { | 225 | desc = (FFVulkanDescriptorSetBinding []) { |
| @@ -36,7 +36,7 @@ typedef struct NLMeansVulkanContext { · 35 unmodified lines | |||
| 36 | 36 | ||
| 37 | int initialized; | 37 | int initialized; |
| 38 | FFVkExecPool e; | 38 | FFVkExecPool e; |
| 39 | FFVkQueueFamilyCtx qf; | 39 | AVVulkanDeviceQueueFamily *qf; |
| 40 | VkSampler sampler; | 40 | VkSampler sampler; |
| 41 | 41 | ||
| 42 | AVBufferPool *integral_buf_pool; | 42 | AVBufferPool *integral_buf_pool; |
| @@ -652,8 +652,14 @@ static av_cold int init_filter(AVFilterContext *ctx) · 609 unmodified lines | |||
| 652 | return AVERROR_EXTERNAL; | 652 | return AVERROR_EXTERNAL; |
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 655 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 656 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, 1, 0, 0, 0, NULL)); | 656 | if (!s->qf) { |
| 657 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 658 | err = AVERROR(ENOTSUP); | ||
| 659 | goto fail; | ||
| 660 | } | ||
| 661 | |||
| 662 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, 1, 0, 0, 0, NULL)); | ||
| 657 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); | 663 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); |
| 658 | 664 | ||
| 659 | RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights, s->sampler, | 665 | RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights, s->sampler, |
| @@ -33,7 +33,7 @@ typedef struct OverlayVulkanContext { · 32 unmodified lines | |||
| 33 | 33 | ||
| 34 | int initialized; | 34 | int initialized; |
| 35 | FFVkExecPool e; | 35 | FFVkExecPool e; |
| 36 | FFVkQueueFamilyCtx qf; | 36 | AVVulkanDeviceQueueFamily *qf; |
| 37 | FFVulkanShader shd; | 37 | FFVulkanShader shd; |
| 38 | VkSampler sampler; | 38 | VkSampler sampler; |
| 39 | 39 | ||
| @@ -101,8 +101,14 @@ static av_cold int init_filter(AVFilterContext *ctx) · 61 unmodified lines | |||
| 101 | return AVERROR_EXTERNAL; | 101 | return AVERROR_EXTERNAL; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 104 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 105 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 105 | if (!s->qf) { |
| 106 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 107 | err = AVERROR(ENOTSUP); | ||
| 108 | goto fail; | ||
| 109 | } | ||
| 110 | |||
| 111 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 106 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); | 112 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); |
| 107 | RET(ff_vk_shader_init(vkctx, &s->shd, "overlay", | 113 | RET(ff_vk_shader_init(vkctx, &s->shd, "overlay", |
| 108 | VK_SHADER_STAGE_COMPUTE_BIT, | 114 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -39,7 +39,7 @@ typedef struct ScaleVulkanContext { · 38 unmodified lines | |||
| 39 | 39 | ||
| 40 | int initialized; | 40 | int initialized; |
| 41 | FFVkExecPool e; | 41 | FFVkExecPool e; |
| 42 | FFVkQueueFamilyCtx qf; | 42 | AVVulkanDeviceQueueFamily *qf; |
| 43 | FFVulkanShader shd; | 43 | FFVulkanShader shd; |
| 44 | VkSampler sampler; | 44 | VkSampler sampler; |
| 45 | 45 | ||
| @@ -142,8 +142,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 96 unmodified lines | |||
| 142 | return AVERROR_EXTERNAL; | 142 | return AVERROR_EXTERNAL; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 145 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 146 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 146 | if (!s->qf) { |
| 147 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 148 | err = AVERROR(ENOTSUP); | ||
| 149 | goto fail; | ||
| 150 | } | ||
| 151 | |||
| 152 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 147 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 0, sampler_mode)); | 153 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 0, sampler_mode)); |
| 148 | RET(ff_vk_shader_init(vkctx, &s->shd, "scale", | 154 | RET(ff_vk_shader_init(vkctx, &s->shd, "scale", |
| 149 | VK_SHADER_STAGE_COMPUTE_BIT, | 155 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -33,7 +33,7 @@ typedef struct TransposeVulkanContext { · 32 unmodified lines | |||
| 33 | 33 | ||
| 34 | int initialized; | 34 | int initialized; |
| 35 | FFVkExecPool e; | 35 | FFVkExecPool e; |
| 36 | FFVkQueueFamilyCtx qf; | 36 | AVVulkanDeviceQueueFamily *qf; |
| 37 | FFVulkanShader shd; | 37 | FFVulkanShader shd; |
| 38 | VkSampler sampler; | 38 | VkSampler sampler; |
| 39 | 39 | ||
| @@ -61,8 +61,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 21 unmodified lines | |||
| 61 | return AVERROR_EXTERNAL; | 61 | return AVERROR_EXTERNAL; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 64 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 65 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 65 | if (!s->qf) { |
| 66 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 67 | err = AVERROR(ENOTSUP); | ||
| 68 | goto fail; | ||
| 69 | } | ||
| 70 | |||
| 71 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 66 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); | 72 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR)); |
| 67 | RET(ff_vk_shader_init(vkctx, &s->shd, "transpose", | 73 | RET(ff_vk_shader_init(vkctx, &s->shd, "transpose", |
| 68 | VK_SHADER_STAGE_COMPUTE_BIT, | 74 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -41,7 +41,7 @@ typedef struct XFadeVulkanContext { · 40 unmodified lines | |||
| 41 | 41 | ||
| 42 | int initialized; | 42 | int initialized; |
| 43 | FFVkExecPool e; | 43 | FFVkExecPool e; |
| 44 | FFVkQueueFamilyCtx qf; | 44 | AVVulkanDeviceQueueFamily *qf; |
| 45 | FFVulkanShader shd; | 45 | FFVulkanShader shd; |
| 46 | VkSampler sampler; | 46 | VkSampler sampler; |
| 47 | 47 | ||
| @@ -335,8 +335,14 @@ static av_cold int init_vulkan(AVFilterContext *avctx) · 287 unmodified lines | |||
| 335 | return AVERROR_EXTERNAL; | 335 | return AVERROR_EXTERNAL; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 338 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 339 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 339 | if (!s->qf) { |
| 340 | av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 341 | err = AVERROR(ENOTSUP); | ||
| 342 | goto fail; | ||
| 343 | } | ||
| 344 | |||
| 345 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 340 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); | 346 | RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); |
| 341 | RET(ff_vk_shader_init(vkctx, &s->shd, "xfade", | 347 | RET(ff_vk_shader_init(vkctx, &s->shd, "xfade", |
| 342 | VK_SHADER_STAGE_COMPUTE_BIT, | 348 | VK_SHADER_STAGE_COMPUTE_BIT, |
| @@ -40,7 +40,7 @@ typedef struct TestSrcVulkanContext { · 39 unmodified lines | |||
| 40 | 40 | ||
| 41 | int initialized; | 41 | int initialized; |
| 42 | FFVkExecPool e; | 42 | FFVkExecPool e; |
| 43 | FFVkQueueFamilyCtx qf; | 43 | AVVulkanDeviceQueueFamily *qf; |
| 44 | FFVulkanShader shd; | 44 | FFVulkanShader shd; |
| 45 | 45 | ||
| 46 | /* Only used by color_vulkan */ | 46 | /* Only used by color_vulkan */ |
| @@ -82,8 +82,14 @@ static av_cold int init_filter(AVFilterContext *ctx, enum TestSrcVulkanMode mode · 35 unmodified lines | |||
| 82 | return AVERROR_EXTERNAL; | 82 | return AVERROR_EXTERNAL; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT); | 85 | s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 86 | RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL)); | 86 | if (!s->qf) { |
| 87 | av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n"); | ||
| 88 | err = AVERROR(ENOTSUP); | ||
| 89 | goto fail; | ||
| 90 | } | ||
| 91 | |||
| 92 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | ||
| 87 | RET(ff_vk_shader_init(vkctx, &s->shd, "scale", | 93 | RET(ff_vk_shader_init(vkctx, &s->shd, "scale", |
| 88 | VK_SHADER_STAGE_COMPUTE_BIT, | 94 | VK_SHADER_STAGE_COMPUTE_BIT, |
| 89 | NULL, 0, | 95 | NULL, 0, |
| @@ -104,8 +104,8 @@ typedef struct VulkanDevicePriv { · 103 unmodified lines | |||
| 104 | void *libvulkan; | 104 | void *libvulkan; |
| 105 | 105 | ||
| 106 | FFVulkanContext vkctx; | 106 | FFVulkanContext vkctx; |
| 107 | FFVkQueueFamilyCtx compute_qf; | 107 | AVVulkanDeviceQueueFamily *compute_qf; |
| 108 | FFVkQueueFamilyCtx transfer_qf; | 108 | AVVulkanDeviceQueueFamily *transfer_qf; |
| 109 | 109 | ||
| 110 | /* Properties */ | 110 | /* Properties */ |
| 111 | VkPhysicalDeviceProperties2 props; | 111 | VkPhysicalDeviceProperties2 props; |
| @@ -1904,8 +1904,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1792 unmodified lines | |||
| 1904 | p->vkctx.hwctx = hwctx; | 1904 | p->vkctx.hwctx = hwctx; |
| 1905 | 1905 | ||
| 1906 | ff_vk_load_props(&p->vkctx); | 1906 | ff_vk_load_props(&p->vkctx); |
| 1907 | ff_vk_qf_init(&p->vkctx, &p->compute_qf, VK_QUEUE_COMPUTE_BIT); | 1907 | p->compute_qf = ff_vk_qf_find(&p->vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 1908 | ff_vk_qf_init(&p->vkctx, &p->transfer_qf, VK_QUEUE_TRANSFER_BIT); | 1908 | p->transfer_qf = ff_vk_qf_find(&p->vkctx, VK_QUEUE_TRANSFER_BIT, 0); |
| 1909 | 1909 | ||
| 1910 | end: | 1910 | end: |
| 1911 | av_free(qf_vid); | 1911 | av_free(qf_vid); |
| @@ -2789,18 +2789,18 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) · 877 unmodified lines | |||
| 2789 | if (!hwctx->unlock_frame) | 2789 | if (!hwctx->unlock_frame) |
| 2790 | hwctx->unlock_frame = unlock_frame; | 2790 | hwctx->unlock_frame = unlock_frame; |
| 2791 | 2791 | ||
| 2792 | err = ff_vk_exec_pool_init(&p->vkctx, &p->compute_qf, &fp->compute_exec, | 2792 | err = ff_vk_exec_pool_init(&p->vkctx, p->compute_qf, &fp->compute_exec, |
| 2793 | p->compute_qf.nb_queues, 0, 0, 0, NULL); | 2793 | p->compute_qf->num, 0, 0, 0, NULL); |
| 2794 | if (err) | 2794 | if (err) |
| 2795 | return err; | 2795 | return err; |
| 2796 | 2796 | ||
| 2797 | err = ff_vk_exec_pool_init(&p->vkctx, &p->transfer_qf, &fp->upload_exec, | 2797 | err = ff_vk_exec_pool_init(&p->vkctx, p->transfer_qf, &fp->upload_exec, |
| 2798 | p->transfer_qf.nb_queues*2, 0, 0, 0, NULL); | 2798 | p->transfer_qf->num*2, 0, 0, 0, NULL); |
| 2799 | if (err) | 2799 | if (err) |
| 2800 | return err; | 2800 | return err; |
| 2801 | 2801 | ||
| 2802 | err = ff_vk_exec_pool_init(&p->vkctx, &p->transfer_qf, &fp->download_exec, | 2802 | err = ff_vk_exec_pool_init(&p->vkctx, p->transfer_qf, &fp->download_exec, |
| 2803 | p->transfer_qf.nb_queues, 0, 0, 0, NULL); | 2803 | p->transfer_qf->num, 0, 0, 0, NULL); |
| 2804 | if (err) | 2804 | if (err) |
| 2805 | return err; | 2805 | return err; |
| 2806 | 2806 | ||
| @@ -217,26 +217,17 @@ int ff_vk_load_props(FFVulkanContext *s) · 216 unmodified lines | |||
| 217 | return 0; | 217 | return 0; |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | static int vk_qf_get_index(FFVulkanContext *s, VkQueueFlagBits dev_family, int *nb) | 220 | AVVulkanDeviceQueueFamily *ff_vk_qf_find(FFVulkanContext *s, |
| 221 | VkQueueFlagBits dev_family, | ||
| 222 | VkVideoCodecOperationFlagBitsKHR vid_ops) | ||
| 221 | { | 223 | { |
| 222 | for (int i = 0; i < s->hwctx->nb_qf; i++) { | 224 | for (int i = 0; i < s->hwctx->nb_qf; i++) { |
| 223 | if (s->hwctx->qf[i].flags & dev_family) { | 225 | if ((s->hwctx->qf[i].flags & dev_family) && |
| 224 | *nb = s->hwctx->qf[i].num; | 226 | (s->hwctx->qf[i].video_caps & vid_ops) == vid_ops) { |
| 225 | return s->hwctx->qf[i].idx; | 227 | return &s->hwctx->qf[i]; |
| 226 | } | 228 | } |
| 227 | } | 229 | } |
| 228 | 230 | return NULL; | |
| 229 | av_assert0(0); /* Should never happen */ | ||
| 230 | } | ||
| 231 | |||
| 232 | int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, | ||
| 233 | VkQueueFlagBits dev_family) | ||
| 234 | { | ||
| 235 | /* Fill in queue families from context if not done yet */ | ||
| 236 | if (!s->nb_qfs) | ||
| 237 | load_enabled_qfs(s); | ||
| 238 | |||
| 239 | return (qf->queue_family = vk_qf_get_index(s, dev_family, &qf->nb_queues)); | ||
| 240 | } | 231 | } |
| 241 | 232 | ||
| 242 | void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool) | 233 | void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool) |
| @@ -302,7 +293,7 @@ void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool) · 59 unmodified lines | |||
| 302 | av_free(pool->contexts); | 293 | av_free(pool->contexts); |
| 303 | } | 294 | } |
| 304 | 295 | ||
| 305 | int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, | 296 | int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, |
| 306 | FFVkExecPool *pool, int nb_contexts, | 297 | FFVkExecPool *pool, int nb_contexts, |
| 307 | int nb_queries, VkQueryType query_type, int query_64bit, | 298 | int nb_queries, VkQueryType query_type, int query_64bit, |
| 308 | const void *query_create_pnext) | 299 | const void *query_create_pnext) |
| @@ -330,7 +321,7 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, · 21 unmodified lines | |||
| 330 | .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, | 321 | .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, |
| 331 | .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | | 322 | .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | |
| 332 | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, | 323 | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, |
| 333 | .queueFamilyIndex = qf->queue_family, | 324 | .queueFamilyIndex = qf->idx, |
| 334 | }; | 325 | }; |
| 335 | ret = vk->CreateCommandPool(s->hwctx->act_dev, &cqueue_create, | 326 | ret = vk->CreateCommandPool(s->hwctx->act_dev, &cqueue_create, |
| 336 | s->hwctx->alloc, &pool->cmd_buf_pool); | 327 | s->hwctx->alloc, &pool->cmd_buf_pool); |
| @@ -443,10 +434,9 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, · 106 unmodified lines | |||
| 443 | e->buf = pool->cmd_bufs[i]; | 434 | e->buf = pool->cmd_bufs[i]; |
| 444 | 435 | ||
| 445 | /* Queue index distribution */ | 436 | /* Queue index distribution */ |
| 446 | e->qi = i % qf->nb_queues; | 437 | e->qi = i % qf->num; |
| 447 | e->qf = qf->queue_family; | 438 | e->qf = qf->idx; |
| 448 | vk->GetDeviceQueue(s->hwctx->act_dev, qf->queue_family, | 439 | vk->GetDeviceQueue(s->hwctx->act_dev, qf->idx, e->qi, &e->queue); |
| 449 | e->qi, &e->queue); | ||
| 450 | } | 440 | } |
| 451 | 441 | ||
| 452 | return 0; | 442 | return 0; |
| @@ -99,11 +99,6 @@ typedef struct FFVkBuffer { · 98 unmodified lines | |||
| 99 | uint8_t *mapped_mem; | 99 | uint8_t *mapped_mem; |
| 100 | } FFVkBuffer; | 100 | } FFVkBuffer; |
| 101 | 101 | ||
| 102 | typedef struct FFVkQueueFamilyCtx { | ||
| 103 | int queue_family; | ||
| 104 | int nb_queues; | ||
| 105 | } FFVkQueueFamilyCtx; | ||
| 106 | |||
| 107 | typedef struct FFVkExecContext { | 102 | typedef struct FFVkExecContext { |
| 108 | uint32_t idx; | 103 | uint32_t idx; |
| 109 | const struct FFVkExecPool *parent; | 104 | const struct FFVkExecPool *parent; |
| @@ -393,10 +388,11 @@ const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt, · 283 unmodified lines | |||
| 393 | int ff_vk_load_props(FFVulkanContext *s); | 388 | int ff_vk_load_props(FFVulkanContext *s); |
| 394 | 389 | ||
| 395 | /** | 390 | /** |
| 396 | * Chooses a QF and loads it into a context. | 391 | * Chooses an appropriate QF. |
| 397 | */ | 392 | */ |
| 398 | int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, | 393 | AVVulkanDeviceQueueFamily *ff_vk_qf_find(FFVulkanContext *s, |
| 399 | VkQueueFlagBits dev_family); | 394 | VkQueueFlagBits dev_family, |
| 395 | VkVideoCodecOperationFlagBitsKHR vid_ops); | ||
| 400 | 396 | ||
| 401 | /** | 397 | /** |
| 402 | * Allocates/frees an execution pool. | 398 | * Allocates/frees an execution pool. |
| @@ -405,7 +401,7 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, · 2 unmodified lines | |||
| 405 | * ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add() | 401 | * ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add() |
| 406 | * has been called. | 402 | * has been called. |
| 407 | */ | 403 | */ |
| 408 | int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, | 404 | int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, |
| 409 | FFVkExecPool *pool, int nb_contexts, | 405 | FFVkExecPool *pool, int nb_contexts, |
| 410 | int nb_queries, VkQueryType query_type, int query_64bit, | 406 | int nb_queries, VkQueryType query_type, int query_64bit, |
| 411 | const void *query_create_pnext); | 407 | const void *query_create_pnext); |