Skip to content

Commit 06e811d

Browse files
ReaperReaper
authored andcommitted
Update VulkanHeaders
- fix bitwidth, don't load funcpointer - move header processing to Globals - generate FeaturesConfigMap, FeaturesConfig and the loader for it - skip useless shit extension features
1 parent d1f104c commit 06e811d

7 files changed

Lines changed: 563 additions & 183 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Auto-generated, do not modify
2+
3+
#include "Vulkan.h"
4+
5+
#include "GraphicsCoreStore.h"
6+
7+
#include "EngineConfig.h"
8+
9+
#include "FeaturesConfig.h"
10+
11+
FeaturesConfig GetPhysicalDeviceFeatures( const VkPhysicalDevice physicalDevice, const EngineConfig& engineCfg ) {
12+
const bool intelWorkaround = std::string( engineCfg.driverName ).find( "Intel" ) != std::string::npos;
13+

libs/VulkanHeaders/GenerateAll.py

Lines changed: 132 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,132 @@
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\nvoid 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" )
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+
31+
headers = [
32+
( "vulkan_core", "w", "" ),
33+
( "vulkan_beta", "a", "VK_ENABLE_BETA_EXTENSIONS" ),
34+
( "vulkan_win32", "a", "VK_USE_PLATFORM_WIN32_KHR" ),
35+
( "vulkan_wayland", "a", "VK_USE_PLATFORM_WAYLAND_KHR" ),
36+
( "vulkan_xlib", "a", "VK_USE_PLATFORM_XLIB_KHR" ),
37+
( "vulkan_xlib_xrandr", "a", "VK_USE_PLATFORM_XLIB_XRANDR_EXT" )
38+
]
39+
40+
with open( "FunctionDecls.h", "w", encoding = 'utf-8' ) as f:
41+
with open( "FunctionLoaderInstance.cpp", "w", encoding = 'utf-8' ) as f1:
42+
with open( "FunctionLoaderDevice.cpp", "w", encoding = 'utf-8' ) as f2:
43+
print( "" )
44+
45+
for header in headers:
46+
if header[2]:
47+
define = " -define " + header[2]
48+
else:
49+
define = ""
50+
system( "python genvk.py -o ../../../src/engine/renderer-vulkan/VulkanLoader/vulkan -apiname vulkan -mode " + header[1] + define + " " + header[0] + ".h" )
51+
52+
with open( "FunctionDecls.h", "r" ) as inp:
53+
with open( "../../../src/engine/renderer-vulkan/VulkanLoader/Vulkan.h", mode = 'w', encoding = 'utf-8', newline = '' ) as out:
54+
out.write( inp.read() )
55+
out.write( '#endif // VULKAN_LOADER_H' )
56+
57+
with open( 'VulkanLoadFunctions.cpp', mode = 'r', encoding = 'utf-8', newline = '\n' ) as inp:
58+
functionLoadStart = inp.read()
59+
60+
with open( "FunctionLoaderInstance.cpp", "r" ) as inp:
61+
with open( "FunctionLoaderDevice.cpp", "r" ) as inp2:
62+
with open( "../../../src/engine/renderer-vulkan/VulkanLoader/VulkanLoadFunctions.cpp", mode = 'w', encoding = 'utf-8', newline = '' ) as out:
63+
out.write( functionLoadStart )
64+
out.write( '\n\nvoid VulkanLoadInstanceFunctions( VkInstance instance ) {\n' )
65+
out.write( inp.read() )
66+
out.write( '}\n\n' )
67+
out.write( 'void VulkanLoadDeviceFunctions( VkDevice device ) {\n' )
68+
out.write( inp2.read() )
69+
out.write( '}' )
70+
71+
with open( 'FeaturesConfig.cpp', mode = 'r', encoding = 'utf-8', newline = '' ) as inp:
72+
featuresConfigStart = inp.read()
73+
74+
with open( "FeaturesConfigGet", mode = 'r' ) as inpGet:
75+
with open( "FeaturesConfigCreate", mode = 'r' ) as inpCreate:
76+
with open( "FeaturesConfigGetMain", mode = 'r' ) as inpGetMain:
77+
with open( "FeaturesConfigCreateMain", mode = 'r' ) as inpCreateMain:
78+
with open( "FeaturesConfigCreateDevice", mode = 'r' ) as inpCreateDevice:
79+
with open( "FeaturesConfigCreateDeviceMain", mode = 'r' ) as inpCreateDeviceMain:
80+
with open( "../../../src/engine/renderer-vulkan/GraphicsCore/FeaturesConfig.cpp", mode = 'w', encoding = 'utf-8', newline = '' ) as out:
81+
out.write( featuresConfigStart )
82+
out.write( inpGet.read() )
83+
out.write( inpGetMain.read() )
84+
out.write( "\tFeaturesConfig cfg {\n" )
85+
out.write( inpCreate.read() )
86+
out.write( inpCreateMain.read() )
87+
out.write( "int CreateDevice( VkDeviceCreateInfo& deviceInfo, const VkAllocationCallbacks* allocator,\n" )
88+
out.write( " const EngineConfig& engineCfg, const FeaturesConfig& cfg, VkDevice* device ) {\n" )
89+
out.write( "\tconst bool intelWorkaround = std::string( engineCfg.driverName ).find( \"Intel\" ) != std::string::npos;\n\n" )
90+
out.write( inpCreateDevice.read() )
91+
out.write( inpCreateDeviceMain.read() )
92+
93+
with open( "FeaturesConfig.h", mode = 'r' ) as inpCfg:
94+
with open( "FeaturesConfigMain.h", mode = 'r' ) as inpCfgMain:
95+
with open( "../../../src/engine/renderer-vulkan/GraphicsCore/FeaturesConfig.h", mode = 'w', encoding = 'utf-8', newline = '' ) as out:
96+
out.write( "// Auto-generated, do not modify\n\n" )
97+
out.write( "#ifndef FEATURES_CONFIG_H\n" )
98+
out.write( "#define FEATURES_CONFIG_H\n\n" )
99+
out.write( "#include \"Decls.h\"\n\n" )
100+
out.write( "struct FeaturesConfig {\n" )
101+
out.write( inpCfg.read() )
102+
out.write( inpCfgMain.read() )
103+
out.write( "};\n\n" )
104+
out.write( "FeaturesConfig GetPhysicalDeviceFeatures( const VkPhysicalDevice physicalDevice, const EngineConfig& engineCfg );\n\n" )
105+
out.write( "int CreateDevice( VkDeviceCreateInfo& deviceInfo, const VkAllocationCallbacks* allocator,\n" )
106+
out.write( " const EngineConfig& engineCfg, const FeaturesConfig& cfg, VkDevice* device );\n\n" )
107+
out.write( "#endif // FEATURES_CONFIG_H\n" )
108+
109+
with open( "FeaturesConfigMap", mode = 'r' ) as inpMap:
110+
with open( "FeaturesConfigMapMain", mode = 'r' ) as inpMapMain:
111+
with open( "../../../src/engine/renderer-vulkan/GraphicsCore/FeaturesConfigMap.cpp", mode = 'w', encoding = 'utf-8', newline = '' ) as out:
112+
out.write( "// Auto-generated, do not modify\n\n" )
113+
out.write( "#include \"FeaturesConfig.h\"\n\n" )
114+
out.write( "#include \"FeaturesConfigMap.h\"\n\n" )
115+
out.write( "std::unordered_map<std::string, FeatureData> featuresConfigMap {\n" )
116+
out.write( inpMap.read() )
117+
out.write( inpMapMain.read().rstrip( "," ) + "};" )
118+
119+
remove( "FunctionDecls.h" )
120+
remove( "FunctionLoaderInstance.cpp" )
121+
remove( "FunctionLoaderDevice.cpp" )
122+
remove( "FeaturesConfig.h" )
123+
remove( "FeaturesConfigMain.h" )
124+
remove( "FeaturesConfigGet" )
125+
remove( "FeaturesConfigGetMain" )
126+
remove( "FeaturesConfigCreate" )
127+
remove( "FeaturesConfigCreateMain" )
128+
remove( "FeaturesConfigCreateDevice" )
129+
remove( "FeaturesConfigCreateDeviceMain" )
130+
remove( "FeaturesConfigMap" )
131+
remove( "FeaturesConfigMapMain" )
132+
remove( "prev" )

0 commit comments

Comments
 (0)