#include <vertex_stream_manager.h>
Nevrax France
Definition at line 50 of file vertex_stream_manager.h.
Public Member Functions | |
CVertexStreamManager () | |
Constructor. | |
~CVertexStreamManager () | |
Rendering. Those method assert if init() not called with correct parameters. | |
void | activate () |
activate the currentVBhard as the current VB in the driver, for future rendering | |
uint8 * | lock () |
lock the currently activated VBHard, for future filling | |
void | swapVBHard () |
void | unlock (uint numVertices) |
unlock the currently activated VBHard. Tell how many vertices have changed. | |
Init/Setup | |
IDriver * | getDriver () const |
return the driver used. | |
uint | getMaxVertices () const |
get max vertices the Buffer allows. | |
uint | getNumVBHard () const |
get the numVBhard used (Nb: if !vbHardMode(), still returns the argument passed in init(), ie not 0 or 1) | |
uint | getVertexFormat () const |
get the vertexFormat | |
uint | getVertexSize () const |
get the vertexSize | |
void | init (IDriver *driver, uint vertexFormat, uint maxVertices, uint numVBHard, const std::string &vbName) |
void | release () |
release the VBHard. init() can be called after this. | |
bool | vbHardMode () const |
true if vbHard (fast) mode. | |
Private Attributes | |
uint | _CurentVBHard |
NLMISC::CRefPtr< IDriver > | _Driver |
bool | _InitOk |
uint | _MaxVertices |
uint | _NumVBHard |
std::vector< NLMISC::CRefPtr< IVertexBufferHard > > | _VBHard |
bool | _VBHardMode |
CVertexBuffer | _VBSoft |
uint | _VertexFormat |
uint | _VertexSize |
|
Constructor.
Definition at line 39 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, and _VBHardMode.
00040 { 00041 _InitOk= false; 00042 _VBHardMode= false; 00043 _VertexFormat= 0; 00044 _VertexSize= 0; 00045 _MaxVertices= 0; 00046 _CurentVBHard= 0; 00047 _NumVBHard= 0; 00048 } |
|
Definition at line 50 of file vertex_stream_manager.cpp. References release().
00051 { 00052 release(); 00053 } |
|
activate the currentVBhard as the current VB in the driver, for future rendering
Definition at line 178 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, _VBHardMode, H_AUTO, and nlassert. Referenced by NL3D::CLodCharacterManager::endRender(), NL3D::CSkeletonModel::renderShadowSkins(), and NL3D::CSkeletonModel::renderSkinList().
00179 { 00180 H_AUTO( NL3D_VertexStreamManager_activate ) 00181 nlassert(_InitOk); 00182 00183 if(_VBHardMode) 00184 _Driver->activeVertexBufferHard(_VBHard[_CurentVBHard]); 00185 else 00186 _Driver->activeVertexBuffer(_VBSoft); 00187 } |
|
return the driver used.
Definition at line 76 of file vertex_stream_manager.h. Referenced by NL3D::CLodCharacterManager::addRenderCharacterKey(), NL3D::CLodCharacterManager::beginRender(), NL3D::CLodCharacterManager::endRender(), and NL3D::CRenderTrav::traverse().
00076 {return _Driver;} |
|
get max vertices the Buffer allows.
Definition at line 82 of file vertex_stream_manager.h. References uint. Referenced by NL3D::CLodCharacterManager::beginRender(), NL3D::CSkeletonModel::renderShadowSkins(), and NL3D::CSkeletonModel::renderSkinList().
00082 {return _MaxVertices;} |
|
get the numVBhard used (Nb: if !vbHardMode(), still returns the argument passed in init(), ie not 0 or 1)
Definition at line 74 of file vertex_stream_manager.h. References uint. Referenced by NL3D::CLodCharacterManager::beginRender().
00074 {return _NumVBHard;} |
|
get the vertexFormat
Definition at line 78 of file vertex_stream_manager.h. References uint.
00078 {return _VertexFormat;} |
|
get the vertexSize
Definition at line 80 of file vertex_stream_manager.h. References uint. Referenced by NL3D::CLodCharacterManager::beginRender(), NL3D::CSkeletonModel::renderShadowSkins(), and NL3D::CSkeletonModel::renderSkinList().
00080 {return _VertexSize;} |
|
init the manager with a driver, allocate the VBHards, and setup the vertexFormat. Must call each time the drive changes. NB: if VBufferHard creation fail (not supported etc...), then a VBSoft is created instead (and just one since not usefull)
Definition at line 56 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, _VBHardMode, NL3D::CVertexBuffer::getUVRouting(), NL3D::CVertexBuffer::getValueTypePointer(), NL3D::CVertexBuffer::getVertexFormat(), NL3D::CVertexBuffer::getVertexSize(), nlassert, release(), NL3D::CVertexBuffer::setNumVertices(), NL3D::CVertexBuffer::setUVRouting(), NL3D::CVertexBuffer::setVertexFormat(), and uint. Referenced by NL3D::CLodCharacterManager::beginRender(), and NL3D::CRenderTrav::traverse().
00057 { 00058 nlassert(driver); 00059 // clean before. 00060 release(); 00061 00062 // Create VBHard placeholder 00063 if(numVBHard==0 || maxVertices==0) 00064 return; 00065 _NumVBHard= numVBHard; 00066 _VBHard.resize(_NumVBHard, NULL); 00067 00068 // setup, => correct for possible release below 00069 _Driver= driver; 00070 00071 // setup the VB soft, for easy setup 00072 _VBSoft.setVertexFormat(vertexFormat); 00073 00074 // For the moment, all UV channel are routed to UV0 00075 uint i; 00076 for (i=0; i<CVertexBuffer::MaxStage; i++) 00077 _VBSoft.setUVRouting (i, 0); 00078 00079 // create the VBHard, if possible 00080 _VBHardMode= true; 00081 for(i=0;i<_NumVBHard;i++) 00082 { 00083 _VBHard[i]= _Driver->createVertexBufferHard(_VBSoft.getVertexFormat(), _VBSoft.getValueTypePointer(), maxVertices, IDriver::VBHardAGP, _VBSoft.getUVRouting()); 00084 // if filas, release all, and quit 00085 if(_VBHard[i]==NULL) 00086 { 00087 _VBHardMode= false; 00088 break; 00089 } 00090 // ok, set name for lock profiling 00091 else 00092 { 00093 _VBHard[i]->setName(vbName + NLMISC::toString(i)); 00094 } 00095 } 00096 00097 // if fails to create vbHard, abort, and create only one vbSoft 00098 if(!_VBHardMode) 00099 { 00100 // release all vbhard created 00101 for(uint i=0;i<_NumVBHard;i++) 00102 { 00103 if(_VBHard[i]) 00104 _Driver->deleteVertexBufferHard(_VBHard[i]); 00105 } 00106 _VBHard.clear(); 00107 00108 // create the Soft One 00109 _VBSoft.setNumVertices(maxVertices); 00110 } 00111 00112 // init misc 00113 _InitOk= true; 00114 _VertexFormat= _VBSoft.getVertexFormat(); 00115 _VertexSize= _VBSoft.getVertexSize(); 00116 _MaxVertices= maxVertices; 00117 _CurentVBHard= 0; 00118 00119 // release the VBsoft if in vbHardMode (no more used) 00120 if(_VBHardMode) 00121 { 00122 contReset(_VBSoft); 00123 } 00124 } |
|
lock the currently activated VBHard, for future filling
Definition at line 155 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, _VBHardMode, NL3D::CVertexBuffer::getVertexCoordPointer(), H_AUTO, nlassert, and uint8. Referenced by NL3D::CLodCharacterManager::addRenderCharacterKey(), NL3D::CSkeletonModel::renderShadowSkins(), and NL3D::CSkeletonModel::renderSkinList().
00156 { 00157 H_AUTO( NL3D_VertexStreamManager_lock ) 00158 nlassert(_InitOk); 00159 00160 if(_VBHardMode) 00161 return (uint8*)_VBHard[_CurentVBHard]->lock(); 00162 else 00163 return (uint8*)_VBSoft.getVertexCoordPointer(); 00164 } |
|
release the VBHard. init() can be called after this.
Definition at line 126 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, _VBHardMode, and uint. Referenced by NL3D::CLodCharacterManager::beginRender(), init(), NL3D::CNELU::releaseDriver(), NL3D::CLodCharacterManager::reset(), NL3D::CRenderTrav::traverse(), and ~CVertexStreamManager().
00127 { 00128 // release driver/VBHard 00129 if(_Driver) 00130 { 00131 for(uint i=0;i<_NumVBHard;i++) 00132 { 00133 if(_VBHard[i]) 00134 _Driver->deleteVertexBufferHard(_VBHard[i]); 00135 _VBHard[i]= NULL; 00136 } 00137 _Driver= NULL; 00138 } 00139 00140 _VBHard.clear(); 00141 00142 // release VBSoft 00143 contReset(_VBSoft); 00144 00145 // misc 00146 _InitOk= false; 00147 _VBHardMode= false; 00148 _VertexFormat= 0; 00149 _VertexSize= 0; 00150 _MaxVertices= 0; 00151 _CurentVBHard= 0; 00152 _NumVBHard= 0; 00153 } |
|
Swap to the next VBHard. This allow some parralelism, since CPU fill one VBHard while the other is rendered NB: no-op if the vertex stream manager falls down to the VBSoft solution. Definition at line 189 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, _VBHardMode, and nlassert. Referenced by NL3D::CLodCharacterManager::endRender(), NL3D::CSkeletonModel::renderShadowSkins(), and NL3D::CSkeletonModel::renderSkinList().
00190 { 00191 nlassert(_InitOk); 00192 00193 if(_VBHardMode) 00194 { 00195 _CurentVBHard++; 00196 _CurentVBHard= _CurentVBHard%_NumVBHard; 00197 } 00198 } |
|
unlock the currently activated VBHard. Tell how many vertices have changed.
Definition at line 166 of file vertex_stream_manager.cpp. References _CurentVBHard, _InitOk, _VBHardMode, H_AUTO, nlassert, and uint. Referenced by NL3D::CLodCharacterManager::endRender(), NL3D::CSkeletonModel::renderShadowSkins(), and NL3D::CSkeletonModel::renderSkinList().
00167 { 00168 H_AUTO( NL3D_VertexStreamManager_unlock ) 00169 nlassert(_InitOk); 00170 00171 if(_VBHardMode) 00172 { 00173 // ATI: release only vertices used. 00174 _VBHard[_CurentVBHard]->unlock(0, numVertices); 00175 } 00176 } |
|
true if vbHard (fast) mode.
Definition at line 72 of file vertex_stream_manager.h. References _VBHardMode.
00072 {return _VBHardMode;} |
|
Definition at line 117 of file vertex_stream_manager.h. Referenced by activate(), CVertexStreamManager(), init(), lock(), release(), swapVBHard(), and unlock(). |
|
Definition at line 108 of file vertex_stream_manager.h. |
|
Definition at line 112 of file vertex_stream_manager.h. Referenced by activate(), CVertexStreamManager(), init(), lock(), release(), swapVBHard(), and unlock(). |
|
Definition at line 115 of file vertex_stream_manager.h. |
|
Definition at line 106 of file vertex_stream_manager.h. |
|
Definition at line 109 of file vertex_stream_manager.h. |
|
Definition at line 111 of file vertex_stream_manager.h. Referenced by activate(), CVertexStreamManager(), init(), lock(), release(), swapVBHard(), unlock(), and vbHardMode(). |
|
Definition at line 110 of file vertex_stream_manager.h. |
|
Definition at line 113 of file vertex_stream_manager.h. |
|
Definition at line 114 of file vertex_stream_manager.h. |