diff options
author | Dave Parks <davep@lindenlab.com> | 2011-02-09 15:28:46 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-02-09 15:28:46 -0600 |
commit | 068822b18d4e62381a25c833cfa2639eddd4c24d (patch) | |
tree | 61d8b5b468158d86bfeec2b582eec9a3dfe4fdfd /indra/newview/llspatialpartition.cpp | |
parent | 42404a89a3966b1f8d1d85c81c7e550f2adb11cc (diff) |
SH-874 Fix for bad performance on cards without GL_ARB_depth_clamp in cases where water and terrain should be occluded.
Diffstat (limited to 'indra/newview/llspatialpartition.cpp')
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
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); |