1+ # =============================================================================
2+ # Daemon-vulkan BSD Source Code
3+ # Copyright (c) 2025-2026 Reaper
4+ # All rights reserved.
5+ #
6+ # Redistribution and use in source and binary forms, with or without
7+ # modification, are permitted provided that the following conditions are met:
8+ # * Redistributions of source code must retain the above copyright
9+ # notice, this list of conditions and the following disclaimer.
10+ # * Redistributions in binary form must reproduce the above copyright
11+ # notice, this list of conditions and the following disclaimer in the
12+ # documentation and/or other materials provided with the distribution.
13+ # * Neither the name of the Reaper nor the
14+ # names of its contributors may be used to endorse or promote products
15+ # derived from this software without specific prior written permission.
16+ #
17+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
18+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+ # DISCLAIMED. IN NO EVENT SHALL REAPER BE LIABLE FOR ANY
21+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ # =============================================================================
28+
29+ from os import system , remove
30+ from sys import executable
31+ from subprocess import run
32+
33+ headers = [
34+ ( "vulkan_core" , "w" , "" ),
35+ ( "vulkan_beta" , "a" , "VK_ENABLE_BETA_EXTENSIONS" ),
36+ ( "vulkan_win32" , "a" , "VK_USE_PLATFORM_WIN32_KHR" ),
37+ ( "vulkan_wayland" , "a" , "VK_USE_PLATFORM_WAYLAND_KHR" ),
38+ ( "vulkan_xlib" , "a" , "VK_USE_PLATFORM_XLIB_KHR" ),
39+ ( "vulkan_xlib_xrandr" , "a" , "VK_USE_PLATFORM_XLIB_XRANDR_EXT" )
40+ ]
41+
42+ with open ( "FunctionDecls.h" , "w" ) as f :
43+ with open ( "FunctionLoaderInstance.cpp" , "w" ) as f1 :
44+ with open ( "FunctionLoaderDevice.cpp" , "w" ) as f2 :
45+ print ( "" )
46+
47+ vulkanLoaderPath = "../../src/engine/renderer-vulkan/VulkanLoader/"
48+
49+ for header in headers :
50+ if header [2 ]:
51+ run ( [executable , "genvk.py" , "-o" , vulkanLoaderPath + "vulkan/" , "-apiname" , "vulkan" , "-mode" , header [1 ],
52+ "-define" , header [2 ], header [0 ] + ".h" ], check = True )
53+ else :
54+ run ( [executable , "genvk.py" , "-o" , vulkanLoaderPath + "vulkan/" , "-apiname" , "vulkan" , "-mode" , header [1 ],
55+ header [0 ] + ".h" ], check = True )
56+
57+ with open ( "FunctionDecls.h" , "r" ) as inp :
58+ with open ( vulkanLoaderPath + "Vulkan.h" , "w" ) as out :
59+ out .write ( inp .read () )
60+ out .write ( '#endif // VULKAN_LOADER_H' )
61+
62+ with open ( 'VulkanLoadFunctions.cpp' , mode = 'r' , encoding = 'utf-8' , newline = '\n ' ) as inp :
63+ functionLoadStart = inp .read ()
64+
65+ with open ( "FunctionLoaderInstance.cpp" , "r" ) as inp :
66+ with open ( "FunctionLoaderDevice.cpp" , "r" ) as inp2 :
67+ with open ( vulkanLoaderPath + "VulkanLoadFunctions.cpp" , "w" ) as out :
68+ out .write ( functionLoadStart )
69+ out .write ( '\n \n void VulkanLoadInstanceFunctions( VkInstance instance ) {\n ' )
70+ out .write ( inp .read () )
71+ out .write ( '}\n \n ' )
72+ out .write ( 'void VulkanLoadDeviceFunctions( VkDevice device ) {\n ' )
73+ out .write ( inp2 .read () )
74+ out .write ( '}' )
75+
76+ remove ( "FunctionDecls.h" )
77+ remove ( "FunctionLoaderInstance.cpp" )
78+ remove ( "FunctionLoaderDevice.cpp" )
0 commit comments