summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
authorNyx (Neal Orman) <nyx@lindenlab.com>2011-02-07 21:03:10 -0500
committerNyx (Neal Orman) <nyx@lindenlab.com>2011-02-07 21:03:10 -0500
commit8b15ca8d6b9cf516670e66ee57591e79b898394d (patch)
treef1100d1c858c7ee6635191f00d4d2790587d3f25 /indra/newview/llvovolume.cpp
parentaf5cdbbb9681bb9f22bccf2af4777975e54010ee (diff)
SH-930 FIX revert ARC algorithm for merge to viewer-development
Reverting incomplete changes to ARC so that we don't change RC when we merge down.
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rw-r--r--indra/newview/llvovolume.cpp237
1 files changed, 55 insertions, 182 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index c65b888bf9..8f1a761549 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2931,35 +2931,24 @@ const LLMatrix4 LLVOVolume::getRenderMatrix() const
// total cost is returned value + 5 * size of the resulting set.
// Cannot include cost of textures, as they may be re-used in linked
// children, and cost should only be increased for unique textures -Nyx
-U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
+U32 LLVOVolume::getRenderCost(std::set<LLUUID> &textures) const
{
- // Get access to params we'll need at various points.
- // Skip if this is object doesn't have a volume (e.g. is an avatar).
- BOOL has_volume = (getVolume() != NULL);
- LLVolumeParams volume_params;
- LLPathParams path_params;
- LLProfileParams profile_params;
-
- U32 num_triangles = 0;
-
+ // base cost of each prim should be 10 points
+ static const U32 ARC_PRIM_COST = 10;
// per-prim costs
- static const U32 ARC_PARTICLE_COST = 1;
- static const U32 ARC_PARTICLE_MAX = 2048;
- static const U32 ARC_TEXTURE_COST = 5;
+ static const U32 ARC_INVISI_COST = 1;
+ static const U32 ARC_SHINY_COST = 1;
+ static const U32 ARC_GLOW_COST = 1;
+ static const U32 ARC_FLEXI_COST = 8;
+ static const U32 ARC_PARTICLE_COST = 16;
+ static const U32 ARC_BUMP_COST = 4;
- // per-prim multipliers
- static const F32 ARC_GLOW_MULT = 1.5f; // tested based on performance
- static const F32 ARC_BUMP_MULT = 1.25f; // tested based on performance
- static const F32 ARC_FLEXI_MULT = 4;
- static const F32 ARC_SHINY_MULT = 1.6f; // tested based on performance
- static const F32 ARC_INVISI_COST = 1.2f; // tested based on performance
- static const F32 ARC_WEIGHTED_MESH = 1.2f;
+ // per-face costs
+ static const U32 ARC_PLANAR_COST = 1;
+ static const U32 ARC_ANIM_TEX_COST = 4;
+ static const U32 ARC_ALPHA_COST = 4;
- static const F32 ARC_PLANAR_COST = 1.2f; // 1.2x max
- static const F32 ARC_ANIM_TEX_COST = 1.4f; // 1.4x max
- static const F32 ARC_ALPHA_COST = 4.f; // 4x max
-
- F32 shame = 0;
+ U32 shame = ARC_PRIM_COST;
U32 invisi = 0;
U32 shiny = 0;
@@ -2968,87 +2957,9 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
U32 flexi = 0;
U32 animtex = 0;
U32 particles = 0;
+ U32 scale = 0;
U32 bump = 0;
U32 planar = 0;
- U32 weighted_mesh = 0;
-
- // these multipliers are variable and can be floating point
- F32 scale = 0.f;
-
- const LLDrawable* drawablep = mDrawable;
- U32 num_faces = drawablep->getNumFaces();
-
- if (has_volume)
- {
- volume_params = getVolume()->getParams();
- path_params = volume_params.getPathParams();
- profile_params = volume_params.getProfileParams();
-
- F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length();
- S32 default_detail = llclamp((S32) (sqrtf(radius)*LLVOVolume::sLODFactor*4.f), 0, 3);
- if (default_detail == getLOD())
- {
- num_triangles = getTriangleCount();
- }
- else
- {
- LLVolume* default_volume = LLPrimitive::getVolumeManager()->refVolume(volume_params, default_detail);
- if(default_volume != NULL)
- {
- num_triangles = default_volume->getNumTriangles();
- LLPrimitive::getVolumeManager()->unrefVolume(default_volume);
- default_volume = NULL;
- }
- else
- {
- has_volume = false;
- }
- }
- }
-
- if (isSculpted())
- {
- if (isMesh())
- {
- // base cost is dependent on mesh complexity
- // note that 3 is the highest LOD as of the time of this coding.
- S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(),3);
- if ( size > 0)
- {
- num_triangles = (U32)(size / 10.f); // avg 1 triangle per 10 bytes
- if (gMeshRepo.getSkinInfo(volume_params.getSculptID()))
- {
- // weighted attachment - 1 point for every 3 bytes
- weighted_mesh = 1;
- }
-
- if (num_triangles == 0)
- {
- // someone made a really tiny mesh. Approximate with a tetrahedron.
- num_triangles = 4;
- }
- }
- else
- {
- // something went wrong - user should know their content isn't render-free
- return 0;
- }
- }
- else
- {
- const LLSculptParams *sculpt_params = (LLSculptParams *) getParameterEntry(LLNetworkData::PARAMS_SCULPT);
- LLUUID sculpt_id = sculpt_params->getSculptTexture();
- if (textures.find(sculpt_id) == textures.end())
- {
- LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(sculpt_id);
- if (texture)
- {
- S32 texture_cost = (S32)(ARC_TEXTURE_COST * (texture->getFullHeight() / 128.f + texture->getFullWidth() / 128.f + 1));
- textures.insert(texture_cost_t::value_type(sculpt_id, texture_cost));
- }
- }
- }
- }
if (isFlexible())
{
@@ -3060,12 +2971,18 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
}
const LLVector3& sc = getScale();
- scale += (sc.mV[0] + sc.mV[1] + sc.mV[2]) / 4.f; // scale to 1/4 the sum of the size
- // enforce scale multiplier to be in the range [1,7] (7 was determined to experimentally be a reasonable max)
- scale = scale > 7.f ? 7.f : scale;
- scale = scale < 1.f ? 1.f : scale;
+ scale += (U32) sc.mV[0] + (U32) sc.mV[1] + (U32) sc.mV[2];
+
+ const LLDrawable* drawablep = mDrawable;
- for (S32 i = 0; i < num_faces; ++i)
+ if (isSculpted())
+ {
+ const LLSculptParams *sculpt_params = (LLSculptParams *) getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+ LLUUID sculpt_id = sculpt_params->getSculptTexture();
+ textures.insert(sculpt_id);
+ }
+
+ for (S32 i = 0; i < drawablep->getNumFaces(); ++i)
{
const LLFace* face = drawablep->getFace(i);
const LLTextureEntry* te = face->getTextureEntry();
@@ -3073,16 +2990,12 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
if (img)
{
- if (textures.find(img->getID()) == textures.end())
- {
- S32 texture_cost = (S32)(ARC_TEXTURE_COST * (img->getFullHeight() / 128.f + img->getFullWidth() / 128.f + 1));
- textures.insert(texture_cost_t::value_type(img->getID(), texture_cost));
- }
+ textures.insert(img->getID());
}
if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
{
- alpha = 1;
+ alpha++;
}
else if (img && img->getPrimaryFormat() == GL_ALPHA)
{
@@ -3093,98 +3006,58 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
{
if (te->getBumpmap())
{
- // bump is a multiplier, don't add per-face
bump = 1;
}
if (te->getShiny())
{
- // shiny is a multiplier, don't add per-face
shiny = 1;
}
if (te->getGlow() > 0.f)
{
- // glow is a multiplier, don't add per-face
glow = 1;
}
if (face->mTextureMatrix != NULL)
{
- animtex = 1;
+ animtex++;
}
if (te->getTexGen())
{
- planar = 1;
+ planar++;
}
}
}
- // shame currently has the "base" cost of 1 point per 50 triangles, min 2.
- shame = num_triangles / 50.f;
- shame = shame < 2.f ? 2.f : shame;
-
- // factor in scale
- shame *= scale;
-
- // multiply by per-face modifiers
- if (planar)
- {
- shame *= planar * ARC_PLANAR_COST;
- }
-
- if (animtex)
- {
- shame *= animtex * ARC_ANIM_TEX_COST;
- }
-
- if (alpha)
- {
- shame *= alpha * ARC_ALPHA_COST;
- }
-
- if(invisi)
- {
- shame *= invisi * ARC_INVISI_COST;
- }
-
- if (glow)
- {
- shame *= glow * ARC_GLOW_MULT;
- }
-
- if (bump)
- {
- shame *= bump * ARC_BUMP_MULT;
- }
-
- if (shiny)
- {
- shame *= shiny * ARC_SHINY_MULT;
- }
+ shame += invisi * ARC_INVISI_COST;
+ shame += shiny * ARC_SHINY_COST;
+ shame += glow * ARC_GLOW_COST;
+ shame += alpha * ARC_ALPHA_COST;
+ shame += flexi * ARC_FLEXI_COST;
+ shame += animtex * ARC_ANIM_TEX_COST;
+ shame += particles * ARC_PARTICLE_COST;
+ shame += bump * ARC_BUMP_COST;
+ shame += planar * ARC_PLANAR_COST;
+ shame += scale;
- // multiply shame by multipliers
- if (weighted_mesh)
+ LLViewerObject::const_child_list_t& child_list = getChildren();
+ for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
+ iter != child_list.end();
+ ++iter)
{
- shame *= weighted_mesh * ARC_WEIGHTED_MESH;
- }
-
- if (flexi)
- {
- shame *= flexi * ARC_FLEXI_MULT;
+ const LLViewerObject* child_objectp = *iter;
+ const LLDrawable* child_drawablep = child_objectp->mDrawable;
+ if (child_drawablep)
+ {
+ const LLVOVolume* child_volumep = child_drawablep->getVOVolume();
+ if (child_volumep)
+ {
+ shame += child_volumep->getRenderCost(textures);
+ }
+ }
}
+ return shame;
- // add additional costs
- if (particles)
- {
- const LLPartSysData *part_sys_data = &(mPartSourcep->mPartSysData);
- const LLPartData *part_data = &(part_sys_data->mPartData);
- U32 num_particles = (U32)(part_sys_data->mBurstPartCount * llceil( part_data->mMaxAge / part_sys_data->mBurstRate));
- num_particles = num_particles > ARC_PARTICLE_MAX ? ARC_PARTICLE_MAX : num_particles;
- F32 part_size = (llmax(part_data->mStartScale[0], part_data->mEndScale[0]) + llmax(part_data->mStartScale[1], part_data->mEndScale[1])) / 2.f;
- shame += num_particles * part_size * ARC_PARTICLE_COST;
- }
-
- return (U32)shame;
}
F32 LLVOVolume::getStreamingCost()