Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PMAtomicStatistics.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <cstddef>
5#include <cstdint>
6
7namespace ph
8{
9
13{
14public:
16
19 void zero();
20
21 void addNumTracedPhotons(std::size_t num);
23
24 std::size_t numTracedPhotons() const;
25 std::size_t numProcessedSteps() const;
26
27private:
28 std::atomic_uint64_t m_numTracedPhotons;
29 std::atomic_uint32_t m_numProcessedSteps;
30};
31
32// In-header Implementations:
33
38
40{
41 m_numTracedPhotons = 0;
42 m_numProcessedSteps = 0;
43}
44
45inline void PMAtomicStatistics::addNumTracedPhotons(const std::size_t num)
46{
47 m_numTracedPhotons.fetch_add(static_cast<std::uint64_t>(num), std::memory_order_relaxed);
48}
49
51{
52 m_numProcessedSteps.fetch_add(1, std::memory_order_relaxed);
53}
54
55inline std::size_t PMAtomicStatistics::numTracedPhotons() const
56{
57 return static_cast<std::size_t>(m_numTracedPhotons.load(std::memory_order_relaxed));
58}
59
60inline std::size_t PMAtomicStatistics::numProcessedSteps() const
61{
62 return static_cast<std::size_t>(m_numProcessedSteps.load(std::memory_order_relaxed));
63}
64
65}// end namespace ph
Thread safe statictics tracking utilities.
Definition PMAtomicStatistics.h:13
void zero()
Resets all internal states.
Definition PMAtomicStatistics.h:39
std::size_t numProcessedSteps() const
Definition PMAtomicStatistics.h:60
void addNumTracedPhotons(std::size_t num)
Definition PMAtomicStatistics.h:45
std::size_t numTracedPhotons() const
Definition PMAtomicStatistics.h:55
void incrementNumProcessedSteps()
Definition PMAtomicStatistics.h:50
PMAtomicStatistics()
Definition PMAtomicStatistics.h:34
The root for all renderer implementations.
Definition EEngineProject.h:6