Vulkan: Debugging Tools #107635

Merged
Jeroen Bakker merged 11 commits from :vk_debug_messenger2 into main 2023-06-02 09:50:39 +02:00
Contributor

This PR is a split off part of this PR.It mainly provides utilities for using Messenger from an extension called VkDebugUtils.

Problem Description:

Blender is currently targeting Vulkan version 1.2.
However, if we don't make vulkan's dynamic function group a side-by-side configuration, etc., it will load the default Vulkan(dll or so) on the user's PC.
What kind of problems does this cause?

First, VkDebugUtils is an extension included in VKValidationLayer, but we can use this messenger function without VKValidationLayer.
And when we load the VKValidationLayer, it adds a lot of validation items and a lot of messenger handling.

In other words, basically version differences do not cause malfunctions, but when VkValidationLayer is involved, there are more differences in validation details for each version.

Description of the proposed solution:

To alleviate those worries, I think it's better to check the version.

Problem Description:

a Message has an Id.
Since the Id is an int32, it can also be used when excluding messages.
Should it match the OpenGL implementation?

Description of the proposed solution:

Add the ID of the message to the exclusion set when entering the scope of the exclusion message. Remove id when leaving scope.

### This PR is a split off part of [this PR](https://projects.blender.org/blender/blender/pulls/105484).It mainly provides utilities for using Messenger from an extension called VkDebugUtils. > ### Problem Description: > Blender is currently targeting Vulkan version 1.2. However, if we don't make vulkan's dynamic function group a side-by-side configuration, etc., it will load the default Vulkan(dll or so) on the user's PC. > What kind of problems does this cause? >> First, VkDebugUtils is an extension included in VKValidationLayer, but we can use this messenger function without VKValidationLayer. >> And when we load the VKValidationLayer, it adds a lot of validation items and a lot of messenger handling. >>> In other words, basically version differences do not cause malfunctions, but when VkValidationLayer is involved, there are more differences in validation details for each version. > ### Description of the proposed solution: >> To alleviate those worries, I think it's better to check the version. > ### Problem Description: > a Message has an Id. > Since the Id is an int32, it can also be used when excluding messages. > Should it match the OpenGL implementation? > ### Description of the proposed solution: > Add the ID of the message to the exclusion set when entering the scope of the exclusion message. Remove id when leaving scope.
Kazashi Yoshioka added 1 commit 2023-05-05 00:06:44 +02:00
21b23fcf93 Vulkan: Debugging Tools
Add Messenger from the functions of VkDebugUtils.
Kazashi Yoshioka requested review from Jeroen Bakker 2023-05-05 00:09:27 +02:00
Kazashi Yoshioka changed title from Vulkan: Debugging Tools to WIP: Vulkan: Debugging Tools 2023-05-05 00:09:33 +02:00
Jeroen Bakker requested changes 2023-05-05 13:06:19 +02:00
@ -530,1 +530,4 @@
const char *to_string(VkObjectType type)
{
#define __STR_VK_CHECK(s) "" #s
Member

Use BLI_utildefines.h#STRINGIFY

Use `BLI_utildefines.h#STRINGIFY`
vnapdv marked this conversation as resolved
@ -59,6 +59,10 @@ void VKContext::activate()
back_left = framebuffer;
framebuffer->bind(false);
}
debug::raise_message(0xB41CA2,
Member

I imagine this is a test and would be removed eventually

I imagine this is a test and would be removed eventually
@ -98,3 +103,4 @@
void VKDebuggingTools::deinit()
{
if (enabled) {
Member

Best to add VkInstance as parameter to this method to make it consistent with init

Best to add `VkInstance` as parameter to this method to make it consistent with `init`
vnapdv marked this conversation as resolved
@ -207,0 +232,4 @@
void VKDebuggingTools::print_labels(const VkDebugUtilsMessengerCallbackDataEXT *callback_data,
bool use_color)
{
#define COLOR_FILE \
Member

Although they are useful terminal colors aren't cross platform compatible. So would prefer to not using colors at all in local code. If you want colored output, use CLog.

Although they are useful terminal colors aren't cross platform compatible. So would prefer to not using colors at all in local code. If you want colored output, use CLog.
Author
Contributor

It should have been confirmed in this passage.

It should have been confirmed in [this passage](https://projects.blender.org/vnapdv/blender/src/commit/07beb066befc746a92daf7872277ee471c77e7fb/intern/clog/clog.c#L569).
Member

I see, perhaps use decimal notation for consistency for better traceability \033[2m etc.

I see, perhaps use decimal notation for consistency for better traceability `\033[2m` etc.
@ -207,0 +370,4 @@
return VK_TRUE;
};
VkResult VKDebuggingTools::create_messenger(VkInstance vk_instance)
Member

create typically returns the newly created resource, here I would use init_messenger.

create typically returns the newly created resource, here I would use `init_messenger`.
vnapdv marked this conversation as resolved
Kazashi Yoshioka added 1 commit 2023-05-05 18:13:48 +02:00
Kazashi Yoshioka requested review from Jeroen Bakker 2023-05-05 18:17:59 +02:00
Jeroen Bakker requested changes 2023-05-08 09:19:49 +02:00
Jeroen Bakker left a comment
Member

Just a small change requested. For the rest seems fine!

Just a small change requested. For the rest seems fine!
Kazashi Yoshioka added 1 commit 2023-05-08 10:39:53 +02:00
Kazashi Yoshioka changed title from WIP: Vulkan: Debugging Tools to Vulkan: Debugging Tools 2023-05-08 10:42:02 +02:00
Kazashi Yoshioka requested review from Jeroen Bakker 2023-05-08 10:42:07 +02:00
Kazashi Yoshioka added 1 commit 2023-05-08 10:42:42 +02:00
Jeroen Bakker requested changes 2023-05-11 14:56:50 +02:00
Jeroen Bakker left a comment
Member

There are some circular includes that makes this not compile on linux.

vk_context include vk_debug, vk_debug needs full definition of vk_context.

In file included from /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_device.hh:13,
                 from /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_backend.hh:17,
                 from /home/jeroen/blender-git/blender/source/blender/gpu/intern/gpu_context.cc:37:
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh: In function ‘void blender::gpu::debug::raise_message(int32_t, VkDebugUtilsMessageSeverityFlagBitsEXT, const char*, Args ...)’:
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:90:35: error: incomplete type ‘blender::gpu::VKContext’ used in nested name specifier
   90 |   VKContext *context = VKContext::get();
      |                                   ^~~
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:94:28: error: ‘VKBackend’ has not been declared
   94 |   const VKDevice &device = VKBackend::get().device_get();
      |                            ^~~~~~~~~
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:95:45: warning: invalid use of incomplete type ‘const class blender::gpu::VKDevice’
   95 |   const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
      |                                             ^~~~~~
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:20:7: note: forward declaration of ‘class blender::gpu::VKDevice’
   20 | class VKDevice;
      |       ^~~~~~~~
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:107:52: warning: invalid use of incomplete type ‘const class blender::gpu::VKDevice’
  107 |     debugging_tools.vkSubmitDebugUtilsMessageEXT_r(device.instance_get(),
      |                                                    ^~~~~~
/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:20:7: note: forward declaration of ‘class blender::gpu::VKDevice’
   20 | class VKDevice;
      |       ^~~~~~~~
ninja: build stopped: subcommand failed.

Perhaps inversing the include (vk_debug includes vk_context, and vk_context does a pre-declaration would solve this.

There are some circular includes that makes this not compile on linux. vk_context include vk_debug, vk_debug needs full definition of vk_context. ``` In file included from /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_device.hh:13, from /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_backend.hh:17, from /home/jeroen/blender-git/blender/source/blender/gpu/intern/gpu_context.cc:37: /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh: In function ‘void blender::gpu::debug::raise_message(int32_t, VkDebugUtilsMessageSeverityFlagBitsEXT, const char*, Args ...)’: /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:90:35: error: incomplete type ‘blender::gpu::VKContext’ used in nested name specifier 90 | VKContext *context = VKContext::get(); | ^~~ /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:94:28: error: ‘VKBackend’ has not been declared 94 | const VKDevice &device = VKBackend::get().device_get(); | ^~~~~~~~~ /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:95:45: warning: invalid use of incomplete type ‘const class blender::gpu::VKDevice’ 95 | const VKDebuggingTools &debugging_tools = device.debugging_tools_get(); | ^~~~~~ /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:20:7: note: forward declaration of ‘class blender::gpu::VKDevice’ 20 | class VKDevice; | ^~~~~~~~ /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:107:52: warning: invalid use of incomplete type ‘const class blender::gpu::VKDevice’ 107 | debugging_tools.vkSubmitDebugUtilsMessageEXT_r(device.instance_get(), | ^~~~~~ /home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.hh:20:7: note: forward declaration of ‘class blender::gpu::VKDevice’ 20 | class VKDevice; | ^~~~~~~~ ninja: build stopped: subcommand failed. ``` Perhaps inversing the include (vk_debug includes vk_context, and vk_context does a pre-declaration would solve this.
Kazashi Yoshioka added 2 commits 2023-05-11 16:27:07 +02:00
Kazashi Yoshioka added 1 commit 2023-05-11 18:53:36 +02:00
Kazashi Yoshioka added 1 commit 2023-05-11 19:07:20 +02:00
Kazashi Yoshioka requested review from Jeroen Bakker 2023-05-11 19:07:36 +02:00
Kazashi Yoshioka added 1 commit 2023-05-11 19:13:00 +02:00
Jeroen Bakker reviewed 2023-06-01 13:54:24 +02:00
Jeroen Bakker left a comment
Member

I retested this branch and it is working.
I would only keep the objects close to the message it belongs to. But I can tweak a bit when it is applied. Can you make sure this branch is up to date with main. Thanks!

WARN (gpu.debug.vulkan):  :  UNASSIGNED-CoreValidation-Shader-OutputNotConsumed {0x609a13b}
 Validation Performance Warning: [ UNASSIGNED-CoreValidation-Shader-OutputNotConsumed ] Object 0: handle = 0x85798b0000000067, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x609a13b | VK_SHADER_STAGE_VERTEX_BIT writes to output location 0.0 which is not consumed by VK_SHADER_STAGE_GEOMETRY_BIT. Enable VK_KHR_maintenance4 device extension to allow relaxed interface matching between input and output vectors. 

1 Object[s] related 
ObjectType[VK_OBJECT_TYPE_SHADER_MODULE],Handle[0x85798b0000000067]

ERROR (gpu.debug.vulkan):  :  VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588 {0x30f70d65}
 Validation Error: [ VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588 ] Object 0: handle = 0x7fa09d19ea80, name = LogicalDevice_0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x30f70d65 | vkSetDebugUtilsObjectNameEXT() pNameInfo->objectHandle cannot be VK_NULL_HANDLE. The Vulkan spec states: pNameInfo->objectHandle must not be VK_NULL_HANDLE (https://vulkan.lunarg.com/doc/view/1.3.243.0/linux/1.3-extensions/vkspec.html#VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588) 

1 Object[s] related 
ObjectType[VK_OBJECT_TYPE_DEVICE],Handle[0x7fa09d19ea80],Name[LogicalDevice_0]

ERROR (gpu.debug.vulkan):  :  UNASSIGNED-GeneralParameterError-RequiredParameter {0x99fb7dfd}
 Validation Error: [ UNASSIGNED-GeneralParameterError-RequiredParameter ] Object 0: handle = 0x7fa09d19ea80, name = LogicalDevice_0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x99fb7dfd | vkCmdBindPipeline: required parameter pipeline specified as VK_NULL_HANDLE 

1 Object[s] related 
ObjectType[VK_OBJECT_TYPE_DEVICE],Handle[0x7fa09d19ea80],Name[LogicalDevice_0]

I retested this branch and it is working. I would only keep the objects close to the message it belongs to. But I can tweak a bit when it is applied. Can you make sure this branch is up to date with main. Thanks! ``` WARN (gpu.debug.vulkan): : UNASSIGNED-CoreValidation-Shader-OutputNotConsumed {0x609a13b} Validation Performance Warning: [ UNASSIGNED-CoreValidation-Shader-OutputNotConsumed ] Object 0: handle = 0x85798b0000000067, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x609a13b | VK_SHADER_STAGE_VERTEX_BIT writes to output location 0.0 which is not consumed by VK_SHADER_STAGE_GEOMETRY_BIT. Enable VK_KHR_maintenance4 device extension to allow relaxed interface matching between input and output vectors. 1 Object[s] related ObjectType[VK_OBJECT_TYPE_SHADER_MODULE],Handle[0x85798b0000000067] ERROR (gpu.debug.vulkan): : VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588 {0x30f70d65} Validation Error: [ VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588 ] Object 0: handle = 0x7fa09d19ea80, name = LogicalDevice_0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x30f70d65 | vkSetDebugUtilsObjectNameEXT() pNameInfo->objectHandle cannot be VK_NULL_HANDLE. The Vulkan spec states: pNameInfo->objectHandle must not be VK_NULL_HANDLE (https://vulkan.lunarg.com/doc/view/1.3.243.0/linux/1.3-extensions/vkspec.html#VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588) 1 Object[s] related ObjectType[VK_OBJECT_TYPE_DEVICE],Handle[0x7fa09d19ea80],Name[LogicalDevice_0] ERROR (gpu.debug.vulkan): : UNASSIGNED-GeneralParameterError-RequiredParameter {0x99fb7dfd} Validation Error: [ UNASSIGNED-GeneralParameterError-RequiredParameter ] Object 0: handle = 0x7fa09d19ea80, name = LogicalDevice_0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x99fb7dfd | vkCmdBindPipeline: required parameter pipeline specified as VK_NULL_HANDLE 1 Object[s] related ObjectType[VK_OBJECT_TYPE_DEVICE],Handle[0x7fa09d19ea80],Name[LogicalDevice_0] ```
Kazashi Yoshioka added 1 commit 2023-06-01 16:16:35 +02:00
Author
Contributor

No conflict seems to occur.thank you too from me.

No conflict seems to occur.thank you too from me.
Kazashi Yoshioka added 1 commit 2023-06-01 18:15:31 +02:00
Jeroen Bakker approved these changes 2023-06-02 09:34:51 +02:00
Jeroen Bakker added the
Interest
Vulkan
label 2023-06-02 09:35:02 +02:00
Jeroen Bakker added this to the 4.0 milestone 2023-06-02 09:35:13 +02:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-06-02 09:35:17 +02:00
Jeroen Bakker merged commit a4249588cd into main 2023-06-02 09:50:39 +02:00
Kazashi Yoshioka deleted branch vk_debug_messenger2 2023-06-02 10:49:14 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107635
No description provided.