Blender  V2.93
deg_debug.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
27 #include "intern/depsgraph_type.h"
28 
29 #include "BKE_global.h"
30 
31 #include "DEG_depsgraph_debug.h"
32 
33 namespace blender {
34 namespace deg {
35 
37  public:
39 
40  bool do_time_debug() const;
41 
43  void end_graph_evaluation();
44 
45  /* NOTE: Corresponds to G_DEBUG_DEPSGRAPH_* flags. */
46  int flags;
47 
48  /* Name of this dependency graph (is used for debug prints, helping to distinguish graphs
49  * created for different view layer). */
50  string name;
51 
52  /* Is true when dependency graph was evaluated at least once.
53  * This is NOT an indication that depsgraph is at its evaluated state. */
55 
56  protected:
57  /* Maximum number of counters used to calculate frame rate of depsgraph update. */
58  static const constexpr int MAX_FPS_COUNTERS = 64;
59 
60  /* Point in time when last graph evaluation began.
61  * Is initialized from begin_graph_evaluation() when time debug is enabled.
62  */
64 
66 };
67 
68 #define DEG_DEBUG_PRINTF(depsgraph, type, ...) \
69  do { \
70  if (DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_##type) { \
71  DEG_debug_print_begin(depsgraph); \
72  fprintf(stdout, __VA_ARGS__); \
73  } \
74  } while (0)
75 
76 #define DEG_GLOBAL_DEBUG_PRINTF(type, ...) \
77  do { \
78  if (G.debug & G_DEBUG_DEPSGRAPH_##type) { \
79  fprintf(stdout, __VA_ARGS__); \
80  } \
81  } while (0)
82 
83 #define DEG_ERROR_PRINTF(...) \
84  do { \
85  fprintf(stderr, __VA_ARGS__); \
86  fflush(stderr); \
87  } while (0)
88 
89 bool terminal_do_color(void);
90 string color_for_pointer(const void *pointer);
91 string color_end(void);
92 
93 } // namespace deg
94 } // namespace blender
AveragedTimeSampler< MAX_FPS_COUNTERS > fps_samples_
Definition: deg_debug.h:65
static constexpr const int MAX_FPS_COUNTERS
Definition: deg_debug.h:58
bool terminal_do_color()
Definition: deg_debug.cc:75
string color_for_pointer(const void *pointer)
Definition: deg_debug.cc:80
string color_end()
Definition: deg_debug.cc:92