From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7D73A4CB42 for ; Wed, 14 Aug 2024 14:34:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C012168DB6F; Wed, 14 Aug 2024 17:34:09 +0300 (EEST) Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9760668DB64 for ; Wed, 14 Aug 2024 17:34:03 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Aug 2024 16:33:45 +0200 Message-ID: <20240814143351.841585-4-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b In-Reply-To: <20240814143351.841585-1-dev@lynne.ee> References: <20240814143351.841585-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] hwcontext_vulkan: setup extensions before features X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lynne via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Lynne Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The issue is that enabling features requires that the device extension is supported. The extensions bitfield was set later, so it was always 0, leading to no features being added. --- libavutil/hwcontext_vulkan.c | 73 +++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 2c958b86bb..18148353c2 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -1440,35 +1440,6 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, }; - hwctx->device_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; - hwctx->device_features.pNext = &p->device_features_1_1; - p->device_features_1_1.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; - p->device_features_1_1.pNext = &p->device_features_1_2; - p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; - p->device_features_1_2.pNext = &p->device_features_1_3; - p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; - p->device_features_1_3.pNext = NULL; - -#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE) \ - do { \ - if (p->vkctx.extensions & EXT_FLAG) { \ - (STRUCT_P)->sType = TYPE; \ - ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \ - } \ - } while (0) - - OPT_CHAIN(FF_VK_EXT_DESCRIPTOR_BUFFER, &p->desc_buf_features, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT); - OPT_CHAIN(FF_VK_EXT_ATOMIC_FLOAT, &p->atomic_float_features, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT); - OPT_CHAIN(FF_VK_EXT_COOP_MATRIX, &p->coop_matrix_features, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR); - OPT_CHAIN(FF_VK_EXT_SHADER_OBJECT, &p->shader_object_features, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT); - OPT_CHAIN(FF_VK_EXT_OPTICAL_FLOW, &p->optical_flow_features, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV); -#undef OPT_CHAIN - ctx->free = vulkan_device_free; /* Create an instance if not given one */ @@ -1537,12 +1508,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, p->shader_object_features.shaderObject = shader_object_features.shaderObject; - dev_info.pNext = &hwctx->device_features; - - /* Setup queue family */ - if ((err = setup_queue_families(ctx, &dev_info))) - goto end; - + /* Find and enable extensions */ if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames, &dev_info.enabledExtensionCount, 0))) { for (int i = 0; i < dev_info.queueCreateInfoCount; i++) @@ -1551,6 +1517,43 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, goto end; } + /* Setup enabled device features */ + hwctx->device_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + hwctx->device_features.pNext = &p->device_features_1_1; + p->device_features_1_1.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; + p->device_features_1_1.pNext = &p->device_features_1_2; + p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; + p->device_features_1_2.pNext = &p->device_features_1_3; + p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; + p->device_features_1_3.pNext = NULL; + +#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE) \ + do { \ + if (p->vkctx.extensions & EXT_FLAG) { \ + (STRUCT_P)->sType = TYPE; \ + ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \ + } \ + } while (0) + + OPT_CHAIN(FF_VK_EXT_DESCRIPTOR_BUFFER, &p->desc_buf_features, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT); + OPT_CHAIN(FF_VK_EXT_ATOMIC_FLOAT, &p->atomic_float_features, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT); + OPT_CHAIN(FF_VK_EXT_COOP_MATRIX, &p->coop_matrix_features, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR); + OPT_CHAIN(FF_VK_EXT_SHADER_OBJECT, &p->shader_object_features, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT); + OPT_CHAIN(FF_VK_EXT_OPTICAL_FLOW, &p->optical_flow_features, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV); +#undef OPT_CHAIN + + /* Add the enabled features into the pnext chain of device creation */ + dev_info.pNext = &hwctx->device_features; + + /* Setup enabled queue families */ + if ((err = setup_queue_families(ctx, &dev_info))) + goto end; + ret = vk->CreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc, &hwctx->act_dev); -- 2.45.2.753.g447d99e1c3b _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".