i misunderstood about HardwareVertexBuffer design.
HardwareVertexBuffer have no independent buffer, it have shared buffer.
Code: Select all
void* GLHardwareVertexBuffer::lockImpl(size_t offset,
size_t length, LockOptions options)
{
if(mIsLocked)
{
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
"Invalid attempt to lock an vertex buffer that has already been locked",
"GLHardwareVertexBuffer::lock");
}
void* retPtr = 0;
GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::getSingletonPtr());
// Try to use scratch buffers for smaller buffers
if( length < glBufManager->getGLMapBufferThreshold() )
{
// if this fails, we fall back on mapping
[u][b] retPtr = glBufManager->allocateScratch((uint32)length)[/b][/u];
There are two problems here.
first it is not thread safe.
second , useless working....
first ....
this design can't work with thread.
Things like a paritcle, it should be able to update vertex buffer with thread.
second
Code: Select all
char* const pStartBuf = static_cast<char*>(hardwareBufferPtr->lock(HardwareBuffer::HBL_DISCARD));
....
hardwareBufferPtr->unlock()
that's all
This memory need not be........
i think hardwarebuffer must have independent memory..... with thread safe
[ maybe , independent memory buffer has to write opengl buffer when render object ]