VertexArrayRange allocation thing is pointless when using ARB VBOs since, the driver takes care about allocating to either system RAM or video RAM.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent e41a15ae30
commit b444f69db3

@ -455,29 +455,9 @@ bool CDriverGL3::setupDisplay()
_NVCurrentVARPtr= NULL; _NVCurrentVARPtr= NULL;
_NVCurrentVARSize= 0; _NVCurrentVARSize= 0;
if (_SupportVBHard) if( _SupportVBHard )
{
// try to allocate 16Mo by default of AGP Ram.
initVertexBufferHard(NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE, 0); initVertexBufferHard(NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE, 0);
// If not success to allocate at least a minimum space in AGP, then disable completely VBHard feature
if( _AGPVertexArrayRange->sizeAllocated()==0 )
{
// reset any allocated VRAM space.
resetVertexArrayRange();
// delete containers
delete _AGPVertexArrayRange;
delete _VRAMVertexArrayRange;
_AGPVertexArrayRange= NULL;
_VRAMVertexArrayRange= NULL;
// disable.
_SupportVBHard= false;
_SlowUnlockVBHard= false;
_MaxVerticesByVBHard= 0;
}
}
// Init embm if present // Init embm if present
//=========================================================== //===========================================================

@ -332,8 +332,8 @@ public:
virtual bool copyTextToClipboard(const ucstring &text); virtual bool copyTextToClipboard(const ucstring &text);
virtual bool pasteTextFromClipboard(ucstring &text); virtual bool pasteTextFromClipboard(ucstring &text);
virtual uint32 getAvailableVertexAGPMemory (); uint32 getAvailableVertexAGPMemory (){ return 0; };
virtual uint32 getAvailableVertexVRAMMemory (); uint32 getAvailableVertexVRAMMemory (){ return 0; };
virtual emptyProc getWindowProc(); virtual emptyProc getWindowProc();

@ -1483,12 +1483,6 @@ void CDriverGL3::resetVertexArrayRange()
} }
// Clear any VertexBufferHard created. // Clear any VertexBufferHard created.
_VertexBufferHardSet.clear(); _VertexBufferHardSet.clear();
// After, Clear the 2 vertexArrayRange, if any.
if(_AGPVertexArrayRange)
_AGPVertexArrayRange->free();
if(_VRAMVertexArrayRange)
_VRAMVertexArrayRange->free();
} }
@ -1505,83 +1499,8 @@ bool CDriverGL3::initVertexBufferHard(uint agpMem, uint vramMem)
// First, reset any VBHard created. // First, reset any VBHard created.
resetVertexArrayRange(); resetVertexArrayRange();
bool ok= true;
// Try to allocate AGPMemory.
if(agpMem>0)
{
agpMem&= ~15; // ensure 16-bytes aligned mem count (maybe useful :) ).
agpMem= max(agpMem, (uint)NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE);
while(agpMem>= NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
{
if(_AGPVertexArrayRange->allocate(agpMem, CVertexBuffer::AGPPreferred))
{
nlinfo("3D: %.u vertices supported", _MaxVerticesByVBHard);
nlinfo("3D: Success to allocate %.1f Mo of AGP VAR Ram", agpMem / 1000000.f);
break;
}
else
{
agpMem/=2;
agpMem &=~15;
}
}
if(agpMem< NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
{
nlinfo("3D: %.u vertices supported", _MaxVerticesByVBHard);
nlinfo("3D: Failed to allocate %.1f Mo of AGP VAR Ram", NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE / 1000000.f);
ok= false;
}
}
// Try to allocate VRAMMemory.
if(vramMem>0)
{
vramMem&= ~15; // ensure 16-bytes aligned mem count (maybe useful :) ).
vramMem= max(vramMem, (uint)NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE);
while(vramMem>= NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
{
if(_VRAMVertexArrayRange->allocate(vramMem, CVertexBuffer::StaticPreferred))
break;
else
{
vramMem/=2;
vramMem &=~15;
}
}
if(vramMem< NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
{
ok= false;
}
}
return ok;
}
// *************************************************************************** return true;
uint32 CDriverGL3::getAvailableVertexAGPMemory ()
{
H_AUTO_OGL(CDriverGL3_getAvailableVertexAGPMemory )
if (_AGPVertexArrayRange)
return _AGPVertexArrayRange->sizeAllocated();
else
return 0;
}
// ***************************************************************************
uint32 CDriverGL3::getAvailableVertexVRAMMemory ()
{
H_AUTO_OGL(CDriverGL3_getAvailableVertexVRAMMemory )
if (_VRAMVertexArrayRange)
return _VRAMVertexArrayRange->sizeAllocated();
else
return 0;
} }

@ -92,50 +92,6 @@ CVertexArrayRangeARB::CVertexArrayRangeARB(CDriverGL3 *drv) : IVertexArrayRange(
H_AUTO_OGL(CVertexArrayRangeARB_CVertexArrayRangeARB) H_AUTO_OGL(CVertexArrayRangeARB_CVertexArrayRangeARB)
} }
// ***************************************************************************
bool CVertexArrayRangeARB::allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType)
{
H_AUTO_OGL(CVertexArrayRangeARB_allocate)
nlassert(_SizeAllocated == 0);
/*
// We don't manage memory ourselves, but test if there's enough room anyway
GLuint vertexBufferID;
glGetError();
glGenBuffersARB(1, &vertexBufferID);
if (glGetError() != GL_NO_ERROR) return false;
switch(vbType)
{
case CVertexBuffer::AGPPreferred:
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
break;
case CVertexBuffer::VRAMPreferred:
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
break;
default:
nlassert(0);
break;
}
if (glGetError() != GL_NO_ERROR)
{
glDeleteBuffersARB(1, &vertexBufferID);
return false;
}
glDeleteBuffersARB(1, &vertexBufferID);
*/
_SizeAllocated = size;
_VBType = vbType;
return true;
}
// ***************************************************************************
void CVertexArrayRangeARB::free()
{
H_AUTO_OGL(CVertexArrayRangeARB_free)
_SizeAllocated = 0;
}
// *************************************************************************** // ***************************************************************************
IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuffer *vb) IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuffer *vb)
{ {

@ -50,14 +50,8 @@ public:
IVertexArrayRange(CDriverGL3 *drv); IVertexArrayRange(CDriverGL3 *drv);
virtual ~IVertexArrayRange(); virtual ~IVertexArrayRange();
/// allocate a vertex array space. false if error. client must free before re-allocate.
virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType)= 0;
/// free this space.
virtual void free()= 0;
/// create a IVertexBufferHardGL /// create a IVertexBufferHardGL
virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb) =0; virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb) =0;
/// return the size allocated. 0 if not allocated or failure
virtual uint sizeAllocated() const =0;
// Check & invalidate lost buffers. Default assume they can't be lost // Check & invalidate lost buffers. Default assume they can't be lost
virtual void updateLostBuffers() {} virtual void updateLostBuffers() {}
// Get driver // Get driver
@ -124,21 +118,7 @@ class CVertexArrayRangeARB : public IVertexArrayRange
public: public:
CVertexArrayRangeARB(CDriverGL3 *drv); CVertexArrayRangeARB(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); 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. // Those methods read/write in _Driver->_CurrentVertexArrayRange.
/** active this VertexArrayRange as the current vertex array range used. no-op if already setup. /** active this VertexArrayRange as the current vertex array range used. no-op if already setup.

Loading…
Cancel
Save