GL3: Cleanup

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent 636b93a7b5
commit 60851a863e

@ -286,11 +286,11 @@ void CDriverGL3::updateLostBuffers()
{ {
for (std::list<CVertexBufferGL3 *>::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it) for (std::list<CVertexBufferGL3 *>::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it)
{ {
nlassert((*it)->VertexObjectId); nlassert((*it)->m_VertexObjectId);
GLuint id = (GLuint) (*it)->VertexObjectId; GLuint id = (GLuint) (*it)->m_VertexObjectId;
nlassert(nglIsBuffer(id)); nlassert(nglIsBuffer(id));
nglDeleteBuffers(1, &id); nglDeleteBuffers(1, &id);
(*it)->VertexObjectId = 0; (*it)->m_VertexObjectId = 0;
(*it)->VB->setLocation(CVertexBuffer::NotResident); (*it)->VB->setLocation(CVertexBuffer::NotResident);
} }
_LostVBList.clear(); _LostVBList.clear();

@ -47,7 +47,7 @@ IVertexBufferGL3::~IVertexBufferGL3()
CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb) CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb)
: IVertexBufferGL3(drv, vb, IVertexBufferGL3::GL3), : IVertexBufferGL3(drv, vb, IVertexBufferGL3::GL3),
m_VertexPtr(NULL), m_VertexPtr(NULL),
VertexObjectId(0) m_VertexObjectId(0)
{ {
H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARB) H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARB)
} }
@ -56,16 +56,16 @@ CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb)
CVertexBufferGL3::~CVertexBufferGL3() CVertexBufferGL3::~CVertexBufferGL3()
{ {
H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARBDtor) H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARBDtor)
if (m_Driver && VertexObjectId) if (m_Driver && m_VertexObjectId)
{ {
if (m_Driver->_DriverGLStates.getCurrBoundARBVertexBuffer() == VertexObjectId) if (m_Driver->_DriverGLStates.getCurrBoundARBVertexBuffer() == m_VertexObjectId)
{ {
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0); m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
} }
} }
if (VertexObjectId) if (m_VertexObjectId)
{ {
GLuint id = (GLuint) VertexObjectId; GLuint id = (GLuint)m_VertexObjectId;
nlassert(nglIsBuffer(id)); nlassert(nglIsBuffer(id));
nglDeleteBuffers(1, &id); nglDeleteBuffers(1, &id);
} }
@ -117,9 +117,9 @@ void *CVertexBufferGL3::lock()
nglDeleteBuffers(1, &vertexBufferID); nglDeleteBuffers(1, &vertexBufferID);
return &m_DummyVB[0];; return &m_DummyVB[0];;
} }
VertexObjectId = vertexBufferID; m_VertexObjectId = vertexBufferID;
NLMISC::contReset(m_DummyVB); // free vector memory for real NLMISC::contReset(m_DummyVB); // free vector memory for real
nlassert(VertexObjectId); nlassert(m_VertexObjectId);
m_Invalid = false; m_Invalid = false;
m_Driver->_LostVBList.erase(m_IteratorInLostVBList); m_Driver->_LostVBList.erase(m_IteratorInLostVBList);
// continue to standard mapping code below .. // continue to standard mapping code below ..
@ -129,7 +129,7 @@ void *CVertexBufferGL3::lock()
{ {
beforeLock= CTime::getPerformanceTime(); beforeLock= CTime::getPerformanceTime();
} }
m_Driver->_DriverGLStates.bindARBVertexBuffer(VertexObjectId); m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId);
// m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); // m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
@ -163,7 +163,7 @@ void *CVertexBufferGL3::lock()
if (!m_VertexPtr) if (!m_VertexPtr)
{ {
nglUnmapBuffer(GL_ARRAY_BUFFER); nglUnmapBuffer(GL_ARRAY_BUFFER);
nlassert(nglIsBuffer((GLuint) VertexObjectId)); nlassert(nglIsBuffer((GLuint)m_VertexObjectId));
invalidate(); invalidate();
return &m_DummyVB[0]; return &m_DummyVB[0];
} }
@ -190,13 +190,13 @@ void CVertexBufferGL3::unlock()
m_VertexPtr = NULL; m_VertexPtr = NULL;
if (m_Invalid) return; if (m_Invalid) return;
if (!VertexObjectId) return; if (!m_VertexObjectId) return;
TTicks beforeLock = 0; TTicks beforeLock = 0;
if (m_Driver->_VBHardProfiling) if (m_Driver->_VBHardProfiling)
{ {
beforeLock= CTime::getPerformanceTime(); beforeLock= CTime::getPerformanceTime();
} }
m_Driver->_DriverGLStates.bindARBVertexBuffer(VertexObjectId); m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId);
// double start = CTime::ticksToSecond(CTime::getPerformanceTime()); // double start = CTime::ticksToSecond(CTime::getPerformanceTime());
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = true; _Unmapping = true;
@ -269,7 +269,7 @@ void CVertexBufferGL3::disable()
void CVertexBufferGL3::initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemory memType) void CVertexBufferGL3::initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemory memType)
{ {
H_AUTO_OGL(CVertexBufferGLARB_initGL) H_AUTO_OGL(CVertexBufferGLARB_initGL)
VertexObjectId = vertexObjectID; m_VertexObjectId = vertexObjectID;
m_MemType = memType; m_MemType = memType;
} }
@ -277,7 +277,7 @@ void CVertexBufferGL3::initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemo
void CVertexBufferGL3::setupVBInfos(CVertexBufferInfo &vb) void CVertexBufferGL3::setupVBInfos(CVertexBufferInfo &vb)
{ {
H_AUTO_OGL(CVertexBufferGLARB_setupVBInfos) H_AUTO_OGL(CVertexBufferGLARB_setupVBInfos)
vb.VertexObjectId = VertexObjectId; vb.VertexObjectId = m_VertexObjectId;
} }
// *************************************************************************** // ***************************************************************************

@ -78,14 +78,13 @@ public:
/// Setup ptrs allocated by createVBHard() /// Setup ptrs allocated by createVBHard()
void initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemory memType); void initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemory memType);
public:
/// Get Handle of the ARB buffer.
uint getARBVertexObjectId() const { return VertexObjectId;}
/// Invalidate the buffer (when it is lost, or when a lock fails) /// Invalidate the buffer (when it is lost, or when a lock fails)
void invalidate(); void invalidate();
private: private:
friend class CDriverGL3;
CVertexBuffer::TPreferredMemory m_MemType; CVertexBuffer::TPreferredMemory m_MemType;
void *m_VertexPtr; // pointer on current datas. Null if not locked void *m_VertexPtr; // pointer on current datas. Null if not locked
@ -94,8 +93,7 @@ private:
// for use by CVertexArrayRange // for use by CVertexArrayRange
std::list<CVertexBufferGL3*>::iterator m_IteratorInLostVBList; std::list<CVertexBufferGL3*>::iterator m_IteratorInLostVBList;
public: uint m_VertexObjectId;
uint VertexObjectId;
}; };
#ifdef NL_STATIC #ifdef NL_STATIC

Loading…
Cancel
Save