summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2010-02-06 17:33:12 -0600
committerDave Parks <davep@lindenlab.com>2010-02-06 17:33:12 -0600
commitadf601ef1f46e5728988a08068cb2a8b16c7a056 (patch)
tree9dc89a67cd991c4d8a346c419bf2dd47d3b7f1b0 /indra/newview
parente5a68a626e10e32bab31d676d9db055e97fd93b6 (diff)
Draw prims using triangle strips instead of triangle lists.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/lldrawpool.cpp4
-rw-r--r--indra/newview/lldrawpoolalpha.cpp8
-rw-r--r--indra/newview/lldrawpoolbump.cpp8
-rw-r--r--indra/newview/lldrawpooltree.cpp4
-rw-r--r--indra/newview/llface.cpp25
-rw-r--r--indra/newview/llspatialpartition.cpp3
-rw-r--r--indra/newview/llspatialpartition.h1
-rw-r--r--indra/newview/llviewercontrol.cpp1
-rw-r--r--indra/newview/llviewerjointmesh.cpp2
-rw-r--r--indra/newview/llvotree.cpp6
-rw-r--r--indra/newview/llvovolume.cpp16
-rw-r--r--indra/newview/llvowlsky.cpp2
-rw-r--r--indra/newview/pipeline.cpp15
-rw-r--r--indra/newview/pipeline.h4
15 files changed, 82 insertions, 28 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 73c08c4867..7e4ab1a872 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7443,6 +7443,17 @@
<key>Value</key>
<integer>0</integer>
</map>
+ <key>RenderUseTriStrips</key>
+ <map>
+ <key>Comment</key>
+ <string>Use triangle strips for rendering prims.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>1</integer>
+ </map>
<key>RenderUseFarClip</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 95ddacb722..ef946ac49e 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -496,8 +496,8 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
params.mGroup->rebuildMesh();
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
}
if (params.mTextureMatrix && texture && params.mTexture.notNull())
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 7be6e82251..875c9ac6a9 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -251,8 +251,8 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
params.mGroup->rebuildMesh();
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
}
}
}
@@ -381,8 +381,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
if (params.mTextureMatrix && params.mTexture.notNull())
{
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 03a8b108e2..d09d4a412f 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -560,8 +560,8 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
params.mGroup->rebuildMesh();
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
}
}
@@ -1231,8 +1231,8 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
params.mGroup->rebuildMesh();
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
if (params.mTextureMatrix)
{
if (mShiny)
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index 5521fb05a8..1a5d55d793 100644
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -115,7 +115,7 @@ void LLDrawPoolTree::render(S32 pass)
LLFace *face = *iter;
face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0);
- gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices()/3);
+ gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices());
}
}
}
@@ -237,7 +237,7 @@ void LLDrawPoolTree::renderForSelect()
face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0);
- gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices()/3);
+ gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices());
}
}
}
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 80acc71a41..ebebd485d2 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -870,7 +870,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
llpushcallstacks ;
const LLVolumeFace &vf = volume.getVolumeFace(f);
S32 num_vertices = (S32)vf.mVertices.size();
- S32 num_indices = (S32)vf.mIndices.size();
+ S32 num_indices = LLPipeline::sUseTriStrips ? (S32)vf.mTriStrip.size() : (S32) vf.mIndices.size();
if (mVertexBuffer.notNull())
{
@@ -1063,9 +1063,19 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
if (full_rebuild)
{
mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
- for (U16 i = 0; i < num_indices; i++)
+ if (LLPipeline::sUseTriStrips)
{
- *indicesp++ = vf.mIndices[i] + index_offset;
+ for (U16 i = 0; i < num_indices; i++)
+ {
+ *indicesp++ = vf.mTriStrip[i] + index_offset;
+ }
+ }
+ else
+ {
+ for (U16 i = 0; i < num_indices; i++)
+ {
+ *indicesp++ = vf.mIndices[i] + index_offset;
+ }
}
}
@@ -1617,8 +1627,13 @@ S32 LLFace::pushVertices(const U16* index_array) const
{
if (mIndicesCount)
{
- mVertexBuffer->drawRange(LLRender::TRIANGLES, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex);
- gPipeline.addTrianglesDrawn(mIndicesCount/3);
+ U32 render_type = LLRender::TRIANGLES;
+ if (mDrawInfo)
+ {
+ render_type = mDrawInfo->mDrawMode;
+ }
+ mVertexBuffer->drawRange(render_type, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex);
+ gPipeline.addTrianglesDrawn(mIndicesCount, render_type);
}
return mIndicesCount;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 2a57d48f16..d6e9256fee 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -3380,7 +3380,8 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
mVSize(0.f),
mGroup(NULL),
mFace(NULL),
- mDistance(0.f)
+ mDistance(0.f),
+ mDrawMode(LLRender::TRIANGLES)
{
mDebugColor = (rand() << 16) + rand();
if (mStart >= mVertexBuffer->getRequestedVerts() ||
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 64c2a9acbc..7896488379 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -93,6 +93,7 @@ public:
LLFace* mFace; //associated face
F32 mDistance;
LLVector3 mExtents[2];
+ U32 mDrawMode;
struct CompareTexture
{
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 64eabe65cf..5daea96123 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -510,6 +510,7 @@ void settings_setup_listeners()
gSavedSettings.getControl("FirstPersonAvatarVisible")->getSignal()->connect(boost::bind(&handleRenderAvatarMouselookChanged, _2));
gSavedSettings.getControl("RenderFarClip")->getSignal()->connect(boost::bind(&handleRenderFarClipChanged, _2));
gSavedSettings.getControl("RenderTerrainDetail")->getSignal()->connect(boost::bind(&handleTerrainDetailChanged, _2));
+ gSavedSettings.getControl("RenderUseTriStrips")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 1a67fc0966..7225aa1523 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -626,7 +626,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
mFace->mVertexBuffer->drawRange(LLRender::TRIANGLES, start, end, count, offset);
glPopMatrix();
}
- gPipeline.addTrianglesDrawn(count/3);
+ gPipeline.addTrianglesDrawn(count);
triangle_count += count;
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 24f1c4bd24..55e2c58a52 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -1141,7 +1141,7 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
glLoadMatrixf((F32*) scale_mat.mMatrix);
glDrawElements(GL_TRIANGLES, sLODIndexCount[trunk_LOD], GL_UNSIGNED_SHORT, indicesp + sLODIndexOffset[trunk_LOD]);
- gPipeline.addTrianglesDrawn(LEAF_INDICES/3);
+ gPipeline.addTrianglesDrawn(LEAF_INDICES);
stop_glerror();
ret += sLODIndexCount[trunk_LOD];
}
@@ -1191,7 +1191,7 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
glLoadMatrixf((F32*) scale_mat.mMatrix);
glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp);
- gPipeline.addTrianglesDrawn(LEAF_INDICES/3);
+ gPipeline.addTrianglesDrawn(LEAF_INDICES);
stop_glerror();
ret += LEAF_INDICES;
}
@@ -1216,7 +1216,7 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
glLoadMatrixf((F32*) scale_mat.mMatrix);
glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp);
- gPipeline.addTrianglesDrawn(LEAF_INDICES/3);
+ gPipeline.addTrianglesDrawn(LEAF_INDICES);
stop_glerror();
ret += LEAF_INDICES;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index fbb44c8e76..f1b27fb4df 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1515,7 +1515,14 @@ void LLVOVolume::updateFaceSize(S32 idx)
else
{
const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
- facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+ if (LLPipeline::sUseTriStrips)
+ {
+ facep->setSize(vol_face.mVertices.size(), vol_face.mTriStrip.size());
+ }
+ else
+ {
+ facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+ }
}
}
@@ -3265,6 +3272,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
draw_info->mExtents[0] = facep->mExtents[0];
draw_info->mExtents[1] = facep->mExtents[1];
validate_draw_info(*draw_info);
+
+ if (LLPipeline::sUseTriStrips)
+ {
+ draw_info->mDrawMode = LLRender::TRIANGLE_STRIP;
+ }
}
}
@@ -3349,7 +3361,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
drawablep->updateFaceSize(i);
LLFace* facep = drawablep->getFace(i);
- if (cur_total > max_total)
+ if (cur_total > max_total || facep->getIndicesCount() <= 0 || facep->getGeomCount() <= 0)
{
facep->mVertexBuffer = NULL;
facep->mLastVertexBuffer = NULL;
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index 0272a2ab34..1749ccef94 100644
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -519,7 +519,7 @@ void LLVOWLSky::drawDome(void)
LLRender::TRIANGLE_STRIP,
0, strips_segment->getRequestedVerts()-1, strips_segment->getRequestedIndices(),
0);
- gPipeline.addTrianglesDrawn(strips_segment->getRequestedIndices() - 2);
+ gPipeline.addTrianglesDrawn(strips_segment->getRequestedIndices(), LLRender::TRIANGLE_STRIP);
}
#else
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e2179fb257..259ca21e93 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -270,6 +270,7 @@ BOOL LLPipeline::sDelayVBUpdate = TRUE;
BOOL LLPipeline::sFastAlpha = TRUE;
BOOL LLPipeline::sDisableShaders = FALSE;
BOOL LLPipeline::sRenderBump = TRUE;
+BOOL LLPipeline::sUseTriStrips = TRUE;
BOOL LLPipeline::sUseFarClip = TRUE;
BOOL LLPipeline::sShadowRender = FALSE;
BOOL LLPipeline::sWaterReflections = FALSE;
@@ -358,6 +359,7 @@ void LLPipeline::init()
sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
+ sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
@@ -3490,9 +3492,19 @@ void LLPipeline::renderGeomShadow(LLCamera& camera)
}
-void LLPipeline::addTrianglesDrawn(S32 count)
+void LLPipeline::addTrianglesDrawn(S32 index_count, U32 render_type)
{
assertInitialized();
+ S32 count = 0;
+ if (render_type == LLRender::TRIANGLE_STRIP)
+ {
+ count = index_count-2;
+ }
+ else
+ {
+ count = index_count/3;
+ }
+
mTrianglesDrawn += count;
mBatchCount++;
mMaxBatchSize = llmax(mMaxBatchSize, count);
@@ -5344,6 +5356,7 @@ void LLPipeline::resetVertexBuffers(LLDrawable* drawable)
void LLPipeline::resetVertexBuffers()
{
sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
+ sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 46231048e8..6aecc23aac 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -277,7 +277,7 @@ public:
LLCullResult::sg_list_t::iterator beginAlphaGroups();
LLCullResult::sg_list_t::iterator endAlphaGroups();
- void addTrianglesDrawn(S32 count);
+ void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
BOOL hasRenderType(const U32 type) const { return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
BOOL hasRenderDebugFeatureMask(const U32 mask) const { return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
BOOL hasRenderDebugMask(const U32 mask) const { return (mRenderDebugMask & mask) ? TRUE : FALSE; }
@@ -447,7 +447,7 @@ public:
static BOOL sFastAlpha;
static BOOL sDisableShaders; // if TRUE, rendering will be done without shaders
static BOOL sRenderBump;
- static BOOL sUseFBO;
+ static BOOL sUseTriStrips;
static BOOL sUseFarClip;
static BOOL sShadowRender;
static BOOL sWaterReflections;