summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rwxr-xr-xindra/newview/llvovolume.cpp118
1 files changed, 87 insertions, 31 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index c9f03a3b7d..945d3711f0 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4059,7 +4059,8 @@ U32 LLVOVolume::getPartitionType() const
}
LLVolumePartition::LLVolumePartition(LLViewerRegion* regionp)
-: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB, regionp)
+: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB, regionp),
+LLVolumeGeometryManager()
{
mLODPeriod = 32;
mDepthMask = FALSE;
@@ -4070,7 +4071,8 @@ LLVolumePartition::LLVolumePartition(LLViewerRegion* regionp)
}
LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep, LLViewerRegion* regionp)
-: LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK, regionp)
+: LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK, regionp),
+LLVolumeGeometryManager()
{
mDepthMask = FALSE;
mLODPeriod = 32;
@@ -4107,6 +4109,70 @@ bool can_batch_texture(LLFace* facep)
return true;
}
+const static U32 MAX_FACE_COUNT = 4096U;
+int32_t LLVolumeGeometryManager::sInstanceCount = 0;
+LLFace** LLVolumeGeometryManager::sFullbrightFaces = NULL;
+LLFace** LLVolumeGeometryManager::sBumpFaces = NULL;
+LLFace** LLVolumeGeometryManager::sSimpleFaces = NULL;
+LLFace** LLVolumeGeometryManager::sNormFaces = NULL;
+LLFace** LLVolumeGeometryManager::sSpecFaces = NULL;
+LLFace** LLVolumeGeometryManager::sNormSpecFaces = NULL;
+LLFace** LLVolumeGeometryManager::sAlphaFaces = NULL;
+
+LLVolumeGeometryManager::LLVolumeGeometryManager()
+ : LLGeometryManager()
+{
+ llassert(sInstanceCount >= 0);
+ if (sInstanceCount == 0)
+ {
+ allocateFaces(MAX_FACE_COUNT);
+ }
+
+ ++sInstanceCount;
+}
+
+LLVolumeGeometryManager::~LLVolumeGeometryManager()
+{
+ llassert(sInstanceCount > 0);
+ --sInstanceCount;
+
+ if (sInstanceCount <= 0)
+ {
+ freeFaces();
+ sInstanceCount = 0;
+ }
+}
+
+void LLVolumeGeometryManager::allocateFaces(U32 pMaxFaceCount)
+{
+ sFullbrightFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+ sBumpFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+ sSimpleFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+ sNormFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+ sSpecFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+ sNormSpecFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+ sAlphaFaces = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount*sizeof(LLFace*)));
+}
+
+void LLVolumeGeometryManager::freeFaces()
+{
+ ll_aligned_free<64>(sFullbrightFaces);
+ ll_aligned_free<64>(sBumpFaces);
+ ll_aligned_free<64>(sSimpleFaces);
+ ll_aligned_free<64>(sNormFaces);
+ ll_aligned_free<64>(sSpecFaces);
+ ll_aligned_free<64>(sNormSpecFaces);
+ ll_aligned_free<64>(sAlphaFaces);
+
+ sFullbrightFaces = NULL;
+ sBumpFaces = NULL;
+ sSimpleFaces = NULL;
+ sNormFaces = NULL;
+ sSpecFaces = NULL;
+ sNormSpecFaces = NULL;
+ sAlphaFaces = NULL;
+}
+
static LLTrace::BlockTimerStatHandle FTM_REGISTER_FACE("Register Face");
void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 type)
@@ -4429,16 +4495,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
mFaceList.clear();
- const U32 MAX_FACE_COUNT = 4096;
-
- static LLFace** fullbright_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
- static LLFace** bump_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
- static LLFace** simple_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
- static LLFace** norm_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
- static LLFace** spec_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
- static LLFace** normspec_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
- static LLFace** alpha_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
-
U32 fullbright_count = 0;
U32 bump_count = 0;
U32 simple_count = 0;
@@ -4816,7 +4872,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //can be treated as alpha mask
if (simple_count < MAX_FACE_COUNT)
{
- simple_faces[simple_count++] = facep;
+ sSimpleFaces[simple_count++] = facep;
}
}
else
@@ -4827,7 +4883,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
}
if (alpha_count < MAX_FACE_COUNT)
{
- alpha_faces[alpha_count++] = facep;
+ sAlphaFaces[alpha_count++] = facep;
}
}
}
@@ -4850,14 +4906,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //has normal and specular maps (needs texcoord1, texcoord2, and tangent)
if (normspec_count < MAX_FACE_COUNT)
{
- normspec_faces[normspec_count++] = facep;
+ sNormSpecFaces[normspec_count++] = facep;
}
}
else
{ //has normal map (needs texcoord1 and tangent)
if (norm_count < MAX_FACE_COUNT)
{
- norm_faces[norm_count++] = facep;
+ sNormFaces[norm_count++] = facep;
}
}
}
@@ -4865,14 +4921,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //has specular map but no normal map, needs texcoord2
if (spec_count < MAX_FACE_COUNT)
{
- spec_faces[spec_count++] = facep;
+ sSpecFaces[spec_count++] = facep;
}
}
else
{ //has neither specular map nor normal map, only needs texcoord0
if (simple_count < MAX_FACE_COUNT)
{
- simple_faces[simple_count++] = facep;
+ sSimpleFaces[simple_count++] = facep;
}
}
}
@@ -4880,14 +4936,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //needs normal + tangent
if (bump_count < MAX_FACE_COUNT)
{
- bump_faces[bump_count++] = facep;
+ sBumpFaces[bump_count++] = facep;
}
}
else if (te->getShiny() || !te->getFullbright())
{ //needs normal
if (simple_count < MAX_FACE_COUNT)
{
- simple_faces[simple_count++] = facep;
+ sSimpleFaces[simple_count++] = facep;
}
}
else
@@ -4895,7 +4951,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
facep->setState(LLFace::FULLBRIGHT);
if (fullbright_count < MAX_FACE_COUNT)
{
- fullbright_faces[fullbright_count++] = facep;
+ sFullbrightFaces[fullbright_count++] = facep;
}
}
}
@@ -4905,7 +4961,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //needs normal + tangent
if (bump_count < MAX_FACE_COUNT)
{
- bump_faces[bump_count++] = facep;
+ sBumpFaces[bump_count++] = facep;
}
}
else if ((te->getShiny() && LLPipeline::sRenderBump) ||
@@ -4913,7 +4969,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //needs normal
if (simple_count < MAX_FACE_COUNT)
{
- simple_faces[simple_count++] = facep;
+ sSimpleFaces[simple_count++] = facep;
}
}
else
@@ -4921,7 +4977,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
facep->setState(LLFace::FULLBRIGHT);
if (fullbright_count < MAX_FACE_COUNT)
{
- fullbright_faces[fullbright_count++] = facep;
+ sFullbrightFaces[fullbright_count++] = facep;
}
}
}
@@ -4993,13 +5049,13 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX;
}
- genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, simple_count, FALSE, batch_textures, FALSE);
- genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, fullbright_count, FALSE, batch_textures);
- genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, alpha_count, TRUE, batch_textures);
- genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, bump_count, FALSE, FALSE);
- genDrawInfo(group, norm_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, norm_faces, norm_count, FALSE, FALSE);
- genDrawInfo(group, spec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, spec_faces, spec_count, FALSE, FALSE);
- genDrawInfo(group, normspec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, normspec_faces, normspec_count, FALSE, FALSE);
+ genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sSimpleFaces, simple_count, FALSE, batch_textures, FALSE);
+ genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sFullbrightFaces, fullbright_count, FALSE, batch_textures);
+ genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sAlphaFaces, alpha_count, TRUE, batch_textures);
+ genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sBumpFaces, bump_count, FALSE, FALSE);
+ genDrawInfo(group, norm_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sNormFaces, norm_count, FALSE, FALSE);
+ genDrawInfo(group, spec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sSpecFaces, spec_count, FALSE, FALSE);
+ genDrawInfo(group, normspec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, sNormSpecFaces, normspec_count, FALSE, FALSE);
if (!LLPipeline::sDelayVBUpdate)
{