Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
WorkUnit.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <Common/assertion.h>
7
8namespace ph
9{
10
17{
18public:
21 WorkUnit();
22
25 explicit WorkUnit(const Region& region);
26
29 WorkUnit(const Region& region, std::size_t depth);
30
31 Region getRegion() const;
32 int64 getWidth() const;
33 int64 getHeight() const;
34 std::size_t getDepth() const;
35 std::size_t getVolume() const;
36 float64 getAspectRatio() const;
37
38 std::string toString() const;
39
40private:
41 Region m_region;
42 std::size_t m_depth;
43};
44
45// In-header Implementations:
46
48 WorkUnit({{0, 0}, {0, 0}}, 0)
49{}
50
51inline WorkUnit::WorkUnit(const Region& region) :
52 WorkUnit(region, 1)
53{}
54
55inline WorkUnit::WorkUnit(const Region& region, const std::size_t depth) :
56 m_region(region),
57 m_depth(depth)
58{
59 PH_ASSERT_MSG(!m_region.isEmpty(), "region = " + m_region.toString());
60}
61
62inline int64 WorkUnit::getWidth() const
63{
64 return m_region.getWidth();
65}
66
67inline int64 WorkUnit::getHeight() const
68{
69 return m_region.getHeight();
70}
71
73{
74 return m_region;
75}
76
77inline std::size_t WorkUnit::getDepth() const
78{
79 return m_depth;
80}
81
82inline std::size_t WorkUnit::getVolume() const
83{
84 PH_ASSERT(!m_region.isEmpty());
85
86 return static_cast<std::size_t>(m_region.getArea()) * m_depth;
87}
88
89inline float64 WorkUnit::getAspectRatio() const
90{
91 PH_ASSERT_GE(m_region.getWidth(), 0);
92 PH_ASSERT_GT(m_region.getHeight(), 0);
93
94 return static_cast<float64>(m_region.getWidth()) / static_cast<float64>(m_region.getHeight());
95}
96
97inline std::string WorkUnit::toString() const
98{
99 return "region = " + m_region.toString() + ", depth = " + std::to_string(m_depth);
100}
101
102}// end namespace ph
Represents some amount of work.
Definition WorkUnit.h:17
std::size_t getVolume() const
Definition WorkUnit.h:82
WorkUnit()
Represents zero amount of work.
Definition WorkUnit.h:47
Region getRegion() const
Definition WorkUnit.h:72
float64 getAspectRatio() const
Definition WorkUnit.h:89
std::string toString() const
Definition WorkUnit.h:97
int64 getHeight() const
Definition WorkUnit.h:67
std::size_t getDepth() const
Definition WorkUnit.h:77
int64 getWidth() const
Definition WorkUnit.h:62
T getHeight() const
Definition TAABB2D.ipp:144
T getWidth() const
Definition TAABB2D.ipp:138
bool isEmpty() const
Definition TAABB2D.ipp:193
std::string toString() const
Definition TAABB2D.ipp:235
T getArea() const
Definition TAABB2D.ipp:69
The root for all renderer implementations.
Definition EEngineProject.h:6