Skip to content

Commit 1bf9355

Browse files
committed
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 c8cf35f commit 1bf9355

7 files changed

Lines changed: 465 additions & 85 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: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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).
@@ -31,8 +31,6 @@
3131
# ===========================================================================
3232

3333
from os import system, remove
34-
from sys import executable
35-
from subprocess import run
3634

3735
headers = [
3836
( "vulkan_core", "w", "" ),
@@ -43,23 +41,20 @@
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-
5349
for 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

6156
with 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

@@ -68,7 +63,7 @@
6863

6964
with 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\nvoid VulkanLoadInstanceFunctions( VkInstance instance ) {\n' )
7469
out.write( inp.read() )
@@ -77,6 +72,65 @@
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( "\tFeaturesConfig 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( "\tconst 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+
80123
remove( "FunctionDecls.h" )
81124
remove( "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

Comments
 (0)