Header generation is working

- No loading yet
This commit is contained in:
Cody Goodson 2021-05-05 17:55:02 -05:00 committed by Charles Giessen
parent b06763b187
commit a0a0738299
2 changed files with 276 additions and 5 deletions

View File

@ -7,12 +7,54 @@ import xmltodict
with urllib.request.urlopen('https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/registry/vk.xml') as response: with urllib.request.urlopen('https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/registry/vk.xml') as response:
vk_xml_raw = response.read() vk_xml_raw = response.read()
vk_xml = xmltodict.parse(vk_xml_raw) vk_xml = xmltodict.parse(vk_xml_raw,process_namespaces=True)
commands = vk_xml['registry']['commands'] commands = vk_xml['registry']['commands']['command']
device_commands = [] device_commands = [];
device_aliases = {};
def format_header_top(header: str):
header += '\n#pragma once\n\n#include <vulkan/vulkan.h>\n\n'
header += 'namespace vkb {\n\n'
header += 'struct DispatchTable {\n'
return header;
def format_header_bottom(header: str):
header += '}\n\n'
header += '} // namespace vkb'
return header;
def format_declaration(header: str, name):
fptr_name = 'PFN_' + name
member_name = name[2].lower() + name[3:]
header += '\t' + fptr_name + ' ' + member_name + ' = nullptr;\n'
if name in device_aliases:
header = format_declaration(header, device_aliases[name])
return header;
for command in commands: for command in commands:
if(command['command']['proto']) keys = command.keys()
print(command['command']['proto']['name']) if 'proto' in keys and 'param' in keys:
type_device = False;
for p in command['param']:
if 'type' in p:
for t in p:
if t == 'type' and p[t] == 'VkDevice':
#only check first type
type_device = True;
break;
if type_device and command['proto']['name'] != 'vkGetDeviceProcAddr':
device_commands += [command['proto']['name']]
elif '@alias'in keys:
device_aliases[(command['@alias'])] = command['@name'];
header = ''
header = format_header_top(header)
for command in device_commands:
header = format_declaration(header, command);
header = format_header_bottom(header)
header_file = open("../src/VkDispatchTable.h", "w")
header_file.write(header)
header_file.close();

229
src/VkDispatchTable.h Normal file
View File

@ -0,0 +1,229 @@
#pragma once
#include <vulkan/vulkan.h>
namespace vkb {
struct DispatchTable {
PFN_vkCreateDevice createDevice = nullptr;
PFN_vkDestroyDevice destroyDevice = nullptr;
PFN_vkGetDeviceQueue getDeviceQueue = nullptr;
PFN_vkAllocateMemory allocateMemory = nullptr;
PFN_vkFreeMemory freeMemory = nullptr;
PFN_vkMapMemory mapMemory = nullptr;
PFN_vkUnmapMemory unmapMemory = nullptr;
PFN_vkFlushMappedMemoryRanges flushMappedMemoryRanges = nullptr;
PFN_vkInvalidateMappedMemoryRanges invalidateMappedMemoryRanges = nullptr;
PFN_vkGetDeviceMemoryCommitment getDeviceMemoryCommitment = nullptr;
PFN_vkGetBufferMemoryRequirements getBufferMemoryRequirements = nullptr;
PFN_vkBindBufferMemory bindBufferMemory = nullptr;
PFN_vkGetImageMemoryRequirements getImageMemoryRequirements = nullptr;
PFN_vkBindImageMemory bindImageMemory = nullptr;
PFN_vkGetImageSparseMemoryRequirements getImageSparseMemoryRequirements = nullptr;
PFN_vkCreateFence createFence = nullptr;
PFN_vkDestroyFence destroyFence = nullptr;
PFN_vkResetFences resetFences = nullptr;
PFN_vkGetFenceStatus getFenceStatus = nullptr;
PFN_vkWaitForFences waitForFences = nullptr;
PFN_vkCreateSemaphore createSemaphore = nullptr;
PFN_vkDestroySemaphore destroySemaphore = nullptr;
PFN_vkCreateEvent createEvent = nullptr;
PFN_vkDestroyEvent destroyEvent = nullptr;
PFN_vkGetEventStatus getEventStatus = nullptr;
PFN_vkSetEvent setEvent = nullptr;
PFN_vkResetEvent resetEvent = nullptr;
PFN_vkCreateQueryPool createQueryPool = nullptr;
PFN_vkDestroyQueryPool destroyQueryPool = nullptr;
PFN_vkGetQueryPoolResults getQueryPoolResults = nullptr;
PFN_vkResetQueryPool resetQueryPool = nullptr;
PFN_vkResetQueryPoolEXT resetQueryPoolEXT = nullptr;
PFN_vkCreateBuffer createBuffer = nullptr;
PFN_vkDestroyBuffer destroyBuffer = nullptr;
PFN_vkCreateBufferView createBufferView = nullptr;
PFN_vkDestroyBufferView destroyBufferView = nullptr;
PFN_vkCreateImage createImage = nullptr;
PFN_vkDestroyImage destroyImage = nullptr;
PFN_vkGetImageSubresourceLayout getImageSubresourceLayout = nullptr;
PFN_vkCreateImageView createImageView = nullptr;
PFN_vkDestroyImageView destroyImageView = nullptr;
PFN_vkCreateShaderModule createShaderModule = nullptr;
PFN_vkDestroyShaderModule destroyShaderModule = nullptr;
PFN_vkCreatePipelineCache createPipelineCache = nullptr;
PFN_vkDestroyPipelineCache destroyPipelineCache = nullptr;
PFN_vkGetPipelineCacheData getPipelineCacheData = nullptr;
PFN_vkMergePipelineCaches mergePipelineCaches = nullptr;
PFN_vkCreateGraphicsPipelines createGraphicsPipelines = nullptr;
PFN_vkCreateComputePipelines createComputePipelines = nullptr;
PFN_vkDestroyPipeline destroyPipeline = nullptr;
PFN_vkCreatePipelineLayout createPipelineLayout = nullptr;
PFN_vkDestroyPipelineLayout destroyPipelineLayout = nullptr;
PFN_vkCreateSampler createSampler = nullptr;
PFN_vkDestroySampler destroySampler = nullptr;
PFN_vkCreateDescriptorSetLayout createDescriptorSetLayout = nullptr;
PFN_vkDestroyDescriptorSetLayout destroyDescriptorSetLayout = nullptr;
PFN_vkCreateDescriptorPool createDescriptorPool = nullptr;
PFN_vkDestroyDescriptorPool destroyDescriptorPool = nullptr;
PFN_vkResetDescriptorPool resetDescriptorPool = nullptr;
PFN_vkAllocateDescriptorSets allocateDescriptorSets = nullptr;
PFN_vkFreeDescriptorSets freeDescriptorSets = nullptr;
PFN_vkUpdateDescriptorSets updateDescriptorSets = nullptr;
PFN_vkCreateFramebuffer createFramebuffer = nullptr;
PFN_vkDestroyFramebuffer destroyFramebuffer = nullptr;
PFN_vkCreateRenderPass createRenderPass = nullptr;
PFN_vkDestroyRenderPass destroyRenderPass = nullptr;
PFN_vkGetRenderAreaGranularity getRenderAreaGranularity = nullptr;
PFN_vkCreateCommandPool createCommandPool = nullptr;
PFN_vkDestroyCommandPool destroyCommandPool = nullptr;
PFN_vkResetCommandPool resetCommandPool = nullptr;
PFN_vkAllocateCommandBuffers allocateCommandBuffers = nullptr;
PFN_vkFreeCommandBuffers freeCommandBuffers = nullptr;
PFN_vkCreateSharedSwapchainsKHR createSharedSwapchainsKHR = nullptr;
PFN_vkCreateSwapchainKHR createSwapchainKHR = nullptr;
PFN_vkDestroySwapchainKHR destroySwapchainKHR = nullptr;
PFN_vkGetSwapchainImagesKHR getSwapchainImagesKHR = nullptr;
PFN_vkAcquireNextImageKHR acquireNextImageKHR = nullptr;
PFN_vkDebugMarkerSetObjectNameEXT debugMarkerSetObjectNameEXT = nullptr;
PFN_vkDebugMarkerSetObjectTagEXT debugMarkerSetObjectTagEXT = nullptr;
PFN_vkGetMemoryWin32HandleNV getMemoryWin32HandleNV = nullptr;
PFN_vkGetGeneratedCommandsMemoryRequirementsNV getGeneratedCommandsMemoryRequirementsNV = nullptr;
PFN_vkCreateIndirectCommandsLayoutNV createIndirectCommandsLayoutNV = nullptr;
PFN_vkDestroyIndirectCommandsLayoutNV destroyIndirectCommandsLayoutNV = nullptr;
PFN_vkTrimCommandPool trimCommandPool = nullptr;
PFN_vkTrimCommandPoolKHR trimCommandPoolKHR = nullptr;
PFN_vkGetMemoryWin32HandleKHR getMemoryWin32HandleKHR = nullptr;
PFN_vkGetMemoryWin32HandlePropertiesKHR getMemoryWin32HandlePropertiesKHR = nullptr;
PFN_vkGetMemoryFdKHR getMemoryFdKHR = nullptr;
PFN_vkGetMemoryFdPropertiesKHR getMemoryFdPropertiesKHR = nullptr;
PFN_vkGetMemoryZirconHandleFUCHSIA getMemoryZirconHandleFUCHSIA = nullptr;
PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA getMemoryZirconHandlePropertiesFUCHSIA = nullptr;
PFN_vkGetSemaphoreWin32HandleKHR getSemaphoreWin32HandleKHR = nullptr;
PFN_vkImportSemaphoreWin32HandleKHR importSemaphoreWin32HandleKHR = nullptr;
PFN_vkGetSemaphoreFdKHR getSemaphoreFdKHR = nullptr;
PFN_vkImportSemaphoreFdKHR importSemaphoreFdKHR = nullptr;
PFN_vkGetSemaphoreZirconHandleFUCHSIA getSemaphoreZirconHandleFUCHSIA = nullptr;
PFN_vkImportSemaphoreZirconHandleFUCHSIA importSemaphoreZirconHandleFUCHSIA = nullptr;
PFN_vkGetFenceWin32HandleKHR getFenceWin32HandleKHR = nullptr;
PFN_vkImportFenceWin32HandleKHR importFenceWin32HandleKHR = nullptr;
PFN_vkGetFenceFdKHR getFenceFdKHR = nullptr;
PFN_vkImportFenceFdKHR importFenceFdKHR = nullptr;
PFN_vkDisplayPowerControlEXT displayPowerControlEXT = nullptr;
PFN_vkRegisterDeviceEventEXT registerDeviceEventEXT = nullptr;
PFN_vkRegisterDisplayEventEXT registerDisplayEventEXT = nullptr;
PFN_vkGetSwapchainCounterEXT getSwapchainCounterEXT = nullptr;
PFN_vkGetDeviceGroupPeerMemoryFeatures getDeviceGroupPeerMemoryFeatures = nullptr;
PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR getDeviceGroupPeerMemoryFeaturesKHR = nullptr;
PFN_vkBindBufferMemory2 bindBufferMemory2 = nullptr;
PFN_vkBindBufferMemory2KHR bindBufferMemory2KHR = nullptr;
PFN_vkBindImageMemory2 bindImageMemory2 = nullptr;
PFN_vkBindImageMemory2KHR bindImageMemory2KHR = nullptr;
PFN_vkGetDeviceGroupPresentCapabilitiesKHR getDeviceGroupPresentCapabilitiesKHR = nullptr;
PFN_vkGetDeviceGroupSurfacePresentModesKHR getDeviceGroupSurfacePresentModesKHR = nullptr;
PFN_vkAcquireNextImage2KHR acquireNextImage2KHR = nullptr;
PFN_vkCreateDescriptorUpdateTemplate createDescriptorUpdateTemplate = nullptr;
PFN_vkCreateDescriptorUpdateTemplateKHR createDescriptorUpdateTemplateKHR = nullptr;
PFN_vkDestroyDescriptorUpdateTemplate destroyDescriptorUpdateTemplate = nullptr;
PFN_vkDestroyDescriptorUpdateTemplateKHR destroyDescriptorUpdateTemplateKHR = nullptr;
PFN_vkUpdateDescriptorSetWithTemplate updateDescriptorSetWithTemplate = nullptr;
PFN_vkUpdateDescriptorSetWithTemplateKHR updateDescriptorSetWithTemplateKHR = nullptr;
PFN_vkSetHdrMetadataEXT setHdrMetadataEXT = nullptr;
PFN_vkGetSwapchainStatusKHR getSwapchainStatusKHR = nullptr;
PFN_vkGetRefreshCycleDurationGOOGLE getRefreshCycleDurationGOOGLE = nullptr;
PFN_vkGetPastPresentationTimingGOOGLE getPastPresentationTimingGOOGLE = nullptr;
PFN_vkGetBufferMemoryRequirements2 getBufferMemoryRequirements2 = nullptr;
PFN_vkGetBufferMemoryRequirements2KHR getBufferMemoryRequirements2KHR = nullptr;
PFN_vkGetImageMemoryRequirements2 getImageMemoryRequirements2 = nullptr;
PFN_vkGetImageMemoryRequirements2KHR getImageMemoryRequirements2KHR = nullptr;
PFN_vkGetImageSparseMemoryRequirements2 getImageSparseMemoryRequirements2 = nullptr;
PFN_vkGetImageSparseMemoryRequirements2KHR getImageSparseMemoryRequirements2KHR = nullptr;
PFN_vkCreateSamplerYcbcrConversion createSamplerYcbcrConversion = nullptr;
PFN_vkCreateSamplerYcbcrConversionKHR createSamplerYcbcrConversionKHR = nullptr;
PFN_vkDestroySamplerYcbcrConversion destroySamplerYcbcrConversion = nullptr;
PFN_vkDestroySamplerYcbcrConversionKHR destroySamplerYcbcrConversionKHR = nullptr;
PFN_vkGetDeviceQueue2 getDeviceQueue2 = nullptr;
PFN_vkCreateValidationCacheEXT createValidationCacheEXT = nullptr;
PFN_vkDestroyValidationCacheEXT destroyValidationCacheEXT = nullptr;
PFN_vkGetValidationCacheDataEXT getValidationCacheDataEXT = nullptr;
PFN_vkMergeValidationCachesEXT mergeValidationCachesEXT = nullptr;
PFN_vkGetDescriptorSetLayoutSupport getDescriptorSetLayoutSupport = nullptr;
PFN_vkGetDescriptorSetLayoutSupportKHR getDescriptorSetLayoutSupportKHR = nullptr;
PFN_vkGetSwapchainGrallocUsageANDROID getSwapchainGrallocUsageANDROID = nullptr;
PFN_vkGetSwapchainGrallocUsage2ANDROID getSwapchainGrallocUsage2ANDROID = nullptr;
PFN_vkAcquireImageANDROID acquireImageANDROID = nullptr;
PFN_vkGetShaderInfoAMD getShaderInfoAMD = nullptr;
PFN_vkSetLocalDimmingAMD setLocalDimmingAMD = nullptr;
PFN_vkGetCalibratedTimestampsEXT getCalibratedTimestampsEXT = nullptr;
PFN_vkSetDebugUtilsObjectNameEXT setDebugUtilsObjectNameEXT = nullptr;
PFN_vkSetDebugUtilsObjectTagEXT setDebugUtilsObjectTagEXT = nullptr;
PFN_vkGetMemoryHostPointerPropertiesEXT getMemoryHostPointerPropertiesEXT = nullptr;
PFN_vkCreateRenderPass2 createRenderPass2 = nullptr;
PFN_vkCreateRenderPass2KHR createRenderPass2KHR = nullptr;
PFN_vkGetSemaphoreCounterValue getSemaphoreCounterValue = nullptr;
PFN_vkGetSemaphoreCounterValueKHR getSemaphoreCounterValueKHR = nullptr;
PFN_vkWaitSemaphores waitSemaphores = nullptr;
PFN_vkWaitSemaphoresKHR waitSemaphoresKHR = nullptr;
PFN_vkSignalSemaphore signalSemaphore = nullptr;
PFN_vkSignalSemaphoreKHR signalSemaphoreKHR = nullptr;
PFN_vkGetAndroidHardwareBufferPropertiesANDROID getAndroidHardwareBufferPropertiesANDROID = nullptr;
PFN_vkGetMemoryAndroidHardwareBufferANDROID getMemoryAndroidHardwareBufferANDROID = nullptr;
PFN_vkCompileDeferredNV compileDeferredNV = nullptr;
PFN_vkCreateAccelerationStructureNV createAccelerationStructureNV = nullptr;
PFN_vkDestroyAccelerationStructureKHR destroyAccelerationStructureKHR = nullptr;
PFN_vkDestroyAccelerationStructureNV destroyAccelerationStructureNV = nullptr;
PFN_vkGetAccelerationStructureMemoryRequirementsNV getAccelerationStructureMemoryRequirementsNV = nullptr;
PFN_vkBindAccelerationStructureMemoryNV bindAccelerationStructureMemoryNV = nullptr;
PFN_vkCopyAccelerationStructureKHR copyAccelerationStructureKHR = nullptr;
PFN_vkCopyAccelerationStructureToMemoryKHR copyAccelerationStructureToMemoryKHR = nullptr;
PFN_vkCopyMemoryToAccelerationStructureKHR copyMemoryToAccelerationStructureKHR = nullptr;
PFN_vkWriteAccelerationStructuresPropertiesKHR writeAccelerationStructuresPropertiesKHR = nullptr;
PFN_vkGetRayTracingShaderGroupHandlesKHR getRayTracingShaderGroupHandlesKHR = nullptr;
PFN_vkGetRayTracingShaderGroupHandlesNV getRayTracingShaderGroupHandlesNV = nullptr;
PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR getRayTracingCaptureReplayShaderGroupHandlesKHR = nullptr;
PFN_vkGetAccelerationStructureHandleNV getAccelerationStructureHandleNV = nullptr;
PFN_vkCreateRayTracingPipelinesNV createRayTracingPipelinesNV = nullptr;
PFN_vkCreateRayTracingPipelinesKHR createRayTracingPipelinesKHR = nullptr;
PFN_vkGetDeviceAccelerationStructureCompatibilityKHR getDeviceAccelerationStructureCompatibilityKHR = nullptr;
PFN_vkGetRayTracingShaderGroupStackSizeKHR getRayTracingShaderGroupStackSizeKHR = nullptr;
PFN_vkGetImageViewHandleNVX getImageViewHandleNVX = nullptr;
PFN_vkGetImageViewAddressNVX getImageViewAddressNVX = nullptr;
PFN_vkGetDeviceGroupSurfacePresentModes2EXT getDeviceGroupSurfacePresentModes2EXT = nullptr;
PFN_vkAcquireFullScreenExclusiveModeEXT acquireFullScreenExclusiveModeEXT = nullptr;
PFN_vkReleaseFullScreenExclusiveModeEXT releaseFullScreenExclusiveModeEXT = nullptr;
PFN_vkAcquireProfilingLockKHR acquireProfilingLockKHR = nullptr;
PFN_vkGetImageDrmFormatModifierPropertiesEXT getImageDrmFormatModifierPropertiesEXT = nullptr;
PFN_vkGetBufferOpaqueCaptureAddress getBufferOpaqueCaptureAddress = nullptr;
PFN_vkGetBufferOpaqueCaptureAddressKHR getBufferOpaqueCaptureAddressKHR = nullptr;
PFN_vkGetBufferDeviceAddress getBufferDeviceAddress = nullptr;
PFN_vkGetBufferDeviceAddressEXT getBufferDeviceAddressEXT = nullptr;
PFN_vkInitializePerformanceApiINTEL initializePerformanceApiINTEL = nullptr;
PFN_vkAcquirePerformanceConfigurationINTEL acquirePerformanceConfigurationINTEL = nullptr;
PFN_vkReleasePerformanceConfigurationINTEL releasePerformanceConfigurationINTEL = nullptr;
PFN_vkGetPerformanceParameterINTEL getPerformanceParameterINTEL = nullptr;
PFN_vkGetDeviceMemoryOpaqueCaptureAddress getDeviceMemoryOpaqueCaptureAddress = nullptr;
PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR getDeviceMemoryOpaqueCaptureAddressKHR = nullptr;
PFN_vkGetPipelineExecutablePropertiesKHR getPipelineExecutablePropertiesKHR = nullptr;
PFN_vkGetPipelineExecutableStatisticsKHR getPipelineExecutableStatisticsKHR = nullptr;
PFN_vkGetPipelineExecutableInternalRepresentationsKHR getPipelineExecutableInternalRepresentationsKHR = nullptr;
PFN_vkCreateAccelerationStructureKHR createAccelerationStructureKHR = nullptr;
PFN_vkBuildAccelerationStructuresKHR buildAccelerationStructuresKHR = nullptr;
PFN_vkGetAccelerationStructureDeviceAddressKHR getAccelerationStructureDeviceAddressKHR = nullptr;
PFN_vkCreateDeferredOperationKHR createDeferredOperationKHR = nullptr;
PFN_vkDestroyDeferredOperationKHR destroyDeferredOperationKHR = nullptr;
PFN_vkGetDeferredOperationMaxConcurrencyKHR getDeferredOperationMaxConcurrencyKHR = nullptr;
PFN_vkGetDeferredOperationResultKHR getDeferredOperationResultKHR = nullptr;
PFN_vkDeferredOperationJoinKHR deferredOperationJoinKHR = nullptr;
PFN_vkCreatePrivateDataSlotEXT createPrivateDataSlotEXT = nullptr;
PFN_vkDestroyPrivateDataSlotEXT destroyPrivateDataSlotEXT = nullptr;
PFN_vkSetPrivateDataEXT setPrivateDataEXT = nullptr;
PFN_vkGetPrivateDataEXT getPrivateDataEXT = nullptr;
PFN_vkGetAccelerationStructureBuildSizesKHR getAccelerationStructureBuildSizesKHR = nullptr;
PFN_vkCreateVideoSessionKHR createVideoSessionKHR = nullptr;
PFN_vkDestroyVideoSessionKHR destroyVideoSessionKHR = nullptr;
PFN_vkCreateVideoSessionParametersKHR createVideoSessionParametersKHR = nullptr;
PFN_vkUpdateVideoSessionParametersKHR updateVideoSessionParametersKHR = nullptr;
PFN_vkDestroyVideoSessionParametersKHR destroyVideoSessionParametersKHR = nullptr;
PFN_vkGetVideoSessionMemoryRequirementsKHR getVideoSessionMemoryRequirementsKHR = nullptr;
PFN_vkBindVideoSessionMemoryKHR bindVideoSessionMemoryKHR = nullptr;
}
} // namespace vkb