Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Fossilize/extract_vulkan_extensions_sifter.py at master · ValveSoftware/Fossilize · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
ValveSoftware
Fossilize
Repository navigation
Code
Issues
36
(36)
Pull requests
4
(4)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Fossilize
/
extract_vulkan_extensions_sifter.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
165 lines (140 loc) · 5.81 KB
master
Breadcrumbs
Fossilize
/
extract_vulkan_extensions_sifter.py
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
165 lines (140 loc) · 5.81 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python3
import
argparse
from
collections
import
namedtuple
import
xml
.
etree
.
ElementTree
as
ET
import
json
import
sys
def
is_banned_ext
(
ext
):
if
'Scissor'
in
ext
:
return
False
if
'DisplacementMicromap'
in
ext
:
return
True
if
'CudaKernelLaunch'
in
ext
:
return
True
banned_vendors
=
[
'ANDROID'
,
'AMDX'
,
'Sci'
,
'Portability'
,
'VulkanSC'
,
'QNX'
]
for
vendor
in
banned_vendors
:
if
vendor
in
ext
:
return
True
return
False
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Script for extracting what needs to be sifted through w.r.t. PDF2.'
)
parser
.
add_argument
(
'--xml'
,
help
=
'Path to Vulkan registry XML.'
)
args
=
parser
.
parse_args
()
if
not
args
.
xml
:
sys
.
stderr
.
write
(
'Need XML.
\n
'
)
sys
.
exit
(
1
)
tree
=
ET
.
parse
(
args
.
xml
)
root
=
tree
.
getroot
()
struct_types
=
{}
enum_types
=
{}
bitmask_requirements
=
{}
type_aliases
=
{}
feature_structs
=
{}
for
t
in
root
.
find
(
'types'
).
iter
(
'type'
):
if
'alias'
in
t
.
attrib
:
type_aliases
[
t
.
attrib
[
'name'
]]
=
t
.
attrib
[
'alias'
]
pNextLUT
=
[]
for
t
in
root
.
find
(
'types'
).
iter
(
'type'
):
if
'category'
not
in
t
.
attrib
:
continue
category
=
t
.
attrib
[
'category'
]
if
category
==
'struct'
:
name
=
t
.
attrib
[
'name'
]
if
is_banned_ext
(
name
):
continue
member_types
=
[]
extended_types
=
set
()
extends
=
set
()
if
'structextends'
in
t
.
attrib
:
extends
=
t
.
attrib
[
'structextends'
].
split
(
','
)
extends
=
set
([
type_aliases
.
get
(
x
,
x
)
for
x
in
extends
])
if
(
'VkPhysicalDeviceFeatures2'
in
extends
)
or
(
'VkPhysicalDeviceFeatures2KHR'
in
extends
):
stype
=
t
.
find
(
'member'
).
attrib
[
'values'
]
if
name
not
in
type_aliases
:
pNextLUT
.
append
((
stype
,
name
))
feature_structs
[
name
]
=
stype
print
(
'#pragma once'
)
print
(
'// Autogenerated from extract_vulkan_extensions_sifter.py'
)
print
(
'#include <string>'
)
print
(
'static const struct {'
)
print
(
'
\t
VkStructureType sType;'
)
print
(
'
\t
size_t size;'
)
print
(
'} pNextLUT[] = {'
)
for
entry
in
pNextLUT
:
print
(
'
\t
{'
,
entry
[
0
]
+
','
,
f'sizeof(
{
entry
[
1
]
}
)'
,
'},'
)
print
(
'};
\n
'
)
print
(
'struct ExtensionRequirements {'
)
print
(
'
\t
void *primary_feature;'
)
print
(
'
\t
void *secondary_feature;'
)
print
(
'
\t
const char * const *extension_dependencies;'
)
print
(
'
\t
uint32_t num_extension_dependencies;'
)
print
(
'
\t
uint32_t minimum_api_version;'
)
print
(
'};
\n
'
)
member_names
=
[]
print
(
'struct ExistingFeatureStructs {'
)
for
feat
in
feature_structs
:
print
(
f'
\t
{
feat
}
m
{
feat
[
16
:]
}
='
,
'{'
,
feature_structs
[
feat
],
'};'
)
member_names
.
append
(
feat
[
16
:])
info_impl
=
[]
for
ext
in
root
.
find
(
'extensions'
).
iter
(
'extension'
):
if
(
'vulkan'
in
ext
.
attrib
[
'supported'
].
split
(
','
))
and
(
ext
.
attrib
[
'type'
]
==
'device'
):
ext_name
=
ext
.
attrib
[
'name'
]
deps
=
ext
.
attrib
[
'depends'
]
if
'depends'
in
ext
.
attrib
else
None
if
is_banned_ext
(
ext_name
):
continue
core_dep
=
'VK_VERSION_1_0'
ext_deps
=
[]
# Crude parsing. Don't want to implement basic grammar here, so just do
# the minimal hackery needed to parse the xml.
# Just consider everything "and".
if
deps
:
or_deps
=
deps
.
split
(
','
)
for
or_dep
in
or_deps
:
deps
=
or_dep
.
split
(
'+'
)
for
dep
in
deps
:
while
dep
[
0
]
==
'('
:
dep
=
dep
[
1
:]
while
dep
[
-
1
]
==
')'
:
dep
=
dep
[:
-
1
]
if
'VK_VERSION'
in
dep
:
if
dep
>
core_dep
:
core_dep
=
dep
else
:
ext_deps
.
append
(
dep
)
features
=
[]
for
reqs
in
ext
.
iter
(
'require'
):
for
t
in
reqs
.
iter
(
'type'
):
type_name
=
t
.
attrib
[
'name'
]
type_name
=
type_aliases
.
get
(
type_name
,
type_name
)
if
(
type_name
in
feature_structs
)
and
(
type_name
not
in
features
):
features
.
append
(
type_name
)
info_impl
.
append
(
f'if (ext == "
{
ext_name
}
")'
+
' {'
)
info_impl
.
append
(
'
\t
dep = {};'
)
info_impl
.
append
(
f'
\t
dep.minimum_api_version =
{
core_dep
}
;'
)
if
len
(
ext_deps
)
!=
0
:
info_impl
.
append
(
'
\t
static const char * const exts[] = { '
+
', '
.
join
([
f'"
{
e
}
"'
for
e
in
ext_deps
])
+
' };'
)
info_impl
.
append
(
'
\t
dep.num_extension_dependencies = uint32_t(sizeof(exts) / sizeof(exts[0]));'
)
info_impl
.
append
(
'
\t
dep.extension_dependencies = exts;'
)
if
len
(
features
)
>=
1
:
info_impl
.
append
(
f'
\t
dep.primary_feature = &m
{
features
[
0
][
16
:]
}
;'
)
if
len
(
features
)
>=
2
:
info_impl
.
append
(
f'
\t
dep.secondary_feature = &m
{
features
[
1
][
16
:]
}
;'
)
info_impl
.
append
(
'
\t
return true;'
)
info_impl
.
append
(
'}'
)
info_impl
.
append
(
''
)
assert
len
(
features
)
<=
2
,
'Number of feature structs per extension is expected to be max 2.'
print
(
'
\t
void reset_pnext() {'
)
for
member_name
in
member_names
:
print
(
f'
\t
\t
m
{
member_name
}
.pNext = nullptr;'
)
print
(
'
\t
}
\n
'
)
print
(
'
\t
bool get_extension_requirements(const std::string &ext, ExtensionRequirements &dep) {'
)
for
l
in
info_impl
:
if
len
(
l
):
print
(
'
\t
\t
'
+
l
)
else
:
print
(
''
)
print
(
'
\t
\t
return false;'
)
print
(
'
\t
}'
)
print
(
'};
\n
'
)
if
__name__
==
'__main__'
:
main
()
You can’t perform that action at this time.