You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vulkan includes a small number of functions which are called without any dispatchable object.
1461
+
Most layers do not intercept these functions, as layers are enabled when an instance is created.
1462
+
However, under certain conditions it is possible for a layer to intercept these functions.
1463
+
1464
+
In order to intercept the pre-instance functions, several conditions must be met:
1465
+
* The layer must be implicit
1466
+
* The layer manifest version must be 1.1.2 or later
1467
+
* The layer must export the entry point symbols for each intercepted function
1468
+
* The layer manifest must specify the name of each intercepted function in a `pre_instance_functions` JSON object
1469
+
1470
+
The functions that may be intercepted in this way are:
1471
+
*`vkEnumerateInstanceExtensionProperties`
1472
+
*`vkEnumerateInstanceLayerProperties`
1473
+
1474
+
Pre-instance functions work differently from all other layer intercept functions.
1475
+
Other intercept functions have a function prototype identical to that of the function they are intercepting.
1476
+
They then rely on data that was passed to the layer at instance or device creation so that layers can call down the chain.
1477
+
Because there is no need to create an instance before calling the pre-instance functions, these functions must use a separate mechanism for constructing the call chain.
1478
+
This mechanism consists of an extra parameter that will be passed to the layer intercept function when it is called.
1479
+
This parameter will be a pointer to a struct, defined as follows:
1480
+
1481
+
```
1482
+
typedef struct Vk...Chain
1483
+
{
1484
+
struct {
1485
+
VkChainType type;
1486
+
uint32_t version;
1487
+
uint32_t size;
1488
+
} header;
1489
+
PFN_vkVoidFunction pfnNextLayer;
1490
+
const struct Vk...Chain* pNextLink;
1491
+
} Vk...Chain;
1492
+
```
1493
+
1494
+
These structs are defined in the `vk_layer.h` file so that it is not necessary to redefine the chain structs in any external code.
1495
+
The name of each struct is be similar to the name of the function it corresponds to, but the leading "V" is capitalized, and the word "Chain" is added to the end.
1496
+
For example, the struct for `vkEnumerateInstanceExtensionProperties` is called `VkEnumerateInstanceExtensionPropertiesChain`.
1497
+
Furthermore, the `pfnNextLayer` struct member is not actually a void function pointer — its type will be the actual type of each function in the call chain.
1498
+
1499
+
Each layer intercept function must have a prototype that is the same as the prototype of the function being intercepted, except that the first parameter must be that function's chain struct (passed as a const pointer).
1500
+
For example, a function that wishes to intercept `vkEnumerateInstanceExtensionProperties` would have the prototype:
The name of the function is arbitrary; it can be anything provided that it is given in the layer manifest file (see [Layer Manifest File Format](#layer-manifest-file-format)).
1508
+
The implementation of each intercept functions is responsible for calling the next item in the call chain, using the chain parameter.
1509
+
This is done by calling the `pfnNextLayer` member of the chain struct, passing `pNextLink` as the first argument, and passing the remaining function arguments after that.
1510
+
For example, a simple implementation for `vkEnumerateInstanceExtensionProperties` that does nothing but call down the chain would look like:
Unlike with other functions in layers, the layer may not save any global data between these function calls.
1532
+
Because Vulkan does not store any state until an instance has been created, all layer libraries are released at the end of each pre-instance call.
1533
+
This means that implicit layers can use pre-instance intercepts to modify data that is returned by the functions, but they cannot be used to record that data.
1534
+
1456
1535
#### Special Considerations
1457
1536
1458
1537
@@ -1643,7 +1722,7 @@ Here is an example layer JSON Manifest file with a single layer:
1643
1722
],
1644
1723
"enable_environment": {
1645
1724
"ENABLE_LAYER_OVERLAY_1": "1"
1646
-
}
1725
+
},
1647
1726
"disable_environment": {
1648
1727
"DISABLE_LAYER_OVERLAY_1": ""
1649
1728
}
@@ -1694,7 +1773,7 @@ Here's an example of a meta-layer manifest file:
| "layer" | The identifier used to group a single layer's information together. | vkEnumerateInstanceLayerProperties |
1699
1778
| "layers" | The identifier used to group multiple layers' information together. This requires a minimum Manifest file format version of 1.0.1.| vkEnumerateInstanceLayerProperties |
1700
1779
| "name" | The string used to uniquely identify this layer to applications. | vkEnumerateInstanceLayerProperties |
@@ -1710,12 +1789,22 @@ Here's an example of a meta-layer manifest file:
1710
1789
| "enable\_environment" | **Implicit Layers Only** - **OPTIONAL:** Indicates an environment variable used to enable the Implicit Layer (w/ value of 1). This environment variable (which should vary with each "version" of the layer) must be set to the given value or else the implicit layer is not loaded. This is for application environments (e.g. Steam) which want to enable a layer(s) only for applications that they launch, and allows for applications run outside of an application environment to not get that implicit layer(s).| N/A |
1711
1790
| "disable\_environment" | **Implicit Layers Only** - **REQUIRED:**Indicates an environment variable used to disable the Implicit Layer (w/ value of 1). In rare cases of an application not working with an implicit layer, the application can set this environment variable (before calling Vulkan functions) in order to "blacklist" the layer. This environment variable (which should vary with each "version" of the layer) must be set (not particularly to any value). If both the "enable_environment" and "disable_environment" variables are set, the implicit layer is disabled. | N/A |
1712
1791
| "component_layers" | **Meta-layers Only** - Indicates the component layer names that are part of a meta-layer. The names listed must be the "name" identified in each of the component layer's Mainfest file "name" tag (this is the same as the name of the layer that is passed to the `vkCreateInstance` command). All component layers must be present on the system and found by the loader in order for this meta-layer to be available and activated. **This field must not be present if "library\_path" is defined** | N/A |
1792
+
| "pre_instance_functions" | **Implicit Layers Only** - **OPTIONAL:** Indicates which functions the layer wishes to intercept, that do not require that an instance has been created. This should be an object where each function to be intercepted is defined as a string entry where the key is the Vulkan function name and the value is the name of the intercept function in the layer's dynamic library. Available in layer manifest versions 1.1.2 and up. See [Pre-Instance Functions](#pre-instance-functions) for more information. | vkEnumerateInstance*Properties |
1713
1793
1714
1794
##### Layer Manifest File Version History
1715
1795
1716
-
The current highest supported Layer Manifest file format supported is 1.1.0.
1796
+
The current highest supported Layer Manifest file format supported is 1.1.2.
1717
1797
Information about each version is detailed in the following sub-sections:
1718
1798
1799
+
###### Layer Manifest File Version 1.1.2
1800
+
1801
+
Version 1.1.2 introduced the ability of layers to intercept function calls that do not have an instance.
1802
+
1803
+
###### Layer Manifest File Version 1.1.1
1804
+
1805
+
The ability to define custom metalayers was added.
1806
+
To support metalayers, the "component_layers" section was added, and the requirement for a "library_path" section to be present was removed when the "component_layers" section is present.
1807
+
1719
1808
###### Layer Manifest File Version 1.1.0
1720
1809
1721
1810
Layer Manifest File Version 1.1.0 is tied to changes exposed by the Loader/Layer
0 commit comments