Use vku prefix for vk_dispatch_table.h interface

This commit is contained in:
Juan Ramos 2023-09-13 15:49:07 -06:00 committed by Juan Ramos
parent b78ed1a5f0
commit 1c6d92cccf
4 changed files with 20 additions and 20 deletions

View file

@ -15,7 +15,7 @@
typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName); typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
// Instance function pointer dispatch table // Instance function pointer dispatch table
typedef struct VulInstanceDispatchTable_ { typedef struct VkuInstanceDispatchTable_ {
PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr;
PFN_vkCreateInstance CreateInstance; PFN_vkCreateInstance CreateInstance;
@ -176,10 +176,10 @@ typedef struct VulInstanceDispatchTable_ {
PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX GetPhysicalDeviceScreenPresentationSupportQNX; PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX GetPhysicalDeviceScreenPresentationSupportQNX;
#endif // VK_USE_PLATFORM_SCREEN_QNX #endif // VK_USE_PLATFORM_SCREEN_QNX
PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV GetPhysicalDeviceOpticalFlowImageFormatsNV; PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV GetPhysicalDeviceOpticalFlowImageFormatsNV;
} VulInstanceDispatchTable; } VkuInstanceDispatchTable;
// Device function pointer dispatch table // Device function pointer dispatch table
typedef struct VulDeviceDispatchTable_ { typedef struct VkuDeviceDispatchTable_ {
PFN_vkGetDeviceProcAddr GetDeviceProcAddr; PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
PFN_vkDestroyDevice DestroyDevice; PFN_vkDestroyDevice DestroyDevice;
PFN_vkGetDeviceQueue GetDeviceQueue; PFN_vkGetDeviceQueue GetDeviceQueue;
@ -794,9 +794,9 @@ typedef struct VulDeviceDispatchTable_ {
PFN_vkCmdDrawMeshTasksEXT CmdDrawMeshTasksEXT; PFN_vkCmdDrawMeshTasksEXT CmdDrawMeshTasksEXT;
PFN_vkCmdDrawMeshTasksIndirectEXT CmdDrawMeshTasksIndirectEXT; PFN_vkCmdDrawMeshTasksIndirectEXT CmdDrawMeshTasksIndirectEXT;
PFN_vkCmdDrawMeshTasksIndirectCountEXT CmdDrawMeshTasksIndirectCountEXT; PFN_vkCmdDrawMeshTasksIndirectCountEXT CmdDrawMeshTasksIndirectCountEXT;
} VulDeviceDispatchTable; } VkuDeviceDispatchTable;
static inline void vulInitDeviceDispatchTable(VkDevice device, VulDeviceDispatchTable *table, PFN_vkGetDeviceProcAddr gdpa) { static inline void vkuInitDeviceDispatchTable(VkDevice device, VkuDeviceDispatchTable *table, PFN_vkGetDeviceProcAddr gdpa) {
memset(table, 0, sizeof(*table)); memset(table, 0, sizeof(*table));
// Device function pointers // Device function pointers
table->GetDeviceProcAddr = gdpa; table->GetDeviceProcAddr = gdpa;
@ -1415,7 +1415,7 @@ static inline void vulInitDeviceDispatchTable(VkDevice device, VulDeviceDispatch
table->CmdDrawMeshTasksIndirectCountEXT = (PFN_vkCmdDrawMeshTasksIndirectCountEXT)gdpa(device, "vkCmdDrawMeshTasksIndirectCountEXT"); table->CmdDrawMeshTasksIndirectCountEXT = (PFN_vkCmdDrawMeshTasksIndirectCountEXT)gdpa(device, "vkCmdDrawMeshTasksIndirectCountEXT");
} }
static inline void vulInitInstanceDispatchTable(VkInstance instance, VulInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gipa) { static inline void vkuInitInstanceDispatchTable(VkInstance instance, VkuInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gipa) {
memset(table, 0, sizeof(*table)); memset(table, 0, sizeof(*table));
// Instance function pointers // Instance function pointers
table->GetInstanceProcAddr = gipa; table->GetInstanceProcAddr = gipa;

View file

@ -35,7 +35,7 @@ typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance
''') ''')
out.append(''' out.append('''
// Instance function pointer dispatch table // Instance function pointer dispatch table
typedef struct VulInstanceDispatchTable_ { typedef struct VkuInstanceDispatchTable_ {
PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr;
''') ''')
@ -43,20 +43,20 @@ typedef struct VulInstanceDispatchTable_ {
out.extend([f'#ifdef {command.protect}\n'] if command.protect else []) out.extend([f'#ifdef {command.protect}\n'] if command.protect else [])
out.append(f' PFN_{command.name} {command.name[2:]};\n') out.append(f' PFN_{command.name} {command.name[2:]};\n')
out.extend([f'#endif // {command.protect}\n'] if command.protect else []) out.extend([f'#endif // {command.protect}\n'] if command.protect else [])
out.append('} VulInstanceDispatchTable;\n') out.append('} VkuInstanceDispatchTable;\n')
out.append(''' out.append('''
// Device function pointer dispatch table // Device function pointer dispatch table
typedef struct VulDeviceDispatchTable_ { typedef struct VkuDeviceDispatchTable_ {
''') ''')
for command in [x for x in self.vk.commands.values() if x.device]: for command in [x for x in self.vk.commands.values() if x.device]:
out.extend([f'#ifdef {command.protect}\n'] if command.protect else []) out.extend([f'#ifdef {command.protect}\n'] if command.protect else [])
out.append(f' PFN_{command.name} {command.name[2:]};\n') out.append(f' PFN_{command.name} {command.name[2:]};\n')
out.extend([f'#endif // {command.protect}\n'] if command.protect else []) out.extend([f'#endif // {command.protect}\n'] if command.protect else [])
out.append('} VulDeviceDispatchTable;\n') out.append('} VkuDeviceDispatchTable;\n')
out.append(''' out.append('''
static inline void vulInitDeviceDispatchTable(VkDevice device, VulDeviceDispatchTable *table, PFN_vkGetDeviceProcAddr gdpa) { static inline void vkuInitDeviceDispatchTable(VkDevice device, VkuDeviceDispatchTable *table, PFN_vkGetDeviceProcAddr gdpa) {
memset(table, 0, sizeof(*table)); memset(table, 0, sizeof(*table));
// Device function pointers // Device function pointers
table->GetDeviceProcAddr = gdpa; table->GetDeviceProcAddr = gdpa;
@ -69,7 +69,7 @@ static inline void vulInitDeviceDispatchTable(VkDevice device, VulDeviceDispatch
out.append('}\n') out.append('}\n')
out.append(''' out.append('''
static inline void vulInitInstanceDispatchTable(VkInstance instance, VulInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gipa) { static inline void vkuInitInstanceDispatchTable(VkInstance instance, VkuInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gipa) {
memset(table, 0, sizeof(*table)); memset(table, 0, sizeof(*table));
// Instance function pointers // Instance function pointers
table->GetInstanceProcAddr = gipa; table->GetInstanceProcAddr = gipa;

View file

@ -18,14 +18,14 @@ PFN_vkVoidFunction VKAPI_PTR local_vkGetDeviceProcAddr(VkDevice device, const ch
} }
void vk_dispatch_table() { void vk_dispatch_table() {
VulDeviceDispatchTable device_dispatch_table; VkuDeviceDispatchTable device_dispatch_table;
VulInstanceDispatchTable instance_dispatch_table; VkuInstanceDispatchTable instance_dispatch_table;
VkInstance instance = VK_NULL_HANDLE; VkInstance instance = VK_NULL_HANDLE;
vulInitInstanceDispatchTable(instance, &instance_dispatch_table, local_vkGetInstanceProcAddr); vkuInitInstanceDispatchTable(instance, &instance_dispatch_table, local_vkGetInstanceProcAddr);
VkDevice device = VK_NULL_HANDLE; VkDevice device = VK_NULL_HANDLE;
vulInitDeviceDispatchTable(device, &device_dispatch_table, local_vkGetDeviceProcAddr); vkuInitDeviceDispatchTable(device, &device_dispatch_table, local_vkGetDeviceProcAddr);
} }

View file

@ -28,18 +28,18 @@ inline PFN_vkVoidFunction local_vkGetDeviceProcAddr(VkDevice device, const char
} }
TEST(test_vk_dispatch_table, cpp_interface) { TEST(test_vk_dispatch_table, cpp_interface) {
VulDeviceDispatchTable device_dispatch_table{}; VkuDeviceDispatchTable device_dispatch_table{};
VulInstanceDispatchTable instance_dispatch_table{}; VkuInstanceDispatchTable instance_dispatch_table{};
VkInstance instance{}; VkInstance instance{};
vulInitInstanceDispatchTable(instance, &instance_dispatch_table, local_vkGetInstanceProcAddr); vkuInitInstanceDispatchTable(instance, &instance_dispatch_table, local_vkGetInstanceProcAddr);
ASSERT_EQ(instance_dispatch_table.GetInstanceProcAddr, local_vkGetInstanceProcAddr); ASSERT_EQ(instance_dispatch_table.GetInstanceProcAddr, local_vkGetInstanceProcAddr);
VkDevice device{}; VkDevice device{};
vulInitDeviceDispatchTable(device, &device_dispatch_table, local_vkGetDeviceProcAddr); vkuInitDeviceDispatchTable(device, &device_dispatch_table, local_vkGetDeviceProcAddr);
ASSERT_EQ(device_dispatch_table.GetDeviceProcAddr, local_vkGetDeviceProcAddr); ASSERT_EQ(device_dispatch_table.GetDeviceProcAddr, local_vkGetDeviceProcAddr);
} }