Vulkan Loader and Validation Layers on Fuchsia

  • The BUILD.gn files are for building as a part of Fuchsia using GN.
  • The build-fuchsia directory contains customized scripts to generate some of the necessary header files. These header files are pre-generated and used in the root BUILD.gn file.
  • To regenerate the header files after an update, run the following command:
cd $FUCHSIA_ROOT/third_party/vulkan_loader_and_validation_layers
./build-fuchsia/fuchsia-generate.sh build-fuchsia
  • Synchronize layer descriptions; see layers/fuchsia/README.md

  • The header files vulkan.h and vulkan.hpp are generated from vk.xml. If vk.xml changes, regenerate the files with the following steps:

# Before you start, $FUCHSIA_ROOT must point to the root of your
# Fuchsia checkout. Then use that to set $VULKAN_LOADER_SOURCE:
export VULKAN_LOADER_SOURCE=$FUCHSIA_ROOT/third_party/vulkan_loader_and_validation_layers

# Check out Vulkan-Hpp repository. Your current directory should be outside
# FUCHSIA_ROOT, or else jiri update can have errors.
#
# NOTE: using commit b4080fb4254dbc38fef7f71a262a08fe01cd964a is known to work
#
git clone --recursive https://github.com/KhronosGroup/Vulkan-Hpp.git
cd Vulkan-Hpp
git checkout b4080fb4254dbc38fef7f71a262a08fe01cd964a
git submodule update

# Patch in changes to Vulkan-Docs
pushd Vulkan-Docs
git checkout 3c0abef815a9ffe3d1b728bb383f132543e721b1
patch -p1 < $VULKAN_LOADER_SOURCE/build-fuchsia/Vulkan-Docs.diff
popd

# Copy over our version of vk.xml
cp $VULKAN_LOADER_SOURCE/scripts/vk.xml Vulkan-Docs/xml/vk.xml

# Generate header files from vk.xml
cmake . && make && ./VulkanHppGenerator
(cd Vulkan-Docs/xml && make)

# Copy the header files back to our repo
cp vulkan/vulkan.hpp $VULKAN_LOADER_SOURCE/include/vulkan/vulkan.hpp
cp Vulkan-Docs/include/vulkan/vulkan*.h $VULKAN_LOADER_SOURCE/include/vulkan/

Handling Public Symbol Changes

The Fuchsia SDK requires that all library prebuilts expose symbols using C linkage, and requires authors to acknowledge their additions and removals. The Vulkan loader is a shared library that falls under this rule. Its list of exported symbols are checked in at loader/vulkan.smbols.api.

When the list of symbols change, the build would fail with an error message like so:

Error: ABI has changed! In library vulkan

NOTE: the following symbols were added:
my_symbol

Please acknowledge this change by running:
cp /some/build/dir/gen/third_party/vulkan_loader_and_validation_layers/loader/vulkan.symbols.api \
   /source/dir/third_party/vulkan_loader_and_validation_layers/loader/vulkan.symbols.api

Run the cp command on the last line to copy the updated symbol list, and check it in. The build will then be able to proceed.