diff options
Diffstat (limited to 'indra/newview/pipeline.cpp')
| -rw-r--r-- | indra/newview/pipeline.cpp | 176 |
1 files changed, 104 insertions, 72 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a844e29cbb..bccff55a2c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -122,16 +122,27 @@ #include "SMAAAreaTex.h" #include "SMAASearchTex.h" #include "llerror.h" -#ifndef LL_WINDOWS -#define A_GCC 1 + +#if LL_CLANG +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wunused-variable" +#elif LL_GNUC +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" -#if LL_LINUX #pragma GCC diagnostic ignored "-Wrestrict" #endif +#ifndef LL_WINDOWS +#define A_GCC 1 #endif #define A_CPU 1 #include "app_settings/shaders/class1/deferred/CASF.glsl" // This is also C++ +#if LL_CLANG +#pragma clang diagnostic pop +#elif LL_GNUC +#pragma GCC diagnostic pop +#endif extern bool gSnapshot; bool gShiftFrame = false; @@ -229,7 +240,7 @@ const F32 ALPHA_BLEND_CUTOFF = 0.598f; const F32 DEFERRED_LIGHT_FALLOFF = 0.5f; const U32 DEFERRED_VB_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1; -const U32 SHADOWS_RESX = 512; +const U32 SHADOWS_RESX = 768; const U32 SHADOWS_RESY = 512; extern S32 gBoxFrame; @@ -623,7 +634,19 @@ void LLPipeline::init() { cntrl_ptr->getCommitSignal()->connect([](LLControlVariable* control, const LLSD& value, const LLSD& previous) { - LLFontVertexBuffer::enableBufferCollection(control->getValue().asBoolean()); + bool enable_buffers = control->getValue().asBoolean(); + LLFontVertexBuffer::enableBufferCollection(enable_buffers); + LLFontWidthBuffer::enableBufferCollection(enable_buffers); + }); + } + + cntrl_ptr = gSavedSettings.getControl("CollectUIImageVertexBuffers"); + if (cntrl_ptr.notNull()) + { + cntrl_ptr->getCommitSignal()->connect([](LLControlVariable* control, const LLSD& value, const LLSD& previous) + { + bool enable_buffers = control->getValue().asBoolean(); + LLUIImage::enableDisplayListsCollection(enable_buffers); }); } } @@ -765,16 +788,16 @@ void LLPipeline::resizeScreenTexture() releaseScreenBuffers(); releaseSunShadowTargets(); releaseSpotShadowTargets(); - allocateScreenBuffer(resX,resY); + allocateScreenBuffer(resX, resY); gResizeScreenTexture = false; } } } -bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) +bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 snapshot_) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - eFBOStatus ret = doAllocateScreenBuffer(resX, resY); + eFBOStatus ret = doAllocateScreenBuffer(resX, resY, snapshot_); return ret == FBO_SUCCESS_FULLRES; } @@ -786,7 +809,7 @@ void LLPipeline::renderTriangle() } -LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) +LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY, U32 snapshot_) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // try to allocate screen buffers at requested resolution and samples @@ -797,8 +820,11 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) // refresh cached settings here to protect against inconsistent event handling order refreshCachedSettings(); + mHDRBuffers = false; + if(mHDRDisplay && !snapshot_) mHDRBuffers = true; + eFBOStatus ret = FBO_SUCCESS_FULLRES; - if (!allocateScreenBufferInternal(resX, resY)) + if (!allocateScreenBufferInternal(resX, resY, snapshot_)) { //failed to allocate at requested specification, return false ret = FBO_FAILURE; @@ -809,14 +835,14 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) while (resY > 0 && resX > 0) { resY /= 2; - if (allocateScreenBufferInternal(resX, resY)) + if (allocateScreenBufferInternal(resX, resY, snapshot_)) { return FBO_SUCCESS_LOWRES; } releaseScreenBuffers(); resX /= 2; - if (allocateScreenBufferInternal(resX, resY)) + if (allocateScreenBufferInternal(resX, resY, snapshot_)) { return FBO_SUCCESS_LOWRES; } @@ -829,12 +855,11 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) return ret; } -bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) +bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 snapshot_) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - - static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true); - bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr(); + bool has_hdr = gSavedSettings.getBOOL("RenderHDREnabled"); + bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr; static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0); @@ -850,14 +875,14 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) mRT = &mAuxillaryRT; U32 res = mReflectionMapManager.mProbeResolution * 4; //multiply by 4 because probes will be 16x super sampled - allocateScreenBufferInternal(res, res, 1); + allocateScreenBufferInternal(res, res, snapshot_); if (RenderMirrors) { mHeroProbeManager.initReflectionMaps(); res = mHeroProbeManager.mProbeResolution; // We also scale the hero probe RT to the probe res since we don't super sample it. mRT = &mHeroProbeRT; - allocateScreenBufferInternal(res, res, 2); + allocateScreenBufferInternal(res, res, snapshot_); } mRT = &mMainRT; @@ -868,12 +893,15 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) mRT->width = resX; mRT->height = resY; - F32 res_mod = fmin(RenderResolutionDivisor, 4.0); - - if (res_mod >= 0.5 && res_mod <= 4.0) + if(!snapshot_) { - resX = (U32)(floor((F32)resX / res_mod)); - resY = (U32)(floor((F32)resY / res_mod)); + F32 res_mod = fmin(RenderResolutionDivisor, 4.0); + + if (res_mod >= 0.5 && res_mod <= 4.0) + { + resX = (U32)(floor((F32)resX / res_mod)); + resY = (U32)(floor((F32)resY / res_mod)); + } } S32 shadow_detail = RenderShadowDetail; @@ -888,9 +916,10 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16F; - if(!hdr && !mHDRDisplay && MPColorPrecision == 1) screenFormat = GL_RGB10_A2; + if(!hdr || ( !mHDRBuffers && MPColorPrecision == 1 )) screenFormat = GL_RGB10_A2; - if (!mRT->screen.allocate(resX, resY, GL_RGBA16F)) return false; + //if (!mRT->screen.allocate(resX, resY, GL_RGBA16F)) return false; + if (!mRT->screen.allocate(resX, resY, screenFormat)) return false; mRT->deferredScreen.shareDepthBuffer(mRT->screen); @@ -904,16 +933,15 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) } //allocateShadowBuffer(resX, resY); - if(type_ == 0) allocateShadowBuffer(SHADOWS_RESX, SHADOWS_RESY); + allocateShadowBuffer(SHADOWS_RESX, SHADOWS_RESY); if (!gCubeSnapshot) // hack to not re-allocate various targets for cube snapshots { - GLuint UIFormat = GL_RGBA8; - //if(mHDRDisplay && MPColorPrecision == 2) UIFormat = GL_RGBA16F; + U32 post_color_fmt = gSavedSettings.getBOOL("RenderHighPrecisionPostProcess") ? GL_RGBA16F : GL_RGBA8; if (RenderUIBuffer) { - if (!mUIScreen.allocate(resX, resY, UIFormat)) + if (!mUIScreen.allocate(resX, resY, GL_RGBA8)) { return false; } @@ -921,16 +949,15 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) if (RenderFSAAType > 0) { - GLuint AAFormat = GL_RGBA8; if(mHDRDisplay && MPColorPrecision != 1) { - AAFormat = GL_RGBA16F; + post_color_fmt = GL_RGBA16F; } - if (!mFXAAMap.allocate(resX, resY, AAFormat)) return false; + if (!mFXAAMap.allocate(resX, resY, post_color_fmt)) return false; if (RenderFSAAType == 2) { - if (!mSMAABlendBuffer.allocate(resX, resY, AAFormat, false)) return false; + if (!mSMAABlendBuffer.allocate(resX, resY, post_color_fmt, false)) return false; } } else @@ -955,10 +982,6 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) mSceneMap.release(); } -/* - mPostPingMap.allocate(resX, resY, GL_RGBA); - mPostPongMap.allocate(resX, resY, GL_RGBA); -*/ if((hdr && MPColorPrecision == 2) || mHDRDisplay) { mPostMaps[0].allocate(resX, resY, screenFormat); @@ -966,8 +989,8 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_) } else { - mPostMaps[0].allocate(resX, resY, GL_RGBA); - mPostMaps[1].allocate(resX, resY, GL_RGBA); + mPostMaps[0].allocate(resX, resY, post_color_fmt); + mPostMaps[1].allocate(resX, resY, post_color_fmt); } // The water exclusion mask needs its own depth buffer so we can take care of the problem of multiple water planes. @@ -1205,7 +1228,11 @@ void LLPipeline::refreshCachedSettings() LLVOAvatar::updateImpostorRendering(LLVOAvatar::sMaxNonImpostors); } - LLFontVertexBuffer::enableBufferCollection(gSavedSettings.getBOOL("CollectFontVertexBuffers")); + bool enable_buffers = gSavedSettings.getBOOL("CollectFontVertexBuffers"); + LLFontVertexBuffer::enableBufferCollection(enable_buffers); + LLFontWidthBuffer::enableBufferCollection(enable_buffers); + enable_buffers = gSavedSettings.getBOOL("CollectUIImageVertexBuffers"); + LLUIImage::enableDisplayListsCollection(enable_buffers); } void LLPipeline::releaseGLBuffers() @@ -2707,6 +2734,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) gGL.setColorMask(true, true); } + /* if (sReflectionProbesEnabled && sUseOcclusion > 1 && !LLPipeline::sShadowRender && !gCubeSnapshot) { gGL.setColorMask(false, false); @@ -2726,6 +2754,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) gGL.setColorMask(true, true); } + */ if (LLPipeline::sUseOcclusion > 1 && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) @@ -2811,6 +2840,10 @@ void LLPipeline::clearRebuildGroups() { LLSpatialGroup* group = *iter; + if (!group || group->isDead()) + { + continue; + } // If the group contains HUD objects, save the group if (group->isHUDGroup()) { @@ -4514,7 +4547,7 @@ void LLPipeline::renderPhysicsDisplay() LLGLEnable polygon_offset_line(GL_POLYGON_OFFSET_LINE); glPolygonOffset(3.f, 3.f); - //glLineWidth(3.f); + //gGL.setLineWidth(3.f); LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -4556,7 +4589,7 @@ void LLPipeline::renderPhysicsDisplay() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } } - //glLineWidth(1.f); + //gGL.setLineWidth(1.f); gDebugProgram.unbind(); } @@ -4640,8 +4673,7 @@ void LLPipeline::renderDebug() //NavMesh if ( pathfindingConsole->isRenderNavMesh() ) { - gGL.flush(); - //glLineWidth(2.0f); + //gGL.setLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); LLGLDisable blend(GL_BLEND); @@ -4665,7 +4697,7 @@ void LLPipeline::renderDebug() gGL.flush(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - //glLineWidth(1.0f); + //gGL.setLineWidth(1.0f); gGL.flush(); } //User designated path @@ -4780,11 +4812,11 @@ void LLPipeline::renderDebug() gPathfindingProgram.uniform1f(sTint, 1.f); gPathfindingProgram.uniform1f(sAlphaScale, 1.f); - //glLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); + //gGL.setLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); LLGLDisable blendOut(GL_BLEND); llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] ); gGL.flush(); - //glLineWidth(1.f); + //gGL.setLineWidth(1.f); } glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); @@ -4807,7 +4839,7 @@ void LLPipeline::renderDebug() LLGLEnable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); gGL.flush(); - //glLineWidth(2.0f); + //gGL.setLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); @@ -4834,7 +4866,7 @@ void LLPipeline::renderDebug() gPathfindingProgram.bind(); gGL.flush(); - //glLineWidth(1.0f); + //gGL.setLineWidth(1.0f); } glPolygonOffset(0.f, 0.f); @@ -5126,7 +5158,7 @@ void LLPipeline::renderDebug() } /*gGL.flush(); - glLineWidth(16-i*2); + gGL.setLineWidth(16-i*2); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -5144,7 +5176,7 @@ void LLPipeline::renderDebug() } } gGL.flush(); - glLineWidth(1.f);*/ + gGL.setLineWidth(1.f);*/ } } @@ -5693,7 +5725,7 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_ if (light->mDrawable.notNull() && light->mDrawable->isState(LLDrawable::ACTIVE)) { // moving lights get a little higher priority (too much causes artifacts) - dist = llmax(dist - light->getLightRadius()*0.25f, 0.f); + dist = llmax(dist - radius * 0.25f, 0.f); } return dist; } @@ -5926,21 +5958,21 @@ void LLPipeline::setupHWLights() mSunDiffuse.setVec(psky->getSunlightColor()); mMoonDiffuse.setVec(psky->getMoonlightColor()); - if(!mHDRDisplay) - { - F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); - if (max_color > 1.f) + if(!mHDRBuffers) { - mSunDiffuse *= 1.f/max_color; - } - mSunDiffuse.clamp(); + F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); + if (max_color > 1.f) + { + mSunDiffuse *= 1.f/max_color; + } + mSunDiffuse.clamp(); - max_color = llmax(mMoonDiffuse.mV[0], mMoonDiffuse.mV[1], mMoonDiffuse.mV[2]); - if (max_color > 1.f) - { - mMoonDiffuse *= 1.f/max_color; - } - mMoonDiffuse.clamp(); + max_color = llmax(mMoonDiffuse.mV[0], mMoonDiffuse.mV[1], mMoonDiffuse.mV[2]); + if (max_color > 1.f) + { + mMoonDiffuse *= 1.f/max_color; + } + mMoonDiffuse.clamp(); } // prevent underlighting from having neither lightsource facing us @@ -7488,14 +7520,14 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) gDeferredPostGammaCorrectProgram; static LLCachedControl<F32> mp_hdr_gamma(gSavedSettings, "MPHDRGamma", false); - if(mHDRDisplay) shader = gHDRGammaCorrectProgram; + if(mHDRBuffers) shader = gHDRGammaCorrectProgram; shader.bind(); shader.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT); //screensize isn't a uniform in the shader, we comment out for now //shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); - if(mHDRDisplay) + if(mHDRBuffers) { shader.uniform1f(LLShaderMgr::GAMMA, (GLfloat)mp_hdr_gamma); shader.uniform1f(LLShaderMgr::MP_HDR_BOOST, 1.0); @@ -8251,7 +8283,7 @@ bool LLPipeline::renderBloom(LLRenderTarget* src, LLRenderTarget* dst) static LLCachedControl<F32> mp_bloom_nonmetal(gSavedSettings, "MPBloomExtractNonMetal", 0.2); F32 clampValue = 1.0; - if(mHDRDisplay) clampValue = 11.0; + if(mHDRBuffers) clampValue = 11.0; LLGLDepthTest depth(GL_FALSE, GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -8379,11 +8411,11 @@ void LLPipeline::renderFinalize() bool apply_cas = false; static LLCachedControl<F32> cas_sharpness(gSavedSettings, "RenderCASSharpness", 0.0f); - if (cas_sharpness > 0.0f && gCASProgram.isComplete() && gCASLegacyGammaProgram.isComplete() && !mHDRDisplay) apply_cas = true; + if (cas_sharpness > 0.0f && gCASProgram.isComplete() && gCASLegacyGammaProgram.isComplete() && !mHDRBuffers) apply_cas = true; U16 activeRT = 0; - if (hdr && !mHDRDisplay) + if (hdr && !mHDRBuffers) { copyScreenSpaceReflections(&mRT->screen, &mSceneMap); @@ -8402,7 +8434,7 @@ void LLPipeline::renderFinalize() } else { - if(mHDRDisplay) copyScreenSpaceReflections(&mRT->screen, &mSceneMap); + if(mHDRBuffers) copyScreenSpaceReflections(&mRT->screen, &mSceneMap); gammaCorrect(&mRT->screen, &mPostMaps[activeRT]); } @@ -9802,7 +9834,7 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) void LLPipeline::unbindReflectionProbes(LLGLSLShader& shader) { - S32 channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP); + S32 channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { mReflectionMapManager.mTexture->unbind(); |
