diff options
author | Dave Parks <davep@lindenlab.com> | 2011-10-13 01:19:45 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-10-13 01:19:45 -0500 |
commit | 7b6723d1e0158d5dc326266a0332e87f634f9755 (patch) | |
tree | 10efed7ccda1a80889bfb65cd64c86b8d33c75ed /indra/newview | |
parent | 1a499c13c813d4aa9631ffae00b36a053f260747 (diff) |
SH-1650 Mitigate memory fragmentation by holding onto and reusing VBOs
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lldrawpoolavatar.cpp | 6 | ||||
-rw-r--r-- | indra/newview/lldrawpooltree.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llface.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llfloatermodelpreview.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llviewerdisplay.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llvoavatar.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llvowlsky.cpp | 4 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 26 |
10 files changed, 30 insertions, 45 deletions
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index a710bdcdbd..7290a48a1a 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1277,8 +1277,8 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* if (buffer.isNull() || buffer->getTypeMask() != data_mask || - buffer->getRequestedVerts() != vol_face.mNumVertices || - buffer->getRequestedIndices() != vol_face.mNumIndices || + buffer->getNumVerts() != vol_face.mNumVertices || + buffer->getNumIndices() != vol_face.mNumIndices || (drawable && drawable->isState(LLDrawable::REBUILD_ALL))) { face->setGeomIndex(0); @@ -1366,7 +1366,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* LLMatrix4a bind_shape_matrix; bind_shape_matrix.loadu(skin->mBindShapeMatrix); - for (U32 j = 0; j < buffer->getRequestedVerts(); ++j) + for (U32 j = 0; j < buffer->getNumVerts(); ++j) { LLMatrix4a final_mat; final_mat.clear(); diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 3fe5b4d929..cdf6e1ab52 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -113,8 +113,8 @@ void LLDrawPoolTree::render(S32 pass) if(buff) { buff->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); - buff->drawRange(LLRender::TRIANGLES, 0, buff->getRequestedVerts()-1, buff->getRequestedIndices(), 0); - gPipeline.addTrianglesDrawn(buff->getRequestedIndices()); + buff->drawRange(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0); + gPipeline.addTrianglesDrawn(buff->getNumIndices()); } } } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 36b88ebbd4..eab3dcfadd 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -362,8 +362,8 @@ void LLFace::setSize(S32 num_vertices, S32 num_indices, bool align) { if (align) { - //allocate vertices in blocks of 16 for alignment - num_vertices = (num_vertices + 0xF) & ~0xF; + //allocate vertices in blocks of 4 for alignment + num_vertices = (num_vertices + 0x3) & ~0x3; } if (mGeomCount != num_vertices || @@ -1073,6 +1073,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, S32 num_vertices = (S32)vf.mNumVertices; S32 num_indices = (S32) vf.mNumIndices; + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE)) + { + updateRebuildFlags(); + } + bool map_range = gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange; if (mVertexBuffer.notNull()) @@ -2055,7 +2060,7 @@ BOOL LLFace::verify(const U32* indices_array) const } // First, check whether the face data fits within the pool's range. - if ((mGeomIndex + mGeomCount) > mVertexBuffer->getRequestedVerts()) + if ((mGeomIndex + mGeomCount) > mVertexBuffer->getNumVerts()) { ok = FALSE; llinfos << "Face references invalid vertices!" << llendl; @@ -2074,7 +2079,7 @@ BOOL LLFace::verify(const U32* indices_array) const llinfos << "Face has bogus indices count" << llendl; } - if (mIndicesIndex + mIndicesCount > mVertexBuffer->getRequestedIndices()) + if (mIndicesIndex + mIndicesCount > mVertexBuffer->getNumIndices()) { ok = FALSE; llinfos << "Face references invalid indices!" << llendl; diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index d9ce72a2c2..8f6013f2d9 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -5457,7 +5457,7 @@ BOOL LLModelPreview::render() } } - for (U32 j = 0; j < buffer->getRequestedVerts(); ++j) + for (U32 j = 0; j < buffer->getNumVerts(); ++j) { LLMatrix4 final_mat; final_mat.mMatrix[0][0] = final_mat.mMatrix[1][1] = final_mat.mMatrix[2][2] = final_mat.mMatrix[3][3] = 0.f; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index ffb0ce4056..2530f1f0d4 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2454,7 +2454,7 @@ void pushBufferVerts(LLVertexBuffer* buffer, U32 mask) if (buffer) { buffer->setBuffer(mask); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getRequestedVerts()-1, buffer->getRequestedIndices(), 0); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); } } @@ -2526,7 +2526,7 @@ void renderOctree(LLSpatialGroup* group) //coded by buffer usage and activity gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); LLVector4 col; - /*if (group->mBuilt > 0.f) + if (group->mBuilt > 0.f) { group->mBuilt -= 2.f * gFrameIntervalSeconds; if (group->mBufferUsage == GL_STATIC_DRAW_ARB) @@ -2595,7 +2595,7 @@ void renderOctree(LLSpatialGroup* group) gGL.diffuseColor4f(1,1,1,1); } } - else*/ + else { if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->getData().empty() && group->mSpatialPartition->mRenderByGroup) @@ -3442,11 +3442,11 @@ void renderPhysicsShapes(LLSpatialGroup* group) buff->setBuffer(LLVertexBuffer::MAP_VERTEX); gGL.diffuseColor3f(0.2f, 0.5f, 0.3f); - buff->draw(LLRender::TRIANGLES, buff->getRequestedIndices(), 0); + buff->draw(LLRender::TRIANGLES, buff->getNumIndices(), 0); gGL.diffuseColor3f(0.2f, 1.f, 0.3f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - buff->draw(LLRender::TRIANGLES, buff->getRequestedIndices(), 0); + buff->draw(LLRender::TRIANGLES, buff->getNumIndices(), 0); } } } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 1832416a4b..e0359cc61d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -661,10 +661,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLMemType mt_ds(LLMemType::MTYPE_DISPLAY_SWAP); - { - LLFastTimer ftm(FTM_CLIENT_COPY); - LLVertexBuffer::clientCopy(0.016); - } if (gResizeScreenTexture) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2aac43d99e..f3e9bc711a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -532,7 +532,7 @@ public: } - addText(xpos, ypos, llformat("%d MB Vertex Data", LLVertexBuffer::sAllocatedBytes/(1024*1024))); + addText(xpos, ypos, llformat("%d MB Vertex Data (%d MB Pooled)", LLVertexBuffer::sAllocatedBytes/(1024*1024), LLVBOPool::sBytesPooled/(1024*1024))); ypos += y_inc; addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount)); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5687ba5064..6506938766 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2117,8 +2117,8 @@ void LLVOAvatar::updateMeshData() } else { - if (buff->getRequestedIndices() == num_indices && - buff->getRequestedVerts() == num_vertices) + if (buff->getNumIndices() == num_indices && + buff->getNumVerts() == num_vertices) { terse_update = true; } diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 14fd0a1eb1..f1c5499d84 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -516,9 +516,9 @@ void LLVOWLSky::drawDome(void) strips_segment->drawRange( LLRender::TRIANGLE_STRIP, - 0, strips_segment->getRequestedVerts()-1, strips_segment->getRequestedIndices(), + 0, strips_segment->getNumVerts()-1, strips_segment->getNumIndices(), 0); - gPipeline.addTrianglesDrawn(strips_segment->getRequestedIndices(), LLRender::TRIANGLE_STRIP); + gPipeline.addTrianglesDrawn(strips_segment->getNumIndices(), LLRender::TRIANGLE_STRIP); } #else diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e4125c8dc8..5035e0197d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -264,15 +264,7 @@ std::string gPoolNames[] = void drawBox(const LLVector3& c, const LLVector3& r); void drawBoxOutline(const LLVector3& pos, const LLVector3& size); - -U32 nhpo2(U32 v) -{ - U32 r = 1; - while (r < v) { - r *= 2; - } - return r; -} +U32 nhpo2(U32 v); glh::matrix4f glh_copy_matrix(F32* src) { @@ -2902,11 +2894,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } } } - { - LLFastTimer ftm(FTM_CLIENT_COPY); - LLVertexBuffer::clientCopy(); - } - + postSort(camera); } @@ -6122,13 +6110,7 @@ void LLPipeline::resetVertexBuffers() llwarns << "VBO wipe failed." << llendl; } - if (!LLVertexBuffer::sStreamIBOPool.mNameList.empty() || - !LLVertexBuffer::sStreamVBOPool.mNameList.empty() || - !LLVertexBuffer::sDynamicIBOPool.mNameList.empty() || - !LLVertexBuffer::sDynamicVBOPool.mNameList.empty()) - { - llwarns << "VBO name pool cleanup failed." << llendl; - } + llassert(LLVertexBuffer::sGLCount == 0); LLVertexBuffer::unbind(); @@ -6142,6 +6124,8 @@ void LLPipeline::resetVertexBuffers() sBakeSunlight = gSavedSettings.getBOOL("RenderBakeSunlight"); sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha"); LLPipeline::sTextureBindTest = gSavedSettings.getBOOL("RenderDebugTextureBind"); + + LLVertexBuffer::initClass(LLVertexBuffer::sEnableVBOs, LLVertexBuffer::sDisableVBOMapping); } void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture) |