.S
linkable object,.h
linkable symbolThe result is a device and configuration-specific pure data payload that can be included in a component as a file and opened at runtime or ephemerally loaded through some other mechanism.
Additionally, a linkable object and header file are available for applications that wish to link the target archive as read-only data.
To apply this to your own library take the following steps:
Determine what shaders are in your library as well as their arch-specific configuration data.
Determine what configuration data needs to be known at runtime when the selected target archive is handed to your library.
Consider creating your own GN target that extends the base target_archive.gni
and hides implicit dependencies.
An example of extending target_archive.gni
is here: compute/radix_sort/platforms/vk/targets/gn/radix_sort_vk_target.gni
.
Come up with a directory hierarchy for each device-specific target archive and drop a BUILD.gn
in each.
Determine whether you want to load or link the target archive(s).
Add all required device-specific GN targets[^1] to your Fuchsia application.
Fuchsia loadable target archive files will be found in the component's pkg/data/targets
directory.
A linkable target archive's include file looks similar to this:
#pragma once #include "target_archive/target_archive.h" #ifdef __cplusplus extern "C" { #endif extern struct target_archive_header const my_gn_target_name[]; #ifdef __cplusplus } #endif
[^1] GN also uses the word “target” so don't get confused!
The target-archive
executable tool concatenates one or more binaries prefixed by a table containing the number of binaries and the offset and size of each binary.
This format enables type-safe loading of SPIR-V modules and creation of Vulkan pipelines.
The target archive memory map is:
+-----------------------------------------+ 0 | alignas(8) struct target_archive_header | +-----------------------------------------+ 8 | struct target_archive_entry[0] | | struct target_archive_entry[1] | | ... | | struct target_archive_entry[count-1] | +-----------------------------------------+ 8 + 16 * count | alignas(8) data_(0) | | alignas(8) data_(1) | | ... | | alignas(8) data_(count-1) | +-----------------------------------------+