46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
import binascii
|
|
from common import func_name_to_caps, write_epilogue, write_preamble, FIRST_PARAM_BLACKLIST, FUNC_BLACKLIST
|
|
|
|
HEADER_GUARD = 'VK_CAPTURE_FUNCTION_IDS_H_INCLUDED'
|
|
_dbg_hashes = set()
|
|
|
|
|
|
def write_funcid(f, cmd):
|
|
if 'alias' in cmd or cmd["name"] in FUNC_BLACKLIST:
|
|
return
|
|
if len(cmd['params']) > 0 and cmd['params'][0]['type'] in FIRST_PARAM_BLACKLIST:
|
|
return
|
|
funchash = binascii.crc32(cmd['name'].encode('utf8'))
|
|
f.write(f"""
|
|
VK_FUNCTION_{func_name_to_caps(cmd['name'])}_MWN = {funchash},""")
|
|
|
|
# just to make sure there are no hash collisions, we wouldn't want that
|
|
global _dbg_hashes
|
|
assert(funchash not in _dbg_hashes)
|
|
_dbg_hashes.add(funchash)
|
|
|
|
def generate(targets):
|
|
assert(len(targets) == 1)
|
|
with open(targets[0], 'w') as f:
|
|
write_preamble(f, includes = ['<vulkan/vulkan.h>'], header_guard=HEADER_GUARD, c_file=True)
|
|
commands = list(vulkan_hpp['commands'].values())
|
|
commands.sort(key=lambda cmd: cmd['platform'])
|
|
plat = ''
|
|
f.write("""
|
|
typedef enum VkFunctionMWN {""")
|
|
for cmd in commands:
|
|
if plat != cmd['platform']:
|
|
if plat != '':
|
|
f.write(f"""
|
|
#endif // defined({vulkan_hpp['platforms'][plat]['protect']})\n""")
|
|
plat = cmd['platform']
|
|
f.write(f"""
|
|
#if defined({vulkan_hpp['platforms'][plat]['protect']})\n""")
|
|
write_funcid(f, cmd)
|
|
# finish the final platform
|
|
f.write(f"""#endif // defined({vulkan_hpp['platforms'][plat]['protect']})\n""")
|
|
f.write("""
|
|
} VkFunctionMWN;
|
|
""")
|
|
write_epilogue(f, header_guard=HEADER_GUARD, c_file=True)
|