Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::RenderNode Class Reference
[Cluster]

cluster node information

#include <OSGRenderNode.h>

List of all members.

Public Member Functions

Constructors
RenderNode (Real32 invisibleFaceCost=1.0/15000000, Real32 visibleFaceCost=1.0/10000000, Real32 drawPixelCost=1.0/120000000, Real32 readPixelCost=1.0/20000000, Real32 writePixelCost=1.0/20000000, const std::string &vendor="Unknown", const std::string &renderer="Unknown")
 RenderNode (const RenderNode &source)
Destructor
*virtual ~RenderNode (void)
Get
*Real32 getVisibleFaceCost (void) const
Real32 getInvisibleFaceCost (void) const
Real32 getDrawPixelCost (void) const
Real32 getReadPixelCost (void) const
Real32 getWritePixelCost (void) const
std::string getVendor (void) const
std::string getRenderer (void) const
Set
*void setVisibleFaceCost (Real32 value)
void setInvisibleFaceCost (Real32 value)
void setDrawPixelCost (Real32 value)
void setReadPixelCost (Real32 value)
void setWritePixelCost (Real32 value)
void setGroup (const RenderNode *begin, const RenderNode *end)
void setVendor (const std::string &value)
void setRenderer (const std::string &value)
performance analysis
*void determinePerformance (WindowPtr &prt)
Real32 estimatePerformance (Real32 invisibleFaces, Real32 visibleFaces, Real32 pixel) const
load/store
*void copyToBin (BinaryDataHandler &handle)
void copyFromBin (BinaryDataHandler &handle)
Assignment
*RenderNodeoperator= (const RenderNode &source)
dump
*void dump (void) const

Protected Member Functions

helper
*double runFaceBench (float w, int size)
double runRasterBench (void)

Protected Attributes

Fields
*Real32 _visibleFaceCost
Real32 _invisibleFaceCost
Real32 _drawPixelCost
Real32 _readPixelCost
Real32 _writePixelCost
std::string _vendor
std::string _renderer

Static Private Attributes

helper
*static RenderNode_prefefined []


Detailed Description

Definition at line 52 of file OSGRenderNode.h.


Constructor & Destructor Documentation

* osg::RenderNode::RenderNode Real32  invisibleFaceCost = 1.0/15000000,
Real32  visibleFaceCost = 1.0/10000000,
Real32  drawPixelCost = 1.0/120000000,
Real32  readPixelCost = 1.0/20000000,
Real32  writePixelCost = 1.0/20000000,
const std::string &  vendor = "Unknown",
const std::string &  renderer = "Unknown"
 

RenderNode::RenderNode const RenderNode source  ) 
 

copy constructor

Definition at line 200 of file OSGRenderNode.cpp.

00200                                                :
00201     _visibleFaceCost(source._visibleFaceCost),
00202     _invisibleFaceCost(source._invisibleFaceCost),
00203     _drawPixelCost(source._drawPixelCost),
00204     _readPixelCost(source._readPixelCost),
00205     _writePixelCost(source._writePixelCost),
00206     _vendor(source._vendor),
00207     _renderer(source._renderer)
00208 {
00209 }

RenderNode::~RenderNode void   )  [virtual]
 

Destructor documentation

Definition at line 216 of file OSGRenderNode.cpp.

00217 {
00218 }


Member Function Documentation

Real32 osg::RenderNode::getVisibleFaceCost void   )  const [inline]
 

Definition at line 41 of file OSGRenderNode.inl.

References _visibleFaceCost.

00042 {
00043     return _visibleFaceCost;
00044 }

Real32 osg::RenderNode::getInvisibleFaceCost void   )  const [inline]
 

Definition at line 46 of file OSGRenderNode.inl.

References _invisibleFaceCost.

Referenced by osg::TileLoadBalancer::splitRegion().

00047 {
00048     return _invisibleFaceCost;
00049 }

Real32 osg::RenderNode::getDrawPixelCost void   )  const [inline]
 

Definition at line 51 of file OSGRenderNode.inl.

References _drawPixelCost.

00052 {
00053     return _drawPixelCost;
00054 }

Real32 osg::RenderNode::getReadPixelCost void   )  const [inline]
 

Definition at line 56 of file OSGRenderNode.inl.

References _readPixelCost.

00057 {
00058     return _readPixelCost;
00059 }

Real32 osg::RenderNode::getWritePixelCost void   )  const [inline]
 

Definition at line 61 of file OSGRenderNode.inl.

References _writePixelCost.

00062 {
00063     return _writePixelCost;
00064 }

std::string osg::RenderNode::getVendor void   )  const [inline]
 

Definition at line 66 of file OSGRenderNode.inl.

References _vendor.

Referenced by determinePerformance().

00067 {
00068     return _vendor;
00069 }

std::string osg::RenderNode::getRenderer void   )  const [inline]
 

Definition at line 71 of file OSGRenderNode.inl.

References _renderer.

Referenced by determinePerformance().

00072 {
00073     return _renderer;
00074 }

void osg::RenderNode::setVisibleFaceCost Real32  value  )  [inline]
 

Definition at line 76 of file OSGRenderNode.inl.

References _visibleFaceCost.

00077 {
00078     _visibleFaceCost=value;
00079 }

void osg::RenderNode::setInvisibleFaceCost Real32  value  )  [inline]
 

Definition at line 81 of file OSGRenderNode.inl.

References _invisibleFaceCost.

Referenced by osg::TileLoadBalancer::splitRegion().

00082 {
00083     _invisibleFaceCost=value;
00084 }

void osg::RenderNode::setDrawPixelCost Real32  value  )  [inline]
 

Definition at line 86 of file OSGRenderNode.inl.

References _drawPixelCost.

00087 {
00088     _drawPixelCost=value;
00089 }

void osg::RenderNode::setReadPixelCost Real32  value  )  [inline]
 

Definition at line 91 of file OSGRenderNode.inl.

References _readPixelCost.

00092 {
00093     _readPixelCost=value;
00094 }

void osg::RenderNode::setWritePixelCost Real32  value  )  [inline]
 

Definition at line 96 of file OSGRenderNode.inl.

References _writePixelCost.

00097 {
00098     _writePixelCost=value;
00099 }

void RenderNode::setGroup const RenderNode begin,
const RenderNode end
 

Set render performance values for a group of render nodes. The parameter begin points to the first and the parameter end points behind the last member of the group.

It is assumed the a render group is as fast as all its members together. Render costs of culled faces are handled different. In the worst case invisible faces have to be culled by each render node. To take this into account, we set the group speed to process culled faces to the average of all group members.

Definition at line 377 of file OSGRenderNode.cpp.

References _drawPixelCost, _invisibleFaceCost, _readPixelCost, _visibleFaceCost, and _writePixelCost.

Referenced by osg::TileLoadBalancer::splitRegion().

00378 {
00379     const RenderNode    *i;
00380     Real32              invisibleFaces = 0;
00381     Real32              visibleFaces = 0;
00382     Real32              drawPixels = 0;
00383     Real32              readPixels = 0;
00384     Real32              writePixels = 0;
00385     UInt32              count = 0;
00386 
00387     for(count = 0, i = begin; i != end; ++i, count++)
00388     {
00389         invisibleFaces += 1.f / i->_invisibleFaceCost;
00390         visibleFaces += 1.f / i->_visibleFaceCost;
00391         drawPixels += 1.f / i->_drawPixelCost;
00392         readPixels += 1.f / i->_readPixelCost;
00393         writePixels += 1.f / i->_writePixelCost;
00394     }
00395 
00396     _invisibleFaceCost = (1.f / invisibleFaces);
00397     _visibleFaceCost = (1.f / visibleFaces);
00398     _drawPixelCost = (1.f / drawPixels);
00399     _readPixelCost = (1.f / readPixels);
00400     _writePixelCost = (1.f / writePixels);
00401 }

void osg::RenderNode::setVendor const std::string &  value  )  [inline]
 

set vendor string of the graphics board

Definition at line 103 of file OSGRenderNode.inl.

References _vendor.

Referenced by determinePerformance().

00104 {
00105     _vendor=value;
00106 }

void osg::RenderNode::setRenderer const std::string &  value  )  [inline]
 

set renderer string of the graphics board

Definition at line 110 of file OSGRenderNode.inl.

References _renderer.

Referenced by determinePerformance().

00111 {
00112     _renderer=value;
00113 }

void RenderNode::determinePerformance WindowPtr window  ) 
 

This is a rough estimation of rendering costst for visible faces, faces outside the viewport and fill rate.

  // face cost calculation
  cost = invisible * invisibleFaceCost +
         max( visible * visibleFaceCost , pixel * pixelCost)
  

Definition at line 251 of file OSGRenderNode.cpp.

References _drawPixelCost, _invisibleFaceCost, _prefefined, _readPixelCost, _visibleFaceCost, _writePixelCost, getRenderer(), osg::getSystemTime(), getVendor(), runFaceBench(), runRasterBench(), setRenderer(), setVendor(), and SLOG.

Referenced by osg::SortFirstWindow::serverInit().

00252 {
00253     int     c;
00254     double  t;
00255     UInt32  width, height;
00256 
00257     setVendor((const char *) glGetString(GL_VENDOR));
00258     setRenderer((const char *) glGetString(GL_RENDERER));
00259 
00260     // try to find precalculated values
00261     for(c = 0; _prefefined[c] != NULL; ++c)
00262     {
00263         if(_prefefined[c]->getVendor() == getVendor() &&
00264                    _prefefined[c]->getRenderer() == getRenderer())
00265         {
00266             SLOG << "Predefined performance values used." << endl;
00267             *this = *_prefefined[c];
00268             return;
00269         }
00270     }
00271 
00272     SLOG << "Start rendering benchmark" << endl;
00273     window->activate();
00274 
00275     // set viewport
00276     glViewport(0, 0, window->getWidth(), window->getHeight());
00277 
00278     glPushAttrib(GL_ALL_ATTRIB_BITS);
00279     glDisable(GL_SCISSOR_TEST);
00280     glEnable(GL_DEPTH_TEST);
00281     glDisable(GL_COLOR_MATERIAL);
00282     glEnable(GL_LIGHTING);
00283     glDepthFunc(GL_LEQUAL);
00284     for(int i = 0; i < 8; ++i)
00285         glDisable(GL_LIGHT0 + i);
00286     glEnable(GL_LIGHT0);
00287 
00288     double  a1, a2, b, r;
00289     a1 = runFaceBench(1, 1);
00290     a2 = runFaceBench(4, 1);
00291     b = (a2 - .25 * a1) / .75;
00292     r = runRasterBench();
00293 
00294     _visibleFaceCost = Real32(1.0 / a1);
00295     _invisibleFaceCost = Real32(1.0 / b);
00296     _drawPixelCost = Real32(1.0 / r);
00297 
00298     // test write performance
00299     glPixelStorei(GL_PACK_ALIGNMENT, 1);
00300     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00301 
00302     vector<UInt8>   pixels;
00303     width = window->getWidth();
00304     height = window->getHeight();
00305     pixels.resize(width * height * 4);
00306     glFinish();
00307     t = -getSystemTime();
00308     for(c = 0; c < 2; ++c)
00309     {
00310         glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, &pixels[0]);
00311     }
00312 
00313     glFinish();
00314     t += getSystemTime();
00315     _readPixelCost = Real32(t / (c * width * height));
00316 
00317     // test write performance
00318     glMatrixMode(GL_MODELVIEW);
00319     glPushMatrix();
00320     glLoadIdentity();
00321     glMatrixMode(GL_PROJECTION);
00322     glPushMatrix();
00323     glLoadIdentity();
00324     gluOrtho2D(0, width, 0, height);
00325     glRasterPos2i(0, 0);
00326     glDisable(GL_DEPTH_TEST);
00327     glFinish();
00328     t = -getSystemTime();
00329     for(c = 0; c < 2; ++c)
00330     {
00331         glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, &pixels[0]);
00332     }
00333     glFinish();
00334     t += getSystemTime();
00335     _writePixelCost = Real32(t / (c * width * height));
00336     glEnable(GL_DEPTH_TEST);
00337     glPopMatrix();
00338     glMatrixMode(GL_MODELVIEW);
00339     glPopMatrix();
00340     SLOG << "End rendering benchmark" << endl;
00341 
00342     glPopAttrib();
00343 }

Real32 osg::RenderNode::estimatePerformance Real32  invisibleFaces,
Real32  visibleFaces,
Real32  pixel
const [inline]
 

Estimate rendering performance. Facesetup end rasterisation is done in parallel on most hardware plattforms. So we use the maximum of face cost and rasterisation cost.

Definition at line 119 of file OSGRenderNode.inl.

References _drawPixelCost, _invisibleFaceCost, _visibleFaceCost, and osg::osgMax().

Referenced by osg::TileLoadBalancer::RegionLoad::getCost().

00122 {
00123     return 
00124         ( invisibleFaces * _invisibleFaceCost ) +
00125         osgMax( ( visibleFaces   * _visibleFaceCost   ), 
00126                 ( pixel          * _drawPixelCost     ) );
00127 }

void RenderNode::copyToBin BinaryDataHandler handle  ) 
 

Write class contents to the given data stream

Definition at line 347 of file OSGRenderNode.cpp.

References _drawPixelCost, _invisibleFaceCost, _readPixelCost, _visibleFaceCost, _writePixelCost, and osg::BinaryDataHandler::putValue().

Referenced by osg::SortFirstWindow::serverInit().

00348 {
00349     handle.putValue(_invisibleFaceCost);
00350     handle.putValue(_visibleFaceCost);
00351     handle.putValue(_drawPixelCost);
00352     handle.putValue(_readPixelCost);
00353     handle.putValue(_writePixelCost);
00354 }

void RenderNode::copyFromBin BinaryDataHandler handle  ) 
 

Read class contents from the given data stream

Definition at line 358 of file OSGRenderNode.cpp.

References _drawPixelCost, _invisibleFaceCost, _readPixelCost, _visibleFaceCost, _writePixelCost, and osg::BinaryDataHandler::getValue().

Referenced by osg::SortFirstWindow::clientInit().

00359 {
00360     handle.getValue(_invisibleFaceCost);
00361     handle.getValue(_visibleFaceCost);
00362     handle.getValue(_drawPixelCost);
00363     handle.getValue(_readPixelCost);
00364     handle.getValue(_writePixelCost);
00365 }

RenderNode & RenderNode::operator= const RenderNode source  ) 
 

assignment

Definition at line 225 of file OSGRenderNode.cpp.

References _drawPixelCost, _invisibleFaceCost, _readPixelCost, _renderer, _vendor, _visibleFaceCost, and _writePixelCost.

00226 {
00227     if(this == &source)
00228         return *this;
00229 
00230     _visibleFaceCost = source._visibleFaceCost;
00231     _invisibleFaceCost = source._invisibleFaceCost;
00232     _drawPixelCost = source._drawPixelCost;
00233     _readPixelCost = source._readPixelCost;
00234     _writePixelCost = source._writePixelCost;
00235     _vendor = source._vendor;
00236     _renderer = source._renderer;
00237     return *this;
00238 }

void RenderNode::dump void   )  const
 

Dump class contents

Definition at line 405 of file OSGRenderNode.cpp.

References _drawPixelCost, _invisibleFaceCost, _readPixelCost, _renderer, _vendor, _visibleFaceCost, _writePixelCost, and FLOG.

Referenced by osg::SortFirstWindow::clientInit(), and osg::SortFirstWindow::serverInit().

00406 {
00407     FLOG(("Vendor           : %s\n", _vendor.c_str()));
00408     FLOG(("Rnderer          : %s\n", _renderer.c_str()));
00409     FLOG(("Culled Faces/s   : %20.5f\n", 1.0 / _invisibleFaceCost));
00410     FLOG(("Faces/s          : %20.5f\n", 1.0 / _visibleFaceCost));
00411     FLOG(("Pixel/s          : %20.5f\n", 1.0 / _drawPixelCost));
00412     FLOG(("Read pixel/s     : %20.5f\n", 1.0 / _readPixelCost));
00413     FLOG(("Write pixel/s    : %20.5f\n", 1.0 / _writePixelCost));
00414 }

double RenderNode::runFaceBench float  w,
int  size
[protected]
 

Render small faces as triangle stripes. With the parameter w it is possible to set the amount of visible faces. If w=1 then all faces are visible. If w=2 then 1/2 of the faces are visible. The function returns the number of faces that could be rendered in one second. We are using triangle stripes with 8 faces to run the benchmark.

Definition at line 423 of file OSGRenderNode.cpp.

References osg::getSystemTime(), and GLuint().

Referenced by determinePerformance().

00424 {
00425     int     c;
00426     int     faces = 0;
00427 
00428     // vp size
00429     GLint   view[4];
00430     glGetIntegerv(GL_VIEWPORT, view);
00431 
00432     int vw = view[2], vh = view[3];
00433 
00434     // set projection
00435     glMatrixMode(GL_MODELVIEW);
00436     glPushMatrix();
00437     glLoadIdentity();
00438     glMatrixMode(GL_PROJECTION);
00439     glPushMatrix();
00440     glLoadIdentity();
00441     gluOrtho2D(0, vw, 0, vh);
00442     glMatrixMode(GL_MODELVIEW);
00443 
00444     // create display list
00445     GLuint  dList = glGenLists(1);
00446     glNewList(dList, GL_COMPILE);
00447     glBegin(GL_TRIANGLE_STRIP);
00448     for(int x = 0; x <= (vw * w); x += size)
00449     {
00450         glNormal3f(0, 0, 1);
00451         glVertex3i(x, 0, 1);
00452         glNormal3f(0, 0, 1);
00453         glVertex3i(x, size, 1);
00454         if(((x & 3) == 3) && (x != (vw * w)))
00455         {
00456             glEnd();
00457             glBegin(GL_TRIANGLE_STRIP);
00458             glNormal3f(0, 0, 1);
00459             glVertex3i(x, 0, 1);
00460             glNormal3f(0, 0, 1);
00461             glVertex3i(x, size, 1);
00462         }
00463     }
00464 
00465     glEnd();
00466     glEndList();
00467     glFinish();
00468 
00469     // run test
00470     Time    t = 0;
00471     c = 0;
00472     glPushMatrix();
00473     do
00474     {
00475         glLoadIdentity();
00476         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00477         glFinish();
00478         t -= getSystemTime();
00479         for(int y = 0; y < vh; y += size)
00480         {
00481             glCallList(dList);
00482             glTranslatef(0, GLfloat(size), 0);
00483         }
00484 
00485         glFinish();
00486         t += getSystemTime();
00487         c++;
00488     } while(t < .5);
00489     glPopMatrix();
00490     faces = (int) (((vw * w * 2) / size) * (vh / size) * c);
00491 
00492     // reset projection
00493     glMatrixMode(GL_PROJECTION);
00494     glPopMatrix();
00495     glMatrixMode(GL_MODELVIEW);
00496     glPopMatrix();
00497     glMatrixMode(GL_PROJECTION);
00498 
00499     glDeleteLists(dList, 1);
00500     return faces / t;
00501 }

double RenderNode::runRasterBench void   )  [protected]
 

Render one large face over the whole viewport. The returned value is the number of pixels that could be rendered in one second.

Definition at line 506 of file OSGRenderNode.cpp.

References osg::getSystemTime(), and GLuint().

Referenced by determinePerformance().

00507 {
00508     int     c;
00509 
00510     // vp size
00511     GLint   view[4];
00512     glGetIntegerv(GL_VIEWPORT, view);
00513 
00514     int vw = view[2], vh = view[3];
00515 
00516     // set projection
00517     glMatrixMode(GL_MODELVIEW);
00518     glPushMatrix();
00519     glLoadIdentity();
00520     glMatrixMode(GL_PROJECTION);
00521     glPushMatrix();
00522     glLoadIdentity();
00523     gluOrtho2D(0, vw, 0, vh);
00524 
00525     // create display list
00526     GLuint  dList = glGenLists(1);
00527     glNewList(dList, GL_COMPILE);
00528     glBegin(GL_QUADS);
00529     glVertex3i(0, 0, 1);
00530     glNormal3f(0, 0, 1);
00531     glVertex3i(0, vh - 1, 1);
00532     glNormal3f(0, 0, 1);
00533     glVertex3i(vw - 1, vh - 1, 1);
00534     glNormal3f(0, 0, 1);
00535     glVertex3i(vw - 1, 0, 1);
00536     glNormal3f(0, 0, 1);
00537     glEnd();
00538     glEndList();
00539     glFinish();
00540 
00541     // run test
00542     Time    t = 0;
00543     c = 0;
00544     do
00545     {
00546         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00547         glFinish();
00548         t -= getSystemTime();
00549         glCallList(dList);
00550         glFinish();
00551         t += getSystemTime();
00552         c++;
00553     } 
00554     while(t < .5);
00555 
00556     // reset projection
00557     glMatrixMode(GL_PROJECTION);
00558     glPopMatrix();
00559     glMatrixMode(GL_MODELVIEW);
00560     glPopMatrix();
00561     glMatrixMode(GL_PROJECTION);
00562 
00563     glDeleteLists(dList, 1);
00564     return (vw * vh * c) / t;
00565 }


Member Data Documentation

* Real32 osg::RenderNode::_visibleFaceCost [protected]
 

Definition at line 144 of file OSGRenderNode.h.

Referenced by copyFromBin(), copyToBin(), determinePerformance(), dump(), estimatePerformance(), getVisibleFaceCost(), operator=(), setGroup(), and setVisibleFaceCost().

Real32 osg::RenderNode::_invisibleFaceCost [protected]
 

Definition at line 145 of file OSGRenderNode.h.

Referenced by copyFromBin(), copyToBin(), determinePerformance(), dump(), estimatePerformance(), getInvisibleFaceCost(), operator=(), setGroup(), and setInvisibleFaceCost().

Real32 osg::RenderNode::_drawPixelCost [protected]
 

Definition at line 146 of file OSGRenderNode.h.

Referenced by copyFromBin(), copyToBin(), determinePerformance(), dump(), estimatePerformance(), getDrawPixelCost(), operator=(), setDrawPixelCost(), and setGroup().

Real32 osg::RenderNode::_readPixelCost [protected]
 

Definition at line 147 of file OSGRenderNode.h.

Referenced by copyFromBin(), copyToBin(), determinePerformance(), dump(), getReadPixelCost(), operator=(), setGroup(), and setReadPixelCost().

Real32 osg::RenderNode::_writePixelCost [protected]
 

Definition at line 148 of file OSGRenderNode.h.

Referenced by copyFromBin(), copyToBin(), determinePerformance(), dump(), getWritePixelCost(), operator=(), setGroup(), and setWritePixelCost().

std::string osg::RenderNode::_vendor [protected]
 

Definition at line 149 of file OSGRenderNode.h.

Referenced by dump(), getVendor(), operator=(), and setVendor().

std::string osg::RenderNode::_renderer [protected]
 

Definition at line 150 of file OSGRenderNode.h.

Referenced by dump(), getRenderer(), operator=(), and setRenderer().

RenderNode * RenderNode::_prefefined [static, private]
 

Definition at line 62 of file OSGRenderNode.cpp.

Referenced by determinePerformance().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:13:03 2005 for OpenSG by  doxygen 1.4.3