View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

parrendmgr.h
Go to the documentation of this file.
1#ifndef VISTLE_PARRENDMGR_H
2#define VISTLE_PARRENDMGR_H
3
4#include <IceT.h>
5#include <IceTMPI.h>
6#include "rhrcontroller.h"
7#include "renderobject.h"
8
9namespace vistle {
10
11class RenderObject;
12class Renderer;
13
14class V_RENDEREREXPORT ParallelRemoteRenderManager {
15public:
16 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
17
18 typedef void (*IceTDrawCallback)(const IceTDouble *proj, const IceTDouble *mv, const IceTFloat *bg,
19 const IceTInt *viewport, IceTImage image);
20 struct PerViewState;
21
22 ParallelRemoteRenderManager(Renderer *module, IceTDrawCallback drawCallback);
24
25 Port *outputPort() const;
26 void connectionAdded(const Port *to);
27 void connectionRemoved(const Port *to);
28
29 bool handleMessage(const message::Message *message, const MessagePayload &payload);
30
31 bool handleParam(const Parameter *p);
32 bool prepareFrame(size_t numTimesteps);
33 int timestep() const;
34 size_t numViews() const;
35 void setCurrentView(size_t i);
36 void compositeCurrentView(const unsigned char *rgba, const float *depth, const int viewport[4], int timestep,
37 bool lastView);
38 void finishCurrentView(const IceTImage &img, int timestep);
39 void finishCurrentView(const IceTImage &img, int timestep, bool lastView);
40 bool finishFrame(int timestep);
41 vistle::Matrix4 getModelViewMat(size_t viewIdx) const;
42 vistle::Matrix4 getProjMat(size_t viewIdx) const;
43 const PerViewState &viewData(size_t viewIdx) const;
44 unsigned char *rgba(size_t viewIdx);
45 float *depth(size_t viewIdx);
46 void updateRect(size_t viewIdx, const IceTInt *viewport);
48 bool sceneChanged() const;
49 bool isVariantVisible(const std::string &variant) const;
50 void setLocalBounds(const Vector3 &min, const Vector3 &max);
51 int rootRank() const { return m_displayRank == -1 ? 0 : m_displayRank; }
52 void addObject(std::shared_ptr<RenderObject> ro);
53 void removeObject(std::shared_ptr<RenderObject> ro);
54 bool checkIceTError(const char *msg) const;
55
56 Renderer *m_module;
57 IceTDrawCallback m_drawCallback;
60 IntParameter *m_continuousRendering;
61
62 FloatParameter *m_delay;
63 double m_delaySec;
64
65 IntParameter *m_colorRank;
67
68 Vector3 localBoundMin, localBoundMax;
69
70 size_t m_updateCount = -1;
76
77 struct PerViewState {
78 // synchronized across all ranks
79
80 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
81
85 std::vector<RhrServer::Light> lights;
87 int width, height;
88
89 PerViewState(): width(0), height(0)
90 {
91 model.Identity();
92 view.Identity();
93 proj.Identity();
94 }
95
96 template<class Archive>
97 void serialize(Archive &ar, const unsigned int version)
98 {
99 ar &width;
100 ar &height;
101 ar &model;
102 ar &view;
103 ar &proj;
104 ar &lights;
105 }
106 };
107
109 struct DisplayTile {
110 int rank;
111 int x, y, width, height;
112
113 DisplayTile(): rank(-1), x(0), y(0), width(0), height(0) {}
114
115 template<class Archive>
116 void serialize(Archive &ar, const unsigned int version)
117 {
118 ar &x;
119 ar &y;
120 ar &width;
121 ar &height;
122 }
123 };
124
126 struct GlobalState {
127 int timestep = -1;
128 int numTimesteps = 0;
130
131 GlobalState(): timestep(-1), numTimesteps(0) {}
132
133 template<class Archive>
134 void serialize(Archive &ar, const unsigned int version)
135 {
136 ar &timestep;
137 ar &numTimesteps;
138 }
139 };
140 struct GlobalState m_state;
141
142 std::vector<PerViewState, Eigen::aligned_allocator<PerViewState>> m_viewData; // synchronized from rank 0 to slaves
143 std::vector<std::vector<unsigned char>> m_rgba;
144 std::vector<std::vector<float>> m_depth;
147
149 struct IceTData {
151 int width, height; // dimensions of local tile
152 IceTContext ctx;
153
154 IceTData(): ctxValid(false), width(0), height(0) { ctx = 0; }
155 };
156 std::vector<IceTData> m_icet; // managed locally
157
160 Renderer::VariantMap m_localVariants;
161};
162
163} // namespace vistle
164#endif
Definition: parrendmgr.h:14
int m_updateScene
Definition: parrendmgr.h:73
void compositeCurrentView(const unsigned char *rgba, const float *depth, const int viewport[4], int timestep, bool lastView)
double m_delaySec
Definition: parrendmgr.h:63
int m_doRender
Definition: parrendmgr.h:74
int m_currentView
holds no. of view currently being rendered - not a problem as IceT is not reentrant anyway
Definition: parrendmgr.h:145
bool m_frameComplete
track whether frame has been flushed to clients
Definition: parrendmgr.h:146
bool isVariantVisible(const std::string &variant) const
int rootRank() const
Definition: parrendmgr.h:51
vistle::Matrix4 getProjMat(size_t viewIdx) const
void removeObject(std::shared_ptr< RenderObject > ro)
bool prepareFrame(size_t numTimesteps)
void finishCurrentView(const IceTImage &img, int timestep)
Vector3 localBoundMax
Definition: parrendmgr.h:68
vistle::Matrix4 getModelViewMat(size_t viewIdx) const
std::vector< std::vector< float > > m_depth
Definition: parrendmgr.h:144
IntParameter * m_colorRank
Definition: parrendmgr.h:65
std::vector< PerViewState, Eigen::aligned_allocator< PerViewState > > m_viewData
Definition: parrendmgr.h:142
bool handleMessage(const message::Message *message, const MessagePayload &payload)
int m_displayRank
Definition: parrendmgr.h:58
void updateRect(size_t viewIdx, const IceTInt *viewport)
const PerViewState & viewData(size_t viewIdx) const
IntParameter * m_continuousRendering
Definition: parrendmgr.h:60
float * depth(size_t viewIdx)
RhrServer::VariantVisibilityMap m_clientVariants
Definition: parrendmgr.h:159
IceTDrawCallback m_drawCallback
Definition: parrendmgr.h:57
Renderer * m_module
Definition: parrendmgr.h:56
void finishCurrentView(const IceTImage &img, int timestep, bool lastView)
size_t m_lightsUpdateCount
Definition: parrendmgr.h:75
void setLocalBounds(const Vector3 &min, const Vector3 &max)
unsigned char * rgba(size_t viewIdx)
Vector4 m_defaultColor
Definition: parrendmgr.h:66
std::vector< IceTData > m_icet
Definition: parrendmgr.h:156
int m_updateVariants
Definition: parrendmgr.h:72
void connectionRemoved(const Port *to)
Renderer::VariantMap m_localVariants
Definition: parrendmgr.h:160
ParallelRemoteRenderManager(Renderer *module, IceTDrawCallback drawCallback)
bool checkIceTError(const char *msg) const
std::vector< std::vector< unsigned char > > m_rgba
Definition: parrendmgr.h:143
bool handleParam(const Parameter *p)
void addObject(std::shared_ptr< RenderObject > ro)
RhrController m_rhrControl
Definition: parrendmgr.h:59
void connectionAdded(const Port *to)
int m_updateBounds
Definition: parrendmgr.h:71
FloatParameter * m_delay
Definition: parrendmgr.h:62
Definition: rhrcontroller.h:11
std::map< std::string, bool > VariantVisibilityMap
Definition: rhrserver.h:92
Eigen::Matrix< Scalar, 3, 1 > Vector3
Eigen::Matrix< Scalar, 4, 1 > Vector4
Eigen::Matrix< Scalar, 4, 4 > Matrix4
serializable description of one IceT tile - usable by boost::mpi
Definition: parrendmgr.h:109
int height
Definition: parrendmgr.h:111
int rank
Definition: parrendmgr.h:110
void serialize(Archive &ar, const unsigned int version)
Definition: parrendmgr.h:116
DisplayTile()
Definition: parrendmgr.h:113
state shared among all views
Definition: parrendmgr.h:126
GlobalState()
Definition: parrendmgr.h:131
Vector3 bMax
Definition: parrendmgr.h:129
void serialize(Archive &ar, const unsigned int version)
Definition: parrendmgr.h:134
per view IceT state
Definition: parrendmgr.h:149
IceTContext ctx
Definition: parrendmgr.h:152
bool ctxValid
Definition: parrendmgr.h:150
IceTData()
Definition: parrendmgr.h:154
int height
Definition: parrendmgr.h:151
Matrix4 proj
Definition: parrendmgr.h:84
RhrServer::ViewParameters rhrParam
Definition: parrendmgr.h:86
std::vector< RhrServer::Light > lights
Definition: parrendmgr.h:85
Matrix4 view
Definition: parrendmgr.h:83
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Matrix4 model
Definition: parrendmgr.h:82
void serialize(Archive &ar, const unsigned int version)
Definition: parrendmgr.h:97
Definition: rhrserver.h:216