From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02715.html | 1601 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1601 insertions(+) create mode 100644 docs/doxygen/nel/a02715.html (limited to 'docs/doxygen/nel/a02715.html') diff --git a/docs/doxygen/nel/a02715.html b/docs/doxygen/nel/a02715.html new file mode 100644 index 00000000..1ecd2471 --- /dev/null +++ b/docs/doxygen/nel/a02715.html @@ -0,0 +1,1601 @@ + + +NeL: NL3D::CLandscapeVBAllocator class Reference + + + +
+

NL3D::CLandscapeVBAllocator Class Reference

#include <landscapevb_allocator.h> +

+


Detailed Description

+A class to easily allocate vertices for Landscape Far / Tile faces.
Author:
Lionel Berenguier

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 61 of file landscapevb_allocator.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Vertex Program mgt .

enum  { MaxVertexProgram = 2 + }
void deleteVertexProgram ()
void setupVBFormatAndVertexProgram (bool withVertexProgram)
CVertexProgram_VertexProgram [MaxVertexProgram]

VB mgt .

void allocateVertexBuffer (uint32 numVertices)
void deleteVertexBuffer ()
bool _BufferLocked
NLMISC::CRefPtr< IDriver_Driver
CVertexBuffer _VB
NLMISC::CRefPtr< IVertexBufferHard_VBHard
bool _VBHardOk

Public Types

enum  TType { Far0, +Far1, +Tile + }

Public Member Functions

 CLandscapeVBAllocator (TType type, const std::string &vbName)
 Constructor.

void clear ()
void updateDriver (IDriver *driver)
 ~CLandscapeVBAllocator ()
Buffer access.
void activate (uint vpId)
bool bufferLocked () const
void lockBuffer (CNearVertexBufferInfo &tileVB)
void lockBuffer (CFarVertexBufferInfo &farVB)
void synchronizeATIVBHard ()
 only if ATI VBHard is enabled intenally. Copy the entire VBuffer to _ATIVBHard. This last is used in activate().

void unlockBuffer ()
Allocation.
uint allocateVertex ()
void deleteVertex (uint vid)
bool reallocationOccurs () const
void resetReallocation ()

Private Types


Private Attributes

uint _NumVerticesAllocated
bool _ReallocationOccur
TType _Type
std::string _VBName
std::vector< uint_VertexFreeMemory
std::vector< CVertexInfo_VertexInfos
Special ATI VBHard mgt.
NLMISC::CRefPtr< IVertexBufferHard_ATIVBHard
bool _ATIVBHardOk
+


Member Enumeration Documentation

+

+ + + + +
+ + +
anonymous enum [private] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + +
MaxVertexProgram  +
+
+ +

+Definition at line 172 of file landscapevb_allocator.h. +

+

00172 {MaxVertexProgram= 2,};
+
+

+ + + + +
+ + +
enum NL3D::CLandscapeVBAllocator::TType +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + +
Far0  +
Far1  +
Tile  +
+
+ +

+Definition at line 65 of file landscapevb_allocator.h. +

+

00065 {Far0, Far1, Tile};
+
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
NL3D::CLandscapeVBAllocator::CLandscapeVBAllocator TType  type,
const std::string &  vbName
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 56 of file landscapevb_allocator.cpp. +

+References _ATIVBHardOk, _BufferLocked, _NumVerticesAllocated, _ReallocationOccur, _Type, _VBHardOk, _VBName, _VertexFreeMemory, _VertexProgram, MaxVertexProgram, NL3D_VERTEX_FREE_MEMORY_RESERVE, type, and uint. +

+

00057 {
+00058         _Type= type;
+00059         _VBName= vbName;
+00060         _VertexFreeMemory.reserve(NL3D_VERTEX_FREE_MEMORY_RESERVE);
+00061 
+00062         _ReallocationOccur= false;
+00063         _NumVerticesAllocated= 0;
+00064         _VBHardOk= false;
+00065         _ATIVBHardOk= false;
+00066         _BufferLocked= false;
+00067 
+00068         for(uint i=0;i<MaxVertexProgram;i++)
+00069                 _VertexProgram[i]= NULL;
+00070 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CLandscapeVBAllocator::~CLandscapeVBAllocator  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 73 of file landscapevb_allocator.cpp. +

+References clear(). +

+

00074 {
+00075         clear();
+00076 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::activate uint  vpId  ) 
+
+ + + + + +
+   + + +

+activate the VB or the VBHard in Driver setuped. nlassert if driver is NULL or if buffer is locked. If vertexProgram possible, activate the vertexProgram too. Give a vertexProgram Id to activate. Always 0, but 1 For tile Lightmap Pass. +

+Definition at line 310 of file landscapevb_allocator.cpp. +

+References _ATIVBHard, _BufferLocked, _VB, _VBHard, _VertexProgram, nlassert, nlverify, and uint. +

+Referenced by NL3D::CLandscape::render(). +

+

00311 {
+00312         nlassert(_Driver);
+00313         nlassert(!_BufferLocked);
+00314 
+00315         // If enabled, activate Vertex program first.
+00316         if(_VertexProgram[vpId])
+00317         {
+00318                 //nlinfo("\nSTARTVP\n%s\nENDVP\n", _VertexProgram[vpId]->getProgram().c_str());
+00319                 nlverify(_Driver->activeVertexProgram(_VertexProgram[vpId]));
+00320         }
+00321 
+00322         // Activate VB.
+00323         if(_VBHard)
+00324                 _Driver->activeVertexBufferHard(_VBHard);
+00325         // If ATI VBHard possible, use it
+00326         else if(_ATIVBHard)
+00327                 _Driver->activeVertexBufferHard(_ATIVBHard);
+00328         // must use std VB
+00329         else
+00330                 _Driver->activeVertexBuffer(_VB);
+00331 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CLandscapeVBAllocator::allocateVertex  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 152 of file landscapevb_allocator.cpp. +

+References _NumVerticesAllocated, _VertexFreeMemory, _VertexInfos, allocateVertexBuffer(), NL3D_LANDSCAPE_VERTEX_ALLOCATE_SECURITY, NL3D_LANDSCAPE_VERTEX_ALLOCATE_START, nlassert, and uint. +

+

00153 {
+00154         // if no more free, allocate.
+00155         if( _VertexFreeMemory.size()==0 )
+00156         {
+00157                 // enlarge capacity.
+00158                 uint    newResize;
+00159                 if(_NumVerticesAllocated==0)
+00160                         newResize= NL3D_LANDSCAPE_VERTEX_ALLOCATE_START;
+00161                 else
+00162                         newResize= NL3D_LANDSCAPE_VERTEX_ALLOCATE_SECURITY;
+00163                 _NumVerticesAllocated+= newResize;
+00164                 // re-allocate VB.
+00165                 allocateVertexBuffer(_NumVerticesAllocated);
+00166                 // resize infos on vertices.
+00167                 _VertexInfos.resize(_NumVerticesAllocated);
+00168 
+00169                 // Fill list of free elements.
+00170                 for(uint i=0;i<newResize;i++)
+00171                 {
+00172                         // create a new entry which points to this vertex.
+00173                         // the list is made so allocation is in growing order.
+00174                         _VertexFreeMemory.push_back( _NumVerticesAllocated - (i+1) );
+00175 
+00176                         // Mark as free the new vertices. (Debug).
+00177                         _VertexInfos[_NumVerticesAllocated - (i+1)].Free= true;
+00178                 }
+00179         }
+00180 
+00181         // get a vertex (pop_back).
+00182         uint    id= _VertexFreeMemory.back();
+00183         // delete this vertex free entry.
+00184         _VertexFreeMemory.pop_back();
+00185 
+00186         // check and Mark as not free the vertex. (Debug).
+00187         nlassert(id<_NumVerticesAllocated);
+00188         nlassert(_VertexInfos[id].Free);
+00189         _VertexInfos[id].Free= false;
+00190 
+00191         return id;
+00192 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::allocateVertexBuffer uint32  numVertices  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 368 of file landscapevb_allocator.cpp. +

+References _ReallocationOccur, _VB, _VBHard, _VBHardOk, _VBName, NL3D::CVertexBuffer::getUVRouting(), NL3D::CVertexBuffer::getValueTypePointer(), NL3D::CVertexBuffer::getVertexFormat(), NL3D_VERTEX_MAX_VERTEX_VBHARD, nlassert, NL3D::CVertexBuffer::setNumVertices(), uint32, and unlockBuffer(). +

+Referenced by allocateVertex(), and updateDriver(). +

+

00369 {
+00370         // no allocation must be done if the Driver is not setuped, or if the driver has been deleted by refPtr.
+00371         nlassert(_Driver);
+00372 
+00373         // allocate() =>_ReallocationOccur= true;
+00374         _ReallocationOccur= true;
+00375         // must unlock VBhard before.
+00376         unlockBuffer();
+00377 
+00378         // trye to allocate a vbufferhard if possible.
+00379         if( _VBHardOk )
+00380         {
+00381                 // delete possible old _VBHard.
+00382                 if(_VBHard!=NULL)
+00383                 {
+00384                         // VertexBufferHard lifetime < Driver lifetime.
+00385                         nlassert(_Driver!=NULL);
+00386                         _Driver->deleteVertexBufferHard(_VBHard);
+00387                 }
+00388 
+00389                 // try to create new one, in AGP Ram
+00390                 // If too many vertices wanted, abort VBHard.
+00391                 if(numVertices <= NL3D_VERTEX_MAX_VERTEX_VBHARD)
+00392                 {
+00393                         _VBHard= _Driver->createVertexBufferHard(_VB.getVertexFormat(), _VB.getValueTypePointer(), numVertices, IDriver::VBHardAGP, _VB.getUVRouting());
+00394                         // Set Name For lock Profiling.
+00395                         if(_VBHard)
+00396                                 _VBHard->setName(_VBName);
+00397                 }
+00398                 else
+00399                         _VBHard= NULL;
+00400 
+00401                 // If KO, never try again.
+00402                 if(_VBHard==NULL)
+00403                         _VBHardOk= false;
+00404         }
+00405 
+00406         // else, or if last fails, allocate a standard VB.
+00407         if(!_VBHardOk)
+00408         {
+00409                 // This always works.
+00410                 _VB.setNumVertices(numVertices);
+00411         }
+00412 
+00413         /*
+00414                 NB: ATI VBHard allocation is done in synchronizeATIVBHard()
+00415         */
+00416 
+00417         //nlinfo("Alloc a LandVB %s of %d vertices in %s", _Type==Far0?"Far0":(_Type==Far1?"Far1":"Tile"), numVertices, _VBHardOk?"VBHard":"VBSoft");
+00418 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CLandscapeVBAllocator::bufferLocked  )  const [inline]
+
+ + + + + +
+   + + +

+activate the VB or the VBHard in Driver setuped. nlassert if driver is NULL or if buffer is locked. If vertexProgram possible, activate the vertexProgram too. Give a vertexProgram Id to activate. Always 0, but 1 For tile Lightmap Pass. +

+Definition at line 111 of file landscapevb_allocator.h. +

+References _BufferLocked. +

+

00111 {return _BufferLocked;}
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeVBAllocator::clear  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 114 of file landscapevb_allocator.cpp. +

+References _ATIVBHardOk, _NumVerticesAllocated, _ReallocationOccur, _VBHardOk, _VertexFreeMemory, deleteVertexBuffer(), and deleteVertexProgram(). +

+Referenced by NL3D::CLandscape::clear(), and ~CLandscapeVBAllocator(). +

+

00115 {
+00116         // clear list.
+00117         _VertexFreeMemory.clear();
+00118         _NumVerticesAllocated= 0;
+00119 
+00120         // delete the VB.
+00121         deleteVertexBuffer();
+00122 
+00123         // delete vertex Program, if any
+00124         deleteVertexProgram();
+00125 
+00126         // clear other states.
+00127         _ReallocationOccur= false;
+00128         _Driver= NULL;
+00129         _VBHardOk= false;
+00130         _ATIVBHardOk= false;
+00131 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::deleteVertex uint  vid  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 195 of file landscapevb_allocator.cpp. +

+References _NumVerticesAllocated, _VertexFreeMemory, _VertexInfos, nlassert, and uint. +

+

00196 {
+00197         // check and Mark as free the vertex. (Debug).
+00198         nlassert(vid<_NumVerticesAllocated);
+00199         nlassert(!_VertexInfos[vid].Free);
+00200         _VertexInfos[vid].Free= true;
+00201 
+00202         // Add this vertex to the free list.
+00203         // create a new entry which points to this vertex.
+00204         _VertexFreeMemory.push_back( vid );
+00205 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeVBAllocator::deleteVertexBuffer  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 335 of file landscapevb_allocator.cpp. +

+References _ATIVBHard, _VB, _VBHard, NL3D::CVertexBuffer::deleteAllVertices(), nlassert, and unlockBuffer(). +

+Referenced by clear(), and updateDriver(). +

+

00336 {
+00337         // must unlock VBhard before.
+00338         unlockBuffer();
+00339 
+00340         // test (refptr) if the object still exist in memory.
+00341         if(_VBHard!=NULL)
+00342         {
+00343                 // A vbufferhard should still exist only if driver still exist.
+00344                 nlassert(_Driver!=NULL);
+00345 
+00346                 // delete it from driver.
+00347                 _Driver->deleteVertexBufferHard(_VBHard);
+00348                 _VBHard= NULL;
+00349         }
+00350 
+00351         // Do the same for ATI one if exist
+00352         if(_ATIVBHard!=NULL)
+00353         {
+00354                 // A vbufferhard should still exist only if driver still exist.
+00355                 nlassert(_Driver!=NULL);
+00356 
+00357                 // delete it from driver.
+00358                 _Driver->deleteVertexBufferHard(_ATIVBHard);
+00359                 _ATIVBHard= NULL;
+00360         }
+00361 
+00362         // delete the soft one.
+00363         _VB.deleteAllVertices();
+00364 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeVBAllocator::deleteVertexProgram  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 648 of file landscapevb_allocator.cpp. +

+References _VertexProgram, MaxVertexProgram, and uint. +

+Referenced by clear(), and updateDriver(). +

+

00649 {
+00650         for(uint i=0;i<MaxVertexProgram;i++)
+00651         {
+00652                 if(_VertexProgram[i])
+00653                 {
+00654                         delete _VertexProgram[i];
+00655                         _VertexProgram[i]= NULL;
+00656                 }
+00657         }
+00658 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::lockBuffer CNearVertexBufferInfo tileVB  ) 
+
+ + + + + +
+   + + +

+activate the VB or the VBHard in Driver setuped. nlassert if driver is NULL or if buffer is locked. If vertexProgram possible, activate the vertexProgram too. Give a vertexProgram Id to activate. Always 0, but 1 For tile Lightmap Pass. +

+Definition at line 228 of file landscapevb_allocator.cpp. +

+References _BufferLocked, _Type, _VB, _VBHard, _VertexProgram, data, nlassert, NL3D::CNearVertexBufferInfo::setupVertexBuffer(), NL3D::CNearVertexBufferInfo::setupVertexBufferHard(), Tile, and unlockBuffer(). +

+

00229 {
+00230         nlassert(_Type==Tile);
+00231         // force unlock
+00232         unlockBuffer();
+00233 
+00234         if(_VBHard)
+00235         {
+00236                 void    *data= _VBHard->lock();
+00237                 tileVB.setupVertexBufferHard(*_VBHard, data, _VertexProgram[0]!=NULL );
+00238         }
+00239         else
+00240         {
+00241                 tileVB.setupVertexBuffer(_VB, _VertexProgram[0]!=NULL );
+00242         }
+00243 
+00244         _BufferLocked= true;
+00245 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::lockBuffer CFarVertexBufferInfo farVB  ) 
+
+ + + + + +
+   + + +

+lock buffers Hard (if any). "slow call", so batch them. nlassert good TType. return is the VB info. NB: if the buffer is locked while a reallocation occurs, then the buffer is unlocked. +

+Definition at line 209 of file landscapevb_allocator.cpp. +

+References _BufferLocked, _Type, _VB, _VBHard, _VertexProgram, data, Far0, Far1, nlassert, NL3D::CFarVertexBufferInfo::setupVertexBuffer(), NL3D::CFarVertexBufferInfo::setupVertexBufferHard(), and unlockBuffer(). +

+Referenced by NL3D::CLandscape::lockBuffers(). +

+

00210 {
+00211         nlassert( _Type==Far0 || _Type==Far1 );
+00212         // force unlock
+00213         unlockBuffer();
+00214 
+00215         if(_VBHard)
+00216         {
+00217                 void    *data= _VBHard->lock();
+00218                 farVB.setupVertexBufferHard(*_VBHard, data, _VertexProgram[0]!=NULL );
+00219         }
+00220         else
+00221         {
+00222                 farVB.setupVertexBuffer(_VB, _VertexProgram[0]!=NULL );
+00223         }
+00224 
+00225         _BufferLocked= true;
+00226 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CLandscapeVBAllocator::reallocationOccurs  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 92 of file landscapevb_allocator.h. +

+References _ReallocationOccur. +

+Referenced by NL3D::CLandscape::render(). +

+

00092 {return _ReallocationOccur;}
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeVBAllocator::resetReallocation  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 136 of file landscapevb_allocator.cpp. +

+References _ReallocationOccur. +

+Referenced by NL3D::CLandscape::render(). +

+

00137 {
+00138         _ReallocationOccur= false;
+00139 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::setupVBFormatAndVertexProgram bool  withVertexProgram  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 662 of file landscapevb_allocator.cpp. +

+References _Type, _VB, _VertexProgram, NL3D::CVertexBuffer::addValueEx(), NL3D::CVertexBuffer::clearValueEx(), Far0, Far1, NL3D::CVertexBuffer::initEx(), NL3D_LANDSCAPE_VPPOS_ALPHAINFO, NL3D_LANDSCAPE_VPPOS_DELTAPOS, NL3D_LANDSCAPE_VPPOS_GEOMINFO, NL3D_LANDSCAPE_VPPOS_STARTPOS, NL3D_LANDSCAPE_VPPOS_TEX0, NL3D_LANDSCAPE_VPPOS_TEX1, NL3D_LANDSCAPE_VPPOS_TEX2, NL3D::NL3D_LandscapeCommonStartProgram, NL3D::NL3D_LandscapeFar0EndProgram, NL3D::NL3D_LandscapeFar1EndProgram, NL3D::NL3D_LandscapeTileEndProgram, NL3D::NL3D_LandscapeTileLightMapEndProgram, and NL3D::CVertexBuffer::setVertexFormat(). +

+Referenced by updateDriver(). +

+

00663 {
+00664         // If not vertexProgram mode
+00665         if(!withVertexProgram)
+00666         {
+00667                 // setup normal VB format.
+00668                 if(_Type==Far0)
+00669                         // v3f/t2f0/t2f1
+00670                         _VB.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag);
+00671                 else if(_Type==Far1)
+00672                         // v3f/t2f/t2f1/c4ub
+00673                         _VB.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag | CVertexBuffer::PrimaryColorFlag );
+00674                 else
+00675                         // v3f/t2f0/t2f1/t2f2
+00676                         _VB.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag | CVertexBuffer::TexCoord2Flag);
+00677         }
+00678         else
+00679         {
+00680                 // Else Setup our Vertex Program, and good VBuffers, according to _Type.
+00681 
+00682                 if(_Type==Far0)
+00683                 {
+00684                         // Build the Vertex Format.
+00685                         _VB.clearValueEx();
+00686                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_STARTPOS,   CVertexBuffer::Float3); // v[0]= StartPos.
+00687                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX0,               CVertexBuffer::Float2); // v[8]= Tex0.
+00688                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX1,               CVertexBuffer::Float2); // v[9]= Tex1.
+00689                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO,   CVertexBuffer::Float2); // v[10]= GeomInfos.
+00690                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS,   CVertexBuffer::Float3); // v[11]= EndPos-StartPos.
+00691                         _VB.initEx();
+00692 
+00693                         // Init the Vertex Program.
+00694                         string  vpgram= string(NL3D_LandscapeCommonStartProgram) + 
+00695                                 string(NL3D_LandscapeFar0EndProgram);
+00696                         _VertexProgram[0]= new CVertexProgram(vpgram.c_str());
+00697                 }
+00698                 else if(_Type==Far1)
+00699                 {
+00700                         // Build the Vertex Format.
+00701                         _VB.clearValueEx();
+00702                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_STARTPOS,   CVertexBuffer::Float3); // v[0]= StartPos.
+00703                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX0,               CVertexBuffer::Float2); // v[8]= Tex0.
+00704                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX1,               CVertexBuffer::Float2); // v[9]= Tex1.
+00705                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO,   CVertexBuffer::Float2); // v[10]= GeomInfos.
+00706                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS,   CVertexBuffer::Float3); // v[11]= EndPos-StartPos.
+00707                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_ALPHAINFO,  CVertexBuffer::Float2); // v[12]= AlphaInfos.
+00708                         _VB.initEx();
+00709 
+00710                         // Init the Vertex Program.
+00711                         string  vpgram= string(NL3D_LandscapeCommonStartProgram) + 
+00712                                 string(NL3D_LandscapeFar1EndProgram);
+00713                         _VertexProgram[0]= new CVertexProgram(vpgram.c_str());
+00714                 }
+00715                 else
+00716                 {
+00717                         // Build the Vertex Format.
+00718                         _VB.clearValueEx();
+00719                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_STARTPOS,   CVertexBuffer::Float3); // v[0]= StartPos.
+00720                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX0,               CVertexBuffer::Float2); // v[8]= Tex0.
+00721                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX1,               CVertexBuffer::Float2); // v[9]= Tex1.
+00722                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_TEX2,               CVertexBuffer::Float2); // v[13]= Tex2.
+00723                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO,   CVertexBuffer::Float2); // v[10]= GeomInfos.
+00724                         _VB.addValueEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS,   CVertexBuffer::Float3); // v[11]= EndPos-StartPos.
+00725                         _VB.initEx();
+00726 
+00727                         // Init the Vertex Program.
+00728                         string  vpgram= string(NL3D_LandscapeCommonStartProgram) + 
+00729                                 string(NL3D_LandscapeTileEndProgram);
+00730                         _VertexProgram[0]= new CVertexProgram(vpgram.c_str());
+00731 
+00732                         // Init the Vertex Program for lightmap pass
+00733                         vpgram= string(NL3D_LandscapeCommonStartProgram) + 
+00734                                 string(NL3D_LandscapeTileLightMapEndProgram);
+00735                         _VertexProgram[1]= new CVertexProgram(vpgram.c_str());
+00736                 }
+00737         }
+00738 
+00739 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeVBAllocator::synchronizeATIVBHard  ) 
+
+ + + + + +
+   + + +

+only if ATI VBHard is enabled intenally. Copy the entire VBuffer to _ATIVBHard. This last is used in activate(). +

+ +

+Definition at line 258 of file landscapevb_allocator.cpp. +

+References _ATIVBHard, _ATIVBHardOk, _VB, NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getUVRouting(), NL3D::CVertexBuffer::getValueTypePointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexFormat(), NL3D::CVertexBuffer::getVertexSize(), NL3D_VERTEX_MAX_VERTEX_VBHARD, nlassert, and uint. +

+Referenced by NL3D::CLandscape::synchronizeATIVBHards(). +

+

00259 {
+00260         // no-op if disabled, or if std _VBHard scheme
+00261         if(!_ATIVBHardOk)
+00262                 return;
+00263 
+00264         // num verts to sync
+00265         uint    numVertices= _VB.getNumVertices();
+00266 
+00267         // if the ATI VBhard do not exist, or if too small, allocate it now
+00268         if( _ATIVBHard==NULL || _ATIVBHard->getNumVertices()<numVertices )
+00269         {
+00270                 // delete possible old _ATIVBHard
+00271                 if(_ATIVBHard!=NULL)
+00272                 {
+00273                         // VertexBufferHard lifetime < Driver lifetime.
+00274                         nlassert(_Driver!=NULL);
+00275                         _Driver->deleteVertexBufferHard(_ATIVBHard);
+00276                 }
+00277 
+00278                 // try to create new one, in AGP Ram
+00279                 // If too many vertices wanted, abort VBHard.
+00280                 if(numVertices <= NL3D_VERTEX_MAX_VERTEX_VBHARD)
+00281                         _ATIVBHard= _Driver->createVertexBufferHard(_VB.getVertexFormat(), _VB.getValueTypePointer(), numVertices, IDriver::VBHardAGP, _VB.getUVRouting());
+00282                 else
+00283                         _ATIVBHard= NULL;
+00284 
+00285                 // If KO, never try again.
+00286                 if(_ATIVBHard==NULL)
+00287                         _ATIVBHardOk= false;
+00288         }
+00289 
+00290         // if still ok, fill the VBHard with std VB.
+00291         if(_ATIVBHardOk)
+00292         {
+00293                 void    *dst= _ATIVBHard->lock();
+00294                 // fill the entire buffer.
+00295                 CFastMem::memcpy(dst, _VB.getVertexCoordPointer(), numVertices*_VB.getVertexSize() );
+00296                 // unlock the entire buffer
+00297                 _ATIVBHard->unlock();
+00298         }
+00299 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeVBAllocator::unlockBuffer  ) 
+
+ + + + + +
+   + + +

+activate the VB or the VBHard in Driver setuped. nlassert if driver is NULL or if buffer is locked. If vertexProgram possible, activate the vertexProgram too. Give a vertexProgram Id to activate. Always 0, but 1 For tile Lightmap Pass. +

+Definition at line 247 of file landscapevb_allocator.cpp. +

+References _BufferLocked, and _VBHard. +

+Referenced by allocateVertexBuffer(), deleteVertexBuffer(), lockBuffer(), and NL3D::CLandscape::unlockBuffers(). +

+

00248 {
+00249         if(_BufferLocked)
+00250         {
+00251                 if(_VBHard)
+00252                         _VBHard->unlock();
+00253                 _BufferLocked= false;
+00254         }
+00255 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CLandscapeVBAllocator::updateDriver IDriver driver  ) 
+
+ + + + + +
+   + + +

+setup driver, and test for possible VBHard reallocation. if the VBhard/Driver has been deleted externally, Vertices are lost. The vertex buffer is reallocated and reallocationOccurs() return true (see reallocationOccurs()). to do anytime you're not sure of change of the driver/vbHard state.

+Note: the vertexProgram is created/changed here, according to driver, and TType.

+

Parameters:
+ + +
driver must not be NULL.
+
+ +

+Definition at line 80 of file landscapevb_allocator.cpp. +

+References _ATIVBHardOk, _NumVerticesAllocated, _VBHard, _VBHardOk, allocateVertexBuffer(), deleteVertexBuffer(), deleteVertexProgram(), nlassert, and setupVBFormatAndVertexProgram(). +

+Referenced by NL3D::CLandscape::updateGlobalsAndLockBuffers(). +

+

00081 {
+00082         // test change of driver.
+00083         nlassert(driver);
+00084         if( _Driver==NULL || driver!=_Driver )
+00085         {
+00086                 deleteVertexBuffer();
+00087                 _Driver= driver;
+00088                 // Don't use std VBHard scheme if ATI slow unlock case.
+00089                 _ATIVBHardOk = _Driver->supportVertexBufferHard() && _Driver->slowUnlockVertexBufferHard();
+00090                 _VBHardOk =        _Driver->supportVertexBufferHard() && !_Driver->slowUnlockVertexBufferHard();
+00091 
+00092 
+00093                 // If change of driver, delete the VertexProgram first, if any
+00094                 deleteVertexProgram();
+00095                 // Then rebuild VB format, and VertexProgram, if needed.
+00096                 // Do it only if VP supported by GPU.
+00097                 setupVBFormatAndVertexProgram(_Driver->isVertexProgramSupported()  && !_Driver->isVertexProgramEmulated());
+00098 
+00099                 // must reallocate the VertexBuffer.
+00100                 if( _NumVerticesAllocated>0 )
+00101                         allocateVertexBuffer(_NumVerticesAllocated);
+00102         }
+00103         else
+00104         {
+00105                 // if VBHard possible, and if vbHardDeleted but space needed, reallocate.
+00106                 if( _VBHardOk && _VBHard==NULL && _NumVerticesAllocated>0 )
+00107                         allocateVertexBuffer(_NumVerticesAllocated);
+00108         }
+00109 
+00110 }
+
+


Field Documentation

+

+ + + + +
+ + +
NLMISC::CRefPtr<IVertexBufferHard> NL3D::CLandscapeVBAllocator::_ATIVBHard [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 166 of file landscapevb_allocator.h. +

+Referenced by activate(), deleteVertexBuffer(), and synchronizeATIVBHard().

+

+ + + + +
+ + +
bool NL3D::CLandscapeVBAllocator::_ATIVBHardOk [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 165 of file landscapevb_allocator.h. +

+Referenced by CLandscapeVBAllocator(), clear(), synchronizeATIVBHard(), and updateDriver().

+

+ + + + +
+ + +
bool NL3D::CLandscapeVBAllocator::_BufferLocked [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 153 of file landscapevb_allocator.h. +

+Referenced by activate(), bufferLocked(), CLandscapeVBAllocator(), lockBuffer(), and unlockBuffer().

+

+ + + + +
+ + +
NLMISC::CRefPtr<IDriver> NL3D::CLandscapeVBAllocator::_Driver [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 148 of file landscapevb_allocator.h.

+

+ + + + +
+ + +
uint NL3D::CLandscapeVBAllocator::_NumVerticesAllocated [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 141 of file landscapevb_allocator.h. +

+Referenced by allocateVertex(), CLandscapeVBAllocator(), clear(), deleteVertex(), and updateDriver().

+

+ + + + +
+ + +
bool NL3D::CLandscapeVBAllocator::_ReallocationOccur [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 137 of file landscapevb_allocator.h. +

+Referenced by allocateVertexBuffer(), CLandscapeVBAllocator(), clear(), reallocationOccurs(), and resetReallocation().

+

+ + + + +
+ + +
TType NL3D::CLandscapeVBAllocator::_Type [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 134 of file landscapevb_allocator.h. +

+Referenced by CLandscapeVBAllocator(), lockBuffer(), and setupVBFormatAndVertexProgram().

+

+ + + + +
+ + +
CVertexBuffer NL3D::CLandscapeVBAllocator::_VB [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 151 of file landscapevb_allocator.h. +

+Referenced by activate(), allocateVertexBuffer(), deleteVertexBuffer(), lockBuffer(), setupVBFormatAndVertexProgram(), and synchronizeATIVBHard().

+

+ + + + +
+ + +
NLMISC::CRefPtr<IVertexBufferHard> NL3D::CLandscapeVBAllocator::_VBHard [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 152 of file landscapevb_allocator.h. +

+Referenced by activate(), allocateVertexBuffer(), deleteVertexBuffer(), lockBuffer(), unlockBuffer(), and updateDriver().

+

+ + + + +
+ + +
bool NL3D::CLandscapeVBAllocator::_VBHardOk [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 150 of file landscapevb_allocator.h. +

+Referenced by allocateVertexBuffer(), CLandscapeVBAllocator(), clear(), and updateDriver().

+

+ + + + +
+ + +
std::string NL3D::CLandscapeVBAllocator::_VBName [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 135 of file landscapevb_allocator.h. +

+Referenced by allocateVertexBuffer(), and CLandscapeVBAllocator().

+

+ + + + +
+ + +
std::vector<uint> NL3D::CLandscapeVBAllocator::_VertexFreeMemory [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 139 of file landscapevb_allocator.h. +

+Referenced by allocateVertex(), CLandscapeVBAllocator(), clear(), and deleteVertex().

+

+ + + + +
+ + +
std::vector<CVertexInfo> NL3D::CLandscapeVBAllocator::_VertexInfos [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 140 of file landscapevb_allocator.h. +

+Referenced by allocateVertex(), and deleteVertex().

+

+ + + + +
+ + +
CVertexProgram* NL3D::CLandscapeVBAllocator::_VertexProgram[MaxVertexProgram] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 174 of file landscapevb_allocator.h. +

+Referenced by activate(), CLandscapeVBAllocator(), deleteVertexProgram(), lockBuffer(), and setupVBFormatAndVertexProgram().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:49:15 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1