summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-02-09 15:28:46 -0600
committerDave Parks <davep@lindenlab.com>2011-02-09 15:28:46 -0600
commit068822b18d4e62381a25c833cfa2639eddd4c24d (patch)
tree61d8b5b468158d86bfeec2b582eec9a3dfe4fdfd
parent42404a89a3966b1f8d1d85c81c7e550f2adb11cc (diff)
SH-874 Fix for bad performance on cards without GL_ARB_depth_clamp in cases where water and terrain should be occluded.
-rw-r--r--indra/newview/lldrawpool.h8
-rw-r--r--indra/newview/llspatialpartition.cpp49
2 files changed, 30 insertions, 27 deletions
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 9d944ee213..d3fd9ead0d 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -47,14 +47,14 @@ public:
{
// Correspond to LLPipeline render type
POOL_SIMPLE = 1,
+ POOL_GROUND,
+ POOL_FULLBRIGHT,
+ POOL_BUMP,
POOL_TERRAIN,
- POOL_TREE,
POOL_SKY,
POOL_WL_SKY,
- POOL_GROUND,
+ POOL_TREE,
POOL_GRASS,
- POOL_FULLBRIGHT,
- POOL_BUMP,
POOL_INVISIBLE, // see below *
POOL_AVATAR,
POOL_VOIDWATER,
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index a4c9b66e38..40f1596139 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -273,12 +273,6 @@ void LLSpatialGroup::buildOcclusion()
LLVector4a r;
r.setAdd(mBounds[1], fudge);
- LLVector4a r2;
- r2.splat(0.25f);
- r2.add(mBounds[1]);
-
- r.setMin(r, r2);
-
LLStrider<LLVector3> pos;
mOcclusionVerts->getVertexStrider(pos);
@@ -1627,8 +1621,7 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
{
// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
- if ((mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER && !gGLManager.mHasDepthClamp) ||
- earlyFail(camera, this))
+ if (earlyFail(camera, this))
{
setOcclusionState(LLSpatialGroup::DISCARD_QUERY);
assert_states_valid(this);
@@ -1656,12 +1649,11 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
// behind the far clip plane, and in the case of edge water to avoid
// it being culled while still visible.
bool const use_depth_clamp = gGLManager.mHasDepthClamp &&
- (mSpatialPartition->mDrawableType == LLDrawPool::POOL_WATER ||
+ (mSpatialPartition->mDrawableType == LLDrawPool::POOL_WATER ||
mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER);
- if (use_depth_clamp)
- {
- glEnable(GL_DEPTH_CLAMP);
- }
+
+ LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0);
+
#if !LL_DARWIN
U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB;
#else
@@ -1676,22 +1668,33 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
mOcclusionVerts->setBuffer(LLVertexBuffer::MAP_VERTEX);
- if (camera->getOrigin().isExactlyZero())
- { //origin is invalid, draw entire box
- mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
- mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);
+ if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER)
+ {
+ LLGLSquashToFarClip squash(glh_get_current_projection());
+ if (camera->getOrigin().isExactlyZero())
+ { //origin is invalid, draw entire box
+ mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
+ mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);
+ }
+ else
+ {
+ mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+ }
}
else
{
- mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+ if (camera->getOrigin().isExactlyZero())
+ { //origin is invalid, draw entire box
+ mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
+ mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);
+ }
+ else
+ {
+ mOcclusionVerts->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+ }
}
glEndQueryARB(mode);
-
- if (use_depth_clamp)
- {
- glDisable(GL_DEPTH_CLAMP);
- }
}
setOcclusionState(LLSpatialGroup::QUERY_PENDING);