Skip to content

Commit 4329a7e

Browse files
docs: Update GPU-AV Docs
1 parent 1ee7afc commit 4329a7e

3 files changed

Lines changed: 89 additions & 42 deletions

File tree

docs/gpu_av_development.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# GPU-AV Development Guide
2+
3+
For those brave souls, here are some overall basic tips/advice that should not get outdated as things actively change
4+
5+
## You need to Validate with "Self Valiation"
6+
7+
Since GPU-AV itself utilizes the Vulkan API to perform its tasks,
8+
Vulkan function calls have to valid. To ensure that, those calls have to
9+
go through another instance of the Vulkan Validation Layer. We refer to this
10+
as "self validation".
11+
12+
How to setup self validation:
13+
- Build the self validation layer:
14+
- Make sure to use a Release build
15+
- Otherwise might be really slow with double validation
16+
- Use the the `-DBUILD_SELF_VVL=ON` cmake option when generating the CMake project
17+
- The build will produce a manifest file used by the Vulkan loader, `VkLayer_dev_self_validation.json`.
18+
The `name` field in this file is `VK_LAYER_DEV_self_validation` to differentiate the self validation layer from the one you work on.
19+
- If the name were the same, the loader/os would mark both layers as duplicates and not load the second instance
20+
- Then use it:
21+
- you need to ask the loader to load the self validation layer, and tell it where to find it.
22+
Do this by modifying the `VK_INSTANCE_LAYERS` and `VK_LAYER_PATH`, like so for instance:
23+
```bash
24+
# Windows
25+
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation;VK_LAYER_DEV_self_validation
26+
VK_LAYER_PATH=C:\Path\To\Vulkan-ValidationLayers\build\debug\layers\Debug;C:\Path\To\Vulkan-ValidationLayers\build_self_vvl\layers\Release
27+
28+
# Linux
29+
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:VK_LAYER_DEV_self_validation
30+
VK_LAYER_PATH=/Path/To/Vulkan-ValidationLayers/build/debug/layers/Debug:/Path/To/Vulkan-ValidationLayers/build_self_vvl/layers/Release
31+
```
32+
33+
⚠️ Make sure to load the self validation layer **after** the validation layer you work on, by putting its name in `VK_INSTANCE_LAYERS` after the validation layer you work on. Otherwise your Vulkan calls will not be intercepted by the self validation layer.
34+
To make sure you did it properly, you can use the environment variable `VK_LOADER_DEBUG=layer` to see how the loader sets up layers.
35+
36+
## We generate our SPIR-V offline
37+
38+
There is a `scripts/generate_spirv.py` that will take GLSL (maybe Slang in the future) and creates SPIR-V blobs baked in a C++ file. [We have more details here](../layers/gpuav/shaders/README.md)
39+

docs/gpu_av_selective_shader.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# GPU-AV Selective Shader Instrumentation
2+
3+
With the `khronos_validation.gpuav_select_instrumented_shaders`/`VK_LAYER_GPUAV_SELECT_INSTRUMENTED_SHADERS` feature, an application can control which shaders are instrumented and thus, will return GPU-AV errors.
4+
5+
With the feature enabled, all SPIR-V will not be modified by default.
6+
7+
Inside your `VkShaderModuleCreateInfo` or `vkCreateShadersEXT` pass in a `VkValidationFeaturesEXT` into the `pNext` with `VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT` to have the shader instrumented.
8+
9+
```c++
10+
// Example
11+
VkValidationFeatureEnableEXT enabled[] = {VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT};
12+
VkValidationFeaturesEXT features = {};
13+
features.enabledValidationFeatureCount = 1;
14+
features.pEnabledValidationFeatures = enabled;
15+
16+
VkShaderModuleCreateInfo module_ci = {};
17+
module_ci.pNext = &features;
18+
```

docs/gpu_validation.md

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,58 +37,48 @@ There are various other feature requirements, but if not met, GPU-AV will turn o
3737

3838
If a feature is not enabled, we will try to enable it for you at device creation time.
3939

40-
## Types of GPU-AV
40+
## Reality
4141

42-
GPU-AV has many things it validates, all of which have different implementation designs.
42+
There are 5 goals we constantly think about when developing GPU-AV
4343

44-
TODO - Add various internal sections
44+
1. It is fast enough to use
45+
3. It won't crash on you
46+
2. It is accurate (no false positive!)
47+
4. It has good error messages
48+
5. It actually catches your invalid code
4549

46-
## Selective Shader Instrumentation
50+
The development of GPU-AV has taught us showed that to perfectly validate your GPU workload, it can be painfully slow (like multiple seconds a frame slow).
4751

48-
With the `khronos_validation.gpuav_select_instrumented_shaders`/`VK_LAYER_GPUAV_SELECT_INSTRUMENTED_SHADERS` feature, an application can control which shaders are instrumented and thus, will return GPU-AV errors.
52+
There are 2 main reasons people use GPU-AV: `regression mode` and `debug mode`
4953

50-
With the feature enabled, all SPIR-V will not be modified by default.
54+
### Regression Mode
5155

52-
Inside your `VkShaderModuleCreateInfo` or `vkCreateShadersEXT` pass in a `VkValidationFeaturesEXT` into the `pNext` with `VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT` to have the shader instrumented.
56+
If you find yourself turning on GPU-AV all the time to "make sure no hidden issues" then this is you. You likely want to have things fast and can compromise not having have try and track multiple error in a single shader.
5357

54-
```c++
55-
// Example
56-
VkValidationFeatureEnableEXT enabled[] = {VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT};
57-
VkValidationFeaturesEXT features = {};
58-
features.enabledValidationFeatureCount = 1;
59-
features.pEnabledValidationFeatures = enabled;
58+
**By default**, we assume this is the use case and why we have the "Safe Mode" setting turned **off** by default.
6059

61-
VkShaderModuleCreateInfo module_ci = {};
62-
module_ci.pNext = &features;
63-
```
60+
By assuming things "should likely be working", we can make GPU-AV much faster
6461

65-
## Validating Vulkan calls made by GPU Assisted Validation
62+
### Debug Mode
6663

67-
Since GPU-AV itself utilizes the Vulkan API to perform its tasks,
68-
Vulkan function calls have to valid. To ensure that, those calls have to
69-
go through another instance of the Vulkan Validation Layer. We refer to this
70-
as "self validation".
64+
We realize if we don't stop your Device Lost, no one else will. If you are stuck on a nasty bug and need the extra help, this is for you.
7165

72-
How to setup self validation:
73-
- Build the self validation layer:
74-
- Make sure to use a Release build
75-
- Otherwise might be really slow with double validation
76-
- Use the the `-DBUILD_SELF_VVL=ON` cmake option when generating the CMake project
77-
- The build will produce a manifest file used by the Vulkan loader, `VkLayer_dev_self_validation.json`.
78-
The `name` field in this file is `VK_LAYER_DEV_self_validation` to differentiate the self validation layer from the one you work on.
79-
- If the name were the same, the loader/os would mark both layers as duplicates and not load the second instance
80-
- Then use it:
81-
- you need to ask the loader to load the self validation layer, and tell it where to find it.
82-
Do this by modifying the `VK_INSTANCE_LAYERS` and `VK_LAYER_PATH`, like so for instance:
83-
```bash
84-
# Windows
85-
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation;VK_LAYER_DEV_self_validation
86-
VK_LAYER_PATH=C:\Path\To\Vulkan-ValidationLayers\build\debug\layers\Debug;C:\Path\To\Vulkan-ValidationLayers\build_self_vvl\layers\Release
66+
**Please turn off Safe Mode**, this will sacrifice performance, but GPU-AV will try to stop things from crashing. We have a way to [select the bad shader](./gpu_av_selective_shader.md) as this will **greatly** improve performance if we only need to validate a smaller surface area.
8767

88-
# Linux
89-
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:VK_LAYER_DEV_self_validation
90-
VK_LAYER_PATH=/Path/To/Vulkan-ValidationLayers/build/debug/layers/Debug:/Path/To/Vulkan-ValidationLayers/build_self_vvl/layers/Release
91-
```
68+
#### Force on Robustness
9269

93-
⚠️ Make sure to load the self validation layer **after** the validation layer you work on, by putting its name in `VK_INSTANCE_LAYERS` after the validation layer you work on. Otherwise your Vulkan calls will not be intercepted by the self validation layer.
94-
To make sure you did it properly, you can use the environment variable `VK_LOADER_DEBUG=layer` to see how the loader sets up layers.
70+
There is also a "Force robustness on" setting we provide in GPU-AV, this has 2 main purposes
71+
72+
1. A way for developers to toggle this on and off
73+
2. Improve GPU-AV performance by assuming the developer relies on [robust behavior to work](https://docs.vulkan.org/guide/latest/robustness.html)
74+
75+
## Internal Details
76+
77+
The state of GPU-AV is constantly evolving as we find out what does and doesn't work.
78+
79+
The following are extra information around GPU-AV for those who want to know:
80+
81+
- [General development advice](./gpu_av_development.md)
82+
- [How descriptor indexing works](./gpu_av_descriptor_indexing.md)
83+
- [How post processing works](./gpu_av_post_process.md)
84+
- [How shader instrumentation works](./gpu_av_shader_instrumentation.md)

0 commit comments

Comments
 (0)