WIP: Vulkan: Add functions for Debug to GPU Vulkan Module #105484
No reviewers
Labels
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 project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105484
Loading…
Reference in New Issue
No description provided.
Delete Branch "(deleted):vulkan-debuggingtools"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add functions for Debug to GPU Vulkan Module.
I would like to add Debug function to GPU/Vulkan.
The newly added items are roughly divided into three.
Check errors
To manage the internal message of Vulkan.
Vulkan Object labeling, command and queue framing.
Alternative proposals
Splitting this pull request
Policy on linking with vulkanSDK.[#105922 (comment)]
Implementation of DebugUtils.
Handling runtime errors.
Discussion and improvements to ContextVK initialization.
TODO
debugprintfEXT.
Debug messages are classified, especially to operate the performance flag message.
Vulkan : Add functions for Debug to GPU Vulkan Module.to WIP: Vulkan : Add functions for Debug to GPU Vulkan Module.WIP: Vulkan : Add functions for Debug to GPU Vulkan Module.to WIP: Vulkan: Add functions for Debug to GPU Vulkan Module@ -992,2 +992,4 @@
set(WITH_VULKAN_BACKEND OFF)
endif()
if(EXISTS ${LIBDIR}/shaderc)
This part should be done in an additional PR. And should follow the same structure as platform_unix/apple.
Fixed by LazyDodo.
Did a global overview. think we should first move bits and pieces into the right location before going in more details.
@ -0,0 +29,4 @@
/* Function pointer definitions for use only in this file.*/
#if defined(VK_EXT_debug_utils)
PFN_vkCreateDebugUtilsMessengerEXT pfvkCreateDebugUtilsMessengerEXT = nullptr;
We should move these pointers to the VKContext. We might want to add a class there to put all the debug stuff in.
These functions are only used in this cc file. I should have VKContext load all of the extension functions in one place, but I can't think of any benefit from creating multiple instances.
@ -0,0 +470,4 @@
/*
* TODO:: Comment
*/
void GHOST_VulkanInstanceLoad(void *m_instance)
GPU module is allowed to call GHOST, but we don't allow the reverse.
The m_instance is part of the VKContext and might just need to call it here.
There we also use vk function pointers to setup the vma. We might want to incorporate it there.
Here's what we want to do with this change:
Even though many vulkan objects are generated in the initializeDrawingContext function, debugutils can't keep track of them.
So, we should register debugutils after the VkInstance is generated but before the VkDevice is generated.
The benefits of this.
@ -0,0 +33,4 @@
template<typename T> void object_vk_label(VkDevice device, T obj, const std::string &name);
void object_vk_label(VkDevice device, VkObjectType objType, uint64_t obj, const std::string &name);
void pushMarker(VkCommandBuffer cmd, const std::string &name);
We might want to add this to
VKContext.debug_group_begin/end
and hook it with theGPU_debug.h
It will be done by labeling for VkQueue.
@ -0,0 +45,4 @@
}
#define VK_ERROR_CHECK_ENABLE
Why not use the validation layers. For OpenGL this was desired, but not sure we need it for Vulkan/Metal as it is already part of its SDK/Infrastructure.
Error check using wrap function instead of VK_CHECK by #define.
This advantages.
> we don't have to write a define like VK_CHECK.
> we can also switch at runtime.
> it becomes easy to uncheck uniformly.
I thought about removing this check completely in release builds.
However, it's always a good idea to do runtime error checking.
I think I'm a little misunderstood.
What exactly does use the validation layers mean?
Again, as you say, we have to keep the functions as members of the structure.
I'm still verifying that it works.
I created a mode that defines all the vulkan functions our own, using the definition VK_NO_PROTOTYPES. Then check for errors.
As a premise, define
VK_NO_PROTOTYPES
before includingvulkan.h
.Keep only what blender uses.
Here, LibraryFunc (LF) is a function that gets a library such as LoadlibraryA.
above part
how to load
Inside the GPU module, all vulkan functions are compiled as nullptrs and loaded outside the main program.
An externally defined vulkan function wraps them. This technique is thanks to extern inline.
about speed
In the test, VkInstance was created and destroyed 1000 times. here!
With or without definition = VK_NO_PROTOTYPES(If you remove the definition, the built-in function will remain as it is.),there is almost no difference. In a few alternating runs, the fastest result was the one that dynamically loaded, but on average it seems to have a bit more overhead.
here is the definition
VkInstance 1000 creation intern callee 4.646438 extern callee 4.589588
as it is
VkInstance 1000 creation intern callee 4.708100 extern callee 5.095500
The print of debugUtils looks like this!
This PR feels like it contains multiple changes in a single PR. It is better to split this into multiple PR's explain for each PR the reasoning. I am not a Vulkan expert and perhaps the changes are needed, but we should discuss them one by one, explain and document. Decisions should be clearly made and documented.
For example:
@ -103,0 +174,4 @@
extern VKWrapper vk_wrapper;
# endif
#endif
class VKFunctionsLoader {
Unclear to me why we need to load all functions lazy. What are we trying to solve and if we want to solve something, we should describe that and perhaps create a different pull request for that.
@ -0,0 +45,4 @@
}
}
/* clang-format off */
When having
VK_LAYER_KHRONOS_validation
available on your system and starting blender with--debug-gpu
you should already get the same results.It might be that the validation layer misses some calls, but what I have found so far this makes it really easy to enable/disable validation at runtime without recompiling blender.
When I was testing the linux build, it seems that the warning due to undefined function of extern inline cannot be suppressed.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66918
Should have investigated first.
Thank you for your kind comments.
Since Vulkan functions are global, they are easier to understand and run faster than static definitions, so that's what I did.
However, it seems that Linux does not allow immaterial use without warning.
Write programs that do one thing and do it well.
However, I think it's debatable when it comes to initializing ContextVK.
As you suggested, I'm going to break it down into several PRs.
@ -0,0 +45,4 @@
}
}
/* clang-format off */
There is no direct relationship between VK_LAYER_KHRONOS_validation being enabled and error(VkResult) handling for vulkan functions.
I wrote it because I thought it would be easier to operate if the function can be called as is, without the execution speed overhead of wrapping the function.And within gl_debug.hh, to align with such an implementation.
9703088d03/source/blender/gpu/opengl/gl_debug.hh (L106)
Would you like to use something like Vk_CHECK to handle VkResult in the same way as ContextVk?
@ -0,0 +45,4 @@
}
}
/* clang-format off */
Although this can be done in a similar way as OpenGL. I expect that developers working on the vulkan backend most likely have the validation layer enabled.
For end users I can see the additional value as it can help with finding out what the specific platform works. In that case I would use a similar approach as OpenGL. Note that the downside is that during development you might receive the message twice, but that is expected.
We should extract this in a separate PR another implementation would be to provide a validation layer that will report this. This way the overhead/code will be isolated.
@ -0,0 +45,4 @@
}
}
/* clang-format off */
In order for developers to use the validation layer, we will use vulkanSDK, but first I would like to make a PR about how to load it. In particular we have to decide whether to do it Explicit or Implicit. Do you have an opinion on this point?
windows
linux
@ -0,0 +45,4 @@
}
}
/* clang-format off */
We mentioned setting the environment variable VK_LAYER_PATH.
Pre-installing the SDK in a path that normally requires permissions.
Is there a problem setting the environment variables? Obviously you don't want to change variables like LD_LIBRARY_PATH, but not setting VK_LAYER_PATH is an implicit way of asking for permissions directly.
Pull request closed