Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
RenderWorker.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <Common/primitive_type.h>
8
9#include <atomic>
10#include <utility>
11
12namespace ph
13{
14
15class RenderWork;
16
17class RenderWorker final
18{
19public:
20 inline RenderWorker() = default;
21 RenderWorker(const RendererProxy& renderer, uint32 id);
22 RenderWorker(const RenderWorker& other);
23
24 void run();
25 void setWork(RenderWork* work);
26 void setTotalWork(uint32 totalWork);
27 void setWorkDone(uint32 workDone);
28 void incrementWorkDone();
29 uint32 getId() const;
30 //RenderProgress asyncQueryProgress();
31
33
34private:
35 RendererProxy m_renderer;
36 uint32 m_id;
37 RenderWork* m_work;
38 std::atomic_uint32_t m_totalWork;
39 std::atomic_uint32_t m_workDone;
40 std::atomic_uint32_t m_numElapsedMs;
41
42 void doWork();
43};
44
45// In-header Implementations:
46
47inline uint32 RenderWorker::getId() const
48{
49 return m_id;
50}
51
52inline void RenderWorker::setTotalWork(const uint32 totalWork)
53{
54 m_totalWork = totalWork;
55}
56
57inline void RenderWorker::setWorkDone(const uint32 workDone)
58{
59 m_workDone = workDone;
60}
61
63{
64 m_workDone++;
65}
66
67//inline RenderProgress RenderWorker::asyncQueryProgress()
68//{
69// RenderProgress progress;
70// progress.totalWork = m_totalWork;
71// progress.workDone = m_workDone;
72//
73// return progress;
74//}
75
76}// end namespace ph
Definition RenderWork.h:16
Definition RenderWorker.h:18
void incrementWorkDone()
Definition RenderWorker.h:62
RenderWorker & operator=(const RenderWorker &rhs)
Definition RenderWorker.cpp:52
void run()
Definition RenderWorker.cpp:28
void setWork(RenderWork *work)
Definition RenderWorker.cpp:43
void setTotalWork(uint32 totalWork)
Definition RenderWorker.h:52
RenderWorker()=default
uint32 getId() const
Definition RenderWorker.h:47
void setWorkDone(uint32 workDone)
Definition RenderWorker.h:57
Definition RendererProxy.h:15
The root for all renderer implementations.
Definition EEngineProject.h:6