From 5c7540d85e60137382be38302b4be291d064e346 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 30 Jul 2013 03:09:21 +0200 Subject: [PATCH] Removed vendor specific VBO code. --HG-- branch : gsoc2013-dfighter --- .../src/3d/driver/OpenGL3/driver_opengl.cpp | 68 -- .../nel/src/3d/driver/OpenGL3/driver_opengl.h | 2 - .../driver/OpenGL3/driver_opengl_vertex.cpp | 29 - .../driver_opengl_vertex_buffer_hard.cpp | 1059 ----------------- .../driver_opengl_vertex_buffer_hard.h | 340 ------ 5 files changed, 1498 deletions(-) diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl.cpp index acd002f86..b74b49d8c 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl.cpp @@ -449,37 +449,6 @@ bool CDriverGL3::setupDisplay() _MaxVerticesByVBHard = std::numeric_limits::max(); // cant' know the value.. } - // Next with NVidia ext - else if(_Extensions.NVVertexArrayRange) - { - _AGPVertexArrayRange= new CVertexArrayRangeNVidia(this); - _VRAMVertexArrayRange= new CVertexArrayRangeNVidia(this); - _SupportVBHard= true; - _MaxVerticesByVBHard= _Extensions.NVVertexArrayRangeMaxVertex; - } - else if(_Extensions.ATITextureEnvCombine3 && _Extensions.ATIVertexArrayObject) - { - // NB - // on Radeon 9200 and below : ATI_vertex_array_object is better (no direct access to AGP with ARB_vertex_buffer_object -> slow unlock) - // on Radeon 9500 and above : ARB_vertex_buffer_object is better - if (!_Extensions.ATIMapObjectBuffer) - { - _AGPVertexArrayRange= new CVertexArrayRangeATI(this); - _VRAMVertexArrayRange= new CVertexArrayRangeATI(this); - // BAD ATI extension scheme. - _SlowUnlockVBHard= true; - } - else - { - _AGPVertexArrayRange= new CVertexArrayRangeMapObjectATI(this); - _VRAMVertexArrayRange= new CVertexArrayRangeMapObjectATI(this); - } - _SupportVBHard= true; - // _MaxVerticesByVBHard= 65535; // should always work with recent drivers. - // tmp fix for ati - _MaxVerticesByVBHard= 16777216; - } - // Reset VertexArrayRange. _CurrentVertexArrayRange= NULL; _CurrentVertexBufferHard= NULL; @@ -818,43 +787,6 @@ bool CDriverGL3::swapBuffers() nlassert(_CurrentVertexBufferHard==NULL); } - /* PATCH For Possible NVidia Synchronisation. - /*/ - // Because of Bug with GeForce, must finishFence() for all VBHard. - /*set::iterator itVBHard= _VertexBufferHardSet.Set.begin(); - while(itVBHard != _VertexBufferHardSet.Set.end() ) - { - // Need only to do it for NVidia VB ones. - if((*itVBHard)->NVidiaVertexBufferHard) - { - CVertexBufferHardGLNVidia *vbHardNV= static_cast(*itVBHard); - // If needed, "flush" these VB. - vbHardNV->finishFence(); - } - itVBHard++; - }*/ - /* Need to Do this code only if Synchronisation PATCH before not done! - AS NV_Fence GeForce Implementation says. Test each frame the NVFence, until completion. - NB: finish is not required here. Just test. This is like a "non block synchronisation" - */ - if (!_Extensions.ARBVertexBufferObject && _Extensions.NVVertexArrayRange) - { - set::iterator itVBHard= _VertexBufferHardSet.Set.begin(); - while(itVBHard != _VertexBufferHardSet.Set.end() ) - { - if((*itVBHard)->VBType == IVertexBufferHardGL::NVidiaVB) - { - CVertexBufferHardGLNVidia *vbHardNV= static_cast(*itVBHard); - if(vbHardNV->isFenceSet()) - { - // update Fence Cache. - vbHardNV->testFence(); - } - } - itVBHard++; - } - } - #ifdef NL_OS_WINDOWS if (_EventEmitter.getNumEmitters() > 1) // is direct input running ? { diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl.h b/code/nel/src/3d/driver/OpenGL3/driver_opengl.h index ad335fd52..9cdc093b6 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl.h +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl.h @@ -1220,8 +1220,6 @@ private: /// \name VertexBufferHard // @{ CPtrSet _VertexBufferHardSet; - friend class CVertexArrayRangeNVidia; - friend class CVertexBufferHardGLNVidia; friend class CVertexArrayRangeATI; friend class CVertexArrayRangeARB; friend class CVertexBufferHardARB; diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex.cpp index 490737bc6..35abae377 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex.cpp @@ -1746,35 +1746,6 @@ uint32 CDriverGL3::getAvailableVertexVRAMMemory () void CDriverGL3::fenceOnCurVBHardIfNeeded(IVertexBufferHardGL *newVBHard) { H_AUTO_OGL(CDriverGL3_fenceOnCurVBHardIfNeeded); - - // If old is not a VBHard, or if not a NVidia VBHard, no-op. - if( _CurrentVertexBufferHard==NULL || !_CurrentVertexBufferHard->VBType == IVertexBufferHardGL::NVidiaVB) - return; - - // if we do not activate the same (NB: newVBHard==NULL if not a VBHard). - if(_CurrentVertexBufferHard!=newVBHard) - { - // get NVidia interface - CVertexBufferHardGLNVidia *vbHardNV= static_cast(_CurrentVertexBufferHard); - - // If some render() have been done with this VB. - if( vbHardNV->GPURenderingAfterFence ) - { - /* - Since we won't work with this VB for a long time, we set a fence. - - NB: if the fence was previously set. NV_Fence Specification says that the new ONE replaces it. - This is EXACTLY what we wants, since the old one is no more interesting. - - NB: never insert a fence for said "Static Lock" VBHard. Those VBHard are said to be "static" - therefore, user should never modify them (else lock() is much slower...) - */ - if( !vbHardNV->getLockHintStatic() ) - vbHardNV->setFence(); - // Since we have set a new Fence, we won't need to do it at next vbHardNV->lock() - vbHardNV->GPURenderingAfterFence= false; - } - } } // *************************************************************************** diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.cpp index 746e41a5a..6903d8b31 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.cpp @@ -69,1065 +69,6 @@ IVertexBufferHardGL::~IVertexBufferHardGL() H_AUTO_OGL(IVertexBufferHardGL_IVertexBufferHardGLDtor) } -// *************************************************************************** -// *************************************************************************** -// *************************************************************************** -// -// NVidia implementation -// -// *************************************************************************** -// *************************************************************************** -// *************************************************************************** - - - -// *************************************************************************** -// CVertexArrayRangeNVidia -// *************************************************************************** - - -// *************************************************************************** -CVertexArrayRangeNVidia::CVertexArrayRangeNVidia(CDriverGL3 *drv) : IVertexArrayRange(drv) -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_CVertexArrayRangeNVidia) - _VertexArrayPtr= NULL; - _VertexArraySize= 0; -} - - -// *************************************************************************** -bool CVertexArrayRangeNVidia::allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType) -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_allocate) - nlassert(_VertexArrayPtr==NULL); - - // try to allocate AGP or VRAM data. - switch(vbType) - { -#ifdef NL_OS_WINDOWS - case CVertexBuffer::AGPPreferred: - _VertexArrayPtr= nwglAllocateMemoryNV(size, 0, 0, 0.5f); - break; - case CVertexBuffer::StaticPreferred: - if (_Driver->getStaticMemoryToVRAM()) - _VertexArrayPtr= nwglAllocateMemoryNV(size, 0, 0, 1.0f); - else - _VertexArrayPtr= nwglAllocateMemoryNV(size, 0, 0, 0.5f); - break; -#elif defined(NL_OS_MAC) - // TODO: implement for Mac OS X -#elif defined(NL_OS_UNIX) - case CVertexBuffer::AGPPreferred: - _VertexArrayPtr= nglXAllocateMemoryNV(size, 0, 0, 0.5f); - break; - case CVertexBuffer::StaticPreferred: - if (_Driver->getStaticMemoryToVRAM()) - _VertexArrayPtr= nglXAllocateMemoryNV(size, 0, 0, 1.0f); - else - _VertexArrayPtr= nglXAllocateMemoryNV(size, 0, 0, 0.5f); - break; -#endif // NL_OS_WINDOWS - default: - break; - } - - // init the allocator. - if(_VertexArrayPtr) - { - /* Init with an alignment of 8. Not sure it is useful, but GDC01_Performance.pdf papers talks about - "Data arrays must be 8-byte aligned". Don't know what "Data" is. - */ - _HeapMemory.initHeap(_VertexArrayPtr, size, 8); - - // set the size - _VertexArraySize= size; - } - - - return _VertexArrayPtr!=NULL; -} - - -// *************************************************************************** -uint CVertexArrayRangeNVidia::sizeAllocated() const -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_sizeAllocated) - return _VertexArraySize; -} - - -// *************************************************************************** -void CVertexArrayRangeNVidia::free() -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_free) - // release the ptr. - if(_VertexArrayPtr) - { - // reset the allocator. - _HeapMemory.reset(); - -#ifdef NL_OS_WINDOWS - // Free special memory. - nwglFreeMemoryNV(_VertexArrayPtr); -#elif defined(NL_OS_MAC) - // TODO: implement for Mac OS X -#elif defined(NL_OS_UNIX) - nglXFreeMemoryNV(_VertexArrayPtr); -#endif // NL_OS_WINDOWS - - _VertexArrayPtr= NULL; - _VertexArraySize= 0; - } -} - - -// *************************************************************************** -void CVertexArrayRangeNVidia::enable() -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_enable) - // if not already enabled. - if(_Driver->_CurrentVertexArrayRange!=this) - { - // Setup the ptrs only if differnets from last time (may rarely happens) - if( _Driver->_NVCurrentVARSize != _VertexArraySize || _Driver->_NVCurrentVARPtr != _VertexArrayPtr) - { - // Yoyo: NVidia Bug ?? must do this strange thing, this ensure that it is correclty setuped. - glFinish(); - nglVertexArrayRangeNV(_VertexArraySize, _VertexArrayPtr); - glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV); - glVertexPointer(3,GL_FLOAT, 0, _VertexArrayPtr); - // cache. - _Driver->_NVCurrentVARSize= _VertexArraySize; - _Driver->_NVCurrentVARPtr= _VertexArrayPtr; - } - // enable VAR. NB: flush is useless, so don't flush if extension is OK - glEnableClientState(_Driver->_Extensions.NVStateVARWithoutFlush); - _Driver->_CurrentVertexArrayRange= this; - } -} - - -// *************************************************************************** -void CVertexArrayRangeNVidia::disable() -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_disable) - // if not already disabled. - if(_Driver->_CurrentVertexArrayRange!=NULL) - { - // just disable the state, don't change VAR ptr setup. - // NB: flush is useless, so don't flush if extension is OK - glDisableClientState(_Driver->_Extensions.NVStateVARWithoutFlush); - _Driver->_CurrentVertexArrayRange= NULL; - } -} - - -// *************************************************************************** -void *CVertexArrayRangeNVidia::allocateVB(uint32 size) -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_allocateVB) - return _HeapMemory.allocate(size); -} - - -// *************************************************************************** -void CVertexArrayRangeNVidia::freeVB(void *ptr) -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_freeVB) - _HeapMemory.free(ptr); -} - - -// *************************************************************************** -IVertexBufferHardGL *CVertexArrayRangeNVidia::createVBHardGL(uint size, CVertexBuffer *vb) -{ - H_AUTO_OGL(CVertexArrayRangeNVidia_createVBHardGL) - // create a NVidia VBHard - CVertexBufferHardGLNVidia *newVbHard= new CVertexBufferHardGLNVidia(_Driver, vb); - - // try to allocate - void *vertexPtr = 0; - if( allocated() ) - { - vertexPtr= allocateVB(size); - } - - // If allocation fails. - if( !vertexPtr ) - { - // just destroy this object (no free()). - delete newVbHard; - return NULL; - } - else - { - // Ok, setup, and allocate the fence. - newVbHard->initGL(this, vertexPtr); - return newVbHard; - } -} - - -// *************************************************************************** -// CVertexBufferHardGLNVidia -// *************************************************************************** - - -// *************************************************************************** -CVertexBufferHardGLNVidia::CVertexBufferHardGLNVidia(CDriverGL3 *drv, CVertexBuffer *vb) : IVertexBufferHardGL(drv, vb) -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_CVertexBufferHardGLNVidia) - _VertexArrayRange= NULL; - _VertexPtr= NULL; - - GPURenderingAfterFence= false; - _FenceSet= false; - - // Flag our type - VBType = NVidiaVB; - - // default: dynamic Loick - _LockHintStatic= false; -} - - -// *************************************************************************** -CVertexBufferHardGLNVidia::~CVertexBufferHardGLNVidia() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_CVertexBufferHardGLNVidiaDtor) - if(_VertexArrayRange) - { - // Destroy Fence. - // First wait for completion. - finishFence(); - // then delete. - nglDeleteFencesNV(1, &_Fence); - - // Then free the VAR. - _VertexArrayRange->freeVB(_VertexPtr); - _VertexPtr= NULL; - _VertexArrayRange= NULL; - } -} - - -// *************************************************************************** -void CVertexBufferHardGLNVidia::initGL(CVertexArrayRangeNVidia *var, void *vertexPtr) -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_initGL) - _VertexArrayRange= var; - _VertexPtr= vertexPtr; - nglGenFencesNV(1, &_Fence); -} - - -// *************************************************************************** -void *CVertexBufferHardGLNVidia::lock() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_lock) - // sync the 3d card with the system. - - // If the user lock an activated VBHard, after rendering some primitives, we must stall the CPU - // Also always do this for Static Lock VBHard (because no setFence are inserted after rendering - if(GPURenderingAfterFence || _LockHintStatic) - { - // Set a new fence at the current position in the command stream, replacing the old one - setFence(); - // And so the GPU has rendered all our primitives. - GPURenderingAfterFence= false; - } - - // Lock Profile? - TTicks beforeLock = 0; - if(_Driver->_VBHardProfiling) - { - beforeLock= CTime::getPerformanceTime(); - } - - // Ensure the GPU has finished with the current VBHard. - finishFence(); - - // Lock Profile? - if(_Driver->_VBHardProfiling) - { - TTicks afterLock; - afterLock= CTime::getPerformanceTime(); - _Driver->appendVBHardLockProfile(afterLock-beforeLock, VB); - } - - return _VertexPtr; -} - - -// *************************************************************************** -void CVertexBufferHardGLNVidia::unlock() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_unlock) - // no op. -} - -// *************************************************************************** -void CVertexBufferHardGLNVidia::unlock(uint /* start */, uint /* end */) -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_unlock_start_end) - // no op. - // NB: start-end only useful for ATI ext. -} - -// *************************************************************************** -void *CVertexBufferHardGLNVidia::getPointer() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_getPointer) - return _VertexPtr; -} - -// *************************************************************************** -void CVertexBufferHardGLNVidia::enable() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_enable) - if(_Driver->_CurrentVertexBufferHard != this) - { - nlassert(_VertexArrayRange); - _VertexArrayRange->enable(); - _Driver->_CurrentVertexBufferHard= this; - } -} - - -// *************************************************************************** -void CVertexBufferHardGLNVidia::disable() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_disbale) - if(_Driver->_CurrentVertexBufferHard != NULL) - { - nlassert(_VertexArrayRange); - _VertexArrayRange->disable(); - _Driver->_CurrentVertexBufferHard= NULL; - } -} - -// *************************************************************************** -void CVertexBufferHardGLNVidia::lockHintStatic(bool staticLock) -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_lockHintStatic) - // Store the flag. - _LockHintStatic= staticLock; -} - -// *************************************************************************** - -void CVertexBufferHardGLNVidia::setupVBInfos(CVertexBufferInfo &vb) -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_setupVBInfos) - vb.VBMode = CVertexBufferInfo::HwNVIDIA; -} - -// *************************************************************************** -void CVertexBufferHardGLNVidia::setFence() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_setFence) - // NB: if the Fence was set and not finished, then the new one will KICK the old. - nglSetFenceNV(_Fence, GL_ALL_COMPLETED_NV); - _FenceSet= true; -} - -// *************************************************************************** -void CVertexBufferHardGLNVidia::finishFence() -{ - H_AUTO_OGL(CVertexBufferHardGLNVidia_finishFence) - if(isFenceSet()) - { - // Stall CPU while the fence command is not reached in the GPU command stream. - nglFinishFenceNV(_Fence); - _FenceSet= false; - } -} - -// *************************************************************************** -void CVertexBufferHardGLNVidia::testFence() -{ - - H_AUTO_OGL(CVertexBufferHardGLNVidia_testFence) - if(isFenceSet()) - { - // Don't stall the CPU - GLboolean b= nglTestFenceNV(_Fence); - // if completed - if(b==GL_TRUE) - _FenceSet= false; - } -} - - - -// *************************************************************************** -// *************************************************************************** -// *************************************************************************** -// -// ATI implementation -// -// *************************************************************************** -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -// CVertexArrayRangeATI -// *************************************************************************** - - -// *************************************************************************** -CVertexArrayRangeATI::CVertexArrayRangeATI(CDriverGL3 *drv) : IVertexArrayRange(drv) -{ - H_AUTO_OGL(CVertexArrayRangeATI_CVertexArrayRangeATI) - _Allocated= false; - _VertexObjectId= 0; - _VertexArraySize= 0; -} -// *************************************************************************** -bool CVertexArrayRangeATI::allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType) -{ - H_AUTO_OGL(CVertexArrayRangeATI_allocate) - nlassert(!_Allocated); - - // try to allocate AGP (suppose mean ATI dynamic) or VRAM (suppose mean ATI static) data. - switch(vbType) - { - case CVertexBuffer::AGPPreferred: - _VertexObjectId= nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - case CVertexBuffer::StaticPreferred: - if (_Driver->getStaticMemoryToVRAM()) - _VertexObjectId= nglNewObjectBufferATI(size, NULL, GL_STATIC_ATI); - else - _VertexObjectId= nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - default: - break; - }; - - - // init the allocator, if success - if( nglIsObjectBufferATI(_VertexObjectId) ) - { - _Allocated= true; - /* Init with an alignment of 8. Not sure if it is useful. - Init With a FAKE memory starting at NL3D_DRV_ATI_FAKE_MEM_START - */ - _HeapMemory.initHeap((void*)NL3D_DRV_ATI_FAKE_MEM_START, size, 8); - - // set the size - _VertexArraySize= size; - - // Ok! - return true; - } - else - { - // failure. - return false; - } -} -// *************************************************************************** -uint CVertexArrayRangeATI::sizeAllocated() const -{ - H_AUTO_OGL(CVertexArrayRangeATI_sizeAllocated) - return _VertexArraySize; -} -// *************************************************************************** -void CVertexArrayRangeATI::free() -{ - H_AUTO_OGL(CVertexArrayRangeATI_free) - // release the ptr. - if(_Allocated) - { - // reset the allocator. - _HeapMemory.reset(); - - // Free special memory. - nglDeleteObjectBufferATI(_VertexObjectId); - - _Allocated= false; - _VertexArraySize= 0; - } -} -// *************************************************************************** -IVertexBufferHardGL *CVertexArrayRangeATI::createVBHardGL(uint size, CVertexBuffer *vb) -{ - H_AUTO_OGL(CVertexArrayRangeATI_createVBHardGL) - // create a ATI VBHard - CVertexBufferHardGLATI *newVbHard= new CVertexBufferHardGLATI(_Driver, vb); - - // try to allocate - void *vertexPtr =NULL; - if( _Allocated ) - { - vertexPtr= allocateVB(size); - } - - // If allocation fails. - if( !vertexPtr ) - { - // just destroy this object (no free()). - delete newVbHard; - return NULL; - } - else - { - // Then try to create a RAM mirror in the VB. - if( newVbHard->createRAMMirror(size) ) - { - // Ok, setup - newVbHard->initGL(this, vertexPtr); - return newVbHard; - } - else - { - // Discard the VB. - delete newVbHard; - return NULL; - } - } -} -// *************************************************************************** -void CVertexArrayRangeATI::enable() -{ - H_AUTO_OGL(CVertexArrayRangeATI_enable) - // No-op for ATI !!! - _Driver->_CurrentVertexArrayRange= this; -} -// *************************************************************************** -void CVertexArrayRangeATI::disable() -{ - H_AUTO_OGL(CVertexArrayRangeATI_disable) - // No-op for ATI !!! - _Driver->_CurrentVertexArrayRange= NULL; -} -// *************************************************************************** -void *CVertexArrayRangeATI::allocateVB(uint32 size) -{ - H_AUTO_OGL(CVertexArrayRangeATI_allocateVB) - return _HeapMemory.allocate(size); -} -// *************************************************************************** -void CVertexArrayRangeATI::freeVB(void *ptr) -{ - H_AUTO_OGL(CVertexArrayRangeATI_freeVB) - _HeapMemory.free(ptr); -} - - -// *************************************************************************** -// CVertexBufferHardGLATI -// *************************************************************************** - - -// *************************************************************************** -CVertexBufferHardGLATI::CVertexBufferHardGLATI(CDriverGL3 *drv, CVertexBuffer *vb) : IVertexBufferHardGL(drv, vb) -{ - H_AUTO_OGL(CVertexBufferHardGLATI_CVertexBufferHardGLATI) - _VertexArrayRange= NULL; - _VertexPtr= NULL; - _RAMMirrorVertexPtr= NULL; - _RAMMirrorVertexSize= 0; - - // Flag our type - VBType = ATIVB; -} - - -// *************************************************************************** -CVertexBufferHardGLATI::~CVertexBufferHardGLATI() -{ - H_AUTO_OGL(CVertexBufferHardGLATI_CVertexBufferHardGLATIDtor) - if(_VertexArrayRange) - { - // free the VAR. - _VertexArrayRange->freeVB(_VertexPtr); - _VertexPtr= NULL; - _VertexArrayRange= NULL; - } - - if(_RAMMirrorVertexPtr) - { - delete [] ((uint8*)_RAMMirrorVertexPtr); - _RAMMirrorVertexPtr= NULL; - _RAMMirrorVertexSize= 0; - } -} - - -// *************************************************************************** -bool CVertexBufferHardGLATI::createRAMMirror(uint memSize) -{ - H_AUTO_OGL(CVertexBufferHardGLATI_createRAMMirror) - // delete old if any - if(_RAMMirrorVertexPtr) - { - free(_RAMMirrorVertexPtr); - _RAMMirrorVertexPtr= NULL; - _RAMMirrorVertexSize= 0; - } - // create - _RAMMirrorVertexPtr = (void*)new uint8[memSize]; - if(_RAMMirrorVertexPtr) - { - _RAMMirrorVertexSize= memSize; - return true; - } - else - return false; -} - - -// *************************************************************************** -void CVertexBufferHardGLATI::initGL(CVertexArrayRangeATI *var, void *vertexPtr) -{ - H_AUTO_OGL(CVertexBufferHardGLATI_initGL) - _VertexArrayRange= var; - _VertexPtr= vertexPtr; -} - - -// *************************************************************************** -void *CVertexBufferHardGLATI::lock() -{ - H_AUTO_OGL(CVertexBufferHardGLATI_lock) - // return directly the mirror one. => client will write into RAM. - return _RAMMirrorVertexPtr; -} - - -// *************************************************************************** -void CVertexBufferHardGLATI::unlock() -{ - H_AUTO_OGL(CVertexBufferHardGLATI_unlock) - // Copy All mirror into the ATI Vertex Object - nglUpdateObjectBufferATI(getATIVertexObjectId(), (ptrdiff_t)_VertexPtr - NL3D_DRV_ATI_FAKE_MEM_START, - _RAMMirrorVertexSize, _RAMMirrorVertexPtr, GL_PRESERVE_ATI); -} - - -// *************************************************************************** -void CVertexBufferHardGLATI::unlock(uint start, uint end) -{ - H_AUTO_OGL(CVertexBufferHardGLATI_unlosk_start_end) - unlock(); - // clamp end. - if(end>VB->getNumVertices()*VB->getVertexSize()) - end=VB->getNumVertices()*VB->getVertexSize(); - - // verify bound. - //if(start>=end) - // return; - if (start == 0 && end == 0) - { - end = VB->getVertexSize() * VB->getNumVertices(); - } - - // Copy a subset of the mirror into the ATI Vertex Object - uint size= end-start; - uint srcOffStart= start; - uint dstOffStart= ((ptrdiff_t)_VertexPtr - NL3D_DRV_ATI_FAKE_MEM_START) + srcOffStart; - // copy. - nglUpdateObjectBufferATI(getATIVertexObjectId(), dstOffStart, - size, (uint8*)_RAMMirrorVertexPtr + srcOffStart, GL_PRESERVE_ATI); -} - - -// *************************************************************************** -void *CVertexBufferHardGLATI::getPointer() -{ - H_AUTO_OGL(CVertexBufferHardGLATI_getPointer) - return (uint8 *) _VertexPtr - NL3D_DRV_ATI_FAKE_MEM_START; -} - -// *************************************************************************** -void CVertexBufferHardGLATI::enable() -{ - H_AUTO_OGL(CVertexBufferHardGLATI_enable) - if(_Driver->_CurrentVertexBufferHard != this) - { - nlassert(_VertexArrayRange); - _VertexArrayRange->enable(); - _Driver->_CurrentVertexBufferHard= this; - } -} - - -// *************************************************************************** -void CVertexBufferHardGLATI::disable() -{ - H_AUTO_OGL(CVertexBufferHardGLATI_disbale) - if(_Driver->_CurrentVertexBufferHard != NULL) - { - nlassert(_VertexArrayRange); - _VertexArrayRange->disable(); - _Driver->_CurrentVertexBufferHard= NULL; - } -} - -// *************************************************************************** -void CVertexBufferHardGLATI::lockHintStatic(bool /* staticLock */) -{ - H_AUTO_OGL(CVertexBufferHardGLATI_lockHintStatic) - // no op. -} - -// *************************************************************************** - -void CVertexBufferHardGLATI::setupVBInfos(CVertexBufferInfo &vb) -{ - H_AUTO_OGL(CVertexBufferHardGLATI_setupVBInfos) - vb.VBMode = CVertexBufferInfo::HwATI; - vb.VertexObjectId = getATIVertexObjectId(); -} - -// *************************************************************************** - -// *************************************************************************** -// *************************************************************************** -// *************************************************************************** -// -// ATI implementation, version 2 using the map object buffer extension -// -// *************************************************************************** -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -// CVertexArrayRangeMapObjectATI -// *************************************************************************** - - -// *************************************************************************** -CVertexArrayRangeMapObjectATI::CVertexArrayRangeMapObjectATI(CDriverGL3 *drv) : IVertexArrayRange(drv), - _VBType(CVertexBuffer::AGPPreferred), - _SizeAllocated(0) -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_CVertexArrayRangeMapObjectATI) -} - -// *************************************************************************** -bool CVertexArrayRangeMapObjectATI::allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType) -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_allocate) - // We don't manage memory ourselves, but test if there's enough room anyway - GLuint vertexObjectId; - switch(vbType) - { - case CVertexBuffer::AGPPreferred: - vertexObjectId = nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - case CVertexBuffer::StaticPreferred: - if (_Driver->getStaticMemoryToVRAM()) - vertexObjectId = nglNewObjectBufferATI(size, NULL, GL_STATIC_ATI); - else - vertexObjectId = nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - default: - vertexObjectId = 0; - break; - } - if (vertexObjectId) - { - // free the object - nglDeleteObjectBufferATI(vertexObjectId); - // - _SizeAllocated = size; - _VBType = vbType; - return true; - } - return false; -} - -// *************************************************************************** -void CVertexArrayRangeMapObjectATI::free() -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_free) - _SizeAllocated = 0; -} - -// *************************************************************************** -IVertexBufferHardGL *CVertexArrayRangeMapObjectATI::createVBHardGL(uint size, CVertexBuffer *vb) -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_createVBHardGL) - // create a ATI VBHard - CVertexBufferHardGLMapObjectATI *newVbHard= new CVertexBufferHardGLMapObjectATI(_Driver, vb); - uint vertexObjectId; - // just allocate a new buffer.. - switch(_VBType) - { - case CVertexBuffer::AGPPreferred: - vertexObjectId = nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - case CVertexBuffer::StaticPreferred: - if (_Driver->getStaticMemoryToVRAM()) - vertexObjectId = nglNewObjectBufferATI(size, NULL, GL_STATIC_ATI); - else - vertexObjectId = nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - default: - vertexObjectId = 0; - break; - }; - // init the allocator, if success - if( nglIsObjectBufferATI(vertexObjectId) ) - { - newVbHard->initGL(this, vertexObjectId); - return newVbHard; - } - else - { - delete newVbHard; - return NULL; - } -} - -// *************************************************************************** -void CVertexArrayRangeMapObjectATI::enable() -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_enable) -} - -// *************************************************************************** -void CVertexArrayRangeMapObjectATI::disable() -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_disbale) -} - - - -// *************************************************************************** -// CVertexBufferHardGLMapObjectATI -// *************************************************************************** - -// *************************************************************************** -CVertexBufferHardGLMapObjectATI::CVertexBufferHardGLMapObjectATI(CDriverGL3 *drv, CVertexBuffer *vb) : IVertexBufferHardGL(drv, vb), - _VertexPtr(NULL), - _VertexArrayRange(NULL), - _VertexObjectId(0) -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_CVertexBufferHardGLMapObjectATI) - // Flag our type - VBType = ATIMapObjectVB; -} - -// *************************************************************************** -CVertexBufferHardGLMapObjectATI::~CVertexBufferHardGLMapObjectATI() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_CVertexBufferHardGLMapObjectATIDtor) - if (_VertexObjectId) nglDeleteObjectBufferATI(_VertexObjectId); - #ifdef NL_DEBUG - if (_VertexPtr) - { - _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); - } - #endif - if (_VertexArrayRange) - { - if (_Invalid) - { - if (VB->getLocation() != CVertexBuffer::NotResident) - { - // when the vb is put in tthe NotResident state, it is removed from that list - _VertexArrayRange->_LostVBList.erase(_IteratorInLostVBList); - } - } - } -} - -// *************************************************************************** -void *CVertexBufferHardGLMapObjectATI::lock() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_lock) - if (_VertexPtr) return _VertexPtr; // already locked - if (_Invalid) - { - if (VB->getLocation() != CVertexBuffer::NotResident) - { - nlassert(!_DummyVB.empty()); - return &_DummyVB[0]; - } - // recreate a vb - const uint size = VB->getNumVertices() * VB->getVertexSize(); - nlassert(!_VertexObjectId); - switch(_VertexArrayRange->getVBType()) - { - case CVertexBuffer::AGPPreferred: - _VertexObjectId = nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - case CVertexBuffer::StaticPreferred: - if (_Driver->getStaticMemoryToVRAM()) - _VertexObjectId = nglNewObjectBufferATI(size, NULL, GL_STATIC_ATI); - else - _VertexObjectId = nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI); - break; - default: - break; - }; - if (!_VertexObjectId) - { - _Driver->incrementResetCounter(); - nlassert(!_DummyVB.empty()); - return &_DummyVB[0]; - } - NLMISC::contReset(_DummyVB); // free vector memory for real - nlassert(_VertexObjectId); - _Invalid = false; - _VertexArrayRange->_LostVBList.erase(_IteratorInLostVBList); - // continue to standard mapping code below .. - } - if (!_VertexObjectId) return NULL; - _VertexPtr = nglMapObjectBufferATI(_VertexObjectId); - if (!_VertexPtr) - { - nglUnmapObjectBufferATI(_VertexObjectId); - nlassert(nglIsObjectBufferATI(_VertexObjectId)); - invalidate(); - return &_DummyVB[0]; - } - #ifdef NL_DEBUG - _VertexArrayRange->_MappedVBList.push_front(this); - _IteratorInMappedVBList = _VertexArrayRange->_MappedVBList.begin(); - #endif - return _VertexPtr; - - -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::invalidate() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_invalidate) - nlassert(!_Invalid); - // Buffer is lost (maybe there was a alt-tab or fullscrren / windowed change) - // Buffer is deleted at end of frame only - _Invalid = true; - _Driver->incrementResetCounter(); - _DummyVB.resize(VB->getNumVertices() * VB->getVertexSize(), 0); - // insert in lost vb list - _VertexArrayRange->_LostVBList.push_front(this); - _IteratorInLostVBList = _VertexArrayRange->_LostVBList.begin(); -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::unlock() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_unlock) - #ifdef NL_DEBUG - if (_VertexPtr) - { - _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); - } - #endif - _VertexPtr = NULL; - if (_Invalid) return; - if (!_VertexObjectId) return; - #ifdef NL_DEBUG - _Unmapping = true; - #endif - nglUnmapObjectBufferATI(_VertexObjectId); - #ifdef NL_DEBUG - _Unmapping = false; - #endif -} - -// *************************************************************************** -void *CVertexBufferHardGLMapObjectATI::getPointer() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_getPointer) - return _VertexPtr; -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::unlock(uint /* start */,uint /* endVert */) -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_unlock) - unlock(); // can't do a lock on a range of the vb.. -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::enable() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_enable) - if(_Driver->_CurrentVertexBufferHard != this) - { - /* nlassert(_VertexArrayRange); - _VertexArrayRange->enable(); */ - _Driver->_CurrentVertexBufferHard= this; - } -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::disable() -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_disable) - if(_Driver->_CurrentVertexBufferHard != NULL) - { - /* nlassert(_VertexArrayRange); - _VertexArrayRange->disable(); */ - _Driver->_CurrentVertexBufferHard= NULL; - } -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::initGL(CVertexArrayRangeMapObjectATI *var, uint vertexObjectID) -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_initGL) - _VertexArrayRange = var; - _VertexObjectId = vertexObjectID; -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::lockHintStatic(bool /* staticLock */) -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_lockHintStatix) - // no op. -} - -// *************************************************************************** -void CVertexBufferHardGLMapObjectATI::setupVBInfos(CVertexBufferInfo &vb) -{ - H_AUTO_OGL(CVertexBufferHardGLMapObjectATI_setupVBInfos) - vb.VBMode = CVertexBufferInfo::HwATI; - vb.VertexObjectId = getATIVertexObjectId(); -} - -// *************************************************************************** -void CVertexArrayRangeMapObjectATI::updateLostBuffers() -{ - H_AUTO_OGL(CVertexArrayRangeMapObjectATI_updateLostBuffers) - // Put all vb that have been lost in the NotResident state so that they will be recomputed - // We do this only if the app is active, because if vb were lost, it is likely that there are no resources available. - nlassert(_Driver); - if (_Driver->isWndActive()) - { - for(std::list::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it) - { - nlassert((*it)->_VertexObjectId); - nlassert(nglIsObjectBufferATI((*it)->_VertexObjectId)); - nglDeleteObjectBufferATI((*it)->_VertexObjectId); - (*it)->_VertexObjectId = 0; - (*it)->VB->setLocation(CVertexBuffer::NotResident); - } - _LostVBList.clear(); - } -} -// *************************************************************************** -#ifdef NL_DEBUG - void CVertexArrayRangeMapObjectATI::dumpMappedBuffers() - { - nlwarning("*****************************************************"); - nlwarning("Mapped buffers :"); - for(std::list::iterator it = _MappedVBList.begin(); it != _MappedVBList.end(); ++it) - { - CVertexBufferHardGLMapObjectATI &vbati = **it; - nlwarning("Buffer id = %u, size = %u, address = %p", vbati._VertexObjectId, vbati.VB->getVertexSize() * vbati.VB->getNumVertices(), vbati.getPointer()); - } - } -#endif // *************************************************************************** // *************************************************************************** diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.h b/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.h index 746b0a579..d5578421b 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.h +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_vertex_buffer_hard.h @@ -113,346 +113,6 @@ protected: bool _Invalid; }; -// *************************************************************************** -// *************************************************************************** -// NVidia implementation -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -/** Work only if ARRAY_RANGE_NV is enabled. else, only call to ctor/dtor/free() is valid. - * any call to allocateVB() will return NULL. - */ -class CVertexArrayRangeNVidia : public IVertexArrayRange -{ -public: - CVertexArrayRangeNVidia(CDriverGL3 *drv); - - - /// \name Implementation - // @{ - /// allocate a vertex array sapce. false if error. must free before re-allocate. - virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); - /// free this space. - virtual void free(); - /// create a IVertexBufferHardGL - virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); - /// return the size allocated. 0 if not allocated or failure - virtual uint sizeAllocated() const; - // @} - - - // Those methods read/write in _Driver->_CurrentVertexArrayRange. - /// active this VertexArrayRange as the current vertex array range used. no-op if already setup. - void enable(); - /// disable this VertexArrayRange. _Driver->_CurrentVertexArrayRange= NULL; - void disable(); - - /// free a VB allocated with allocateVB. No-op if NULL. - void freeVB(void *ptr); - - -// ************************* -private: - void *_VertexArrayPtr; - uint32 _VertexArraySize; - - // Allocator. - NLMISC::CHeapMemory _HeapMemory; - - /// true if allocated. - bool allocated() const {return _VertexArrayPtr!=NULL;} - /// Allocate a small subset of the memory. NULL if not enough mem. - void *allocateVB(uint32 size); - -}; - - - -// *************************************************************************** -/// Work only if ARRAY_RANGE_NV is enabled. -class CVertexBufferHardGLNVidia : public IVertexBufferHardGL -{ -public: - - CVertexBufferHardGLNVidia(CDriverGL3 *drv, CVertexBuffer *vb); - virtual ~CVertexBufferHardGLNVidia(); - - - /// \name Implementation - // @{ - virtual void *lock(); - virtual void unlock(); - virtual void unlock(uint start, uint end); - virtual void *getPointer(); - virtual void enable(); - virtual void disable(); - virtual void lockHintStatic(bool staticLock); - virtual void setupVBInfos(CVertexBufferInfo &vb); - // @} - - - // setup ptrs allocated by createVBHard(), and init Fence. - void initGL(CVertexArrayRangeNVidia *var, void *vertexPtr); - - - // true if a setFence() has been done, without a finishFence(). NB: not the same thing as nglTestFenceNV()!! - bool isFenceSet() const {return _FenceSet;} - // set or re-set the fence, whatever isFenceSet(). - void setFence(); - // if(isFenceSet()), finish the fence, else no-op - void finishFence(); - // if fence is not set, no-op, else test nglTestFenceNV(), and update local _FenceSet flag. - void testFence(); - - bool getLockHintStatic() const {return _LockHintStatic;} - -// ************************* -private: - CVertexArrayRangeNVidia *_VertexArrayRange; - void *_VertexPtr; - - // The fence inserted in command stream - GLuint _Fence; - // True if a setFence() has been done, without a finishFence(). - bool _FenceSet; - - bool _LockHintStatic; - -}; - - - -// *************************************************************************** -// *************************************************************************** -// ATI implementation -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -// This is a fake value to simulate allocation on CHeapMemory for ATI mgt. -// NB: can set 0, since won't work for multiple reasons.... -#define NL3D_DRV_ATI_FAKE_MEM_START 0x10000 - - -// *************************************************************************** -/** Work only if ATIVertexArrayObject is enabled. else, only call to ctor/dtor/free() is valid. - * any call to allocateVB() will return NULL. - */ -class CVertexArrayRangeATI : public IVertexArrayRange -{ -public: - CVertexArrayRangeATI(CDriverGL3 *drv); - - - /// \name Implementation - // @{ - /// allocate a vertex array sapce. false if error. must free before re-allocate. - virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); - /// free this space. - virtual void free(); - /// create a IVertexBufferHardGL - virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); - /// return the size allocated. 0 if not allocated or failure - virtual uint sizeAllocated() const; - // @} - - - // Those methods read/write in _Driver->_CurrentVertexArrayRange. - /** active this VertexArrayRange as the current vertex array range used. no-op if already setup. - * NB: no-op for ATI, but ensure correct _Driver->_CurrentVertexArrayRange value. - */ - void enable(); - /** disable this VertexArrayRange. _Driver->_CurrentVertexArrayRange= NULL; - * NB: no-op for ATI, but ensure correct _Driver->_CurrentVertexArrayRange value. - */ - void disable(); - - /// free a VB allocated with allocateVB. No-op if NULL. - void freeVB(void *ptr); - - - /// get Handle of the ATI buffer. - uint getATIVertexObjectId() const {return _VertexObjectId;} - -// ************************* -private: - uint _VertexObjectId; - bool _Allocated; - uint32 _VertexArraySize; - - // Allocator. NB: We don't have any Mem Ptr For ATI extension, so use a Fake Ptr: NL3D_DRV_ATI_FAKE_MEM_START - NLMISC::CHeapMemory _HeapMemory; - - /// Allocate a small subset of the memory. NULL if not enough mem. - void *allocateVB(uint32 size); - -}; - - - - -// *************************************************************************** -/// Work only if ARRAY_RANGE_NV is enabled. -class CVertexBufferHardGLATI : public IVertexBufferHardGL -{ -public: - - CVertexBufferHardGLATI(CDriverGL3 *drv, CVertexBuffer *vb); - virtual ~CVertexBufferHardGLATI(); - - - /// \name Implementation - // @{ - virtual void *lock(); - virtual void unlock(); - virtual void unlock(uint start, uint end); - virtual void *getPointer(); - virtual void enable(); - virtual void disable(); - virtual void lockHintStatic(bool staticLock); - virtual void setupVBInfos(CVertexBufferInfo &vb); - // @} - - - /// try to create a RAM mirror that 'll contain a copy of the VB. - bool createRAMMirror(uint memSize); - - /** setup ptrs allocated by createVBHard() - */ - void initGL(CVertexArrayRangeATI *var, void *vertexPtr); - - -public: - - /// get Handle of the ATI buffer. - uint getATIVertexObjectId() const {return _VertexArrayRange->getATIVertexObjectId();} - - -// ************************* -private: - CVertexArrayRangeATI *_VertexArrayRange; - void *_VertexPtr; - void *_RAMMirrorVertexPtr; - uint _RAMMirrorVertexSize; - -}; - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** TEMP nico : test if better with ATI_map_object_buffer - * We don't manage a heap there, we just allocate separate objects (can't get a pointer on a portion of the buffer only ..) - * todo : test if such maneer is still efficient (because of vb switching) - * NB : this is available only it GL_ATI_map_object_buffer is available - */ -class CVertexArrayRangeMapObjectATI : public IVertexArrayRange -{ -public: - CVertexArrayRangeMapObjectATI(CDriverGL3 *drv); - - - /// \name Implementation - // @{ - /** Allocate a vertex array space. false if error. must free before re-allocate. - * Will always succeed, because vb are not managed in a heap, but are rather kept as separate objects - */ - virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); - /// free this space. - virtual void free(); - /// create a IVertexBufferHardGL - virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); - /// return the size allocated. 0 if not allocated or failure - virtual uint sizeAllocated() const { return _SizeAllocated; } - // @} - - - // Those methods read/write in _Driver->_CurrentVertexArrayRange. - /** active this VertexArrayRange as the current vertex array range used. no-op if already setup. - * NB: no-op for ATI, but ensure correct _Driver->_CurrentVertexArrayRange value. - */ - void enable(); - /** disable this VertexArrayRange. _Driver->_CurrentVertexArrayRange= NULL; - * NB: no-op for ATI, but ensure correct _Driver->_CurrentVertexArrayRange value. - */ - void disable(); - - CVertexBuffer::TPreferredMemory getVBType() const { return _VBType; } - - // check & invalidate lost buffers - void updateLostBuffers(); - - // tmp for debug - #ifdef NL_DEBUG - void dumpMappedBuffers(); - #endif - -// ************************* -private: - CVertexBuffer::TPreferredMemory _VBType; - uint32 _SizeAllocated; -public: - // for use by CVertexBufferHardGLMapObjectATI - std::list _LostVBList; - #ifdef NL_DEBUG - std::list _MappedVBList; - #endif -}; - - -/** vb hard using the ATI_map_object_buffer extension. Buffer are kept separate rather than managed in a heap - */ -class CVertexBufferHardGLMapObjectATI : public IVertexBufferHardGL -{ -public: - - CVertexBufferHardGLMapObjectATI(CDriverGL3 *drv, CVertexBuffer *vb); - virtual ~CVertexBufferHardGLMapObjectATI(); - - - /// \name Implementation - // @{ - virtual void *lock(); - virtual void unlock(); - virtual void unlock(uint start, uint end); - virtual void *getPointer(); - virtual void enable(); - virtual void disable(); - virtual void lockHintStatic(bool staticLock); - virtual void setupVBInfos(CVertexBufferInfo &vb); - // @} - - /** setup ptrs allocated by createVBHard() - */ - void initGL(CVertexArrayRangeMapObjectATI *var, uint vertexObjectID); - - -public: - - /// get Handle of the ATI buffer. - uint getATIVertexObjectId() const { return _VertexObjectId;} - - -// ************************* -private: - void *_VertexPtr; // pointer on current datas. Null if not locked - CVertexArrayRangeMapObjectATI *_VertexArrayRange; - // if buffer has been invalidated, returns a dummy memory block and silently fails rendering - std::vector _DummyVB; - // Invalidate the buffer (when it is lost, or when a lock fails) - void invalidate(); -public: - // for use by CVertexArrayRangeMapObjectATI - std::list::iterator _IteratorInLostVBList; - uint _VertexObjectId; - // tmp for debug - #ifdef NL_DEBUG - bool _Unmapping; - std::list::iterator _IteratorInMappedVBList; - #endif -}; // *************************************************************************** // ***************************************************************************