Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
Statistics.h
Go to the documentation of this file.
1#pragma once
2
3#include <Common/primitive_type.h>
4
5#include <atomic>
6
7namespace ph
8{
9
10class Statistics final
11{
12public:
13 class Record final
14 {
15 public:
16 uint32 totalWork;
17 uint32 workDone;
20
22 };
23
24public:
25 inline Statistics() :
26 m_totalWork(0), m_workDone(0), m_numSamplesTaken(0), m_numMsElapsed(0)
27 {}
28
29 inline Statistics(const Statistics& other) :
30 m_totalWork (other.m_totalWork.load()),
31 m_workDone (other.m_workDone.load()),
32 m_numSamplesTaken(other.m_numSamplesTaken.load()),
33 m_numMsElapsed (other.m_numMsElapsed.load())
34 {}
35
36 inline void setTotalWork(const uint32 totalWork)
37 {
38 m_totalWork = totalWork;
39 }
40
41 inline void setWorkDone(const uint32 workDone)
42 {
43 m_workDone = workDone;
44 }
45
46 inline void setNumSamplesTaken(const uint32 numSamples)
47 {
48 m_numSamplesTaken = numSamples;
49 }
50
51 inline void setNumMsElapsed(const uint32 numMsElapsed)
52 {
53 m_numMsElapsed = numMsElapsed;
54 }
55
56 inline void incrementWorkDone()
57 {
58 ++m_workDone;
59 }
60
61 inline Record record() const
62 {
64 record.totalWork = m_totalWork;
65 record.workDone = m_workDone;
66 record.numSamplesTaken = m_numSamplesTaken;
67 record.numMsElapsed = m_numMsElapsed;
68
69 return record;
70 }
71
72 inline Statistics& operator = (const Statistics& rhs)
73 {
74 m_totalWork = rhs.m_totalWork.load();
75 m_workDone = rhs.m_workDone.load();
76 m_numSamplesTaken = rhs.m_numSamplesTaken.load();
77 m_numMsElapsed = rhs.m_numMsElapsed.load();
78
79 return *this;
80 }
81
82private:
83 std::atomic_uint32_t m_totalWork;
84 std::atomic_uint32_t m_workDone;
85 std::atomic_uint32_t m_numSamplesTaken;
86 std::atomic_uint32_t m_numMsElapsed;
87};
88
89}// end namespace ph
Definition Statistics.h:14
uint32 workDone
Definition Statistics.h:17
Record()
Definition Statistics.h:21
uint32 totalWork
Definition Statistics.h:16
uint32 numSamplesTaken
Definition Statistics.h:18
uint32 numMsElapsed
Definition Statistics.h:19
Definition Statistics.h:11
void setNumSamplesTaken(const uint32 numSamples)
Definition Statistics.h:46
Statistics()
Definition Statistics.h:25
void setTotalWork(const uint32 totalWork)
Definition Statistics.h:36
Record record() const
Definition Statistics.h:61
void setNumMsElapsed(const uint32 numMsElapsed)
Definition Statistics.h:51
void setWorkDone(const uint32 workDone)
Definition Statistics.h:41
Statistics(const Statistics &other)
Definition Statistics.h:29
void incrementWorkDone()
Definition Statistics.h:56
Statistics & operator=(const Statistics &rhs)
Definition Statistics.h:72
The root for all renderer implementations.
Definition EEngineProject.h:6