Blender V5.0
vk_render_graph.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "vk_render_graph.hh"
10#include "gpu_backend.hh"
11
12#include <sstream>
13
15
16VKRenderGraph::VKRenderGraph(VKResourceStateTracker &resources) : resources_(resources) {}
17
19{
20#if 0
21 memstats();
22#endif
23
24 links_.clear_and_shrink();
25 for (VKRenderGraphNode &node : nodes_) {
26 node.free_data(storage_);
27 }
28 nodes_.clear_and_shrink();
29 storage_.reset();
30
31 debug_.node_group_map.clear();
32 debug_.used_groups.clear();
33 debug_.group_stack.clear();
34 debug_.groups.clear();
35}
36
38{
39 std::cout << __func__ << " nodes: (" << nodes_.size() << "/" << nodes_.capacity() << "), "
40 << "links: (" << links_.size() << "/" << links_.capacity() << ")\n";
41#define PRINT_STORAGE(name) \
42 std::cout << " " #name " : (" << storage_.name.size() << " / " << storage_.name.capacity() \
43 << ")\n "
44
45 PRINT_STORAGE(begin_rendering);
46 PRINT_STORAGE(clear_attachments);
47 PRINT_STORAGE(blit_image);
48 PRINT_STORAGE(copy_buffer_to_image);
49 PRINT_STORAGE(copy_image);
50 PRINT_STORAGE(copy_image_to_buffer);
52 PRINT_STORAGE(draw_indexed);
53 PRINT_STORAGE(draw_indexed_indirect);
54 PRINT_STORAGE(draw_indirect);
55#undef PRINT_STORAGE
56}
57
59
60/* -------------------------------------------------------------------- */
63
65{
66 ColorTheme4f useColor = color;
68 (debug_.group_stack.size() > 0))
69 {
70 useColor = debug_.groups[debug_.group_stack.last()].color;
71 }
72 DebugGroupNameID name_id = debug_.groups.index_of_or_add({std::string(name), useColor});
73 debug_.group_stack.append(name_id);
74 debug_.group_used = false;
75}
76
78{
79 debug_.group_stack.pop_last();
80 debug_.group_used = false;
81}
82
84{
85 std::ostream &os = std::cout;
86 os << "NODE:\n";
87 const VKRenderGraphNode &node = nodes_[node_handle];
88 os << " type:" << node.type << "\n";
89
90 const VKRenderGraphNodeLinks &links = links_[node_handle];
91 os << " inputs:\n";
92 for (const VKRenderGraphLink &link : links.inputs) {
93 os << " ";
94 link.debug_print(os, resources_);
95 os << "\n";
96 }
97 os << " outputs:\n";
98 for (const VKRenderGraphLink &link : links.outputs) {
99 os << " ";
100 link.debug_print(os, resources_);
101 os << "\n";
102 }
103}
104
105std::string VKRenderGraph::full_debug_group(NodeHandle node_handle) const
106{
107 if ((G.debug & G_DEBUG_GPU) == 0) {
108 return std::string();
109 }
110
111 DebugGroupID debug_group = debug_.node_group_map[node_handle];
112 if (debug_group == -1) {
113 return std::string();
114 }
115
116 std::stringstream ss;
117 for (const VKRenderGraph::DebugGroupNameID &name_id : debug_.used_groups[debug_group]) {
118 ss << "/" << debug_.groups[name_id].name;
119 }
120
121 return ss.str();
122}
123
125
126} // namespace blender::gpu::render_graph
@ G_DEBUG_GPU
VKRenderGraph(VKResourceStateTracker &resources)
void debug_group_begin(const char *name, const ColorTheme4f &color)
void debug_print(NodeHandle node_handle) const
std::string full_debug_group(NodeHandle node_handle) const
#define G(x, y, z)
static blender::ColorTheme4f GPU_DEBUG_GROUP_COLOR_DEFAULT
ColorTheme4< float > ColorTheme4f
const char * name
#define PRINT_STORAGE(name)