11# ===========================================================================
22#
33# Daemon BSD Source Code
4- # Copyright (c) 2025 Daemon Developers
4+ # Copyright (c) 2025-2026 Daemon Developers
55# All rights reserved.
66#
77# This file is part of the Daemon BSD Source Code (Daemon Source Code).
3131# ===========================================================================
3232
3333from os import system , remove
34- from sys import executable
35- from subprocess import run
3634
3735headers = [
3836 ( "vulkan_core" , "w" , "" ),
4341 ( "vulkan_xlib_xrandr" , "a" , "VK_USE_PLATFORM_XLIB_XRANDR_EXT" )
4442]
4543
46- with open ( "FunctionDecls.h" , "w" ) as f :
47- with open ( "FunctionLoaderInstance.cpp" , "w" ) as f1 :
48- with open ( "FunctionLoaderDevice.cpp" , "w" ) as f2 :
44+ with open ( "FunctionDecls.h" , "w" , encoding = 'utf-8' ) as f :
45+ with open ( "FunctionLoaderInstance.cpp" , "w" , encoding = 'utf-8' ) as f1 :
46+ with open ( "FunctionLoaderDevice.cpp" , "w" , encoding = 'utf-8' ) as f2 :
4947 print ( "" )
5048
51- vulkanLoaderPath = "../../src/engine/renderer-vulkan/VulkanLoader/"
52-
5349for header in headers :
5450 if header [2 ]:
55- run ( [executable , "genvk.py" , "-o" , vulkanLoaderPath + "vulkan/" , "-apiname" , "vulkan" , "-mode" , header [1 ],
56- "-define" , header [2 ], header [0 ] + ".h" ], check = True )
51+ define = " -define " + header [2 ]
5752 else :
58- run ( [ executable , "genvk.py" , "-o" , vulkanLoaderPath + "vulkan/" , "-apiname" , "vulkan" , "-mode" , header [ 1 ],
59- header [0 ] + ".h" ], check = True )
53+ define = ""
54+ system ( "python genvk.py -o ../../../src/engine/renderer-vulkan/VulkanLoader/vulkan -apiname vulkan -mode " + header [1 ] + define + " " + header [ 0 ] + ".h" )
6055
6156with open ( "FunctionDecls.h" , "r" ) as inp :
62- with open ( vulkanLoaderPath + " Vulkan.h" , "w" ) as out :
57+ with open ( "../../../src/engine/renderer-vulkan/VulkanLoader/ Vulkan.h" , mode = 'w' , encoding = 'utf-8' , newline = '' ) as out :
6358 out .write ( inp .read () )
6459 out .write ( '#endif // VULKAN_LOADER_H' )
6560
6863
6964with open ( "FunctionLoaderInstance.cpp" , "r" ) as inp :
7065 with open ( "FunctionLoaderDevice.cpp" , "r" ) as inp2 :
71- with open ( vulkanLoaderPath + " VulkanLoadFunctions.cpp" , "w" ) as out :
66+ with open ( "../../../src/engine/renderer-vulkan/VulkanLoader/ VulkanLoadFunctions.cpp" , mode = 'w' , encoding = 'utf-8' , newline = '' ) as out :
7267 out .write ( functionLoadStart )
7368 out .write ( '\n \n void VulkanLoadInstanceFunctions( VkInstance instance ) {\n ' )
7469 out .write ( inp .read () )
7772 out .write ( inp2 .read () )
7873 out .write ( '}' )
7974
75+ with open ( 'FeaturesConfig.cpp' , mode = 'r' , encoding = 'utf-8' , newline = '' ) as inp :
76+ featuresConfigStart = inp .read ()
77+
78+ with open ( "FeaturesConfigGet" , mode = 'r' ) as inpGet :
79+ with open ( "FeaturesConfigCreate" , mode = 'r' ) as inpCreate :
80+ with open ( "FeaturesConfigGetMain" , mode = 'r' ) as inpGetMain :
81+ with open ( "FeaturesConfigCreateMain" , mode = 'r' ) as inpCreateMain :
82+ with open ( "FeaturesConfigCreateDevice" , mode = 'r' ) as inpCreateDevice :
83+ with open ( "FeaturesConfigCreateDeviceMain" , mode = 'r' ) as inpCreateDeviceMain :
84+ with open ( "../../../src/engine/renderer-vulkan/GraphicsCore/FeaturesConfig.cpp" , mode = 'w' , encoding = 'utf-8' , newline = '' ) as out :
85+ out .write ( featuresConfigStart )
86+ out .write ( inpGet .read () )
87+ out .write ( inpGetMain .read () )
88+ out .write ( "\t FeaturesConfig cfg {\n " )
89+ out .write ( inpCreate .read () )
90+ out .write ( inpCreateMain .read () )
91+ out .write ( "int CreateDevice( VkDeviceCreateInfo& deviceInfo, const VkAllocationCallbacks* allocator,\n " )
92+ out .write ( " const EngineConfig& engineCfg, const FeaturesConfig& cfg, VkDevice* device ) {\n " )
93+ out .write ( "\t const bool intelWorkaround = std::string( engineCfg.driverName ).find( \" Intel\" ) != std::string::npos;\n \n " )
94+ out .write ( inpCreateDevice .read () )
95+ out .write ( inpCreateDeviceMain .read () )
96+
97+ with open ( "FeaturesConfig.h" , mode = 'r' ) as inpCfg :
98+ with open ( "FeaturesConfigMain.h" , mode = 'r' ) as inpCfgMain :
99+ with open ( "../../../src/engine/renderer-vulkan/GraphicsCore/FeaturesConfig.h" , mode = 'w' , encoding = 'utf-8' , newline = '' ) as out :
100+ out .write ( "// Auto-generated, do not modify\n \n " )
101+ out .write ( "#ifndef FEATURES_CONFIG_H\n " )
102+ out .write ( "#define FEATURES_CONFIG_H\n \n " )
103+ out .write ( "#include \" Decls.h\" \n \n " )
104+ out .write ( "struct FeaturesConfig {\n " )
105+ out .write ( inpCfg .read () )
106+ out .write ( inpCfgMain .read () )
107+ out .write ( "};\n \n " )
108+ out .write ( "FeaturesConfig GetPhysicalDeviceFeatures( const VkPhysicalDevice physicalDevice, const EngineConfig& engineCfg );\n \n " )
109+ out .write ( "int CreateDevice( VkDeviceCreateInfo& deviceInfo, const VkAllocationCallbacks* allocator,\n " )
110+ out .write ( " const EngineConfig& engineCfg, const FeaturesConfig& cfg, VkDevice* device );\n \n " )
111+ out .write ( "#endif // FEATURES_CONFIG_H\n " )
112+
113+ with open ( "FeaturesConfigMap" , mode = 'r' ) as inpMap :
114+ with open ( "FeaturesConfigMapMain" , mode = 'r' ) as inpMapMain :
115+ with open ( "../../../src/engine/renderer-vulkan/GraphicsCore/FeaturesConfigMap.cpp" , mode = 'w' , encoding = 'utf-8' , newline = '' ) as out :
116+ out .write ( "// Auto-generated, do not modify\n \n " )
117+ out .write ( "#include \" FeaturesConfig.h\" \n \n " )
118+ out .write ( "#include \" FeaturesConfigMap.h\" \n \n " )
119+ out .write ( "std::unordered_map<std::string, FeatureData> featuresConfigMap {\n " )
120+ out .write ( inpMap .read () )
121+ out .write ( inpMapMain .read ().rstrip ( "," ) + "};" )
122+
80123remove ( "FunctionDecls.h" )
81124remove ( "FunctionLoaderInstance.cpp" )
82- remove ( "FunctionLoaderDevice.cpp" )
125+ remove ( "FunctionLoaderDevice.cpp" )
126+ remove ( "FeaturesConfig.h" )
127+ remove ( "FeaturesConfigMain.h" )
128+ remove ( "FeaturesConfigGet" )
129+ remove ( "FeaturesConfigGetMain" )
130+ remove ( "FeaturesConfigCreate" )
131+ remove ( "FeaturesConfigCreateMain" )
132+ remove ( "FeaturesConfigCreateDevice" )
133+ remove ( "FeaturesConfigCreateDeviceMain" )
134+ remove ( "FeaturesConfigMap" )
135+ remove ( "FeaturesConfigMapMain" )
136+ remove ( "prev" )
0 commit comments