HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_Stats.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: BRAY_Stats.h (BRAY Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __BRAY_Stats__
12 #define __BRAY_Stats__
13 
14 #include "BRAY_API.h"
15 #include "BRAY_Types.h"
16 #include <UT/UT_UniquePtr.h>
17 #include <UT/UT_Rect.h>
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_JSONValue.h>
21 
22 class BRAY_StatsImpl;
23 class BRAY_Renderer;
24 
25 namespace BRAY
26 {
27 
30 {
31 public:
32  Stats(const BRAY_Renderer &renderer);
33  ~Stats();
34 
35  enum Key
36  {
37  // System information
38  USERNAME, // User name
39  HOSTNAME, // Host name
40  KARMA_VERSION, // Karma version
41  SYSTEM_THREADS, // Thread count
42  SYSTEM_CPU_BRAND, // CPU brand
43  SYSTEM_CPU_ARCHITECTURE,// CPU architecture
44  SYSTEM_MEMORY, // Current system memory usage
45  SYSTEM_TIME, // Current system times
46  SYSTEM_RESOURCE_USAGE, // Current system resource usage
47  SYSTEM_LABEL, // System label
48 
49  // Global render state
50  ENGINE, // Rendering engine (cpu or xpu)
51  XPU_DEVICE_COUNT, // XPU device count
52 
53  RENDER_SETTINGS, // JSON string of all global render settings
54 
55  RENDER_CAMERA, // Path to render camera
56  DICING_CAMERA, // Path to dicing camera
57  RESOLUTION, // Image resoution
58 
59  WORLD_TO_CAMERA, // World to camera transform
60  WORLD_TO_SCREEN, // World to screen transform
61  WORLD_TO_NDC, // World to NDC transform
62  WORLD_TO_RASTER, // World to raster space transform
63 
64  CAMERA_NEAR_FAR, // Camera near/far clipping planes
65 
66  AOV_BUFFERS, // AOV Buffer dictionary
67  AOV_RASTER_MEMORY, // Current/Peak memory used by rasters
68  DEEP_IMAGE_MEMORY, // Current/peak deep memory
69 
70  // Texture information
71  UNIFIED_CACHE, // Unified cache information
72  TEXTURE_ERROR_FILES, // List of bad texture paths
73  TEXTURE_CONVERSIONS, // Textures converted interanally
74  STENCIL_MAP, // Stencil map information
75 
76  RAT_STATS, // Number of .rat textures
77  RAT_DISK_CACHE, // RAT file disk cache performance
78  RAT_DISK_CACHE_ERRORS, // RAT file disk cache conversions
79 
80  OIIO_STATS, // OIIO texture stats
81  OIIO_STATS_STRING, // OIIO stats string (direct from OIIO)
82 
83  PTEX_STATS, // Ptex texture stats
84 
85  // USD information
86  OBJECT_COUNTS, // Object counts in the scene
87  GEOMETRY_COUNTS, // Geometry prim counts in the scene
88  LIGHT_TYPES, // Counts for different light types
89  PRIMVAR_CACHE, // Information about primvar cache
90 
91  // Rendering state information
92  PERCENT_COMPLETE, // Percent complete (0-1)
93  RENDER_STAGE, // Stage of rendering (inactive, loading, etc.)
94  RENDER_STAGE_LABEL, // Stage of rendering (inactive, loading, etc.)
95  LOAD_TIME, // Time to load scene
96  LOAD_MEMORY, // Memory after load
97  TTFP, // Time to first pixel
98  FILTER_ERRORS, // Errors in pixel/image filters (denoisers)
99 
100  // Karma CPU
101  SHADER_CALLS, // Number of shader calls
102  SHADER_NODES, // Number of shader graph nodes
103  RAY_COUNTS, // Primary, indirect, occlusion, etc.
104  TIMINGS, // Breakdown of time
105 
106  // Karma XPU
107  XPU_COMPILES, // XPU compile information
108  XPU_TIMINGS, // XPU-specific timings
109 
110  STOCHASTIC_DEPTH, // Depth of stochastic transparency
111  RAY_DEPTHS, // Distribution of ray-depths
112  RAY_DEPTHS_PERCENTAGE, // Distribution of ray-depths
113  RAY_BATCH_EFFICIENCY, // Batch efficiency
114 
115  // Checkpointing
116  CHECKPOINT_STATS, // Checkpoint stats
117 
118  // Render progress
119  ACTIVE_BUCKETS, // Active buckets list
120 
121  // Annoatations (backward compatibility)
122  PROGRESS_ANNOTATION, // Progress
123  STATS_ANNOTATION, // XPU Stats
124 
125  MAX_KEYS // Sentinal
126  };
127 
129  {
130  DEVICE_LABEL, // Label for the device
131  DEVICE_TYPE, // Type of device (gpu, embree)
132  DEVICE_STATUS, // Device status
133  DEVICE_ERROR, // Device error message
134  DEVICE_MEMORY, // Breakdown of memory
135  DEVICE_SAMPLES, // Number of samples processed by device
136  DEVICE_CONTRIB, // Contribution of device
137 
138  DEVICE_MAX_KEYS // Sentinal
139  };
140 
142  : public UT_NonCopyable
143  {
144  Value(BRAY_StatsImpl &stats, Key key);
145  Value(BRAY_StatsImpl &stats, DeviceKey key, int device);
146  ~Value();
147 
148  SYS_SAFE_BOOL operator bool() const
149  {
150  return myValue.getType() != UT_JSONValue::JSON_NULL;
151  }
152 
153  const UT_JSONValue &get() const { return myValue; }
154  const UT_JSONValue &operator->() const { return myValue; }
155  const UT_JSONValue &operator*() const { return myValue; }
156 
157  const UT_StringHolder &key() const;
158  UT_StringHolder asString() const;
159  private:
160  const UT_JSONValue &myValue;
161  BRAY_StatsImpl &myStats;
162  int myDevice;
163  Key myKey;
164  DeviceKey myDeviceKey;
165  };
166 
167  static const UT_StringHolder &keyName(Key key);
168  static const UT_StringHolder &deviceKeyName(DeviceKey key);
169 
170  /// Lightweight method to get the render stage
171  BRAY_RenderStage renderStage() const;
172  /// Lightweight method to get the percent complete (between 0 and 100)
173  fpreal percentComplete() const;
174 
175  /// Get the value of the stat
176  Value get(Key key) const
177  { return Value(*myImpl, key); }
178 
179  /// Get the value of the device stat
180  Value get(DeviceKey key, int device) const
181  { return Value(*myImpl, key, device); }
182 
183  /// After XPU devices are initialized, call this method to configure the
184  /// stats.
185  void initDevices();
186 
187  /// Clear for next render
188  void clear();
189 
190  /// @{
191  /// @private - methods used by the renderer to update stats during rendering
193  void setPercentDone(fpreal v);
194  void setTTFP(fpreal v);
195  void setProgressAnnotation(const UT_StringHolder &s);
196  void setStatsAnnotation(const UT_StringHolder &s);
197  void setAnnotations(const UT_StringHolder &progress_annotation,
198  const UT_StringHolder &stats_annotation);
199  void startBucket(const UT_DimRect &bounds, int pass);
200  void endBucket();
201 
202  struct AutoBucket
203  {
204  AutoBucket(Stats &stats, const UT_DimRect &bounds, int pass)
205  : myStats(stats)
206  {
207  myStats.startBucket(bounds, pass);
208  }
210  {
211  myStats.endBucket();
212  }
214  };
215  /// @}
216 
217 private:
219 };
220 
221 } // End namespace
222 
223 #endif
224 
const UT_JSONValue & operator*() const
Definition: BRAY_Stats.h:155
const GLdouble * v
Definition: glcorearb.h:837
GLdouble s
Definition: glad.h:3009
OutGridT const XformOp bool bool
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
BRAY_RenderStage
Definition: BRAY_Types.h:683
#define SYS_SAFE_BOOL
Definition: SYS_Compiler.h:55
AutoBucket(Stats &stats, const UT_DimRect &bounds, int pass)
Definition: BRAY_Stats.h:204
fpreal64 fpreal
Definition: SYS_Types.h:278
#define BRAY_API
Definition: BRAY_API.h:12
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
const UT_JSONValue & operator->() const
Definition: BRAY_Stats.h:154