Skip to content
Snippets Groups Projects
Commit c747430c authored by Niklas Haas's avatar Niklas Haas
Browse files

vulkan: do a better job finding the vulkan xml

Hard-code some common alternative locations to the vulkan XML, and
improve the error message otherwise.

Fixes https://github.com/haasn/libplacebo/issues/75
Fixes #95
parent bacc24a0
No related branches found
No related tags found
No related merge requests found
......@@ -210,6 +210,14 @@ A full list of optional dependencies each feature requires:
- **shaderc**: `libshaderc`
- **vulkan**: `libvulkan`, `python3-mako`
#### Vulkan support
Because the vulkan backend requires on code generation at compile time,
`python3-mako` is a hard dependency of the build system. In addition to this,
the path to the Vulkan registry (`vk.xml`) must be locatable, ideally by
explicitly providing it via the `-Dvulkan-registry=/path/to/vk.xml` option,
unless it can be found in one of the built-in hard-coded locations.
### Configuring
To get a list of configuration options supported by libplacebo, after running
......
......@@ -5,8 +5,7 @@ option('vulkan', type: 'feature', value: 'auto',
option('vulkan-link', type: 'boolean', value: true,
description: 'Link directly againt vkGetInstanceProcAddr from libvulkan.so')
option('vulkan-registry', type: 'string',
value: '/usr/share/vulkan/registry/vk.xml',
option('vulkan-registry', type: 'string', value: '',
description: 'Path to vulkan XML registry (for code generation)')
option('opengl', type: 'feature', value: 'auto',
......
#!/usr/bin/env python3
#
# This file is part of libplacebo.
#
# libplacebo is free software; you can redistribute it and/or
......@@ -14,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with libplacebo. If not, see <http://www.gnu.org/licenses/>.
import os.path
import sys
import xml.etree.ElementTree as ET
from mako.template import Template
......@@ -86,11 +88,32 @@ def get_vkstructs(registry):
yield Obj(stype = stype.attrib['values'],
name = e.attrib['name'])
def find_registry_xml():
registry_paths = [
'/usr/share/vulkan/registry/vk.xml',
'%VULKAN_SDK%/share/vulkan/registry/vk.xml',
'$MINGW_PREFIX/share/vulkan/registry/vk.xml',
]
for p in registry_paths:
path = os.path.expandvars(p)
if os.path.isfile(path):
print('Found vk.xml: {0}'.format(path))
return path
print('Could not find the vulkan registry (vk.xml), please specify its '
'location manually using the -Dvulkan-registry=/path/to/vk.xml '
'option!', file=sys.stderr)
sys.exit(1)
if __name__ == '__main__':
assert len(sys.argv) == 3
xmlfile = sys.argv[1]
outfile = sys.argv[2]
if not xmlfile or xmfile == '':
xmlfile = find_registry_xml()
registry = ET.parse(xmlfile)
with open(outfile, 'w') as f:
f.write(TEMPLATE.render(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment