mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
vulkan: Fix weak symbol emulation when compiling with MSVC
Mapping unimplemented entrypoints to a global function pointer variable initialized to NULL is a bit cumbersome, and actually led to a bug in the vk_xxx_dispatch_table_from_entrypoints() template: the !override case didn't have the right check on the source table entries. Instead of fixing that case, let's simplify the logic by creating a stub function and making the alternatename pragma point to this stub. This way we get rid of all those uneeded xxx_Null symbols/variables and simplify the tests in vk_xxxx_dispatch_table_from_entrypoints(). Cc: mesa-stable Fixes:98c622a96e("vulkan: Update dispatch table gen for Windows") Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13348> (cherry picked from commit6d44b21d4f)
This commit is contained in:
parent
7c088e7024
commit
ce5eae0f05
3 changed files with 17 additions and 6 deletions
|
|
@ -85,7 +85,7 @@
|
|||
"description": "vulkan: Fix weak symbol emulation when compiling with MSVC",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "98c622a96e28020640517cb5499a1d7bd56553b0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -464,6 +464,13 @@ vk_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
void vk_entrypoint_stub(void)
|
||||
{
|
||||
unreachable(!"Entrypoint not implemented");
|
||||
}
|
||||
#endif
|
||||
|
||||
<%def name="dispatch_table_from_entrypoints(type)">
|
||||
void vk_${type}_dispatch_table_from_entrypoints(
|
||||
struct vk_${type}_dispatch_table *dispatch_table,
|
||||
|
|
@ -477,8 +484,8 @@ void vk_${type}_dispatch_table_from_entrypoints(
|
|||
memset(dispatch_table, 0, sizeof(*dispatch_table));
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(${type}_compaction_table); i++) {
|
||||
#ifdef _MSC_VER
|
||||
const uintptr_t zero = 0;
|
||||
if (entry[i] == NULL || memcmp(entry[i], &zero, sizeof(zero)) == 0)
|
||||
assert(entry[i] != NULL);
|
||||
if (entry[i] == vk_entrypoint_stub)
|
||||
#else
|
||||
if (entry[i] == NULL)
|
||||
#endif
|
||||
|
|
@ -490,7 +497,12 @@ void vk_${type}_dispatch_table_from_entrypoints(
|
|||
} else {
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(${type}_compaction_table); i++) {
|
||||
unsigned disp_index = ${type}_compaction_table[i];
|
||||
#ifdef _MSC_VER
|
||||
assert(entry[i] != NULL);
|
||||
if (disp[disp_index] == NULL && entry[i] != vk_entrypoint_stub)
|
||||
#else
|
||||
if (disp[disp_index] == NULL)
|
||||
#endif
|
||||
disp[disp_index] = entry[i];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,13 +123,12 @@ TEMPLATE_C = Template(COPYRIGHT + """
|
|||
% endif
|
||||
% for p in prefixes:
|
||||
#ifdef _MSC_VER
|
||||
${e.return_type} (*${p}_${e.name}_Null)(${e.decl_params()}) = 0;
|
||||
#ifdef _M_IX86
|
||||
% for args_size in [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 60, 104]:
|
||||
#pragma comment(linker, "/alternatename:_${p}_${e.name}@${args_size}=_${p}_${e.name}_Null")
|
||||
#pragma comment(linker, "/alternatename:_${p}_${e.name}@${args_size}=_vk_entrypoint_stub")
|
||||
% endfor
|
||||
#else
|
||||
#pragma comment(linker, "/alternatename:${p}_${e.name}=${p}_${e.name}_Null")
|
||||
#pragma comment(linker, "/alternatename:${p}_${e.name}=vk_entrypoint_stub")
|
||||
#endif
|
||||
#else
|
||||
VKAPI_ATTR ${e.return_type} VKAPI_CALL ${p}_${e.name}(${e.decl_params()}) __attribute__ ((weak));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue