Blender V4.5
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{
18 submission_id.reset();
19}
20
22{
23#if 0
24 memstats();
25#endif
26 submission_id.next();
27
28 links_.clear_and_shrink();
29 for (VKRenderGraphNode &node : nodes_) {
30 node.free_data(storage_);
31 }
32 nodes_.clear_and_shrink();
33 storage_.reset();
34
35 debug_.node_group_map.clear();
36 debug_.used_groups.clear();
37 debug_.group_stack.clear();
38 debug_.groups.clear();
39}
40
42{
43 std::cout << __func__ << " nodes: (" << nodes_.size() << "/" << nodes_.capacity() << "), "
44 << "links: (" << links_.size() << "/" << links_.capacity() << ")\n";
45#define PRINT_STORAGE(name) \
46 std::cout << " " #name " : (" << storage_.name.size() << " / " << storage_.name.capacity() \
47 << ")\n "
48
49 PRINT_STORAGE(begin_rendering);
50 PRINT_STORAGE(clear_attachments);
51 PRINT_STORAGE(blit_image);
52 PRINT_STORAGE(copy_buffer_to_image);
53 PRINT_STORAGE(copy_image);
54 PRINT_STORAGE(copy_image_to_buffer);
56 PRINT_STORAGE(draw_indexed);
57 PRINT_STORAGE(draw_indexed_indirect);
58 PRINT_STORAGE(draw_indirect);
59#undef PRINT_STORAGE
60}
61
63
64/* -------------------------------------------------------------------- */
67
69{
70 ColorTheme4f useColor = color;
72 (debug_.group_stack.size() > 0))
73 {
74 useColor = debug_.groups[debug_.group_stack.last()].color;
75 }
76 DebugGroupNameID name_id = debug_.groups.index_of_or_add({std::string(name), useColor});
77 debug_.group_stack.append(name_id);
78 debug_.group_used = false;
79}
80
82{
83 debug_.group_stack.pop_last();
84 debug_.group_used = false;
85}
86
88{
89 std::ostream &os = std::cout;
90 os << "NODE:\n";
91 const VKRenderGraphNode &node = nodes_[node_handle];
92 os << " type:" << node.type << "\n";
93
94 const VKRenderGraphNodeLinks &links = links_[node_handle];
95 os << " inputs:\n";
96 for (const VKRenderGraphLink &link : links.inputs) {
97 os << " ";
98 link.debug_print(os, resources_);
99 os << "\n";
100 }
101 os << " outputs:\n";
102 for (const VKRenderGraphLink &link : links.outputs) {
103 os << " ";
104 link.debug_print(os, resources_);
105 os << "\n";
106 }
107}
108
109std::string VKRenderGraph::full_debug_group(NodeHandle node_handle) const
110{
111 if ((G.debug & G_DEBUG_GPU) == 0) {
112 return std::string();
113 }
114
115 DebugGroupID debug_group = debug_.node_group_map[node_handle];
116 if (debug_group == -1) {
117 return std::string();
118 }
119
120 std::stringstream ss;
121 for (const VKRenderGraph::DebugGroupNameID &name_id : debug_.used_groups[debug_group]) {
122 ss << "/" << debug_.groups[name_id].name;
123 }
124
125 return ss.str();
126}
127
129
130} // 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
Definition BLI_color.hh:292
#define PRINT_STORAGE(name)