mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-25 16:24:35 +00:00
Proxys added to autogen. Updated test.
This commit is contained in:
parent
2445eb0b28
commit
8dc3c2aeee
@ -24,7 +24,7 @@ with urllib.request.urlopen('https://raw.githubusercontent.com/KhronosGroup/Vulk
|
||||
|
||||
vk_xml = xmltodict.parse(vk_xml_raw,process_namespaces=True)
|
||||
|
||||
device_commands = []
|
||||
device_commands = {}
|
||||
core_commands = {}
|
||||
extension_commands = {}
|
||||
|
||||
@ -32,24 +32,24 @@ extension_commands = {}
|
||||
commands = vk_xml['registry']['commands']['command']
|
||||
aliases = {}
|
||||
for command in commands:
|
||||
#Not worrying about aliases as all extension functions are fetched regardless
|
||||
if 'proto' in command:
|
||||
#print(command['proto']['name'])
|
||||
name = command['proto']['name']
|
||||
return_type = command['proto']['type']
|
||||
types = []
|
||||
if type(command['param']) is list:
|
||||
t = command['param'][0]['type']
|
||||
types = command['param']
|
||||
else:
|
||||
t = command['param']['type']
|
||||
types = [command['param']]
|
||||
if not name in exclusions:
|
||||
if t == 'VkDevice' or t == 'VkCommandBuffer' or t == 'VkQueue':
|
||||
device_commands += [name]
|
||||
if types[0]['type'] == 'VkDevice' or types[0]['type'] == 'VkCommandBuffer' or types[0]['type'] == 'VkQueue':
|
||||
device_commands[name] = [types, return_type]
|
||||
elif '@alias' in command:
|
||||
aliases[command['@alias']] = command['@name'];
|
||||
|
||||
#Push the alias name as a device function if the alias exists in device commands
|
||||
for alias in aliases:
|
||||
if alias in device_commands:
|
||||
device_commands += [aliases[alias]]
|
||||
device_commands[aliases[alias]] = device_commands[alias]
|
||||
|
||||
#Gather all core feature levels and functions
|
||||
levels = vk_xml['registry']['feature']
|
||||
@ -112,50 +112,124 @@ header += 'namespace vkb {\n\n'
|
||||
header += 'struct DispatchTable {\n'
|
||||
header += '\tDispatchTable() = default;\n'
|
||||
header += '\tDispatchTable(VkDevice const& device, PFN_vkGetDeviceProcAddr const& procAddr) {\n'
|
||||
header += '\t\t_device = device;\n'
|
||||
|
||||
declaration = ''
|
||||
loading = ''
|
||||
proxy_definition = ''
|
||||
pfn_declaration = ''
|
||||
pfn_loading = ''
|
||||
|
||||
for level in core_commands:
|
||||
declaration += '#ifdef ' + level + '\n';
|
||||
loading += '#ifdef ' + level + '\n';
|
||||
pfn_declaration += '#ifdef ' + level + '\n';
|
||||
pfn_loading += '#ifdef ' + level + '\n';
|
||||
for command in core_commands[level]:
|
||||
fptr_name = 'PFN_' + command
|
||||
member_name = command[2].lower() + command[3:]
|
||||
declaration += '\t' + fptr_name + ' ' + member_name + ' = nullptr;\n'
|
||||
loading += '\t\t' + member_name + ' = (' + fptr_name + ')procAddr(device, "' + command + '");\n'
|
||||
declaration += '#endif\n'
|
||||
loading += '#endif\n'
|
||||
member_name = 'fp_' + command
|
||||
proxy_name = command[2].lower() + command[3:]
|
||||
|
||||
types = device_commands[command][0]
|
||||
names = [];
|
||||
i = 0
|
||||
length = len(types) - 1
|
||||
takes_device = False;
|
||||
proxy_definition += '\t'
|
||||
return_type = device_commands[command][1];
|
||||
proxy_definition += return_type
|
||||
proxy_definition += ' '
|
||||
proxy_definition += proxy_name
|
||||
proxy_definition += '('
|
||||
for t in types:
|
||||
if i == 0 and t['type'] == 'VkDevice':
|
||||
takes_device = True
|
||||
else:
|
||||
if '#text' in t:
|
||||
text = t['#text']
|
||||
if 'const' in text:
|
||||
proxy_definition += 'const '
|
||||
proxy_definition += t['type']
|
||||
if '*' in text and not '**' in text:
|
||||
proxy_definition += '* '
|
||||
proxy_definition += t['name']
|
||||
elif '**' in text:
|
||||
proxy_definition += '** '
|
||||
proxy_definition += t['name']
|
||||
else:
|
||||
proxy_definition += ' '
|
||||
proxy_definition += t['name']
|
||||
if '[' in text and ']' in text:
|
||||
start = text.find('[')
|
||||
end = text.find(']')
|
||||
proxy_definition += text[start:end+1]
|
||||
else:
|
||||
proxy_definition += t['type']
|
||||
proxy_definition += ' '
|
||||
proxy_definition += t['name']
|
||||
names += [t['name']]
|
||||
if i < length:
|
||||
proxy_definition += ', '
|
||||
i += 1
|
||||
proxy_definition += ') {\n'
|
||||
proxy_definition += '\t\t'
|
||||
if return_type != 'void':
|
||||
proxy_definition += 'return '
|
||||
proxy_definition += member_name
|
||||
proxy_definition += '('
|
||||
|
||||
if takes_device:
|
||||
proxy_definition +='_device'
|
||||
if(len(names) > 0):
|
||||
proxy_definition += ', '
|
||||
i = 0
|
||||
length = len(names) - 1
|
||||
for name in names:
|
||||
proxy_definition += name
|
||||
if i < length:
|
||||
proxy_definition += ', '
|
||||
i += 1
|
||||
proxy_definition += ');\n'
|
||||
|
||||
proxy_definition += '\t}\n'
|
||||
#print(proxy_name)
|
||||
#print(names)
|
||||
#print(proxy_definition)
|
||||
|
||||
pfn_declaration += '\t' + fptr_name + ' ' + member_name + ' = nullptr;\n'
|
||||
pfn_loading += '\t\t' + member_name + ' = (' + fptr_name + ')procAddr(device, "' + command + '");\n'
|
||||
pfn_declaration += '#endif\n'
|
||||
pfn_loading += '#endif\n'
|
||||
|
||||
for extension in extension_commands:
|
||||
if len(extension_commands[extension]) > 0:
|
||||
declaration += '#if defined(' + extension[0] + ') && defined(' + extension[1] + ')\n';
|
||||
loading += '#if defined(' + extension[0] + ') && defined(' + extension[1] + ')\n';
|
||||
pfn_declaration += '#if defined(' + extension[0] + ') && defined(' + extension[1] + ')\n';
|
||||
pfn_loading += '#if defined(' + extension[0] + ') && defined(' + extension[1] + ')\n';
|
||||
for command in extension_commands[extension]:
|
||||
fptr_name = 'PFN_' + command
|
||||
member_name = command[2].lower() + command[3:]
|
||||
member_name = 'fp_' + command
|
||||
proxy_name = command[2].lower() + command[3:]
|
||||
#Duplication guards
|
||||
declaration += '#ifndef ' + fptr_name + '_DECLARE\n'
|
||||
declaration += '#define ' + fptr_name + '_DECLARE\n'
|
||||
declaration += '\t' + fptr_name + ' ' + member_name + ' = nullptr;\n'
|
||||
declaration += '#endif\n'
|
||||
pfn_declaration += '#ifndef ' + fptr_name + '_DECLARE\n'
|
||||
pfn_declaration += '#define ' + fptr_name + '_DECLARE\n'
|
||||
pfn_declaration += '\t' + fptr_name + ' ' + member_name + ' = nullptr;\n'
|
||||
pfn_declaration += '#endif\n'
|
||||
#Duplication guards
|
||||
loading += '#ifndef ' + fptr_name + '_LOAD\n'
|
||||
loading += '#define ' + fptr_name + '_LOAD\n'
|
||||
loading += '\t\t' + member_name + ' = (' + fptr_name + ')procAddr(device, "' + command + '");\n'
|
||||
loading += '#endif\n'
|
||||
declaration += '#endif\n'
|
||||
loading += '#endif\n'
|
||||
pfn_loading += '#ifndef ' + fptr_name + '_LOAD\n'
|
||||
pfn_loading += '#define ' + fptr_name + '_LOAD\n'
|
||||
pfn_loading += '\t\t' + member_name + ' = (' + fptr_name + ')procAddr(device, "' + command + '");\n'
|
||||
pfn_loading += '#endif\n'
|
||||
pfn_declaration += '#endif\n'
|
||||
pfn_loading += '#endif\n'
|
||||
|
||||
header += loading
|
||||
header += pfn_loading
|
||||
header += '\t}\n'
|
||||
header += declaration
|
||||
header += proxy_definition
|
||||
header += 'private:\n\nVkDevice _device = VK_NULL_HANDLE;\n\n'
|
||||
header += pfn_declaration
|
||||
header += '};\n\n'
|
||||
header += '} // namespace vkb'
|
||||
|
||||
header_file = open("../src/VkDispatchTable.h", "w")
|
||||
header_file.write(header)
|
||||
header_file.close();
|
||||
#print(test)
|
||||
|
||||
#print(core_commands)
|
||||
#print(core_feature_levels)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -205,6 +205,15 @@ TEST_CASE("Loading Dispatch Table", "[VkBootstrap.bootstrap]") {
|
||||
|
||||
vkb::DispatchTable table = device_ret->get_dispatch_table();
|
||||
|
||||
// Create a basic Device specific type to test with
|
||||
VkFenceCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
|
||||
VkFence fence = VK_NULL_HANDLE;
|
||||
table.createFence(&info, nullptr, &fence);
|
||||
REQUIRE(fence != VK_NULL_HANDLE);
|
||||
|
||||
table.destroyFence(fence, nullptr);
|
||||
vkb::destroy_device(device_ret.value());
|
||||
}
|
||||
vkb::destroy_instance(instance_ret.value());
|
||||
|
Loading…
Reference in New Issue
Block a user