Vulkan: Device statistics

This PR adds device statistics which can be printed to the console.
By default nothing is printed, but developer can choose to enable
it during development.

Pull Request: https://projects.blender.org/blender/blender/pulls/124150
This commit is contained in:
Jeroen Bakker 2024-07-04 13:47:54 +02:00
parent 4cd1245396
commit 89daa19f57
5 changed files with 29 additions and 0 deletions

@ -339,6 +339,9 @@ void VKContext::swap_buffers_pre_handler(const GHOST_VulkanSwapChainData &swap_c
render_graph.submit_for_present(swap_chain_data.image);
device.resources.remove_image(swap_chain_data.image);
#if 0
device.debug_print();
#endif
device.destroy_discarded_resources();
}

@ -68,6 +68,7 @@ namespace blender::gpu {
* Registries of descriptor set layouts.
*/
class VKDescriptorSetLayouts : NonCopyable {
friend class VKDevice;
private:
/**

@ -420,4 +420,26 @@ void VKDevice::memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb) co
/** \} */
/* -------------------------------------------------------------------- */
/** \name Debugging/statistics
* \{ */
void VKDevice::debug_print()
{
std::ostream &os = std::cout;
os << "Pipelines\n";
os << " Graphics: " << pipelines.graphic_pipelines_.size() << "\n";
os << " Compute: " << pipelines.compute_pipelines_.size() << "\n";
os << "Descriptor sets\n";
os << " VkDescriptorSetLayouts: " << descriptor_set_layouts_.size() << "\n";
os << "Discarded resources\n";
os << " VkImageView: " << discarded_image_views_.size() << "\n";
os << " VkImage: " << discarded_images_.size() << "\n";
os << " VkBuffer: " << discarded_buffers_.size() << "\n";
os << "\n";
}
/** \} */
} // namespace blender::gpu

@ -250,6 +250,7 @@ class VKDevice : public NonCopyable {
void destroy_discarded_resources();
void memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb) const;
void debug_print();
/** \} */

@ -230,6 +230,8 @@ class VKDevice;
* lacking.
*/
class VKPipelinePool : public NonCopyable {
friend class VKDevice;
public:
private:
Map<VKComputeInfo, VkPipeline> compute_pipelines_;