18#include <boost/asio.hpp>
25#include <tbb/concurrent_queue.h>
33namespace asio = boost::asio;
34using message::RemoteRenderMessage;
41 typedef asio::ip::tcp::socket
socket;
48 int numClients()
const;
50 bool isConnecting()
const;
51 bool isConnected()
const;
53 unsigned short port()
const;
55 unsigned short destinationPort()
const;
56 const std::string &destinationHost()
const;
58 void setClientModuleId(
int roduleId);
60 int width(
size_t viewNum)
const;
61 int height(
size_t viewNum)
const;
62 unsigned char *rgba(
size_t viewNum);
63 const unsigned char *rgba(
size_t viewNum)
const;
64 float *depth(
size_t viewNum);
65 const float *depth(
size_t viewNum)
const;
67 void resize(
size_t viewNum,
int w,
int h);
70 bool startServer(
unsigned short port);
71 bool makeConnection(
const std::string &host,
unsigned short port,
int secondsToTry = -1);
76 void invalidate(
int viewNum,
int x,
int y,
int w,
int h,
const ViewParameters ¶m,
bool lastView);
77 void updateModificationCount();
79 void setColorCodec(CompressionParameters::ColorCodec value);
80 void setDepthCodec(CompressionParameters::DepthCodec value);
81 void setColorCompression(message::CompressionMode mode);
82 void setDepthPrecision(
int bits);
83 void setDepthCompression(message::CompressionMode mode);
84 void setTileSize(
int w,
int h);
85 void setZfpMode(CompressionParameters::ZfpMode mode);
86 void setDumpImages(
bool enable);
89 void setNumTimesteps(
unsigned num);
90 size_t updateCount()
const;
98 bool handleMatrices(std::shared_ptr<socket> sock,
const matricesMsg &mat);
99 bool handleLights(std::shared_ptr<socket> sock,
const lightsMsg &light);
100 bool handleBounds(std::shared_ptr<socket> sock,
const boundsMsg &bound);
101 bool handleAnimation(std::shared_ptr<socket> sock,
const animationMsg &anim);
102 bool handleVariant(std::shared_ptr<socket> sock,
const variantMsg &variant);
104 size_t numViews()
const;
119 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
161 template<
class Archive>
183 double timestepRequestTime = -1.;
191 ZfpMode depthZfpMode;
192 message::CompressionMode depthCompress;
197 bool rgbaChromaSubsamp;
198 message::CompressionMode rgbaCompress;
207 , depthZfpMode(ZfpAccuracy)
208 , depthCompress(message::CompressionNone)
210 , rgbaChromaSubsamp(false)
211 , rgbaCompress(message::CompressionNone)
225 int32_t timestep = -1;
228 ViewParameters(): matrixTime(0.), width(1), height(1), frameNumber(0), requestNumber(0), timestep(-1)
230 head = vistle::Matrix4::Identity();
231 proj = vistle::Matrix4::Identity();
232 view = vistle::Matrix4::Identity();
233 model = vistle::Matrix4::Identity();
236 template<
class Archive>
258 std::vector<unsigned char>
rgba;
264 updateVariants(
const std::vector<std::pair<std::string, vistle::RenderObject::InitialVariantVisibility>> &added,
265 const std::vector<std::string> &removed);
269 asio::io_service m_io;
270 asio::ip::tcp::acceptor m_acceptorv4, m_acceptorv6;
271 bool m_listen =
false;
272 std::shared_ptr<asio::ip::tcp::socket> m_clientSocket;
273 unsigned short m_port = 0;
274 unsigned short m_destPort = 0;
275 std::string m_destHost;
276 int m_clientModuleId = 0;
278 bool startAccept(asio::ip::tcp::acceptor &a);
279 void handleAccept(asio::ip::tcp::acceptor &a, std::shared_ptr<boost::asio::ip::tcp::socket> sock,
280 const boost::system::error_code &error);
282 size_t m_updateCount = 0;
284 int m_tileWidth, m_tileHeight;
286 std::vector<ViewData, Eigen::aligned_allocator<ViewData>> m_viewData;
288 ImageParameters m_imageParam;
289 bool m_resizeBlocked;
294 unsigned m_numTimesteps;
296 void sendBoundsMessage(std::shared_ptr<socket> sock);
298 void encodeAndSend(
int viewNum,
int x,
int y,
int w,
int h,
const ViewParameters ¶m,
bool lastView);
299 bool finishTiles(
const ViewParameters ¶m,
bool wait,
bool sendTiles =
true);
301 struct EncodeResult {
302 explicit EncodeResult(
tileMsg *msg =
nullptr): message(msg) {}
305 tileMsg *message =
nullptr;
306 RemoteRenderMessage *rhrMessage =
nullptr;
309 friend struct EncodeTask;
311 tbb::concurrent_queue<EncodeResult> m_resultQueue;
312 size_t m_queuedTiles;
315 void deferredResize();
323 int m_framecount = 0;
324 bool m_dumpImages =
false;
325 size_t m_modificationCount = 0;
Implement remote hybrid rendering server.
Definition: rhrserver.h:39
std::vector< Light > lights
Definition: rhrserver.h:179
asio::ip::tcp::socket socket
Definition: rhrserver.h:41
asio::ip::tcp::acceptor acceptor
Definition: rhrserver.h:42
vistle::Scalar vsize
Definition: rhrserver.h:114
vistle::Vector3 hpr
Definition: rhrserver.h:115
vistle::Scalar hsize
Definition: rhrserver.h:112
std::map< std::string, vistle::RenderObject::InitialVariantVisibility > InitialVariantVisibilityMap
Definition: rhrserver.h:91
std::map< std::string, bool > VariantVisibilityMap
Definition: rhrserver.h:92
size_t lightsUpdateCount
Definition: rhrserver.h:180
vistle::Vector3 pos
Definition: rhrserver.h:113
asio::ip::address address
Definition: rhrserver.h:43
Definition: rhrserver.h:111
#define V_RHREXPORT
Definition: export.h:9
bool send(socket_t &sock, const message::Message &msg, error_code &ec, const char *payload, size_t size)
std::vector< char, allocator< char > > buffer
Eigen::Matrix< Scalar, 3, 1 > Vector3
Eigen::Matrix< Scalar, 4, 1 > Vector4
CompressionParameters::DepthCompressionParameters DepthCompressionParameters
Definition: compdecomp.h:48
Eigen::Matrix< Scalar, 4, 4 > Matrix4
RFB protocol extensions for remote hybrid rendering (RHR)
Definition: compdecomp.h:28
Definition: rhrserver.h:182
DepthCompressionParameters depthParam
Definition: rhrserver.h:185
ImageParameters()
Definition: rhrserver.h:201
RgbaCompressionParameters rgbaParam
Definition: rhrserver.h:194
Definition: rhrserver.h:118
vistle::Vector3 attenuation
Definition: rhrserver.h:127
vistle::Vector3 transformedDirection
Definition: rhrserver.h:133
vistle::Scalar spotCutoff
Definition: rhrserver.h:128
vistle::Vector4 transformedPosition
Definition: rhrserver.h:132
vistle::Vector4 specular
Definition: rhrserver.h:125
bool isDirectional
Definition: rhrserver.h:135
void serialize(Archive &ar, const unsigned int version)
Definition: rhrserver.h:162
vistle::Vector3 direction
Definition: rhrserver.h:129
vistle::Vector4 ambient
Definition: rhrserver.h:123
vistle::Vector4 diffuse
Definition: rhrserver.h:124
EIGEN_MAKE_ALIGNED_OPERATOR_NEW vistle::Vector4 position
Definition: rhrserver.h:121
vistle::Scalar spotExponent
Definition: rhrserver.h:130
bool operator==(const Light &rhs) const
Definition: rhrserver.h:137
bool enabled
Definition: rhrserver.h:134
Definition: rhrserver.h:254
ViewParameters nparam
parameters for color/depth tiles currently being updated
Definition: rhrserver.h:256
std::vector< float > depth
Definition: rhrserver.h:259
int newHeight
in case resizing was blocked while message was received
Definition: rhrserver.h:257
ViewParameters param
parameters for color/depth tiles
Definition: rhrserver.h:255
ViewData()
Definition: rhrserver.h:261
std::vector< unsigned char > rgba
Definition: rhrserver.h:258
Definition: rhrserver.h:216
vistle::Matrix4 proj
Definition: rhrserver.h:218
uint32_t requestNumber
Definition: rhrserver.h:224
ViewParameters()
Definition: rhrserver.h:228
vistle::Matrix4 model
Definition: rhrserver.h:220
void serialize(Archive &ar, const unsigned int version)
Definition: rhrserver.h:237
vistle::Matrix4 head
Definition: rhrserver.h:217
int height
Definition: rhrserver.h:222
double matrixTime
Definition: rhrserver.h:221
vistle::Matrix4 view
Definition: rhrserver.h:219
uint32_t frameNumber
Definition: rhrserver.h:223
animation time step on client or no. of animation steps on server changed
Definition: rfbext.h:280
send scene bounding sphere from server to client
Definition: rfbext.h:191
send lighting parameters from client to server
Definition: rfbext.h:94
send matrices from client to server
Definition: rfbext.h:45
send image tile from server to client
Definition: rfbext.h:228