Skip to content

Commit

Permalink
vulkan: do a better job finding the vulkan xml
Browse files Browse the repository at this point in the history
Hard-code some common alternative locations to the vulkan XML, and
improve the error message otherwise.

Fixes haasn#75
Fixes https://code.videolan.org/videolan/libplacebo/-/issues/95
  • Loading branch information
haasn committed May 29, 2020
1 parent bacc24a commit c747430
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
23 changes: 23 additions & 0 deletions src/vulkan/utils_gen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
#
# This file is part of libplacebo.
#
# libplacebo is free software; you can redistribute it and/or
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c747430

Please sign in to comment.