summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-07-09 02:28:34 -0500
committerDave Parks <davep@lindenlab.com>2011-07-09 02:28:34 -0500
commitf1443579b32cf260e7ad35f35de3930f0f801bd2 (patch)
treeeba8949b8dd71832297a0836be58cf2d4c71d830 /indra
parent36a05ebd9a2a969bab4621f522a9a82f69e523d7 (diff)
SH-2038 Potential fix for a myriad of performance problems concering VBO usage.
Diffstat (limited to 'indra')
-rw-r--r--indra/llrender/llvertexbuffer.cpp5
-rw-r--r--indra/newview/featuretable.txt6
-rw-r--r--indra/newview/featuretable_linux.txt6
-rw-r--r--indra/newview/featuretable_mac.txt11
-rw-r--r--indra/newview/featuretable_xp.txt6
-rw-r--r--indra/newview/llface.cpp64
-rw-r--r--indra/newview/llfeaturemanager.cpp4
-rw-r--r--indra/newview/llvovolume.cpp38
8 files changed, 81 insertions, 59 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 4a0b964e61..6c972647f8 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -1008,6 +1008,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran
LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES);
setBuffer(0, type);
mVertexLocked = TRUE;
+ sMappedCount++;
stop_glerror();
if(sDisableVBOMapping)
@@ -1082,7 +1083,6 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran
llerrs << "memory allocation for vertex data failed." << llendl ;
}
}
- sMappedCount++;
}
}
else
@@ -1152,6 +1152,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
setBuffer(0, TYPE_INDEX);
mIndexLocked = TRUE;
+ sMappedCount++;
stop_glerror();
if(sDisableVBOMapping)
@@ -1211,8 +1212,6 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
llerrs << "memory allocation for Index data failed. " << llendl ;
}
}
-
- sMappedCount++;
}
else
{
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 5384660d4c..b81053c140 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -1,4 +1,4 @@
-version 30
+version 31
// NOTE: This is mostly identical to featuretable_mac.txt with a few differences
// Should be combined into one table
@@ -246,9 +246,9 @@ RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
//
-// No GL_ARB_map_buffer_range
+// GL_ARB_map_buffer_range exists
//
-list NoMapBufferRange
+list MapBufferRange
RenderVBOMappingDisable 1 0
diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index dab73dc3d1..a6705e41fe 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -1,4 +1,4 @@
-version 25
+version 26
// NOTE: This is mostly identical to featuretable_mac.txt with a few differences
// Should be combined into one table
@@ -244,9 +244,9 @@ RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
//
-// No GL_ARB_map_buffer_range
+// GL_ARB_map_buffer_range exists
//
-list NoMapBufferRange
+list MapBufferRange
RenderVBOMappingDisable 1 0
diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index a1e25aae08..2f9f82fd9e 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -1,4 +1,4 @@
-version 26
+version 27
// NOTE: This is mostly identical to featuretable_mac.txt with a few differences
// Should be combined into one table
@@ -48,7 +48,7 @@ RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVBOEnable 1 1
-RenderVBOMappingDisable 1 1
+RenderVBOMappingDisable 1 0
RenderVolumeLODFactor 1 2.0
UseStartScreen 1 1
UseOcclusion 1 1
@@ -246,13 +246,6 @@ RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
//
-// No GL_ARB_map_buffer_range
-//
-list NoMapBufferRange
-RenderVBOMappingDisable 1 0
-
-
-//
// "Default" setups for safe, low, medium, high
//
list safe
diff --git a/indra/newview/featuretable_xp.txt b/indra/newview/featuretable_xp.txt
index ce2adac221..50f0f5dec1 100644
--- a/indra/newview/featuretable_xp.txt
+++ b/indra/newview/featuretable_xp.txt
@@ -1,4 +1,4 @@
-version 30
+version 31
// NOTE: This is mostly identical to featuretable_mac.txt with a few differences
// Should be combined into one table
@@ -246,9 +246,9 @@ RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
//
-// No GL_ARB_map_buffer_range
+// GL_ARB_map_buffer_range exists
//
-list NoMapBufferRange
+list MapBufferRange
RenderVBOMappingDisable 1 0
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index b6566fcbd0..d2b05d1088 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1064,6 +1064,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
S32 num_vertices = (S32)vf.mNumVertices;
S32 num_indices = (S32) vf.mNumIndices;
+ bool map_range = gGLManager.mHasMapBufferRange;
+
if (mVertexBuffer.notNull())
{
if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices())
@@ -1182,7 +1184,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
// INDICES
if (full_rebuild)
{
- mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount, true);
+ mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount, map_range);
__m128i* dst = (__m128i*) indicesp.get();
__m128i* src = (__m128i*) vf.mIndices;
@@ -1201,7 +1203,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
indicesp[i] = vf.mIndices[i]+index_offset;
}
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
LLMatrix4a mat_normal;
@@ -1422,11 +1427,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
}
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
else
{ //either bump mapped or in atlas, just do the whole expensive loop
- mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount, map_range);
std::vector<LLVector2> bump_tc;
@@ -1566,12 +1574,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
}
- mVertexBuffer->setBuffer(0);
-
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
if (do_bump)
{
- mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex, mGeomCount, map_range);
for (S32 i = 0; i < num_vertices; i++)
{
@@ -1601,14 +1611,17 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
*tex_coords2++ = tc;
}
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
}
}
if (rebuild_pos)
{
- mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, map_range);
vertices = (LLVector4a*) vert.get();
LLMatrix4a mat_vert;
@@ -1637,12 +1650,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
while (index_dst < index_end);
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
if (rebuild_normal)
{
- mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range);
normals = (LLVector4a*) norm.get();
for (S32 i = 0; i < num_vertices; i++)
@@ -1653,12 +1669,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
normals[i] = normal;
}
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
if (rebuild_binormal)
{
- mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, map_range);
binormals = (LLVector4a*) binorm.get();
for (S32 i = 0; i < num_vertices; i++)
@@ -1669,20 +1688,26 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
binormals[i] = binormal;
}
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
if (rebuild_weights && vf.mWeights)
{
- mVertexBuffer->getWeight4Strider(wght, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getWeight4Strider(wght, mGeomIndex, mGeomCount, map_range);
weights = (LLVector4a*) wght.get();
LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices*4*sizeof(F32));
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
if (rebuild_color)
{
- mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount, true);
+ mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount, map_range);
LLVector4a src;
@@ -1703,7 +1728,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
dst[i] = src;
}
- mVertexBuffer->setBuffer(0);
+ if (map_range)
+ {
+ mVertexBuffer->setBuffer(0);
+ }
}
if (rebuild_tcoord)
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index 83844048d1..0ea0e41dfa 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -769,6 +769,10 @@ void LLFeatureManager::applyBaseMasks()
{
maskFeatures("TexUnit8orLess");
}
+ if (gGLManager.mHasMapBufferRange)
+ {
+ maskFeatures("MapBufferRange");
+ }
// now mask by gpu string
// Replaces ' ' with '_' in mGPUString to deal with inability for parser to handle spaces
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e6da8eb89d..40afabdb65 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4361,6 +4361,8 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
group->mBuilt = 1.f;
+ std::set<LLVertexBuffer*> mapped_buffers;
+
for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
{
LLFastTimer t(FTM_VOLUME_GEOM_PARTIAL);
@@ -4375,35 +4377,31 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
for (S32 i = 0; i < drawablep->getNumFaces(); ++i)
{
LLFace* face = drawablep->getFace(i);
- if (face && face->getVertexBuffer())
+ if (face)
{
- face->getGeometryVolume(*volume, face->getTEOffset(),
- vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex());
+ LLVertexBuffer* buff = face->getVertexBuffer();
+ if (buff)
+ {
+ face->getGeometryVolume(*volume, face->getTEOffset(),
+ vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex());
+
+ if (buff->isLocked())
+ {
+ mapped_buffers.insert(buff);
+ }
+ }
}
}
-
+
drawablep->clearState(LLDrawable::REBUILD_ALL);
}
}
- //unmap all the buffers
- for (LLSpatialGroup::buffer_map_t::iterator i = group->mBufferMap.begin(); i != group->mBufferMap.end(); ++i)
+ for (std::set<LLVertexBuffer*>::iterator iter = mapped_buffers.begin(); iter != mapped_buffers.end(); ++iter)
{
- LLSpatialGroup::buffer_texture_map_t& map = i->second;
- for (LLSpatialGroup::buffer_texture_map_t::iterator j = map.begin(); j != map.end(); ++j)
- {
- LLSpatialGroup::buffer_list_t& list = j->second;
- for (LLSpatialGroup::buffer_list_t::iterator k = list.begin(); k != list.end(); ++k)
- {
- LLVertexBuffer* buffer = *k;
- if (buffer->isLocked())
- {
- buffer->setBuffer(0);
- }
- }
- }
+ (*iter)->setBuffer(0);
}
-
+
// don't forget alpha
if(group != NULL &&
!group->mVertexBuffer.isNull() &&