mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
avutil/vulkan_loader: Avoid relocations for strings
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). Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
674f20813d
commit
0a05577d1e
@ -31,7 +31,6 @@
|
|||||||
req_dev, \
|
req_dev, \
|
||||||
offsetof(FFVulkanFunctions, name), \
|
offsetof(FFVulkanFunctions, name), \
|
||||||
ext_flag, \
|
ext_flag, \
|
||||||
"vk"#name, \
|
|
||||||
},
|
},
|
||||||
|
|
||||||
static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions,
|
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;
|
char req_dev;
|
||||||
uint16_t struct_offset;
|
uint16_t struct_offset;
|
||||||
FFVulkanExtensions ext_flag;
|
FFVulkanExtensions ext_flag;
|
||||||
const char *name;
|
|
||||||
} vk_load_info[] = {
|
} vk_load_info[] = {
|
||||||
FN_LIST(PFN_LOAD_INFO)
|
FN_LIST(PFN_LOAD_INFO)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FN_LIST_WIN32(PFN_LOAD_INFO)
|
FN_LIST_WIN32(PFN_LOAD_INFO)
|
||||||
#endif
|
#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];
|
const struct FunctionLoadInfo *load = &vk_load_info[i];
|
||||||
static const char extensions[][4] = { "", "EXT", "KHR" };
|
static const char extensions[][4] = { "", "EXT", "KHR" };
|
||||||
const char *name = load->name;
|
|
||||||
PFN_vkVoidFunction fn;
|
PFN_vkVoidFunction fn;
|
||||||
|
|
||||||
if (load->req_dev && !has_dev)
|
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;
|
*(PFN_vkVoidFunction *)((uint8_t *)vk + load->struct_offset) = fn;
|
||||||
}
|
}
|
||||||
|
av_assert1(*name == '\0');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user