Blender V5.3
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
16/* -------------------------------------------------------------------- */
19
20VKRenderGraph::VKRenderGraph(VKResourceStateTracker &resources) : resources_(resources) {}
21
23{
24#if 0
25 memstats();
26#endif
27
29
30 links_.clear();
31 for (VKRenderGraphNode &node : nodes_) {
32 node.free_data();
33 }
34 nodes_.clear();
35 storage_.reset();
36
37 debug_.node_group_map.clear();
38 debug_.used_groups.clear();
39 debug_.group_stack.clear();
40 debug_.groups.clear();
41}
42
44{
45 std::cout << __func__ << " nodes: (" << nodes_.size() << "/" << nodes_.capacity() << "), "
46 << "links(buffer): (" << links_.buffers.size() << "/" << links_.buffers.capacity()
47 << "), "
48 << "links(images): (" << links_.images.size() << "/" << links_.images.capacity()
49 << ")\n";
50#define PRINT_STORAGE(name) \
51 std::cout << " " #name " : (" << storage_.name.size() << " / " << storage_.name.capacity() \
52 << ")\n "
53
54 PRINT_STORAGE(begin_rendering);
55 PRINT_STORAGE(clear_attachments);
56 PRINT_STORAGE(blit_image);
57 PRINT_STORAGE(copy_buffer_to_image);
58 PRINT_STORAGE(copy_image);
59 PRINT_STORAGE(copy_image_to_buffer);
61 PRINT_STORAGE(draw_indexed);
62 PRINT_STORAGE(draw_indexed_indirect);
63 PRINT_STORAGE(draw_indirect);
64#undef PRINT_STORAGE
65}
66
68
69/* -------------------------------------------------------------------- */
72
74{
75 ColorTheme4f useColor = color;
76 if ((color == gpu::debug::GPU_DEBUG_GROUP_COLOR_DEFAULT) && (debug_.group_stack.size() > 0)) {
77 useColor = debug_.groups[debug_.group_stack.last()].color;
78 }
79 DebugGroupNameID name_id = debug_.groups.index_of_or_add({std::string(name), useColor});
80 debug_.group_stack.append(name_id);
81 debug_.group_used = false;
82}
83
85{
86 debug_.group_stack.pop_last();
87 debug_.group_used = false;
88}
89
91{
92 std::ostream &os = std::cout;
93 os << "NODE:\n";
94 const VKRenderGraphNode &node = nodes_[node_handle];
95 os << " type:" << node.type << "\n";
96}
97
98std::string VKRenderGraph::full_debug_group(NodeHandle node_handle) const
99{
100 if ((G.debug & G_DEBUG_GPU) == 0) {
101 return std::string();
102 }
103
104 DebugGroupID debug_group = debug_.node_group_map[node_handle];
105 if (debug_group == -1) {
106 return std::string();
107 }
108
109 std::stringstream ss;
110 for (const VKRenderGraph::DebugGroupNameID &name_id : debug_.used_groups[debug_group]) {
111 ss << "/" << debug_.groups[name_id].name;
112 }
113
114 return ss.str();
115}
116
118
119} // namespace blender::gpu::render_graph
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
Global G
Definition blender.cc:57
ColorTheme4< float > ColorTheme4f
#define PRINT_STORAGE(name)