tools: prefer cast::ffs over reinterpret_cast for alignment warnings
This commit is contained in:
parent
c5d2333cfc
commit
db7f691624
@ -299,7 +299,7 @@ VkResult _vkCreateDebugReportCallbackEXT (
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkDebugReportCallbackEXT* pCallback
|
||||
) noexcept {
|
||||
static auto fn = reinterpret_cast<
|
||||
static auto fn = cruft::cast::ffs<
|
||||
decltype(_vkCreateDebugReportCallbackEXT)*
|
||||
> (
|
||||
vkGetInstanceProcAddr (
|
||||
|
@ -850,6 +850,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
||||
#include "load/dispatch.hpp"
|
||||
|
||||
#include <cruft/util/debug/panic.hpp>
|
||||
#include <cruft/util/cast.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
@ -871,11 +872,11 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
||||
if (err != VK_SUCCESS)
|
||||
return err;
|
||||
|
||||
#define GET(NAME) res->table.NAME = reinterpret_cast<decltype(NAME)*> (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (res->handle, #NAME));
|
||||
#define GET(NAME) res->table.NAME = cruft::cast::ffs<decltype(NAME)*> (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (res->handle, #NAME));
|
||||
MAP_INSTANCE_COMMANDS(GET)
|
||||
#undef GET
|
||||
|
||||
#define GET(NAME) if (!res->table.NAME) res->table.NAME = reinterpret_cast<decltype(NAME)*> (res->table.vkGetInstanceProcAddr (res->handle, #NAME));
|
||||
#define GET(NAME) if (!res->table.NAME) res->table.NAME = cruft::cast::ffs<decltype(NAME)*> (res->table.vkGetInstanceProcAddr (res->handle, #NAME));
|
||||
MAP_INSTANCE_COMMANDS(GET)
|
||||
#undef GET
|
||||
|
||||
@ -885,7 +886,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
||||
|
||||
'vkGetInstanceProcAddr': """
|
||||
std::clog << "InstanceProcAddr: " << pName << '\\n';
|
||||
#define ATTEMPT(NAME) if (!strcmp (#NAME, pName)) return reinterpret_cast<PFN_vkVoidFunction> (&NAME);
|
||||
#define ATTEMPT(NAME) if (!strcmp (#NAME, pName)) return cruft::cast::ffs<PFN_vkVoidFunction> (&NAME);
|
||||
MAP_INSTANCE_COMMANDS(ATTEMPT)
|
||||
#undef ATTEMPT
|
||||
return nullptr;
|
||||
@ -927,11 +928,11 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
||||
//MAP_INSTANCE_COMMANDS(GET)
|
||||
//#undef GET
|
||||
|
||||
#define GET(NAME) wrapped->table.NAME = wrapped->table.NAME ?: reinterpret_cast<decltype(NAME)*> (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (entry->handle, #NAME));
|
||||
#define GET(NAME) wrapped->table.NAME = wrapped->table.NAME ?: cruft::cast::ffs<decltype(NAME)*> (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (entry->handle, #NAME));
|
||||
MAP_INSTANCE_COMMANDS(GET)
|
||||
#undef GET
|
||||
|
||||
#define GET(NAME) wrapped->table.NAME = wrapped->table.NAME ?: reinterpret_cast<decltype(NAME)*> (entry->table.vkGetInstanceProcAddr (entry->handle, #NAME));
|
||||
#define GET(NAME) wrapped->table.NAME = wrapped->table.NAME ?: cruft::cast::ffs<decltype(NAME)*> (entry->table.vkGetInstanceProcAddr (entry->handle, #NAME));
|
||||
MAP_INSTANCE_COMMANDS(GET)
|
||||
#undef GET
|
||||
|
||||
@ -996,17 +997,19 @@ def write_trace(dst: TextIO, q: List[Type], reg: Registry):
|
||||
#include "vk.hpp"
|
||||
#include "load/vtable.hpp"
|
||||
#include "ostream.hpp"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <dlfcn.h>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#include <cruft/util/cast.hpp>
|
||||
|
||||
static void* g_lib;
|
||||
|
||||
|
||||
void init [[gnu::constructor]] (void) {
|
||||
g_lib = dlopen (getenv ("REAL_VULKAN"), RTLD_LAZY | RTLD_LOCAL);
|
||||
}
|
||||
|
||||
|
||||
void deinit [[gnu::destructor]] (void) {
|
||||
dlclose (g_lib);
|
||||
g_lib = nullptr;
|
||||
@ -1014,7 +1017,6 @@ def write_trace(dst: TextIO, q: List[Type], reg: Registry):
|
||||
#pragma GCC diagnostic ignored "-Wsign-promo"
|
||||
""")
|
||||
|
||||
|
||||
for obj in (i for i in q if isinstance(i, Command)):
|
||||
inner = ""
|
||||
if obj.name in ['vkGetInstanceProcAddr']:
|
||||
@ -1029,7 +1031,7 @@ def write_trace(dst: TextIO, q: List[Type], reg: Registry):
|
||||
}
|
||||
#undef FWD
|
||||
|
||||
#define FWD(NAME) if (!strcmp(#NAME,pName)) { return reinterpret_cast<PFN_vkVoidFunction> (NAME); }
|
||||
#define FWD(NAME) if (!strcmp(#NAME,pName)) { return cruft::cast::ffs<PFN_vkVoidFunction> (NAME); }
|
||||
MAP_INSTANCE_COMMANDS(FWD)
|
||||
#undef FWD
|
||||
std::clog << "Unhooked: " << pName << '\\n';
|
||||
|
Loading…
Reference in New Issue
Block a user