Skip to content

Commit 6dc87d3

Browse files
committed
Improve Markdown documentation
1 parent f952f5a commit 6dc87d3

File tree

13 files changed

+456
-269
lines changed

13 files changed

+456
-269
lines changed

README.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
11
# About
22

3-
libGPULayers provides tooling to rapidly create new Vulkan layer drivers,
4-
allowing developers to quickly generate new layers that can be used for
5-
ad hoc experiments during development.
3+
libGPULayers provides tooling to create new Vulkan layer drivers, allowing
4+
you to quickly generate new layers suitable for creation of new developer tools
5+
or for ad hoc experiments during development.
66

77
In addition, we provide a number of pre-built layers that have been built
8-
using these tools. These layers can be used as standalone tools in their
9-
own right, and some can be used alongside other Arm tools such as Arm
10-
Performance Studio.
8+
using this framework. These layers might be used as standalone tools in their
9+
own right, or might be used alongside other Arm tools such as
10+
[Arm Performance Studio][2].
1111

1212
## What are layer drivers?
1313

14-
Layers drivers provide a standard mechanism to inject diagnostic functionality
14+
Layer drivers provide a standard mechanism to inject diagnostic functionality
1515
between an application and the underlying graphics driver. Layer drivers
1616
intercept the graphics API calls from the application, perform their diagnostic
17-
function, and then make any necessary API calls into the underlying graphics
18-
driver to actually perform the rendering operations. The ability to see, and
19-
change, everything that the native driver sees makes layers an exceptionally
20-
powerful tool for debugging functional and performance issues.
17+
function, and then call into the underlying graphics driver to actually perform
18+
the requested operation. The ability to see, and change, the calls into the
19+
native driver makes layers an exceptionally powerful tool for debugging both
20+
functional and performance issues.
2121

22-
The Vulkan API defines a standard layer driver mechanism. The API uses layers
23-
to implement API parameter validation and error checking, but they are also a
24-
general purpose mechanism for all kinds of developer tooling.
22+
Layer drivers are designed in to the Vulkan API, and they are the mechanism
23+
for common workflows such as error checking using the Vulkan Validation Layer
24+
(VVL), but they are also a general purpose mechanism suitable for all kinds of
25+
developer tooling.
2526

2627
## What is the purpose of this project?
2728

28-
We support many application developers during their development cycle. We
29-
rarely get access to application source code, so layer drivers provide us with
30-
an invaluable mechanism to make modifications to application API usage. The
31-
`GPU Support` layer in this project is a a tool we use during technical support
32-
investigations to quickly triage developers problems.
29+
We help many application developers to investigate issues during their
30+
development cycle. We rarely get access to application source code for these
31+
investigations, and cannot change drivers on production devices. Layer drivers
32+
provide us with an invaluable mechanism to monitor and make modifications to
33+
application API usage without needing to modify the application itself. The
34+
`GPU Support` layer in this project is a tool we use during technical
35+
support investigations to quickly triage problems.
3336

3437
We also use layer drivers as a way to develop new API-aware debug and profiling
3538
capabilities. The performance layers in this repository, such as the
36-
`GPU Timeline` layer, are often early prototypes that we want to share with
37-
developers to test new ideas and gather feedback. Some are designed to be used
38-
as standalone development tools, others can also be used alongside other Arm
39-
tools such as the Arm Streamline profiler in [Arm Performance Studio][2].
39+
`GPU Profile` and `GPU Timeline` layers, are used to profile performance,
40+
or add API-aware annotations to performance captures made using other tooling.
4041

41-
As you can tell, we find layers exceptionally useful. However, creating a new
42-
layer from scratch requires a lot of boilerplate code and is fiddly to get
43-
right. We therefore also wanted to take this opportunity to share our layer
44-
generation tools which make it trivial to create a complete bare-bones layer
45-
that is ready to extend and use.
42+
As you might be able to tell, we find layers exceptionally useful, and we
43+
often want to create ad hoc layers to use for one-off experiments. Creating a
44+
new layer from scratch requires a lot of code and is fiddly to get right, with
45+
obscure errors when it doesn't work, so we wrote a tool to automate layer
46+
creation. This final part of this project is this layer generation tooling,
47+
which you use to quickly create a new layer that is ready to deploy.
4648

4749
## Supported devices
4850

4951
This library is currently tested on devices running Android or Linux, and using
5052
Arm® Immortalis™ and Arm Mali™ GPUs. Contributions adding support for other
51-
platforms is welcome.
53+
platforms are welcome.
5254

5355
# License
5456

@@ -60,14 +62,17 @@ from this repository you acknowledge that you accept terms specified in the
6062

6163
Common documentation
6264

63-
* [Building a new layer](./docs/building.md)
65+
* [Building a layer](./docs/building.md)
66+
* [Creating a new layer](./docs/creating.md)
6467
* [Running using a layer on Android](./docs/running_android.md)
6568
* [Running using a layer on Linux](./docs/running_linux.md)
69+
* [About layers design notes](./docs/about_layers.md)
6670
* [Frequently asked questions](./docs/faq.md)
6771

6872
Layer documentation
6973

7074
* [Layer: GPU Support](./layer_gpu_support/README_LAYER.md)
75+
* [Layer: GPU Profile](./layer_gpu_support/README_LAYER.md)
7176
* [Layer: GPU Timeline](./layer_gpu_timeline/README_LAYER.md)
7277

7378
# Support

docs/about_layers.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# About Vulkan layers
2+
3+
This page captures some interesting points to note about Vulkan layers, and is
4+
mostly intended for developers of layers and maintainers of this project.
5+
6+
## Android vs Linux differences
7+
8+
Linux and Windows use the Khronos Vulkan loader, which has been extended over
9+
time to have a richer loader-layer interface to support more use cases. The
10+
current Khronos loader implements the v2 protocol from the
11+
[Loader-Layer Interface][LLI] specification.
12+
13+
Android uses a custom Vulkan loader, which supports the basic v0 protocol with
14+
some Android-specific limitations. This interface is functional, but lacks
15+
some useful capabilities of the Khronos layer such as being able to intercept
16+
pre-instance functions in implicit layers.
17+
18+
The libGPULayers framework has been designed to support both loaders, but
19+
currently only supports functionality that works with the Android loader. There
20+
are some areas that could be improved for Linux.
21+
22+
## Layer lifetime
23+
24+
Layer lifetime is managed by the Vulkan loader, and it is possible for a layer
25+
to get loaded and unloaded multiple times within the lifetime of a single
26+
application process. When a layer is unloaded, any global state is lost so
27+
there is no way to use memory to persist per-process state in a layer as you
28+
cannot guarantee you stay loaded.
29+
30+
On Android, layer libraries are loaded when the loader needs them (for a query
31+
or to create an instance) and will be unloaded when a non-zero `VkInstance`
32+
refcount is decremented and hits zero. They might subsequently be reloaded
33+
again if the application restarts using Vulkan functionality.
34+
35+
36+
## Querying Instance version
37+
38+
It could be useful for a layer to query `vkEnumerateInstanceVersion()` to
39+
determine the maximum possible Vulkan API version supported on a platform,
40+
although note that a device version might be a lower version so you need
41+
to check both.
42+
43+
It is not possible for a layer to hook pre-instance functions on Android, and
44+
only implicit layers are allowed to do it with the Khronos loader, so we do
45+
not support doing this in libGPULayers. Layers must defer checking the
46+
supported API versions until they get a concrete `VkDevice` to query, which
47+
they would have to anyway, because the device version might be different to the
48+
instance version.
49+
50+
Note: querying device version is much easier, because that uses normal
51+
dispatchable Vulkan API functions, not pre-instance functions.
52+
53+
## Querying Instance extensions
54+
55+
Similar to the above, it could be useful for a layer to query the available
56+
instance extensions using `vkEnumerateInstanceExtensionProperties()`. This
57+
function is also a pre-instance function, and has the same limitations on
58+
layer use as `vkEnumerateInstanceVersion()` in the section above, so it's not
59+
supported in libGPULayers.
60+
61+
Because a layer cannot query the supported Vulkan version, or the available
62+
instance extensions, layers that require the implementation beneath them to
63+
support a specific extension simply have to assume that it is available.
64+
65+
This might result in an error on instance creation if the extension is not
66+
supported. One possibility is that `vkCreateInstance()` will return
67+
`VK_ERROR_EXTENSION_NOT_PRESENT`, because the extension is known but not
68+
supported. Alternatively, it might result in undefined behavior, because the
69+
layer passes in an extension structure on the `pNext` chain which is not known
70+
by the version of Vulkan implemented by the loader or the driver.
71+
72+
Note: querying device extensions is much easier, as that uses normal
73+
dispatchable Vulkan API functions, not pre-instance functions.
74+
75+
## Adding new extensions
76+
77+
Layers might expose extensions that the driver does not. Layers advertise their
78+
new extensions by adding the extension strings and versions to the extension
79+
properties list returned by `vkEnumerateInstanceExtensionProperties()` and
80+
`vkEnumerateDeviceExtensionProperties()` when the `pLayerName` parameter is
81+
the current layer's name.
82+
83+
For device extensions, it is also possible to modify the extension list
84+
returned by the driver below by adding our extensions to the list returned
85+
when `pLayerName` is `nullptr`.
86+
87+
The specification requires that implementations do not expose extensions that
88+
conflict with other extensions but, given that a layer has no way to check
89+
what other layers might be exposing, we just assume that our list is safe to
90+
expose.
91+
92+
## Hiding device extensions
93+
94+
Layers might hide device extensions exposed by the layers below by modifying
95+
the list returned by `vkEnumerateDeviceExtensionProperties()` when calling
96+
down the stack, removing entries that the layer wants to hide before
97+
returning it to the caller.
98+
99+
Note: This is only possible for device extensions, because instance extensions
100+
are discovered per component by the loader, not in a layered manner.
101+
102+
103+
## References
104+
105+
* [Loader-Layer Interface][LLI].
106+
107+
- - -
108+
109+
[LLI]: https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs
110+
111+
_Copyright © 2025, Arm Limited and contributors._

0 commit comments

Comments
 (0)