diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llrender.cpp | 19 | ||||
-rw-r--r-- | indra/llrender/llrender.h | 1 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 36 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.h | 5 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 1 |
5 files changed, 42 insertions, 20 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 8eb160f4e7..efd0a11b88 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -754,13 +754,7 @@ LLRender::LLRender() mMode(LLRender::TRIANGLES), mCurrTextureUnitIndex(0), mMaxAnisotropy(0.f) -{ - mBuffer = new LLVertexBuffer(immediate_mask, 0); - mBuffer->allocateBuffer(4096, 0, TRUE); - mBuffer->getVertexStrider(mVerticesp); - mBuffer->getTexCoord0Strider(mTexcoordsp); - mBuffer->getColorStrider(mColorsp); - +{ mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) { @@ -786,6 +780,17 @@ LLRender::~LLRender() shutdown(); } +void LLRender::init() +{ + llassert_always(mBuffer.isNull()) ; + + mBuffer = new LLVertexBuffer(immediate_mask, 0); + mBuffer->allocateBuffer(4096, 0, TRUE); + mBuffer->getVertexStrider(mVerticesp); + mBuffer->getTexCoord0Strider(mTexcoordsp); + mBuffer->getColorStrider(mColorsp); +} + void LLRender::shutdown() { for (U32 i = 0; i < mTexUnits.size(); i++) diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 2767aa64a8..611066a960 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -271,6 +271,7 @@ public: LLRender(); ~LLRender(); + void init() ; void shutdown(); // Refreshes renderer state to the cached values diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 2417f88050..6b1fd78733 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -43,6 +43,7 @@ LLVBOPool LLVertexBuffer::sDynamicVBOPool; LLVBOPool LLVertexBuffer::sStreamIBOPool; LLVBOPool LLVertexBuffer::sDynamicIBOPool; +LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL ; U32 LLVertexBuffer::sBindCount = 0; U32 LLVertexBuffer::sSetCount = 0; S32 LLVertexBuffer::sCount = 0; @@ -317,6 +318,11 @@ void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping) LLGLNamePool::registerPool(&sDynamicIBOPool); LLGLNamePool::registerPool(&sStreamVBOPool); LLGLNamePool::registerPool(&sStreamIBOPool); + + if(!sPrivatePoolp) + { + sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC) ; + } } //static @@ -345,6 +351,12 @@ void LLVertexBuffer::cleanupClass() LLMemType mt2(LLMemType::MTYPE_VERTEX_CLEANUP_CLASS); unbind(); clientCopy(); // deletes GL buffers + + if(sPrivatePoolp) + { + LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp) ; + sPrivatePoolp = NULL ; + } } void LLVertexBuffer::clientCopy(F64 max_time) @@ -532,7 +544,7 @@ void LLVertexBuffer::createGLBuffer() { static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; - mMappedData = new U8[size]; + mMappedData = (U8*)sPrivatePoolp->allocate(size); memset(mMappedData, 0, size); } } @@ -562,7 +574,7 @@ void LLVertexBuffer::createGLIndices() } else { - mMappedIndexData = new U8[size]; + mMappedIndexData = (U8*)sPrivatePoolp->allocate(size); memset(mMappedIndexData, 0, size); static int gl_buffer_idx = 0; mGLIndices = ++gl_buffer_idx; @@ -586,7 +598,7 @@ void LLVertexBuffer::destroyGLBuffer() } else { - delete [] mMappedData; + sPrivatePoolp->free(mMappedData) ; mMappedData = NULL; mEmpty = TRUE; } @@ -615,7 +627,7 @@ void LLVertexBuffer::destroyGLIndices() } else { - delete [] mMappedIndexData; + sPrivatePoolp->free(mMappedIndexData) ; mMappedIndexData = NULL; mEmpty = TRUE; } @@ -747,7 +759,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) if (!useVBOs()) { U8* old = mMappedData; - mMappedData = new U8[newsize]; + mMappedData = (U8*)sPrivatePoolp->allocate(newsize); if (old) { memcpy(mMappedData, old, llmin(newsize, oldsize)); @@ -756,7 +768,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) memset(mMappedData+oldsize, 0, newsize-oldsize); } - delete [] old; + sPrivatePoolp->free(old); } else { @@ -784,7 +796,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) { //delete old buffer, keep GL buffer for now U8* old = mMappedIndexData; - mMappedIndexData = new U8[new_index_size]; + mMappedIndexData = (U8*)sPrivatePoolp->allocate(new_index_size); if (old) { @@ -793,7 +805,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) { memset(mMappedIndexData+old_index_size, 0, new_index_size - old_index_size); } - delete [] old; + sPrivatePoolp->free(old); } else { @@ -840,8 +852,8 @@ void LLVertexBuffer::freeClientBuffer() { if(useVBOs() && sDisableVBOMapping && (mMappedData || mMappedIndexData)) { - delete[] mMappedData ; - delete[] mMappedIndexData ; + sPrivatePoolp->free(mMappedData) ; + sPrivatePoolp->free(mMappedIndexData) ; mMappedData = NULL ; mMappedIndexData = NULL ; } @@ -852,7 +864,7 @@ void LLVertexBuffer::allocateClientVertexBuffer() if(!mMappedData) { U32 size = getSize() ; - mMappedData = new U8[size]; + mMappedData = (U8*)sPrivatePoolp->allocate(size); memset(mMappedData, 0, size); } } @@ -862,7 +874,7 @@ void LLVertexBuffer::allocateClientIndexBuffer() if(!mMappedIndexData) { U32 size = getIndicesSize(); - mMappedIndexData = new U8[size]; + mMappedIndexData = (U8*)sPrivatePoolp->allocate(size); memset(mMappedIndexData, 0, size); } } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index c51ce7ac4e..a4b0d5558e 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -69,7 +69,7 @@ protected: //============================================================================ // base class - +class LLPrivateMemoryPool ; class LLVertexBuffer : public LLRefCount { public: @@ -238,6 +238,9 @@ protected: std::vector<DirtyRegion> mDirtyRegions; //vector of dirty regions to rebuild +private: + static LLPrivateMemoryPool* sPrivatePoolp ; + public: static S32 sCount; static S32 sGLCount; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index dfdf429455..8ce367efd2 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1489,6 +1489,7 @@ LLViewerWindow::LLViewerWindow( gSavedSettings.setBOOL("RenderVBOEnable", FALSE); } LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"), gSavedSettings.getBOOL("RenderVBOMappingDisable")); + gGL.init() ; if (LLFeatureManager::getInstance()->isSafe() || (gSavedSettings.getS32("LastFeatureVersion") != LLFeatureManager::getInstance()->getVersion()) |