diff --git a/README.md b/README.md index 3fe2ed88..6eafb702 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/meson_options.txt b/meson_options.txt index aa1c7365..307b9df1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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', diff --git a/src/vulkan/utils_gen.py b/src/vulkan/utils_gen.py index 07d3a5f8..8ac34076 100644 --- a/src/vulkan/utils_gen.py +++ b/src/vulkan/utils_gen.py @@ -1,4 +1,5 @@ #!/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 . +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(