-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: Fixup and add Dispatch Table header
Fixes the vk_layer_dispatch_table.h header file so that they can be used in other projects. The contents of this header and vk_dispatch_table_helper.h have been moved into a new header vul_dispatch_table.h. The structs VulDeviceDispatchTable and VulInstanceDispatchTable struct contain function pointers for the device and instance, respectively. The functions vul_init_device_dispatch_table and vul_init_instance_dispatch_table fill out the aforementioned structs, making the task of setting up the disptach table in a layer much simpler.
- Loading branch information
1 parent
8ea7803
commit c8b671c
Showing
15 changed files
with
1,813 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/python3 -i | ||
# | ||
# Copyright 2023 The Khronos Group Inc. | ||
# Copyright 2023 Valve Corporation | ||
# Copyright 2023 LunarG, Inc. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
from generators.base_generator import BaseGenerator | ||
|
||
class DispatchTableOutputGenerator(BaseGenerator): | ||
def __init__(self): | ||
BaseGenerator.__init__(self) | ||
|
||
def generate(self): | ||
out = [] | ||
out.append(f'''// *** THIS FILE IS GENERATED - DO NOT EDIT *** | ||
// See {os.path.basename(__file__)} for modifications | ||
// Copyright 2023 The Khronos Group Inc. | ||
// Copyright 2023 Valve Corporation | ||
// Copyright 2023 LunarG, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
\n''') | ||
|
||
out.append(''' | ||
#pragma once | ||
#include <vulkan/vulkan.h> | ||
#include <string.h> | ||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName); | ||
''') | ||
out.append(''' | ||
// Instance function pointer dispatch table | ||
typedef struct VulInstanceDispatchTable_ { | ||
PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; | ||
''') | ||
for command in [x for x in self.vk.commands.values() if x.instance]: | ||
out.extend([f'#ifdef {command.protect}\n'] if command.protect else []) | ||
out.append(f' PFN_{command.name} {command.name[2:]};\n') | ||
out.extend([f'#endif //{command.protect}\n'] if command.protect else []) | ||
out.append('} VulInstanceDispatchTable;\n') | ||
|
||
out.append(''' | ||
// Device function pointer dispatch table | ||
typedef struct VulDeviceDispatchTable_ { | ||
''') | ||
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.append(f' PFN_{command.name} {command.name[2:]};\n') | ||
out.extend([f'#endif //{command.protect}\n'] if command.protect else []) | ||
out.append('} VulDeviceDispatchTable;\n') | ||
|
||
out.append(''' | ||
static inline void vul_init_device_dispatch_table(VkDevice device, VulDeviceDispatchTable *table, PFN_vkGetDeviceProcAddr gdpa) { | ||
memset(table, 0, sizeof(*table)); | ||
// Device function pointers | ||
table->GetDeviceProcAddr = gdpa; | ||
''') | ||
|
||
for command in [x for x in self.vk.commands.values() if x.device and x.name != 'vkGetDeviceProcAddr']: | ||
out.extend([f'#ifdef {command.protect}\n'] if command.protect else []) | ||
out.append(f' table->{command.name[2:]} = (PFN_{command.name}) gdpa(device, "{command.name}");\n') | ||
out.extend([f'#endif // {command.protect}\n'] if command.protect else []) | ||
out.append('}\n') | ||
|
||
out.append(''' | ||
static inline void vul_init_instance_dispatch_table(VkInstance instance, VulInstanceDispatchTable_ *table, PFN_vkGetInstanceProcAddr gipa) { | ||
memset(table, 0, sizeof(*table)); | ||
// Instance function pointers | ||
table->GetInstanceProcAddr = gipa; | ||
table->GetPhysicalDeviceProcAddr = (PFN_GetPhysicalDeviceProcAddr) gipa(instance, "vk_layerGetPhysicalDeviceProcAddr"); | ||
''') | ||
|
||
for command in [x for x in self.vk.commands.values() if x.instance and x.name not in [ | ||
'vkCreateInstance', | ||
'vkCreateDevice', | ||
'vkGetPhysicalDeviceProcAddr', | ||
'vkEnumerateInstanceExtensionProperties', | ||
'vkEnumerateInstanceLayerProperties', | ||
'vkEnumerateInstanceVersion', | ||
'vkGetInstanceProcAddr', | ||
]]: | ||
out.extend([f'#ifdef {command.protect}\n'] if command.protect else []) | ||
out.append(f' table->{command.name[2:]} = (PFN_{command.name}) gipa(instance, "{command.name}");\n') | ||
out.extend([f'#endif // {command.protect}\n'] if command.protect else []) | ||
out.append('}\n') | ||
|
||
self.write("".join(out)) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.