From patchwork Mon Feb 12 00:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46196 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9002:b0:19e:cdac:8cce with SMTP id d2csp401955pzc; Sun, 11 Feb 2024 16:02:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXRzP0hdCpE5VX0bUJKmdBStN7VUAa9MQbO4LKDabEt4GFWpgTlxftEJTqwFHy25nl62we0ZJqiH9wm82sDuawH/zCjnxHvCcqgwA== X-Google-Smtp-Source: AGHT+IFPd8hdX6cHbNzjYQVBFC6r8uZfV9NVQwj0+UcQZOB4Oj8xSoTz+4LJKz/hKJHZhbvJCf+N X-Received: by 2002:aa7:df8e:0:b0:560:f94f:a39b with SMTP id b14-20020aa7df8e000000b00560f94fa39bmr3307291edy.16.1707696134389; Sun, 11 Feb 2024 16:02:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVRjrJeDR/b/In/kgvpUjOYnxKK0NBLN4bwWfUcr4MOKp/CeJmAVgxxDWaqppbES6PVDnjfjshGhiUTiUWOfBM91sOwBpgNg36tB0HcwITMFLRuZR/ajHMf7im34/77tCSXilbyxA8jisCi4QXAVlpy/L82vicFchBWkpkc8rvkeH/WN8e0NWuj727qvD/hn89yGpg2xwQiru55Pbs9RDzYMgYsbHcrgb1uzv3PZBtrjovh043TdKykMS2BypVbzvcraCRjOD/bC+cRLfJGSCK+2vaQKkLeBj/R4kNuMn84hRNTCXCDokmX2d4w5ZWkxIv4cQVVIXsE3sLIVNGVrKUSO9H7ra08bUC8T3yQ+WiwUO6x33/+CZN9xE4kFD+o2c3bo1hPOF569ubxL3QsZLVY4a6r+iYIqc8fM4C8t/z7LLgqlILpBW1TbQlRQkbaTll5ESboEgLtr/8E+IqTOdUBvxkWlS/0PsQ/O8Qk2hadG6gnzxIqaYYWXqAgmOXL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wuY Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t24-20020a50d718000000b00561bb5918c5si285463edi.640.2024.02.11.16.02.13; Sun, 11 Feb 2024 16:02:14 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=sloyIMkn; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F08268D140; Mon, 12 Feb 2024 02:02:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04olkn2069.outbound.protection.outlook.com [40.92.73.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB80F68D13D for ; Mon, 12 Feb 2024 02:01:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BHHP7StdW7xeFjglhD4MUkAjYgCCO46wg4AXn6YRWqWxqpzZIh0411J6pOUa3gFKYS/MfP/hyfl2baC/q6qUjonF5KmOLLLHqPeW9qLub+/5iXBpvofm6jeuyjK7kCtyW9Hq0qggEDwIKXBQ7ted3TOcZnwJdXLp87vXNat2cIH1Gtl/beCJf60X2hXrBY5AtQuAd2k/VWqqUST0HMtKZotJetNjlplpSKFjH4Grkqm+Ztugd/Z44MyJvDPjFrCUXs8SvwbhKMiR8bv9Rqj84R6hd0BUrjh8UesWwLtjogUc3pepxQ31Osts18vK4MnVWLsnDOYpQOZtB5EEFSca0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=szF4T8bxqKHtvN+I/2W+NDkQS3b/yLdF0dTKlBvst2E=; b=h6CNRuMJNg4yvFbJaExnmm0uUQchoj6tq+dWmAqdD/T2otxivuwg7G2dSWobYPsDHSIK0tGJxt3EPDkjNvMiEZ/GOpcRXaLQLjn/HGScEkmRoTt3qdHEmRNtv7noFSInb3I1fQoJwUrUwX2j8oy9K418j1viDGny3TsHxraRN7Ql+7esPpXZemiXA8AeU/DLyU0v6sFt7nEp88iXf+xxOA+arYPhxIaGY22MIinKnwQ3uG/9VPGTwVXAZOfsKivtEYkYrUvFQshzktcbeFXA+JWTco7NUeYkm9tq27ViLK6Txnsm/bTKnygIbKYyN17DY3JSlW8c77W5bhfkDsVu2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=szF4T8bxqKHtvN+I/2W+NDkQS3b/yLdF0dTKlBvst2E=; b=sloyIMknhfRuLzqhn2ipsVU5RoKGHXqBCtukJM/nGSNeuykuCJ6v0Ymfc6gZsXCoebA8G6SeRk07V1J2pc/hrjtZqY9NK7BWeP2PnumSzyPQOpV7UkXJA9XtoyflgRTqRiRVk84vywTwEdi/v6Kv35I1so3qOfC0edxDbuATPTOR0dUZrcD7qinErDNUzCCGMhALtFct0P+BlPcjkS7IDDWgXCnFoGthrxD9Y2gvh1S3r7+wgX3WTM9sg11PMp21JiP9gNoWATkb02PbseQ2+Gy45cEFZ494e2DB4tKvFxIMq8TiudihsA8feNQytGvOswyB8ZqsMk+5zJFuY2krhw== Received: from DU0P250MB0747.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3cb::16) by PR3P250MB0257.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.35; Mon, 12 Feb 2024 00:01:55 +0000 Received: from DU0P250MB0747.EURP250.PROD.OUTLOOK.COM ([fe80::db07:87f6:7c75:38cc]) by DU0P250MB0747.EURP250.PROD.OUTLOOK.COM ([fe80::db07:87f6:7c75:38cc%3]) with mapi id 15.20.7270.036; Mon, 12 Feb 2024 00:01:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Feb 2024 01:03:16 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [E/uTq8hgp9ptBFGgfRsn4uOXxzrMRx4sgYU//qb+8nc=] X-ClientProxiedBy: FR3P281CA0146.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::18) To DU0P250MB0747.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3cb::16) X-Microsoft-Original-Message-ID: <20240212000335.27984-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0P250MB0747:EE_|PR3P250MB0257:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e36c955-7b39-40f5-0485-08dc2b5dd2be X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqwZHg0HfSFdl5Zlrnc8YAZFZfeLo88iPyJuTAtvE8aRrrQGCjHciFVmFE3mQddXAkjlRN09gyw8huW9G0FJuAul90VarnWEq31IE42hwoqKKwtraXCmno0wBR/JF4/vDOUvPk6KYVQdxLugOYBqJ7+LByX2J6PpexVuqG1G5D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2tnRm3qhaNyC7SHlFJEqhFcAauDF0hms50qQDKhzcsqZ2UIQ02jVdnGYD9V1YZWqhd2DbXg3UMgtL94cpDPPmrvYXcZ69nVfKrYsbF7u7QfIW+H30EzGhU/VUH+nfP83uwW1U/atUA0F/VVdIzZa4eG8t4Ua9NHo95VL2vE4AQ+t/5tq6BNZxKDrgv9KIWnZDGRZCRTyJNNI+aVjalqktzlzrpVwiNG5MRebBH2ghLDoCTWRpwQSIGZfTIp4egiItn6jf92DeTSw6aSsZ41FUc01bGepfXRc2q0R0W5/mpqeKDsjS3vhvd+Hly1ozlYnEqEbtqrmy8P6zDzR+EV1nx6gL+kXTZbjuFQos1BrQ7vTqNJ+Z40po4H81UqNfJpCYlV6Z80PpqgwuNtdV6oEYaWvgzcstS9JEcbq+EDqtQBr2dk63lNPzHGrTkJcdqLzS8RmNG3o+4uKg2eum4Se6KwOSsyCYoa2DDHOUchZe4KS4BtiBhedDog== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e36c955-7b39-40f5-0485-08dc2b5dd2be X-MS-Exchange-CrossTenant-AuthSource: DU0P250MB0747.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2024 00:01:54.9353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0257 Subject: [FFmpeg-devel] [PATCH 04/23] avutil/hwcontext_vulkan: Allocate public and priv device hwctx together 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: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1MqG5i0iJ1i7 This is possible because the lifetime of both coincide. Besides reducing the number of allocations this also simplifies access to VulkanDevicePriv as one no longer has to go through AVHWDeviceInternal. Signed-off-by: Andreas Rheinhardt --- libavutil/hwcontext_vulkan.c | 109 ++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index a84713e621..3d591dedf9 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -81,6 +81,11 @@ typedef struct VulkanQueueCtx { } VulkanQueueCtx; typedef struct VulkanDevicePriv { + /** + * The public AVVulkanDeviceContext. See hwcontext_vulkan.h for it. + */ + AVVulkanDeviceContext p; + /* Vulkan library and loader functions */ void *libvulkan; @@ -288,8 +293,8 @@ static int vkfmt_from_pixfmt2(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p, VkImageUsageFlags *supported_usage, /* Output supported usage */ int disable_multiplane, int need_storage) { - AVVulkanDeviceContext *hwctx = dev_ctx->hwctx; - VulkanDevicePriv *priv = dev_ctx->internal->priv; + VulkanDevicePriv *priv = dev_ctx->hwctx; + AVVulkanDeviceContext *hwctx = &priv->p; FFVulkanFunctions *vk = &priv->vkctx.vkfn; const VkFormatFeatureFlagBits2 basic_flags = VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT | @@ -369,8 +374,8 @@ static int vkfmt_from_pixfmt2(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p, static int load_libvulkan(AVHWDeviceContext *ctx) { - AVVulkanDeviceContext *hwctx = ctx->hwctx; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; static const char *lib_names[] = { #if defined(_WIN32) @@ -488,9 +493,9 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary *opts, { const char *tstr; const char **extension_names = NULL; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *hwctx = ctx->hwctx; int err = 0, found, extensions_found = 0; const char *mod; @@ -619,7 +624,7 @@ static int check_validation_layers(AVHWDeviceContext *ctx, AVDictionary *opts, static const char default_layer[] = { "VK_LAYER_KHRONOS_validation" }; int found = 0, err = 0; - VulkanDevicePriv *priv = ctx->internal->priv; + VulkanDevicePriv *priv = ctx->hwctx; FFVulkanFunctions *vk = &priv->vkctx.vkfn; uint32_t sup_layer_count; @@ -726,9 +731,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) { int err = 0, debug_mode = 0; VkResult ret; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *hwctx = ctx->hwctx; VkApplicationInfo application_info = { .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pApplicationName = "ffmpeg", @@ -866,13 +871,13 @@ static int find_device(AVHWDeviceContext *ctx, VulkanDeviceSelection *select) int err = 0, choice = -1; uint32_t num; VkResult ret; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; VkPhysicalDevice *devices = NULL; VkPhysicalDeviceIDProperties *idp = NULL; VkPhysicalDeviceProperties2 *prop = NULL; VkPhysicalDeviceDrmPropertiesEXT *drm_prop = NULL; - AVVulkanDeviceContext *hwctx = ctx->hwctx; ret = vk->EnumeratePhysicalDevices(hwctx->inst, &num, NULL); if (ret != VK_SUCCESS || !num) { @@ -1046,9 +1051,9 @@ static int setup_queue_families(AVHWDeviceContext *ctx, VkDeviceCreateInfo *cd) uint32_t num; float *weights; VkQueueFamilyProperties *qf = NULL; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *hwctx = ctx->hwctx; int graph_index, comp_index, tx_index, enc_index, dec_index; /* First get the number of queue families */ @@ -1182,9 +1187,9 @@ static int setup_queue_families(AVHWDeviceContext *ctx, VkDeviceCreateInfo *cd) */ static void vulkan_device_free(AVHWDeviceContext *ctx) { - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *hwctx = ctx->hwctx; if (hwctx->act_dev) vk->DestroyDevice(hwctx->act_dev, hwctx->alloc); @@ -1205,7 +1210,7 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) static void vulkan_device_uninit(AVHWDeviceContext *ctx) { - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; for (uint32_t i = 0; i < p->nb_tot_qfs; i++) { pthread_mutex_destroy(p->qf_mutex[i]); @@ -1224,9 +1229,9 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, int err = 0; VkResult ret; AVDictionaryEntry *opt_d; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *hwctx = ctx->hwctx; /* * VkPhysicalDeviceVulkan12Features has a timelineSemaphore field, but @@ -1401,13 +1406,13 @@ end: static void lock_queue(AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index) { - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; pthread_mutex_lock(&p->qf_mutex[queue_family][index]); } static void unlock_queue(AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index) { - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; pthread_mutex_unlock(&p->qf_mutex[queue_family][index]); } @@ -1415,8 +1420,8 @@ static int vulkan_device_init(AVHWDeviceContext *ctx) { int err; uint32_t qf_num; - AVVulkanDeviceContext *hwctx = ctx->hwctx; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; VkQueueFamilyProperties *qf; int graph_index, comp_index, tx_index, enc_index, dec_index; @@ -1666,7 +1671,7 @@ static int vulkan_frames_get_constraints(AVHWDeviceContext *ctx, AVHWFramesConstraints *constraints) { int count = 0; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; for (enum AVPixelFormat i = 0; i < nb_vk_formats_list; i++) { count += vkfmt_from_pixfmt2(ctx, vk_formats_list[i].pixfmt, @@ -1713,9 +1718,9 @@ static int alloc_mem(AVHWDeviceContext *ctx, VkMemoryRequirements *req, { VkResult ret; int index = -1; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *dev_hwctx = ctx->hwctx; + AVVulkanDeviceContext *dev_hwctx = &p->p; VkMemoryAllocateInfo alloc_info = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = alloc_extension, @@ -1803,8 +1808,8 @@ static void vulkan_free_internal(AVVkFrame *f) static void vulkan_frame_free(AVHWFramesContext *hwfc, AVVkFrame *f) { - AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; int nb_images = ff_vk_count_images(f); @@ -1840,12 +1845,11 @@ static int alloc_bind_mem(AVHWFramesContext *hwfc, AVVkFrame *f, int img_cnt = 0, err; VkResult ret; AVHWDeviceContext *ctx = hwfc->device_ctx; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; VkBindImageMemoryInfo bind_info[AV_NUM_DATA_POINTERS] = { { 0 } }; - AVVulkanDeviceContext *hwctx = ctx->hwctx; - while (f->img[img_cnt]) { int use_ded_mem; VkImageMemoryRequirementsInfo2 req_desc = { @@ -1916,7 +1920,7 @@ static int prepare_frame(AVHWFramesContext *hwfc, FFVkExecPool *ectx, AVVkFrame *frame, enum PrepMode pmode) { int err; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; FFVulkanFunctions *vk = &p->vkctx.vkfn; VkImageMemoryBarrier2 img_bar[AV_NUM_DATA_POINTERS]; int nb_img_bar = 0; @@ -2020,9 +2024,9 @@ static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame, VkResult ret; AVVulkanFramesContext *hwfc_vk = hwfc->hwctx; AVHWDeviceContext *ctx = hwfc->device_ctx; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; - AVVulkanDeviceContext *hwctx = ctx->hwctx; VkExportSemaphoreCreateInfo ext_sem_info = { .sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO, @@ -2126,8 +2130,8 @@ static void try_export_flags(AVHWFramesContext *hwfc, { VkResult ret; AVVulkanFramesContext *hwctx = hwfc->hwctx; - AVVulkanDeviceContext *dev_hwctx = hwfc->device_ctx->hwctx; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; + AVVulkanDeviceContext *dev_hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; const VkImageDrmFormatModifierListCreateInfoEXT *drm_mod_info = @@ -2188,7 +2192,7 @@ static AVBufferRef *vulkan_pool_alloc(void *opaque, size_t size) AVBufferRef *avbuf = NULL; AVHWFramesContext *hwfc = opaque; AVVulkanFramesContext *hwctx = hwfc->hwctx; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; VulkanFramesPriv *fp = hwfc->internal->priv; VkExternalMemoryHandleTypeFlags e = 0x0; VkExportMemoryAllocateInfo eminfo[AV_NUM_DATA_POINTERS]; @@ -2259,7 +2263,7 @@ static void unlock_frame(AVHWFramesContext *fc, AVVkFrame *vkf) static void vulkan_frames_uninit(AVHWFramesContext *hwfc) { - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; VulkanFramesPriv *fp = hwfc->internal->priv; if (fp->modifier_info) { @@ -2279,7 +2283,7 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) AVVkFrame *f; AVVulkanFramesContext *hwctx = hwfc->hwctx; VulkanFramesPriv *fp = hwfc->internal->priv; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; VkImageUsageFlagBits supported_usage; const struct FFVkFormatEntry *fmt; int disable_multiplane = p->disable_multiplane || @@ -2486,8 +2490,8 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f AVVkFrame *f; int bind_counts = 0; AVHWDeviceContext *ctx = hwfc->device_ctx; - AVVulkanDeviceContext *hwctx = ctx->hwctx; - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; VulkanFramesPriv *fp = hwfc->internal->priv; const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)src->data[0]; @@ -2831,10 +2835,10 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc, AVVkFrame *dst_f; AVVkFrameInternal *dst_int; AVHWDeviceContext *ctx = hwfc->device_ctx; - AVVulkanDeviceContext *hwctx = ctx->hwctx; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format); - VulkanDevicePriv *p = ctx->internal->priv; + VulkanDevicePriv *p = ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; AVHWFramesContext *cuda_fc = (AVHWFramesContext*)cuda_hwfc->data; @@ -3087,7 +3091,7 @@ fail: static int vulkan_map_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags) { - av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + av_unused VulkanDevicePriv *p = hwfc->device_ctx->hwctx; switch (src->format) { #if CONFIG_LIBDRM @@ -3139,10 +3143,10 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst, int err = 0; VkResult ret; AVVkFrame *f = (AVVkFrame *)src->data[0]; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; VulkanFramesPriv *fp = hwfc->internal->priv; - AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx; AVVulkanFramesContext *hwfctx = hwfc->hwctx; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); VkImageDrmFormatModifierPropertiesEXT drm_mod = { @@ -3274,7 +3278,7 @@ fail: static int vulkan_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags) { - av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + av_unused VulkanDevicePriv *p = hwfc->device_ctx->hwctx; switch (dst->format) { #if CONFIG_LIBDRM @@ -3314,7 +3318,7 @@ static int transfer_image_buf(AVHWFramesContext *hwfc, AVFrame *f, int err; AVVkFrame *frame = (AVVkFrame *)f->data[0]; VulkanFramesPriv *fp = hwfc->internal->priv; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = hwfc->device_ctx->hwctx; FFVulkanFunctions *vk = &p->vkctx.vkfn; VkImageMemoryBarrier2 img_bar[AV_NUM_DATA_POINTERS]; int nb_img_bar = 0; @@ -3406,8 +3410,8 @@ static int vulkan_transfer_data(AVHWFramesContext *hwfc, const AVFrame *vkf, int err = 0; VkResult ret; AVHWDeviceContext *dev_ctx = hwfc->device_ctx; - AVVulkanDeviceContext *hwctx = dev_ctx->hwctx; - VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + VulkanDevicePriv *p = dev_ctx->hwctx; + AVVulkanDeviceContext *hwctx = &p->p; FFVulkanFunctions *vk = &p->vkctx.vkfn; AVFrame tmp; @@ -3546,7 +3550,7 @@ end: static int vulkan_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src) { - av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + av_unused VulkanDevicePriv *p = hwfc->device_ctx->hwctx; switch (src->format) { #if CONFIG_CUDA @@ -3663,7 +3667,7 @@ fail: static int vulkan_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src) { - av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; + av_unused VulkanDevicePriv *p = hwfc->device_ctx->hwctx; switch (dst->format) { #if CONFIG_CUDA @@ -3718,8 +3722,7 @@ const HWContextType ff_hwcontext_type_vulkan = { .type = AV_HWDEVICE_TYPE_VULKAN, .name = "Vulkan", - .device_hwctx_size = sizeof(AVVulkanDeviceContext), - .device_priv_size = sizeof(VulkanDevicePriv), + .device_hwctx_size = sizeof(VulkanDevicePriv), .frames_hwctx_size = sizeof(AVVulkanFramesContext), .frames_priv_size = sizeof(VulkanFramesPriv),