VBOs now use irrMap
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1151 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
199c83dab5
commit
86eda333c6
|
@ -55,6 +55,14 @@ namespace scene
|
|||
EPT_POINT_SPRITES
|
||||
};
|
||||
|
||||
enum E_BUFFER_TYPE
|
||||
{
|
||||
EBT_NONE=0,
|
||||
EBT_VERTEX,
|
||||
EBT_INDEX,
|
||||
EBT_VERTEX_AND_INDEX
|
||||
};
|
||||
|
||||
//! Struct for holding a mesh with a single material
|
||||
/** SMeshBuffer is a simple implementation of a MeshBuffer. */
|
||||
class IMeshBuffer : public virtual IReferenceCounted
|
||||
|
|
|
@ -1254,7 +1254,6 @@ void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer* mb)
|
|||
drawHardwareBuffer(HWBuffer);
|
||||
else
|
||||
drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES);
|
||||
|
||||
}
|
||||
|
||||
CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IMeshBuffer* mb)
|
||||
|
@ -1263,14 +1262,8 @@ CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IMeshBuffer*
|
|||
return 0;
|
||||
|
||||
//search for hardware links
|
||||
for (u32 n=0;n<HWBufferLinks.size();++n)
|
||||
{
|
||||
SHWBufferLink *Link=HWBufferLinks[n];
|
||||
if (Link->MeshBuffer==mb)
|
||||
{
|
||||
return Link;
|
||||
}
|
||||
}
|
||||
core::map< const scene::IMeshBuffer*,SHWBufferLink* >::Node* node = HWBufferMap.find(mb);
|
||||
if (node) return node->getValue();
|
||||
|
||||
return createHardwareBuffer(mb); //no hardware links, and mesh wants one, create it
|
||||
}
|
||||
|
@ -1278,12 +1271,13 @@ CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IMeshBuffer*
|
|||
//! Update all hardware buffers, remove unused ones
|
||||
void CNullDriver::updateAllHardwareBuffers()
|
||||
{
|
||||
for (u32 n=0;n<HWBufferLinks.size();++n)
|
||||
core::map<const scene::IMeshBuffer*,SHWBufferLink*>::ParentFirstIterator Iterator=HWBufferMap.getParentFirstIterator();
|
||||
|
||||
for (;!Iterator.atEnd();Iterator++)
|
||||
{
|
||||
SHWBufferLink *Link=HWBufferLinks[n];
|
||||
SHWBufferLink *Link=Iterator.getNode()->getValue();
|
||||
|
||||
Link->LastUsed++;
|
||||
|
||||
if (Link->LastUsed>20000)
|
||||
{
|
||||
deleteHardwareBuffer(Link);
|
||||
|
@ -1294,34 +1288,27 @@ void CNullDriver::updateAllHardwareBuffers()
|
|||
|
||||
void CNullDriver::deleteHardwareBuffer(SHWBufferLink *HWBuffer)
|
||||
{
|
||||
s32 n=HWBufferLinks.binary_search(HWBuffer);
|
||||
if (n!=-1) HWBufferLinks.erase(n);
|
||||
|
||||
if (!HWBuffer) return;
|
||||
HWBufferMap.remove( HWBuffer->MeshBuffer );
|
||||
delete HWBuffer;
|
||||
}
|
||||
|
||||
|
||||
//! Remove hardware buffer
|
||||
void CNullDriver::removeHardwareBuffer(const scene::IMeshBuffer* mb)
|
||||
{
|
||||
for (u32 n=0;n<HWBufferLinks.size();++n)
|
||||
{
|
||||
SHWBufferLink *Link=HWBufferLinks[n];
|
||||
if (Link->MeshBuffer==mb)
|
||||
{
|
||||
deleteHardwareBuffer(Link);
|
||||
}
|
||||
}
|
||||
core::map<const scene::IMeshBuffer*,SHWBufferLink*>::Node* node = HWBufferMap.find(mb);
|
||||
if (node) deleteHardwareBuffer( node->getValue() );
|
||||
}
|
||||
|
||||
|
||||
//! Remove all hardware buffers
|
||||
void CNullDriver::removeAllHardwareBuffers()
|
||||
{
|
||||
while (HWBufferLinks.size())
|
||||
deleteHardwareBuffer(HWBufferLinks[0]);
|
||||
}
|
||||
core::map<const scene::IMeshBuffer*,SHWBufferLink*>::ParentLastIterator Iterator=HWBufferMap.getParentLastIterator();
|
||||
|
||||
for (;!Iterator.atEnd();Iterator++)
|
||||
deleteHardwareBuffer(Iterator.getNode()->getValue());
|
||||
|
||||
}
|
||||
|
||||
bool CNullDriver::isHardwareBufferRecommend(const scene::IMeshBuffer* mb)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "IGPUProgrammingServices.h"
|
||||
#include "irrArray.h"
|
||||
#include "irrString.h"
|
||||
#include "irrMap.h"
|
||||
#include "IAttributes.h"
|
||||
#include "IMeshBuffer.h"
|
||||
#include "CFPSCounter.h"
|
||||
|
@ -305,10 +306,13 @@ namespace video
|
|||
MeshBuffer->drop();
|
||||
}
|
||||
|
||||
scene::E_BUFFER_TYPE Contains;
|
||||
const scene::IMeshBuffer *MeshBuffer;
|
||||
u32 ChangedID;
|
||||
u32 LastUsed;
|
||||
scene::E_HARDWARE_MAPPING Mapped;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -555,8 +559,8 @@ namespace video
|
|||
core::array<SLight> Lights;
|
||||
core::array<SMaterialRenderer> MaterialRenderers;
|
||||
|
||||
core::array<SHWBufferLink*> HWBufferLinks;
|
||||
|
||||
//core::array<SHWBufferLink*> HWBufferLinks;
|
||||
core::map< const scene::IMeshBuffer* , SHWBufferLink* > HWBufferMap;
|
||||
|
||||
io::IFileSystem* FileSystem;
|
||||
|
||||
|
|
|
@ -659,6 +659,7 @@ bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer)
|
|||
|| !((SHWBufferLink_opengl*)HWBuffer)->vbo_indicesID
|
||||
|| !((SHWBufferLink_opengl*)HWBuffer)->vbo_verticesID)
|
||||
{
|
||||
|
||||
HWBuffer->ChangedID = HWBuffer->MeshBuffer->getChangedID();
|
||||
|
||||
if (!updateVertexHardwareBuffer((SHWBufferLink_opengl*)HWBuffer))
|
||||
|
@ -680,17 +681,8 @@ COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::I
|
|||
|
||||
SHWBufferLink_opengl *HWBuffer=new SHWBufferLink_opengl(mb);
|
||||
|
||||
//add to list, in order of their meshbuffer pointer
|
||||
|
||||
u32 n;
|
||||
for (n=0;n<HWBufferLinks.size();++n)
|
||||
if (HWBufferLinks[n]->MeshBuffer > HWBuffer->MeshBuffer)
|
||||
break;
|
||||
if (n<HWBufferLinks.size())
|
||||
HWBufferLinks.insert(HWBuffer,n);
|
||||
else
|
||||
|
||||
HWBufferLinks.push_back(HWBuffer);
|
||||
//add to map
|
||||
HWBufferMap.insert(HWBuffer->MeshBuffer, HWBuffer);
|
||||
|
||||
HWBuffer->ChangedID=HWBuffer->MeshBuffer->getChangedID();
|
||||
HWBuffer->Mapped=mb->getHardwareMappingHint();
|
||||
|
@ -715,6 +707,7 @@ void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer)
|
|||
{
|
||||
if (!_HWBuffer) return;
|
||||
|
||||
|
||||
#if defined(GL_ARB_vertex_buffer_object)
|
||||
SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer;
|
||||
if (HWBuffer->vbo_verticesID)
|
||||
|
|
Loading…
Reference in New Issue