diff options
-rw-r--r-- | indra/newview/llvieweroctree.cpp | 30 | ||||
-rw-r--r-- | indra/newview/llvieweroctree.h | 4 | ||||
-rwxr-xr-x | indra/newview/llvocache.cpp | 12 | ||||
-rwxr-xr-x | indra/newview/llvocache.h | 2 |
4 files changed, 29 insertions, 19 deletions
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 576dbfd2c2..7b3186d40a 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -978,7 +978,7 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion"); static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait"); -BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera) +BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds) { if (camera->getOrigin().isExactlyZero()) { @@ -989,7 +989,6 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera) LLVector4a fudge; fudge.splat(vel); - const LLVector4a* bounds = getBounds(); const LLVector4a& c = bounds[0]; LLVector4a r; r.setAdd(bounds[1], fudge); @@ -1125,12 +1124,23 @@ static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer"); static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water"); static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw"); -void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) +void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent) { if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1) { + //move mBounds to the agent space if necessary + LLVector4a bounds[2]; + bounds[0] = mBounds[0]; + bounds[1] = mBounds[1]; + if(region_agent != NULL) + { + LLVector4a shift((*region_agent)[0], (*region_agent)[1], (*region_agent)[2]); + bounds[0].sub(shift); + bounds[1].sub(shift); + } + // Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension - if (earlyFail(camera)) + if (earlyFail(camera, bounds)) { LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL); setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY); @@ -1184,10 +1194,10 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; llassert(shader); - shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mBounds[0].getF32ptr()); - shader->uniform3f(LLShaderMgr::BOX_SIZE, mBounds[1][0]+SG_OCCLUSION_FUDGE, - mBounds[1][1]+SG_OCCLUSION_FUDGE, - mBounds[1][2]+SG_OCCLUSION_FUDGE); + shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, bounds[0].getF32ptr()); + shader->uniform3f(LLShaderMgr::BOX_SIZE, bounds[1][0]+SG_OCCLUSION_FUDGE, + bounds[1][1]+SG_OCCLUSION_FUDGE, + bounds[1][2]+SG_OCCLUSION_FUDGE); if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER) { @@ -1201,7 +1211,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) } else { - gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0])); + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0])); } } else @@ -1214,7 +1224,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) } else { - gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0])); + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0])); } } diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index e210d8f478..980a67367c 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -316,7 +316,7 @@ public: void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE); void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE); void checkOcclusion(); //read back last occlusion query (if any) - void doOcclusion(LLCamera* camera); //issue occlusion query + void doOcclusion(LLCamera* camera, const LLVector3* region_agent = NULL); //issue occlusion query BOOL isOcclusionState(U32 state) const { return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; } BOOL needsUpdate(); @@ -332,7 +332,7 @@ protected: void releaseOcclusionQueryObjectNames(); private: - BOOL earlyFail(LLCamera* camera); + BOOL earlyFail(LLCamera* camera, const LLVector4a* bounds); protected: U32 mOcclusionState[LLViewerCamera::NUM_CAMERAS]; diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7eeabcba2e..60d78890b5 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -494,7 +494,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera) if(!mOccludedGroups.empty()) { - processOccluders(&camera); + processOccluders(&camera, ®ion_agent); mOccludedGroups.clear(); } @@ -505,26 +505,26 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; - const U32 MIN_WAIT_TIME = 16; //wait 16 frames to issue a new occlusion request + const U32 MIN_WAIT_TIME = 19; //wait 19 frames to issue a new occlusion request U32 last_issued_time = group->getLastOcclusionIssuedTime(); - if(gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) + if(!group->needsUpdate() && gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) { return; } - if(group && !group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) + if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) { group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); mOccludedGroups.insert(group); } } -void LLVOCachePartition::processOccluders(LLCamera* camera) +void LLVOCachePartition::processOccluders(LLCamera* camera, const LLVector3* region_agent) { for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLOcclusionCullingGroup* group = *iter; - group->doOcclusion(camera); + group->doOcclusion(camera, region_agent); group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } } diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 1aa58528db..bf75cafac5 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -161,7 +161,7 @@ public: static LLTrace::MemStatHandle sMemStat; private: - void processOccluders(LLCamera* camera); + void processOccluders(LLCamera* camera, const LLVector3* region_agent); private: std::set<LLOcclusionCullingGroup*> mOccludedGroups; |