7#include <Common/assertion.h>
33 std::size_t numWorkers,
37 std::size_t numWorkers,
42 std::size_t numWorkers,
46 std::size_t prioriAxis);
52 std::size_t m_prioriAxis;
54 void scheduleOne(
WorkUnit* out_workUnit)
override;
66 , m_prioriAxis (math::constant::X_AXIS)
70 const std::size_t numWorkers,
77 static_cast<
std::size_t>(
78 std::ceil(math::
fast_sqrt(numWorkers * static_cast<float>(totalWorkUnit.getAspectRatio())))),
79 static_cast<
std::size_t>(
80 std::ceil(math::
fast_sqrt(numWorkers / static_cast<float>(totalWorkUnit.getAspectRatio()))))))
84 const std::size_t numWorkers,
93 math::constant::X_AXIS)
97 const std::size_t numWorkers,
101 const std::size_t prioriAxis)
105 , m_numCells (numCells)
106 , m_currentCell(0, 0)
108 , m_prioriAxis (prioriAxis)
111inline void GridScheduler::scheduleOne(
WorkUnit*
const out_workUnit)
113 PH_ASSERT(out_workUnit);
118 if(m_currentCell.
x() < m_numCells.
x() && m_currentCell.
y() < m_numCells.
y())
124 m_currentCell.
x(), totalWidth, m_numCells.
x());
127 const auto size = sideRangeX.second - sideRangeX.first;
128 sideRangeX.first = totalWidth - sideRangeX.second;
129 sideRangeX.second = sideRangeX.first + size;
133 m_currentCell.
y(), totalHeight, m_numCells.
y());
136 const auto size = sideRangeY.second - sideRangeY.first;
137 sideRangeY.first = totalHeight - sideRangeY.second;
138 sideRangeY.second = sideRangeY.first + size;
141 *out_workUnit = WorkUnit(
150 if(m_currentCell.
x() == m_numCells.
x())
152 m_currentCell.
x() = 0;
159 if(m_currentCell.
y() == m_numCells.
y())
161 m_currentCell.
y() = 0;
168 *out_workUnit = WorkUnit();
Definition GridScheduler.h:20
EOrigin
Definition GridScheduler.h:23
GridScheduler()
Definition GridScheduler.h:59
A manager that distributes a fixed amount of work to workers.
Definition WorkScheduler.h:21
WorkUnit m_totalWorkUnit
Definition WorkScheduler.h:55
Represents some amount of work.
Definition WorkUnit.h:17
Region getRegion() const
Definition WorkUnit.h:72
std::size_t getDepth() const
Definition WorkUnit.h:77
T getHeight() const
Definition TAABB2D.ipp:144
T getWidth() const
Definition TAABB2D.ipp:138
const TVector2< T > & getMinVertex() const
Definition TAABB2D.ipp:120
T & x()
Definition TVector2.ipp:38
T & y()
Definition TVector2.ipp:44
Miscellaneous math utilities.
constexpr std::size_t X_AXIS
Definition constant.h:90
std::pair< std::size_t, std::size_t > ith_evenly_divided_range(const std::size_t rangeIndex, const std::size_t totalSize, const std::size_t numDivisions)
Gets the i-th evenly divided range.
Definition math.h:379
TVector2< std::size_t > Vector2S
Definition math_fwd.h:48
float fast_sqrt(const float x)
Computes sqrt(x) in a fast but approximative way.
Definition math.h:436
The root for all renderer implementations.
Definition EEngineProject.h:6
math::TAABB2D< int64 > Region
Definition Region.h:8