diff options
author | Merov Linden <merov@lindenlab.com> | 2013-10-04 11:27:59 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2013-10-04 11:27:59 -0700 |
commit | 98a89748789034a53f129e19d06649d79b384c52 (patch) | |
tree | 39a1aefb35402db02c8791bc3e5735c36116f426 /indra/newview/pipeline.cpp | |
parent | 796be733b374beb5660ee2713fc28c4e69331cbd (diff) | |
parent | 1e32b9dd33fb9e2f0d9a7935a3696b423a191354 (diff) |
Pull merge from viewer-fbc
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rwxr-xr-x | indra/newview/pipeline.cpp | 168 |
1 files changed, 98 insertions, 70 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b4e59909db..b0c73d0304 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -261,6 +261,17 @@ LLFastTimer::DeclareTimer FTM_RENDER_DEFERRED("Deferred Shading"); static LLFastTimer::DeclareTimer FTM_STATESORT_DRAWABLE("Sort Drawables"); static LLFastTimer::DeclareTimer FTM_STATESORT_POSTSORT("Post Sort"); +static LLStaticHashedString sTint("tint"); +static LLStaticHashedString sAmbiance("ambiance"); +static LLStaticHashedString sAlphaScale("alpha_scale"); +static LLStaticHashedString sNormMat("norm_mat"); +static LLStaticHashedString sOffset("offset"); +static LLStaticHashedString sScreenRes("screenRes"); +static LLStaticHashedString sDelta("delta"); +static LLStaticHashedString sDistFactor("dist_factor"); +static LLStaticHashedString sKern("kern"); +static LLStaticHashedString sKernScale("kern_scale"); + //---------------------------------------- std::string gPoolNames[] = { @@ -799,16 +810,16 @@ void LLPipeline::resizeScreenTexture() if ((resX != mScreen.getWidth()) || (resY != mScreen.getHeight())) { releaseScreenBuffers(); - if (!allocateScreenBuffer(resX,resY)) + if (!allocateScreenBuffer(resX,resY)) { #if PROBABLE_FALSE_DISABLES_OF_ALM_HERE //FAILSAFE: screen buffer allocation failed, disable deferred rendering if it's enabled - //NOTE: if the session closes successfully after this call, deferred rendering will be - // disabled on future sessions - if (LLPipeline::sRenderDeferred) - { - gSavedSettings.setBOOL("RenderDeferred", FALSE); - LLPipeline::refreshCachedSettings(); + //NOTE: if the session closes successfully after this call, deferred rendering will be + // disabled on future sessions + if (LLPipeline::sRenderDeferred) + { + gSavedSettings.setBOOL("RenderDeferred", FALSE); + LLPipeline::refreshCachedSettings(); } #endif @@ -964,7 +975,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { screenFormat = GL_RGBA16F_ARB; } - + if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) { @@ -1202,7 +1213,7 @@ void LLPipeline::releaseGLBuffers() mWaterRef.release(); mWaterDis.release(); mHighlight.release(); - + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -2730,14 +2741,14 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d { shader = &gDownsampleDepthRectProgram; shader->bind(); - shader->uniform2f("delta", 1.f, 1.f); + shader->uniform2f(sDelta, 1.f, 1.f); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight()); } else { shader = &gDownsampleDepthProgram; shader->bind(); - shader->uniform2f("delta", 1.f/source.getWidth(), 1.f/source.getHeight()); + shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight()); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f); } @@ -3112,7 +3123,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) llassert(vobj); // trying to catch a bad assumption if (vobj) // this test may not be needed, see above { - const LLVOAvatar* av = vobj->asAvatar(); + LLVOAvatar* av = vobj->asAvatar(); if (av && av->isImpostor()) { return; @@ -4942,9 +4953,9 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingProgram.bind(); - gPathfindingProgram.uniform1f("tint", 1.f); - gPathfindingProgram.uniform1f("ambiance", 1.f); - gPathfindingProgram.uniform1f("alpha_scale", 1.f); + gPathfindingProgram.uniform1f(sTint, 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); + gPathfindingProgram.uniform1f(sAlphaScale, 1.f); } //Requried character physics capsule render parameters @@ -4961,7 +4972,7 @@ void LLPipeline::renderDebug() llPathingLibInstance->renderSimpleShapeCapsuleID( gGL, id, pos, rot ); gGL.setColorMask(true, false); LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.90f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.90f); llPathingLibInstance->renderSimpleShapeCapsuleID( gGL, id, pos, rot ); gPathfindingProgram.bind(); } @@ -4988,9 +4999,9 @@ void LLPipeline::renderDebug() { gPathfindingProgram.bind(); - gPathfindingProgram.uniform1f("tint", 1.f); - gPathfindingProgram.uniform1f("ambiance", ambiance); - gPathfindingProgram.uniform1f("alpha_scale", 1.f); + gPathfindingProgram.uniform1f(sTint, 1.f); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); + gPathfindingProgram.uniform1f(sAlphaScale, 1.f); } if ( !pathfindingConsole->isRenderWorld() ) @@ -5014,7 +5025,7 @@ void LLPipeline::renderDebug() if ( pathfindingConsole->isRenderWorld() ) { LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.66f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.66f); llPathingLibInstance->renderNavMesh(); } else @@ -5026,8 +5037,8 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingNoNormalsProgram.bind(); - gPathfindingNoNormalsProgram.uniform1f("tint", 1.f); - gPathfindingNoNormalsProgram.uniform1f("alpha_scale", 1.f); + gPathfindingNoNormalsProgram.uniform1f(sTint, 1.f); + gPathfindingNoNormalsProgram.uniform1f(sAlphaScale, 1.f); llPathingLibInstance->renderNavMeshEdges(); gPathfindingProgram.bind(); } @@ -5067,7 +5078,7 @@ void LLPipeline::renderDebug() gGL.setColorMask(true, false); //render the bookends LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.90f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.90f); llPathingLibInstance->renderPathBookend( gGL, LLPathingLib::LLPL_START ); llPathingLibInstance->renderPathBookend( gGL, LLPathingLib::LLPL_END ); gPathfindingProgram.bind(); @@ -5085,7 +5096,7 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.90f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.90f); llPathingLibInstance->renderSimpleShapes( gGL, gAgent.getRegion()->getWaterHeight() ); } else @@ -5133,7 +5144,7 @@ void LLPipeline::renderDebug() LLGLEnable blend(GL_BLEND); { - gPathfindingProgram.uniform1f("ambiance", ambiance); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); { //draw solid overlay LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); @@ -5148,8 +5159,8 @@ void LLPipeline::renderDebug() if (pathfindingConsole->isRenderXRay()) { - gPathfindingProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); - gPathfindingProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingProgram.uniform1f(sAlphaScale, gSavedSettings.getF32("PathfindingXRayOpacity")); LLGLEnable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); @@ -5157,13 +5168,13 @@ void LLPipeline::renderDebug() if (gSavedSettings.getBOOL("PathfindingXRayWireframe")) { //draw hidden wireframe as darker and less opaque - gPathfindingProgram.uniform1f("ambiance", 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] ); } else { glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - gPathfindingProgram.uniform1f("ambiance", ambiance); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] ); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } @@ -5171,9 +5182,9 @@ void LLPipeline::renderDebug() { //draw visible wireframe as brighter, thicker and more opaque glPolygonOffset(offset, offset); - gPathfindingProgram.uniform1f("ambiance", 1.f); - gPathfindingProgram.uniform1f("tint", 1.f); - gPathfindingProgram.uniform1f("alpha_scale", 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); + gPathfindingProgram.uniform1f(sTint, 1.f); + gPathfindingProgram.uniform1f(sAlphaScale, 1.f); glLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); LLGLDisable blendOut(GL_BLEND); @@ -5205,19 +5216,19 @@ void LLPipeline::renderDebug() glLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); - gPathfindingProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); - gPathfindingProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingProgram.uniform1f(sAlphaScale, gSavedSettings.getF32("PathfindingXRayOpacity")); if (gSavedSettings.getBOOL("PathfindingXRayWireframe")) { //draw hidden wireframe as darker and less opaque glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - gPathfindingProgram.uniform1f("ambiance", 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); llPathingLibInstance->renderNavMesh(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } else { - gPathfindingProgram.uniform1f("ambiance", ambiance); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); llPathingLibInstance->renderNavMesh(); } @@ -5225,8 +5236,8 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingNoNormalsProgram.bind(); - gPathfindingNoNormalsProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); - gPathfindingNoNormalsProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingNoNormalsProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingNoNormalsProgram.uniform1f(sAlphaScale, gSavedSettings.getF32("PathfindingXRayOpacity")); llPathingLibInstance->renderNavMeshEdges(); gPathfindingProgram.bind(); } @@ -5422,7 +5433,7 @@ void LLPipeline::renderDebug() if (i > 3) { //render shadow frusta as volumes if (mShadowFrustPoints[i-4].empty()) - { + { continue; } @@ -6336,13 +6347,6 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) F32 x = (3.f * (1.f + light->getLightFalloff())); // why this magic? probably trying to match a historic behavior. float linatten = x / (light_radius); // % of brightness at radius - if (LLPipeline::sRenderDeferred) - { - /*light_color.mV[0] = powf(light_color.mV[0], 2.2f); - light_color.mV[1] = powf(light_color.mV[1], 2.2f); - light_color.mV[2] = powf(light_color.mV[2], 2.2f);*/ - } - mHWLightColors[cur_light] = light_color; LLLightState* light_state = gGL.getLight(cur_light); @@ -7724,7 +7728,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) else { //focus on alt-zoom target - focus_point = LLVector3(gAgentCamera.getFocusGlobal()-gAgent.getRegion()->getOriginGlobal()); + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal()-region->getOriginGlobal()); + } } } @@ -8347,10 +8355,10 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - if (shader.getUniformLocation("norm_mat") >= 0) + if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) { glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose(); - shader.uniformMatrix4fv("norm_mat", 1, FALSE, norm_mat.m); + shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } } @@ -8472,8 +8480,8 @@ void LLPipeline::renderDeferredLighting() } } - gDeferredSunProgram.uniform3fv("offset", slice, offset); - gDeferredSunProgram.uniform2f("screenRes", mDeferredLight.getWidth(), mDeferredLight.getHeight()); + gDeferredSunProgram.uniform3fv(sOffset, slice, offset); + gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); { LLGLDisable blend(GL_BLEND); @@ -8517,10 +8525,10 @@ void LLPipeline::renderDeferredLighting() x += 1.f; } - gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f); - gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor); - gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); - gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); + gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); + gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); + gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); + gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f)); { LLGLDisable blend(GL_BLEND); @@ -8537,7 +8545,7 @@ void LLPipeline::renderDeferredLighting() mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredLight.bindTarget(); - gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f); + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); { LLGLDisable blend(GL_BLEND); @@ -9081,8 +9089,8 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) } } - gDeferredSunProgram.uniform3fv("offset", slice, offset); - gDeferredSunProgram.uniform2f("screenRes", mDeferredLight.getWidth(), mDeferredLight.getHeight()); + gDeferredSunProgram.uniform3fv(LLShaderMgr::DEFERRED_SHADOW_OFFSET, slice, offset); + gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); { LLGLDisable blend(GL_BLEND); @@ -10399,14 +10407,14 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector const LLPlane& cp = camera.getAgentPlane(j); F32 dist = cp.dist(pp[i]); if (dist > 0.05f) //point is above some plane, not contained - { + { found = false; break; - } - } + } + } - if (found) - { + if (found) + { fp.push_back(pp[i]); } } @@ -11308,11 +11316,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) assertInitialized(); - bool muted = avatar->isVisuallyMuted(); + bool visually_muted = avatar->isVisuallyMuted(); pushRenderTypeMask(); - if (muted) + if (visually_muted) { andRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES); } @@ -11468,6 +11476,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) avatar->mImpostor.bindTarget(); } + F32 old_alpha = LLDrawPoolAvatar::sMinimumAlpha; + + if (visually_muted) + { //disable alpha masking for muted avatars (get whole skin silhouette) + LLDrawPoolAvatar::sMinimumAlpha = 0.f; + } + if (LLPipeline::sRenderDeferred) { avatar->mImpostor.clear(); @@ -11512,7 +11527,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) sImpostorRenderAlphaDepthPass = false; } - + + LLDrawPoolAvatar::sMinimumAlpha = old_alpha; + { //create alpha mask based on depth buffer (grey out if muted) LLFastTimer t(FTM_IMPOSTOR_BACKGROUND); @@ -11524,7 +11541,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) LLGLDisable blend(GL_BLEND); - if (muted) + if (visually_muted) { gGL.setColorMask(true, true); } @@ -11549,10 +11566,20 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) if (LLGLSLShader::sNoFixedFunction) { - gUIProgram.bind(); + gDebugProgram.bind(); } - gGL.color4ub(64,64,64,255); + + if (LLMuteList::getInstance()->isMuted(avatar->getID())) + { //grey muted avatar + gGL.diffuseColor4ub(64,64,64,255); + } + else + { // Visually muted avatar + gGL.diffuseColor4fv( avatar->getMutedAVColor().mV ); + } + + { gGL.begin(LLRender::QUADS); gGL.vertex3f(-1, -1, clip_plane); gGL.vertex3f(1, -1, clip_plane); @@ -11560,10 +11587,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) gGL.vertex3f(-1, 1, clip_plane); gGL.end(); gGL.flush(); + } if (LLGLSLShader::sNoFixedFunction) { - gUIProgram.unbind(); + gDebugProgram.unbind(); } gGL.popMatrix(); |