From patchwork Sun Mar 3 18:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46735 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429477pzb; Sun, 3 Mar 2024 10:41:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWOscHsupquIitkqxlhSTwwr8HEiDul0EhEkH4D9w9c2cRDSymo/o8I2cs1peRGg4nis1B3BYT+NXvfdiQ2Zb7yMIcRIddha9BGEg== X-Google-Smtp-Source: AGHT+IEAQZOMlzIMPEQ1fHz4mTYF/FqJsdz/Q7A5QDNSylI3BC4pr0DXYkUY1wR/TE9YlRNHggan X-Received: by 2002:a17:907:c316:b0:a45:5509:e219 with SMTP id tl22-20020a170907c31600b00a455509e219mr134763ejc.1.1709491286976; Sun, 03 Mar 2024 10:41:26 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hp19-20020a1709073e1300b00a453e6bc7a4si260069ejc.180.2024.03.03.10.41.25; Sun, 03 Mar 2024 10:41:26 -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=slxeuTbo; 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 1641468D3BC; Sun, 3 Mar 2024 20:41:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D98C68D3BA for ; Sun, 3 Mar 2024 20:41:10 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GFS7Tatl8PmvIo3HloLPW9yAXWJVRtQ3eEmVKYYMmXMYSC9Ib2tvcwDXcpTRcyP1kXjq2+awszbGOjdjCcm5Jy6ibGf8wnmrPNYrjDz/jBR35qOW4BYB8LUNhqbbMKi3yB7dYrovIHoyAG1PJ4jZH3uWfqqKrtaY3hdIMK0KW8xSmNPO8ET7IOyWQRcmVyHYggxSXUMDBgydqP2ebzY1pNZo81gFJvfrfzeUnPqSdF6Eu+57/wPwlk0AcDhZ6vrv0r6Xzkdm3eq5mmqcXYtUOuksqcLvBq8ZPg3UoUykd7QN4RCPK9HApThv0iWvuuS6+p85JaHFyBIOHiwRDCx1+w== 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=7/QU8eIiiOQpb91onkDUQ7ZPtnWkTRdZ7lC3XXjounw=; b=L/WCpUXqwJ9TcEjJLgP1h6SMSvdTW6yx0gmgoRcf8lfY4+G+ToOVtyIw7E8Xyq1STCXIdxIW2guy138yA7fW6a1jvkkX613qU2Y584I20zBpBgnBMSI/E8uBvHu1OIFcsyr7tTBe3KwAxN0pVZTJSyXIUTQ5VOPh6AIHlVOvxaQ/LqGbfNnn+KIvGFrE+gcUIwRZ/O3FhCVWa0bnVrvsq6JOMqxTzaStXAYZLFHkhfMBAUifoKpLp9FXc9ct9bGBS5eTCTH6NWA1WXYT4322/XglWtBwn17EsnHM6m4pmrklzt0SDzv9XzA3kiUWeWWlVup3Qd6qXNZqGuNpAxGAyQ== 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=7/QU8eIiiOQpb91onkDUQ7ZPtnWkTRdZ7lC3XXjounw=; b=slxeuTboSdJ7XjEXBuhQzkq3PUuYDFlaRnJsUouLeI4VxJQnDvHoeccYI1iORg9vqWsKsaORw+VnugvMP3bTv3OvHHUPGOn3ACKBGSXlr440mFLzR6DotyqbVC/iiqjFh3b686dFPu5IwaJM21I19MEyKN9OtWcmAvdEoa0ux0r+DWCrVI3p8c6JGlBkAStchVYAHgkh2ThPOTAYeXOMq/xMMjKC6uijG3Jd+P9z8QR+bg3EBz9rZ5Blqj46o+2yb6RyzcKdrU013TsSl5YpJnUPXiB5EtVYwCiPtQUiO52Cq7bSOr3F4QJqrLCxyrdo7/m5HjSHNhPRuMiC0Ohkww== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:04 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:04 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:46 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [+6se2w2xmIS/RZAAJ3JnjSgo9rb7lIHSfs6ViJcWwu8=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: e06e66ed-5d90-4735-3e6e-08dc3bb17b03 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0Vp9OyQnCkjKBIU7ouvlD833GxeaKo0AnJLKG24nqEYd0ZccQSGUh4xjd5f4kmopQ651bFMGLQfbc+VolUsCEWfa0z4GddIasRezMbNyD0jaWF9jFLaqB62HwxgS5M4GV685k5UM6EsM5RNtSboCNnWSfp7u6iokmoHb2wgDPG/i2dDTxP1LpCMQhY6qwag5/EB8zwZnLyfZL/N884TXvmmwzjSoQgjy2l66T/kt4ljQMWYwA0P2naJ8RiWgewwHL7dGvAk8eSpJMUflouhXOdslU3qXOpla4hsA4kwm4X7cI8I0eQBeYk+N7LdItx8S/wQqPOLMJt/6JwM6dIkcx3nCfux0bswXOVsGaXupcWaimgoE+R480YSa1LpedYI9YsAGCeXJ/w7fn1OvBl7YAwQyn3ZZdIU03BvjDQeFX1zQPxqa4rG04IJnjqZHqE76cu0QxE4I96bugaLvTWFk2kmBRlFbDEeS72Vu4wXQc+luxx9jX1ZXy1YahUAgwfru84UkT11Nauzs5eGLjgSvppdT7fCHUernJ20TZcOXGj3nSOAT+lDhDuQg960lB2hndRvLKEYgL2pTmSIEWRvO3erig07XGauqv4ZirCqddpVvJpgyXCTCkChDTNWTXVYdwaUGkOmr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-Network-Message-Id: e06e66ed-5d90-4735-3e6e-08dc3bb17b03 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:04.0579 (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: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 4/8] avutil/vulkan_loader: Avoid relocations for strings 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: Wn8kzuk3WR5r To do so, concatenate all the names together to one big string name1\0name2\0....lastname\0\0. This avoids the pointer in the FunctionLoadInfo structure and thereby moves vk_load_info into .rodata (and makes it smaller by 888B). Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan_loader.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h index 37ce339e1d..f9e739e1e3 100644 --- a/libavutil/vulkan_loader.h +++ b/libavutil/vulkan_loader.h @@ -31,7 +31,6 @@ req_dev, \ offsetof(FFVulkanFunctions, name), \ ext_flag, \ - "vk"#name, \ }, static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions, @@ -101,18 +100,26 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, char req_dev; uint16_t struct_offset; FFVulkanExtensions ext_flag; - const char *name; } vk_load_info[] = { FN_LIST(PFN_LOAD_INFO) #ifdef _WIN32 FN_LIST_WIN32(PFN_LOAD_INFO) #endif }; + // Concatenate the names to avoid relocations. The resulting string + // will end with \0\0 +#define FUNC_NAME(req_inst, req_dev, ext_flag, name) "vk"#name"\0" + const char *name = + FN_LIST(FUNC_NAME) +#ifdef _WIN32 + FN_LIST_WIN32(FUNC_NAME) +#endif + ; +#undef FUNC_NAME - for (int i = 0; i < FF_ARRAY_ELEMS(vk_load_info); i++) { + for (int i = 0; i < FF_ARRAY_ELEMS(vk_load_info); name += strlen(name) + 1, i++) { const struct FunctionLoadInfo *load = &vk_load_info[i]; static const char extensions[][4] = { "", "EXT", "KHR" }; - const char *name = load->name; PFN_vkVoidFunction fn; if (load->req_dev && !has_dev) @@ -146,6 +153,7 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, *(PFN_vkVoidFunction *)((uint8_t *)vk + load->struct_offset) = fn; } + av_assert1(*name == '\0'); return 0; }