1515from generator import GeneratorOptions , OutputGenerator , noneStr , write
1616from apiconventions import APIConventions
1717
18+ import Globals
19+
1820def apiNameMatch (str , supported ):
1921 """Return whether a required api name matches a pattern specified for an
2022 XML <feature> 'api' attribute or <extension> 'supported' attribute.
@@ -1656,7 +1658,7 @@ def tagValidExtensionStructs(self):
16561658 for parent in self .validextensionstructs :
16571659 self .validextensionstructs [parent ].sort ()
16581660
1659- def apiGen (self ):
1661+ def apiGen (self , inputDir , outputDir , mode , define ):
16601662 """Generate interface for specified versions using the current
16611663 generator and generator options"""
16621664
@@ -1844,6 +1846,18 @@ def apiGen(self):
18441846 # generated.
18451847 self .gen .logMsg ('diag' , 'PASS 3: GENERATE INTERFACES FOR FEATURES' )
18461848 self .gen .beginFile (self .genOpts )
1849+
1850+ headerStart = ''
1851+ functionLoadStart = ''
1852+ if mode == "w" :
1853+ with open ( inputDir + 'Vulkan.h' , mode = 'r' , encoding = 'utf-8' , newline = '\n ' ) as inp :
1854+ headerStart = inp .read ()
1855+
1856+ with open ( inputDir + 'VulkanLoadFunctions.cpp' , mode = 'r' , encoding = 'utf-8' , newline = '\n ' ) as inp :
1857+ functionLoadStart = inp .read ()
1858+
1859+ Globals .init ()
1860+
18471861 for f in features :
18481862 self .gen .logMsg ('diag' , 'PASS 3: Generating interface for' ,
18491863 f .name )
@@ -1870,6 +1884,59 @@ def apiGen(self):
18701884 for s in self .syncpipelinedict :
18711885 self .generateSyncPipeline (self .syncpipelinedict [s ])
18721886 self .gen .endFile ()
1887+
1888+ outputDir = outputDir .rstrip ( '/' ).rsplit ( '/' , 1 )[0 ] + '/'
1889+
1890+ indent = "\t " if define else ""
1891+
1892+ with open ( 'FunctionDecls.h' , mode = mode , encoding = 'utf-8' , newline = '\n ' ) as out :
1893+ if define :
1894+ out .write ( "#if defined( " + define + " )\n " )
1895+
1896+ out .write ( headerStart + indent + Globals .headerText )
1897+
1898+ if define :
1899+ out .write ( "#endif\n \n " )
1900+
1901+ with open ( outputDir + 'Vulkan.cpp' , mode = mode , encoding = 'utf-8' , newline = '\n ' ) as out :
1902+ if mode == "w" :
1903+ out .write ( '// Auto-generated, do not modify\n \n ' )
1904+ out .write ( '#include "Vulkan.h"\n \n ' )
1905+
1906+ if define :
1907+ out .write ( "#if defined( " + define + " )\n " )
1908+
1909+ out .write ( indent + Globals .functionDefinitionsText )
1910+
1911+ if define :
1912+ out .write ( "#endif\n \n " )
1913+
1914+ #with open( outputDir + 'VulkanLoadFunctions.cpp', mode = mode, encoding = 'utf-8', newline = '\n' ) as out:
1915+ # out.write( functionLoadStart )
1916+ # out.write( '\n\nvoid VulkanLoadInstanceFunctions( VkInstance instance ) {\n' )
1917+ # out.write( Globals.functionLoadInstanceText )
1918+ # out.write( '}\n\n' )
1919+ # out.write( 'void VulkanLoadDeviceFunctions( VkDevice device ) {\n' )
1920+ # out.write( Globals.functionLoadDeviceText )
1921+ # out.write( '}' )
1922+
1923+ with open ( 'FunctionLoaderInstance.cpp' , mode = mode , encoding = 'utf-8' , newline = '\n ' ) as out :
1924+ if define :
1925+ out .write ( "#if defined( " + define + " )\n " )
1926+
1927+ out .write ( Globals .functionLoadInstanceText )
1928+
1929+ if define :
1930+ out .write ( "#endif\n \n " )
1931+
1932+ with open ( 'FunctionLoaderDevice.cpp' , mode = mode , encoding = 'utf-8' , newline = '\n ' ) as out :
1933+ if define :
1934+ out .write ( "#if defined( " + define + " )\n " )
1935+
1936+ out .write ( Globals .functionLoadDeviceText )
1937+
1938+ if define :
1939+ out .write ( "#endif\n \n " )
18731940
18741941 def apiReset (self ):
18751942 """Reset type/enum/command dictionaries before generating another API.
0 commit comments