Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43ff479

Browse files
committed
Update validation layer chapter for newer SDK behaviour
1 parent 4cfed5c commit 43ff479

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,13 @@ The second to last parameter is again the optional allocator callback that we
332332
set to `nullptr`, other than that the parameters are fairly straightforward.
333333
Since the debug messenger is specific to our Vulkan instance and its layers, it
334334
needs to be explicitly specified as first argument. You will also see this
335-
pattern with other *child* objects later on. Let's see if it works... Run the
336-
program and close the window once you're fed up with staring at the blank
337-
window. You'll see that the following messages are printed to the command prompt:
335+
pattern with other *child* objects later on.
338336

339-
![](/images/validation_layer_test.png)
340-
341-
>If you don't see any messages then [check your installation](https://vulkan.lunarg.com/doc/view/1.1.106.0/windows/getting_started.html#user-content-verify-the-installation).
342-
343-
Oops, it has already spotted a bug in our program! The
344-
`VkDebugUtilsMessengerEXT` object needs to be cleaned up with a call to
337+
The `VkDebugUtilsMessengerEXT` object also needs to be cleaned up with a call to
345338
`vkDestroyDebugUtilsMessengerEXT`. Similarly to `vkCreateDebugUtilsMessengerEXT`
346-
the function needs to be explicitly loaded. Note that it is normal for this message to be printed multiple times. This happens because multiple validation layers check for the deletion of the debug messenger.
339+
the function needs to be explicitly loaded.
347340

348-
Create another proxy function right
349-
below `CreateDebugUtilsMessengerEXT`:
341+
Create another proxy function right below `CreateDebugUtilsMessengerEXT`:
350342

351343
```c++
352344
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
@@ -374,10 +366,6 @@ void cleanup() {
374366
}
375367
```
376368

377-
When you run the program again you'll see that the error message has
378-
disappeared. If you want to see which call triggered a message, you can add a
379-
breakpoint to the message callback and look at the stack trace.
380-
381369
## Debugging instance creation and destruction
382370

383371
Although we've now added debugging with validation layers to the program we're not covering everything quite yet. The `vkCreateDebugUtilsMessengerEXT` call requires a valid instance to have been created and `vkDestroyDebugUtilsMessengerEXT` must be called before the instance is destroyed. This currently leaves us unable to debug any issues in the `vkCreateInstance` and `vkDestroyInstance` calls.
@@ -440,6 +428,16 @@ void createInstance() {
440428

441429
The `debugCreateInfo` variable is placed outside the if statement to ensure that it is not destroyed before the `vkCreateInstance` call. By creating an additional debug messenger this way it will automatically be used during `vkCreateInstance` and `vkDestroyInstance` and cleaned up after that.
442430

431+
## Testing
432+
433+
Now let's intentionally make a mistake to see the validation layers in action. Temporarily remove the call to `DestroyDebugUtilsMessengerEXT` in the `cleanup` function and run your program. Once it exits you should see something like this:
434+
435+
![](/images/validation_layer_test.png)
436+
437+
>If you don't see any messages then [check your installation](https://vulkan.lunarg.com/doc/view/1.2.131.1/windows/getting_started.html#user-content-verify-the-installation).
438+
439+
If you want to see which call triggered a message, you can add a breakpoint to the message callback and look at the stack trace.
440+
443441
## Configuration
444442

445443
There are a lot more settings for the behavior of validation layers than just

images/validation_layer_test.png

31.7 KB
Loading

0 commit comments

Comments
 (0)