SH-2038 Potential fix for a myriad of performance problems concering VBO usage.
parent
36a05ebd9a
commit
f1443579b3
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -245,13 +245,6 @@ RenderDeferred 0 0
|
|||
RenderDeferredSSAO 0 0
|
||||
RenderShadowDetail 0 0
|
||||
|
||||
//
|
||||
// No GL_ARB_map_buffer_range
|
||||
//
|
||||
list NoMapBufferRange
|
||||
RenderVBOMappingDisable 1 0
|
||||
|
||||
|
||||
//
|
||||
// "Default" setups for safe, low, medium, high
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue