Removed vendor specific VBO code.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 8f45e49fa0
commit 5c7540d85e

@ -449,37 +449,6 @@ bool CDriverGL3::setupDisplay()
_MaxVerticesByVBHard = std::numeric_limits<uint32>::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<IVertexBufferHardGL*>::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<CVertexBufferHardGLNVidia*>(*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<IVertexBufferHardGL*>::iterator itVBHard= _VertexBufferHardSet.Set.begin();
while(itVBHard != _VertexBufferHardSet.Set.end() )
{
if((*itVBHard)->VBType == IVertexBufferHardGL::NVidiaVB)
{
CVertexBufferHardGLNVidia *vbHardNV= static_cast<CVertexBufferHardGLNVidia*>(*itVBHard);
if(vbHardNV->isFenceSet())
{
// update Fence Cache.
vbHardNV->testFence();
}
}
itVBHard++;
}
}
#ifdef NL_OS_WINDOWS
if (_EventEmitter.getNumEmitters() > 1) // is direct input running ?
{

@ -1220,8 +1220,6 @@ private:
/// \name VertexBufferHard
// @{
CPtrSet<IVertexBufferHardGL> _VertexBufferHardSet;
friend class CVertexArrayRangeNVidia;
friend class CVertexBufferHardGLNVidia;
friend class CVertexArrayRangeATI;
friend class CVertexArrayRangeARB;
friend class CVertexBufferHardARB;

@ -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<CVertexBufferHardGLNVidia*>(_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;
}
}
}
// ***************************************************************************

@ -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<CVertexBufferHardGLMapObjectATI *> _LostVBList;
#ifdef NL_DEBUG
std::list<CVertexBufferHardGLMapObjectATI *> _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<uint8> _DummyVB;
// Invalidate the buffer (when it is lost, or when a lock fails)
void invalidate();
public:
// for use by CVertexArrayRangeMapObjectATI
std::list<CVertexBufferHardGLMapObjectATI *>::iterator _IteratorInLostVBList;
uint _VertexObjectId;
// tmp for debug
#ifdef NL_DEBUG
bool _Unmapping;
std::list<CVertexBufferHardGLMapObjectATI *>::iterator _IteratorInMappedVBList;
#endif
};
// ***************************************************************************
// ***************************************************************************

Loading…
Cancel
Save