From 34e79c8f4e251200496651f9ae2b5126a6f7faa3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 11 Mar 2022 10:21:08 -0600 Subject: SL-17005 WIP Simplify what feeds texture loading bias to only pay attention to available memory according to OS and GL driver, not (broken) internal accounting (breaks intel GPUs, compatibility pass incoming). --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 34c4e2ddb9..2aff3de29b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3712,7 +3712,7 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) if (tex) { LLImageGL* gl_tex = tex->getGLTexture(); - if (gl_tex && gl_tex->updateBindStats(gl_tex->mTextureMemory)) + if (gl_tex && gl_tex->updateBindStats()) { tex->setActive(); tex->addTextureStats(vsize); -- cgit v1.2.3 From b6841d75c2f259c84d5ab6b012bd2ae37d985451 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 15 Apr 2022 19:02:07 -0500 Subject: SL-17219 WIP - Texture pipeline overhaul --- indra/newview/pipeline.cpp | 48 +++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a5ae52af93..bc0d89f4ad 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3776,25 +3776,47 @@ void LLPipeline::postSort(LLCamera& camera) group->rebuildGeom(); } - for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) - { - LLSpatialGroup::drawmap_elem_t& src_vec = j->second; - if (!hasRenderType(j->first)) - { - continue; - } - - for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) - { + for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) + { + LLSpatialGroup::drawmap_elem_t& src_vec = j->second; + if (!hasRenderType(j->first)) + { + continue; + } + + // DEBUG -- force a texture virtual size update every frame + /*if (group->getSpatialPartition()->mDrawableType == LLPipeline::RENDER_TYPE_VOLUME) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("plps - update vsize"); + auto& entries = group->getData(); + for (auto& entry : entries) + { + if (entry) + { + auto* data = entry->getDrawable(); + if (data) + { + LLVOVolume* volume = ((LLDrawable*)data)->getVOVolume(); + if (volume) + { + volume->updateTextureVirtualSize(true); + } + } + } + } + }*/ + + for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) + { LLDrawInfo* info = *k; - - sCull->pushDrawInfo(j->first, info); + + sCull->pushDrawInfo(j->first, info); if (!sShadowRender && !sReflectionRender) { touchTextures(info); addTrianglesDrawn(info->mCount, info->mDrawMode); } - } + } } if (hasRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA)) -- cgit v1.2.3 From deffbca3ee209f6aea3358692d9ca6dc7090e748 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 28 Apr 2022 15:51:31 +0000 Subject: SL-17281 environment map prototype (stupid slow and hacky, but provides a way to get a "real" environment map for shader development) --- indra/newview/pipeline.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 20d6fe39e3..09437473d9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8191,7 +8191,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { - LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; + LLCubeMap* cube_map = mEnvironmentMap.mCubeMap.notNull() ? mEnvironmentMap.mCubeMap : gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if (cube_map) { cube_map->enable(channel); @@ -11467,3 +11467,8 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) } } +void LLPipeline::overrideEnvironmentMap() +{ + mEnvironmentMap.update(LLViewerCamera::instance().getOrigin(), 1024); +} + -- cgit v1.2.3 From 93a025966649e281ceff8d1471bc983cc036bc17 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 29 Apr 2022 13:51:11 +0000 Subject: SL-17282 prototype mixing of reflection map into legacy materials --- indra/newview/pipeline.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 09437473d9..ac7276e1e0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8188,24 +8188,42 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); + bool setup_env_mat = false; channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { - LLCubeMap* cube_map = mEnvironmentMap.mCubeMap.notNull() ? mEnvironmentMap.mCubeMap : gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; + LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if (cube_map) { + setup_env_mat = true; cube_map->enable(channel); cube_map->bind(); - F32* m = gGLModelView; - - F32 mat[] = { m[0], m[1], m[2], - m[4], m[5], m[6], - m[8], m[9], m[10] }; - - shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); } } + channel = shader.enableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); + if (channel > -1) + { + LLCubeMap* cube_map = mEnvironmentMap.mCubeMap; + if (cube_map) + { + setup_env_mat = true; + cube_map->enable(channel); + cube_map->bind(); + } + } + + if (setup_env_mat) + { + F32* m = gGLModelView; + + F32 mat[] = { m[0], m[1], m[2], + m[4], m[5], m[6], + m[8], m[9], m[10] }; + + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); + } + if (gAtmosphere) { // bind precomputed textures necessary for calculating sun and sky luminance @@ -9103,6 +9121,17 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) cube_map->disable(); } } + + channel = shader.disableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); + if (channel > -1) + { + LLCubeMap* cube_map = mEnvironmentMap.mCubeMap; + if (cube_map) + { + cube_map->disable(); + } + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->activate(); shader.unbind(); -- cgit v1.2.3 From 54919fa7495910e6f7877228a0458736024dcdc4 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 2 May 2022 10:05:13 -0700 Subject: SL-17274: Stub for PBR DrawPool and shader --- indra/newview/pipeline.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ac7276e1e0..eaf28e9f4f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -462,6 +462,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); + getPool(LLDrawPool::POOL_PBR_OPAQUE); resetFrameStats(); @@ -1597,6 +1598,10 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mWLSkyPool; break; + case LLDrawPool::POOL_PBR_OPAQUE: + poolp = mPBROpaquePool; + break; + default: llassert(0); LL_ERRS() << "Invalid Pool Type in LLPipeline::findPool() type=" << type << LL_ENDL; @@ -5698,6 +5703,18 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; + case LLDrawPool::POOL_PBR_OPAQUE: + if( mPBROpaquePool ) + { + llassert(0); + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate PBR Opaque Pool" << LL_ENDL; + } + else + { + mPBROpaquePool = new_poolp; + } + break; + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::addPool()" << LL_ENDL; @@ -5814,6 +5831,11 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mGroundPool = NULL; break; + case LLDrawPool::POOL_PBR_OPAQUE: + llassert( poolp == mPBROpaquePool ); + mPBROpaquePool = NULL; + break; + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL; -- cgit v1.2.3 From 93260cfeff2382dd1ffeecaef208d37bf21c2a01 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 4 May 2022 16:07:50 +0000 Subject: SL-17283 LLReflectionMapManager prototype. Remove snapshot code related overhead from reflection map renders. Add parallax correction and support for multiple reflection maps. --- indra/newview/pipeline.cpp | 87 +++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 40 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ac7276e1e0..e93ff95ed4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -767,42 +767,16 @@ void LLPipeline::allocatePhysicsBuffer() bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { - refreshCachedSettings(); - - bool save_settings = sRenderDeferred; - if (save_settings) - { - // Set this flag in case we crash while resizing window or allocating space for deferred rendering targets - gSavedSettings.setBOOL("RenderInitError", TRUE); - gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); - } - + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; eFBOStatus ret = doAllocateScreenBuffer(resX, resY); - if (save_settings) - { - // don't disable shaders on next session - gSavedSettings.setBOOL("RenderInitError", FALSE); - gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); - } - - if (ret == FBO_FAILURE) - { //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(); - } - } - return ret == FBO_SUCCESS_FULLRES; } LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // try to allocate screen buffers at requested resolution and samples // - on failure, shrink number of samples and try again // - if not multisampled, shrink resolution and try again (favor X resolution over Y) @@ -856,8 +830,7 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { - refreshCachedSettings(); - + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // remember these dimensions mScreenWidth = resX; mScreenHeight = resY; @@ -961,8 +934,7 @@ inline U32 BlurHappySize(U32 x, F32 scale) { return U32( x * scale + 16.0f) & ~0 bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { - refreshCachedSettings(); - + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (LLPipeline::sRenderDeferred) { S32 shadow_detail = RenderShadowDetail; @@ -1053,6 +1025,7 @@ void LLPipeline::updateRenderDeferred() // static void LLPipeline::refreshCachedSettings() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; LLPipeline::sAutoMaskAlphaDeferred = gSavedSettings.getBOOL("RenderAutoMaskAlphaDeferred"); LLPipeline::sAutoMaskAlphaNonDeferred = gSavedSettings.getBOOL("RenderAutoMaskAlphaNonDeferred"); LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip"); @@ -8204,12 +8177,41 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { - LLCubeMap* cube_map = mEnvironmentMap.mCubeMap; - if (cube_map) + mReflectionMaps.resize(8); //TODO -- declare the number of reflection maps the shader knows about somewhere sane + mReflectionMapManager.getReflectionMaps(mReflectionMaps); + LLVector3 origin[8]; //origin of refmaps in clip space + + // load modelview matrix into matrix 4a + LLMatrix4a modelview; + modelview.loadu(gGLModelView); + LLVector4a oa; // scratch space for transformed origin + + S32 count = 0; + for (auto* refmap : mReflectionMaps) + { + if (refmap) + { + LLCubeMap* cubemap = refmap->mCubeMap; + if (cubemap) + { + cubemap->enable(channel + count); + cubemap->bind(); + + modelview.affineTransform(refmap->mOrigin, oa); + origin[count].set(oa.getF32ptr()); + + count++; + } + } + } + + if (count > 0) { + LLStaticHashedString refmapCount("refmapCount"); + LLStaticHashedString refOrigin("refOrigin"); + shader.uniform1i(refmapCount, count); + shader.uniform3fv(refOrigin, count, (F32*)origin); setup_env_mat = true; - cube_map->enable(channel); - cube_map->bind(); } } @@ -9125,10 +9127,14 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) channel = shader.disableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { - LLCubeMap* cube_map = mEnvironmentMap.mCubeMap; - if (cube_map) + for (int i = 0; i < mReflectionMaps.size(); ++i) + { + gGL.getTexUnit(channel + i)->disable(); + } + + if (channel == 0) { - cube_map->disable(); + gGL.getTexUnit(channel)->enable(LLTexUnit::TT_TEXTURE); } } @@ -11498,6 +11504,7 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) void LLPipeline::overrideEnvironmentMap() { - mEnvironmentMap.update(LLViewerCamera::instance().getOrigin(), 1024); + mReflectionMapManager.mProbes.clear(); + mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); } -- cgit v1.2.3 From 3400e5fd302c0d9dea6386c4d5bf38876f2cc287 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 16 May 2022 17:21:08 +0000 Subject: SL-17284 Reflection probe tuning and optimization take 1 --- indra/newview/pipeline.cpp | 505 ++++++++++++++++++++++++--------------------- 1 file changed, 269 insertions(+), 236 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ef616f5d83..5eb9817fc4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -227,6 +227,7 @@ extern S32 gBoxFrame; //extern BOOL gHideSelectedObjects; extern BOOL gDisplaySwapBuffers; extern BOOL gDebugGL; +extern BOOL gCubeSnapshot; bool gAvatarBacklight = false; @@ -2006,6 +2007,7 @@ void LLPipeline::updateMove() //static F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera) { + llassert(!gCubeSnapshot); // shouldn't be doing ANY of this during cube snap shots LLVector3 lookAt = center - camera.getOrigin(); F32 dist = lookAt.length(); @@ -2475,7 +2477,7 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) group->setVisible(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { group->updateDistance(camera); } @@ -2581,6 +2583,8 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(!gCubeSnapshot); downsampleDepthBuffer(source, dest, scratch_space); dest.bindTarget(); doOcclusion(camera); @@ -2823,7 +2827,7 @@ void LLPipeline::rebuildPriorityGroups() void LLPipeline::rebuildGroups() { - if (mGroupQ2.empty()) + if (mGroupQ2.empty() || gCubeSnapshot) { return; } @@ -2873,6 +2877,10 @@ void LLPipeline::updateGeom(F32 max_dtime) LLPointer drawablep; LL_RECORD_BLOCK_TIME(FTM_GEO_UPDATE); + if (gCubeSnapshot) + { + return; + } assertInitialized(); @@ -3112,6 +3120,8 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) } } + mReflectionMapManager.shift(offseta); + LLHUDText::shiftAll(offset); LLHUDNameTag::shiftAll(offset); @@ -3292,7 +3302,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { LLSpatialGroup* last_group = NULL; BOOL fov_changed = LLViewerCamera::getInstance()->isDefaultFOVChanged(); @@ -3374,7 +3384,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) stateSort(drawablep, camera); } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { //avoid redundant stateSort calls group->mLastUpdateDistance = group->mDistance; } @@ -3443,7 +3453,7 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) } } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { //if (drawablep->isVisible()) isVisible() check here is redundant, if it wasn't visible, it wouldn't be here { @@ -3721,21 +3731,26 @@ void LLPipeline::postSort(LLCamera& camera) assertInitialized(); LL_PUSH_CALLSTACKS(); - //rebuild drawable geometry - for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) - { - LLSpatialGroup* group = *i; - if (!sUseOcclusion || - !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) - { - group->rebuildGeom(); - } - } - LL_PUSH_CALLSTACKS(); - //rebuild groups - sCull->assertDrawMapsEmpty(); - rebuildPriorityGroups(); + if (!gCubeSnapshot) + { + //rebuild drawable geometry + for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) + { + LLSpatialGroup* group = *i; + if (!sUseOcclusion || + !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + { + group->rebuildGeom(); + } + } + LL_PUSH_CALLSTACKS(); + //rebuild groups + sCull->assertDrawMapsEmpty(); + + rebuildPriorityGroups(); + } + LL_PUSH_CALLSTACKS(); @@ -3751,7 +3766,7 @@ void LLPipeline::postSort(LLCamera& camera) continue; } - if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY)) + if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY) && !gCubeSnapshot) { //no way this group is going to be drawable without a rebuild group->rebuildGeom(); } @@ -3769,7 +3784,7 @@ void LLPipeline::postSort(LLCamera& camera) LLDrawInfo* info = *k; sCull->pushDrawInfo(j->first, info); - if (!sShadowRender && !sReflectionRender) + if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { touchTextures(info); addTrianglesDrawn(info->mCount, info->mDrawMode); @@ -3784,7 +3799,7 @@ void LLPipeline::postSort(LLCamera& camera) if (alpha != group->mDrawMap.end()) { //store alpha groups for sorting LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { if (bridge) { @@ -4411,7 +4426,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) gGL.loadMatrix(gGLModelView); if (occlude) - { + { // catch uncommon condition where pools at drawpool grass and later are disabled occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -4607,6 +4622,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) if (occlude && cur_type >= LLDrawPool::POOL_GRASS) { + llassert(!gCubeSnapshot); // never do occlusion culling on cube snapshots occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -5925,6 +5941,7 @@ void LLPipeline::setupAvatarLights(bool for_edit) static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_dist) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; F32 inten = light->getLightIntensity(); if (inten < .001f) { @@ -5948,9 +5965,10 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_ void LLPipeline::calcNearbyLights(LLCamera& camera) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); - if (LLPipeline::sReflectionRender) + if (LLPipeline::sReflectionRender || gCubeSnapshot) { return; } @@ -6133,6 +6151,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) void LLPipeline::setupHWLights(LLDrawPool* pool) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); LLEnvironment& environment = LLEnvironment::instance(); @@ -7608,7 +7627,8 @@ void LLPipeline::renderFinalize() bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField; + RenderDepthOfField && + !gCubeSnapshot; bool multisample = RenderFSAASamples > 1 && mFXAABuffer.isComplete(); @@ -8196,45 +8216,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - channel = shader.enableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) + channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - mReflectionMaps.resize(8); //TODO -- declare the number of reflection maps the shader knows about somewhere sane - mReflectionMapManager.getReflectionMaps(mReflectionMaps); - LLVector3 origin[8]; //origin of refmaps in clip space - - // load modelview matrix into matrix 4a - LLMatrix4a modelview; - modelview.loadu(gGLModelView); - LLVector4a oa; // scratch space for transformed origin - - S32 count = 0; - for (auto* refmap : mReflectionMaps) - { - if (refmap) - { - LLCubeMap* cubemap = refmap->mCubeMap; - if (cubemap) - { - cubemap->enable(channel + count); - cubemap->bind(); - - modelview.affineTransform(refmap->mOrigin, oa); - origin[count].set(oa.getF32ptr()); - - count++; - } - } - } - - if (count > 0) - { - LLStaticHashedString refmapCount("refmapCount"); - LLStaticHashedString refOrigin("refOrigin"); - shader.uniform1i(refmapCount, count); - shader.uniform3fv(refOrigin, count, (F32*)origin); - setup_env_mat = true; - } + // see comments in class2/deferred/softenLightF.glsl for what these uniforms mean + mReflectionMapManager.mTexture->bind(channel); + mReflectionMapManager.setUniforms(); + setup_env_mat = true; } if (setup_env_mat) @@ -8276,7 +8264,14 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + /*if (gCubeSnapshot) + { // we only really care about the first two values, but the shader needs increasing separation between clip planes + shader.uniform4f(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1.f, 64.f, 128.f, 256.f); + } + else*/ + { + shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + } shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); @@ -8469,66 +8464,78 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) } if (RenderDeferredSSAO) - { // soften direct lighting lightmap - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); - // blur lightmap - screen_target->bindTarget(); - glClearColor(1, 1, 1, 1); - screen_target->clear(GL_COLOR_BUFFER_BIT); - glClearColor(0, 0, 0, 0); - - bindDeferredShader(gDeferredBlurLightProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - LLVector3 go = RenderShadowGaussian; - const U32 kern_length = 4; - F32 blur_size = RenderShadowBlurSize; - F32 dist_factor = RenderShadowBlurDistFactor; - - // sample symmetrically with the middle sample falling exactly on 0.0 - F32 x = 0.f; - - LLVector3 gauss[32]; // xweight, yweight, offset - - for (U32 i = 0; i < kern_length; i++) - { - gauss[i].mV[0] = llgaussian(x, go.mV[0]); - gauss[i].mV[1] = llgaussian(x, go.mV[1]); - gauss[i].mV[2] = x; - x += 1.f; + { + /*if (gCubeSnapshot) + { // SSAO and shadows disabled in reflection maps + deferred_light_target->bindTarget(); + glClearColor(1, 1, 1, 1); + deferred_light_target->clear(); + glClearColor(0, 0, 0, 0); + deferred_light_target->flush(); } + else*/ + { + // soften direct lighting lightmap + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); + // blur lightmap + screen_target->bindTarget(); + glClearColor(1, 1, 1, 1); + screen_target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0, 0, 0, 0); - 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)); + bindDeferredShader(gDeferredBlurLightProgram); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + LLVector3 go = RenderShadowGaussian; + const U32 kern_length = 4; + F32 blur_size = RenderShadowBlurSize; + F32 dist_factor = RenderShadowBlurDistFactor; - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } + // sample symmetrically with the middle sample falling exactly on 0.0 + F32 x = 0.f; + + LLVector3 gauss[32]; // xweight, yweight, offset - screen_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); + for (U32 i = 0; i < kern_length; i++) + { + gauss[i].mV[0] = llgaussian(x, go.mV[0]); + gauss[i].mV[1] = llgaussian(x, go.mV[1]); + gauss[i].mV[2] = x; + x += 1.f; + } - bindDeferredShader(gDeferredBlurLightProgram, screen_target); + 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)); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - deferred_light_target->bindTarget(); + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } - gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + screen_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + bindDeferredShader(gDeferredBlurLightProgram, screen_target); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + deferred_light_target->bindTarget(); + + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + deferred_light_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); } - deferred_light_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); } stop_glerror(); @@ -8595,7 +8602,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gPipeline.popRenderTypeMask(); } - bool render_local = RenderLocalLights; + bool render_local = RenderLocalLights; // && !gCubeSnapshot; if (render_local) { @@ -8604,9 +8611,12 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) LLDrawable::drawable_list_t spot_lights; LLDrawable::drawable_list_t fullscreen_spot_lights; - for (U32 i = 0; i < 2; i++) + if (!gCubeSnapshot) { - mTargetShadowSpotLight[i] = NULL; + for (U32 i = 0; i < 2; i++) + { + mTargetShadowSpotLight[i] = NULL; + } } std::list light_colors; @@ -8942,6 +8952,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) popRenderTypeMask(); } + if (!gCubeSnapshot) { // render highlights, etc. renderHighlights(); @@ -9053,6 +9064,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } + if (!gCubeSnapshot) { LLDrawable* potential = drawablep; //determine if this is a good light for casting shadows @@ -9146,14 +9158,10 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) } } - channel = shader.disableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) + channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - for (int i = 0; i < mReflectionMaps.size(); ++i) - { - gGL.getTexUnit(channel + i)->disable(); - } - + mReflectionMapManager.mTexture->unbind(); if (channel == 0) { gGL.getTexUnit(channel)->enable(LLTexUnit::TT_TEXTURE); @@ -9176,7 +9184,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - if (!assertInitialized()) + if (!assertInitialized() || gCubeSnapshot) { return; } @@ -9767,7 +9775,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID - 1]; - doOcclusion(shadow_cam, occlusion_source, occlusion_target); + if (occlude > 1) + { + doOcclusion(shadow_cam, occlusion_source, occlusion_target); + } if (use_shader) { @@ -10163,6 +10174,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) clip = RenderShadowOrthoClipPlanes; mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); + //if (gCubeSnapshot) + { //always do a single 64m shadow in reflection maps + mSunClipPlanes.set(64.f, 128.f, 256.f); + mSunOrthoClipPlanes.set(64.f, 128.f, 256.f); + } + //currently used for amount to extrude frusta corners for constructing shadow frusta //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; @@ -10279,9 +10296,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) // convenience array of 4 near clip plane distances F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; - if (mSunDiffuse == LLColor4::black) - { //sun diffuse is totally black, shadows don't matter + { //sun diffuse is totally shadows don't matter LLGLDepthTest depth(GL_TRUE); for (S32 j = 0; j < 4; j++) @@ -10293,7 +10309,21 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < 4; j++) + /*if (gCubeSnapshot) + { + // do one shadow split for cube snapshots, clear the rest + mSunClipPlanes.set(64.f, 64.f, 64.f); + dist[1] = dist[2] = dist[3] = dist[4] = 64.f; + for (S32 j = 1; j < 4; j++) + { + mShadow[j].bindTarget(); + mShadow[j].clear(); + mShadow[j].flush(); + } + }*/ + + //for (S32 j = 0; j < (gCubeSnapshot ? 1 : 4); j++) + for (S32 j = 0; j < 4; j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) { @@ -10672,142 +10702,145 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (gen_shadow) { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); - - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); - - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); + if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates + { + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } + } + } + + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - for (S32 i = 0; i < 2; i++) - { - set_current_modelview(saved_view); - set_current_projection(saved_proj); + if (mShadowSpotLight[i].isNull()) + { + continue; + } - if (mShadowSpotLight[i].isNull()) - { - continue; - } + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + LLDrawable* drawable = mShadowSpotLight[i]; - LLDrawable* drawable = mShadowSpotLight[i]; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); + at_axis *= quat; - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); - at_axis *= quat; + LLVector3 np = center + at_axis; + at_axis.normVec(); - LLVector3 np = center+at_axis; - at_axis.normVec(); + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); + LLVector3 origin = np - at_axis * dist; - LLVector3 origin = np - at_axis*dist; + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); - view[i+4] = glh::matrix4f((F32*) mat.mMatrix); + view[i + 4] = view[i + 4].inverse(); - view[i+4] = view[i+4].inverse(); + //get perspective matrix + F32 near_clip = dist + 0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist + volume->getLightRadius() * 1.5f; - //get perspective matrix - F32 near_clip = dist+0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist+volume->getLightRadius()*1.5f; + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width / height; - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width/height; - - proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip); + proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - set_current_modelview(view[i+4]); - set_current_projection(proj[i+4]); + set_current_modelview(view[i + 4]); + set_current_projection(proj[i + 4]); - mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; - - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i+4].m[j]; - gGLLastProjection[j] = mShadowProjection[i+4].m[j]; - } + mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; - mShadowModelview[i+4] = view[i+4]; - mShadowProjection[i+4] = proj[i+4]; + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; + gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; + } - LLCamera shadow_cam = camera; - shadow_cam.setFar(far_clip); - shadow_cam.setOrigin(origin); + mShadowModelview[i + 4] = view[i + 4]; + mShadowProjection[i + 4] = proj[i + 4]; - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + LLCamera shadow_cam = camera; + shadow_cam.setFar(far_clip); + shadow_cam.setOrigin(origin); - stop_glerror(); + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - mShadow[i+4].bindTarget(); - mShadow[i+4].getViewport(gGLViewport); - mShadow[i+4].clear(); + stop_glerror(); + + mShadow[i + 4].bindTarget(); + mShadow[i + 4].getViewport(gGLViewport); + mShadow[i + 4].clear(); - U32 target_width = mShadow[i+4].getWidth(); + U32 target_width = mShadow[i + 4].getWidth(); - static LLCullResult result[2]; + static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); - RenderSpotLight = drawable; + RenderSpotLight = drawable; - renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width); + renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], FALSE, FALSE, target_width); - RenderSpotLight = nullptr; + RenderSpotLight = nullptr; - mShadow[i+4].flush(); - } + mShadow[i + 4].flush(); + } + } } else { //no spotlight shadows @@ -11526,7 +11559,7 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) void LLPipeline::overrideEnvironmentMap() { - mReflectionMapManager.mProbes.clear(); - mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); + //mReflectionMapManager.mProbes.clear(); + //mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); } -- cgit v1.2.3 From 53c692c9597551c9a1ba8eee346432de51d9d22d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 17 May 2022 14:32:07 -0500 Subject: SL-17416 Quick 'n dirty reflection probe override hack. --- indra/newview/pipeline.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5eb9817fc4..4cf8157623 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5150,7 +5150,6 @@ void LLPipeline::renderDebug() glPointSize(1.f); } - // Debug stuff. for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) @@ -5204,6 +5203,12 @@ void LLPipeline::renderDebug() visible_selected_groups.clear(); + //draw reflection probes and links between them + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES) && !hud_only) + { + mReflectionMapManager.renderDebug(); + } + gUIProgram.bind(); if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST) && !hud_only) -- cgit v1.2.3 From 3564b24e2a90e0772c37185cc5dcedca29d62ab8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 19 May 2022 22:24:41 -0500 Subject: SL-17286 Reflection probe alpha/fullbright support. --- indra/newview/pipeline.cpp | 53 +++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4cf8157623..b4b70a3e11 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8208,30 +8208,16 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); - bool setup_env_mat = false; channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if (cube_map) { - setup_env_mat = true; cube_map->enable(channel); cube_map->bind(); } - } - channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); - if (channel > -1 && mReflectionMapManager.mTexture.notNull()) - { - // see comments in class2/deferred/softenLightF.glsl for what these uniforms mean - mReflectionMapManager.mTexture->bind(channel); - mReflectionMapManager.setUniforms(); - setup_env_mat = true; - } - - if (setup_env_mat) - { F32* m = gGLModelView; F32 mat[] = { m[0], m[1], m[2], @@ -8239,8 +8225,10 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ m[8], m[9], m[10] }; shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); - } + } + bindReflectionProbes(shader); + if (gAtmosphere) { // bind precomputed textures necessary for calculating sun and sky luminance @@ -9163,7 +9151,35 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) } } - channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP); + unbindReflectionProbes(shader); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->activate(); + shader.unbind(); +} + +void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) +{ + S32 channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) + { + // see comments in class2/deferred/softenLightF.glsl for what these uniforms mean + mReflectionMapManager.mTexture->bind(channel); + mReflectionMapManager.setUniforms(); + + F32* m = gGLModelView; + + F32 mat[] = { m[0], m[1], m[2], + m[4], m[5], m[6], + m[8], m[9], m[10] }; + + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); + } +} + +void LLPipeline::unbindReflectionProbes(LLGLSLShader& shader) +{ + S32 channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP); if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { mReflectionMapManager.mTexture->unbind(); @@ -9172,12 +9188,9 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) gGL.getTexUnit(channel)->enable(LLTexUnit::TT_TEXTURE); } } - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->activate(); - shader.unbind(); } + inline float sgn(float a) { if (a > 0.0F) return (1.0F); -- cgit v1.2.3 From 096ad1306d1a5db300592d9be87ab6762777d400 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 19 May 2022 22:36:03 -0500 Subject: SL-17286 Only update reflection probe UBO once per pipe flush --- indra/newview/pipeline.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b4b70a3e11..6ea519c71b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4504,11 +4504,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); { - // SL-15709 -- NOTE: Tracy only allows one ZoneScoped per function. - // Solutions are: - // 1. Use a new scope - // 2. Use named zones - // 3. Use transient zones LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); //LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS); LLGLEnable cull(GL_CULL_FACE); @@ -4529,6 +4524,12 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) LLGLState::checkStates(); LLGLState::checkTextureChannels(); + if (LLViewerShaderMgr::instance()->mShaderLevel[LLViewerShaderMgr::SHADER_DEFERRED] > 1) + { + //update reflection probe uniform + mReflectionMapManager.updateUniforms(); + } + U32 cur_type = 0; gGL.setColorMask(true, true); -- cgit v1.2.3 From 6c6d9a10f830e264cf75603949b54a12256cab78 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 May 2022 13:31:18 -0500 Subject: SL-17287 Update Tracy to 0.8.1. Clean up GPU instrumentation. --- indra/newview/pipeline.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6ea519c71b..8f38f7a8f4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4251,7 +4251,7 @@ U32 LLPipeline::sCurRenderPoolType = 0 ; void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); - + LL_PROFILE_GPU_ZONE("renderGeom"); assertInitialized(); F32 saved_modelview[16]; @@ -4501,8 +4501,9 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) void LLPipeline::renderGeomDeferred(LLCamera& camera) { LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); + LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); //LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS); @@ -4601,6 +4602,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLS); + LL_PROFILE_GPU_ZONE("renderGeomPostDeferred"); + U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -4697,6 +4700,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) void LLPipeline::renderGeomShadow(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("renderGeomShadow"); U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -9202,6 +9206,7 @@ inline float sgn(float a) void LLPipeline::generateWaterReflection(LLCamera& camera_in) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("generateWaterReflection"); if (!assertInitialized() || gCubeSnapshot) { @@ -10082,6 +10087,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW); + LL_PROFILE_GPU_ZONE("generateSunShadow"); bool skip_avatar_update = false; if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) @@ -10932,6 +10938,7 @@ static LLTrace::BlockTimerStatHandle FTM_GENERATE_IMPOSTOR("Generate Impostor"); void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) { LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); + LL_PROFILE_GPU_ZONE("generateImpostor"); LLGLState::checkStates(); LLGLState::checkTextureChannels(); @@ -11175,7 +11182,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) if (LLPipeline::sRenderDeferred) { GLuint buff = GL_COLOR_ATTACHMENT0; - LL_PROFILER_GPU_ZONEC( "gl.DrawBuffersARB", 0x8000FF ); glDrawBuffersARB(1, &buff); } -- cgit v1.2.3 From 6eaf8521abae0deeb1162f9c61747183110176b0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 May 2022 19:05:28 -0500 Subject: SL-17287 Instrument and optimize cubemap render. Fix for cubemap snapshots doing a full resolution render instead of a 512x512 render. --- indra/newview/pipeline.cpp | 264 ++++++++++++++++++++++++--------------------- 1 file changed, 140 insertions(+), 124 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8f38f7a8f4..2790628a46 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -406,9 +406,7 @@ LLPipeline::LLPipeline() : mWLSkyPool(NULL), mLightMask(0), mLightMovingMask(0), - mLightingDetail(0), - mScreenWidth(0), - mScreenHeight(0) + mLightingDetail(0) { mNoiseMap = 0; mTrueNoiseMap = 0; @@ -437,6 +435,8 @@ void LLPipeline::init() { refreshCachedSettings(); + mRT = new RenderTargetPack(); + gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); @@ -694,6 +694,9 @@ void LLPipeline::cleanup() mDeferredVB = NULL; mCubeVB = NULL; + + delete mRT; + mRT = nullptr; } //============================================================================ @@ -735,7 +738,7 @@ void LLPipeline::requestResizeShadowTexture() void LLPipeline::resizeShadowTexture() { releaseShadowTargets(); - allocateShadowBuffer(mScreenWidth, mScreenHeight); + allocateShadowBuffer(mRT->width, mRT->height); gResizeShadowTexture = FALSE; } @@ -746,7 +749,7 @@ void LLPipeline::resizeScreenTexture() GLuint resX = gViewerWindow->getWorldViewWidthRaw(); GLuint resY = gViewerWindow->getWorldViewHeightRaw(); - if (gResizeScreenTexture || (resX != mScreen.getWidth()) || (resY != mScreen.getHeight())) + if (gResizeScreenTexture || (resX != mRT->screen.getWidth()) || (resY != mRT->screen.getHeight())) { releaseScreenBuffers(); releaseShadowTargets(); @@ -834,8 +837,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // remember these dimensions - mScreenWidth = resX; - mScreenHeight = resY; + mRT->width = resX; + mRT->height = resY; U32 res_mod = RenderResolutionDivisor; @@ -847,7 +850,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (RenderUIBuffer) { - if (!mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) + if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) { return false; } @@ -861,10 +864,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 occlusion_divisor = 3; //allocate deferred rendering color buffers - if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!mOcclusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!addDeferredAttachments(mDeferredScreen)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16; if (gGLManager.mIsAMD) @@ -877,23 +880,23 @@ 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 (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) { - if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; } else { - mFXAABuffer.release(); + mRT->fxaaBuffer.release(); } if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) - { //only need mDeferredLight for shadows OR ssao OR dof OR fxaa - if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; } else { - mDeferredLight.release(); + mRT->deferredLight.release(); } allocateShadowBuffer(resX, resY); @@ -906,22 +909,22 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) } else { - mDeferredLight.release(); + mRT->deferredLight.release(); releaseShadowTargets(); - mFXAABuffer.release(); - mScreen.release(); - mDeferredScreen.release(); //make sure to release any render targets that share a depth buffer with mDeferredScreen first - mDeferredDepth.release(); - mOcclusionDepth.release(); + mRT->fxaaBuffer.release(); + mRT->screen.release(); + mRT->deferredScreen.release(); //make sure to release any render targets that share a depth buffer with mRT->deferredScreen first + mRT->deferredDepth.release(); + mRT->occlusionDepth.release(); - if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; } if (LLPipeline::sRenderDeferred) { //share depth buffer between deferred targets - mDeferredScreen.shareDepthBuffer(mScreen); + mRT->deferredScreen.shareDepthBuffer(mRT->screen); } gGL.getTexUnit(0)->disable(); @@ -951,12 +954,12 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { //allocate 4 sun shadow maps for (U32 i = 0; i < 4; i++) { - if (!mShadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - if (!mShadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } @@ -979,11 +982,11 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) U32 spot_shadow_map_height = height; for (U32 i = 4; i < 6; i++) { - if (!mShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) + if (!mRT->shadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) { return false; } - if (!mShadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) + if (!mRT->shadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) { return false; } @@ -1174,21 +1177,21 @@ void LLPipeline::releaseShadowBuffers() void LLPipeline::releaseScreenBuffers() { - mUIScreen.release(); - mScreen.release(); - mFXAABuffer.release(); + mRT->uiScreen.release(); + mRT->screen.release(); + mRT->fxaaBuffer.release(); mPhysicsDisplay.release(); - mDeferredScreen.release(); - mDeferredDepth.release(); - mDeferredLight.release(); - mOcclusionDepth.release(); + mRT->deferredScreen.release(); + mRT->deferredDepth.release(); + mRT->deferredLight.release(); + mRT->occlusionDepth.release(); } void LLPipeline::releaseShadowTarget(U32 index) { - mShadow[index].release(); - mShadowOcclusion[index].release(); + mRT->shadow[index].release(); + mRT->shadowOcclusion[index].release(); } void LLPipeline::releaseShadowTargets() @@ -1231,8 +1234,8 @@ void LLPipeline::createGLBuffers() } allocateScreenBuffer(resX, resY); - mScreenWidth = 0; - mScreenHeight = 0; + mRT->width = 0; + mRT->height = 0; if (sRenderDeferred) { @@ -2333,11 +2336,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { if (LLPipeline::sRenderDeferred && can_use_occlusion) { - mOcclusionDepth.bindTarget(); + mRT->occlusionDepth.bindTarget(); } else { - mScreen.bindTarget(); + mRT->screen.bindTarget(); } } @@ -2459,11 +2462,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { if (LLPipeline::sRenderDeferred && can_use_occlusion) { - mOcclusionDepth.flush(); + mRT->occlusionDepth.flush(); } else { - mScreen.flush(); + mRT->screen.flush(); } } } @@ -4631,7 +4634,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); LLGLSLShader::bindNoShader(); - doOcclusion(camera, mScreen, mOcclusionDepth, &mDeferredDepth); + doOcclusion(camera, mRT->screen, mRT->occlusionDepth, &mRT->deferredDepth); gGL.setColorMask(true, false); } @@ -7484,9 +7487,11 @@ void LLPipeline::renderFinalize() } LLVector2 tc1(0, 0); - LLVector2 tc2((F32) mScreen.getWidth() * 2, (F32) mScreen.getHeight() * 2); + LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); + LL_PROFILE_GPU_ZONE("renderFinalize"); + gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -7508,6 +7513,7 @@ void LLPipeline::renderFinalize() if (sRenderGlow) { + LL_PROFILE_GPU_ZONE("glow"); mGlow[2].bindTarget(); mGlow[2].clear(); @@ -7532,7 +7538,7 @@ void LLPipeline::renderFinalize() gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - mScreen.bindTexture(0, 0, LLTexUnit::TFO_POINT); + mRT->screen.bindTexture(0, 0, LLTexUnit::TFO_POINT); gGL.color4f(1, 1, 1, 1); gPipeline.enableLightsFullbright(); @@ -7548,7 +7554,7 @@ void LLPipeline::renderFinalize() gGL.end(); - gGL.getTexUnit(0)->unbind(mScreen.getUsage()); + gGL.getTexUnit(0)->unbind(mRT->screen.getUsage()); mGlow[2].flush(); @@ -7626,7 +7632,7 @@ void LLPipeline::renderFinalize() gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - tc2.setVec((F32) mScreen.getWidth(), (F32) mScreen.getHeight()); + tc2.setVec((F32) mRT->screen.getWidth(), (F32) mRT->screen.getHeight()); gGL.flush(); @@ -7634,18 +7640,18 @@ void LLPipeline::renderFinalize() if (LLPipeline::sRenderDeferred) { - bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && RenderDepthOfField && !gCubeSnapshot; - bool multisample = RenderFSAASamples > 1 && mFXAABuffer.isComplete(); + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); gViewerWindow->setup3DViewport(); if (dof_enabled) { + LL_PROFILE_GPU_ZONE("dof"); LLGLSLShader *shader = &gDeferredPostProgram; LLGLDisable blend(GL_BLEND); @@ -7730,7 +7736,7 @@ void LLPipeline::renderFinalize() const F32 default_fov = CameraFieldOfView * F_PI / 180.f; - // F32 aspect_ratio = (F32) mScreen.getWidth()/(F32)mScreen.getHeight(); + // F32 aspect_ratio = (F32) mRT->screen.getWidth()/(F32)mRT->screen.getHeight(); F32 dv = 2.f * default_focal_length * tanf(default_fov / 2.f); @@ -7750,15 +7756,15 @@ void LLPipeline::renderFinalize() F32 magnification = focal_length / (subject_distance - focal_length); { // build diffuse+bloom+CoF - mDeferredLight.bindTarget(); + mRT->deferredLight.bindTarget(); shader = &gDeferredCoFProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mRT->screen.bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); @@ -7781,23 +7787,23 @@ void LLPipeline::renderFinalize() gGL.end(); unbindDeferredShader(*shader); - mDeferredLight.flush(); + mRT->deferredLight.flush(); } - U32 dof_width = (U32)(mScreen.getWidth() * CameraDoFResScale); - U32 dof_height = (U32)(mScreen.getHeight() * CameraDoFResScale); + U32 dof_width = (U32)(mRT->screen.getWidth() * CameraDoFResScale); + U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); { // perform DoF sampling at half-res (preserve alpha channel) - mScreen.bindTarget(); + mRT->screen.bindTarget(); glViewport(0, 0, dof_width, dof_height); gGL.setColorMask(true, false); shader = &gDeferredPostProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); if (channel > -1) { - mDeferredLight.bindTexture(0, channel); + mRT->deferredLight.bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); @@ -7816,15 +7822,15 @@ void LLPipeline::renderFinalize() gGL.end(); unbindDeferredShader(*shader); - mScreen.flush(); + mRT->screen.flush(); gGL.setColorMask(true, true); } { // combine result based on alpha if (multisample) { - mDeferredLight.bindTarget(); - glViewport(0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); + mRT->deferredLight.bindTarget(); + glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); } else { @@ -7838,10 +7844,10 @@ void LLPipeline::renderFinalize() shader = &gDeferredDoFCombineProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mRT->screen.bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); @@ -7865,24 +7871,25 @@ void LLPipeline::renderFinalize() if (multisample) { - mDeferredLight.flush(); + mRT->deferredLight.flush(); } } } else { + LL_PROFILE_GPU_ZONE("no dof"); if (multisample) { - mDeferredLight.bindTarget(); + mRT->deferredLight.bindTarget(); } LLGLSLShader *shader = &gDeferredPostNoDoFProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mRT->screen.bindTexture(0, channel); } gGL.begin(LLRender::TRIANGLE_STRIP); @@ -7901,17 +7908,18 @@ void LLPipeline::renderFinalize() if (multisample) { - mDeferredLight.flush(); + mRT->deferredLight.flush(); } } if (multisample) { + LL_PROFILE_GPU_ZONE("aa"); // bake out texture2D with RGBL for FXAA shader - mFXAABuffer.bindTarget(); + mRT->fxaaBuffer.bindTarget(); - S32 width = mScreen.getWidth(); - S32 height = mScreen.getHeight(); + S32 width = mRT->screen.getWidth(); + S32 height = mRT->screen.getHeight(); glViewport(0, 0, width, height); LLGLSLShader *shader = &gGlowCombineFXAAProgram; @@ -7919,10 +7927,10 @@ void LLPipeline::renderFinalize() shader->bind(); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); if (channel > -1) { - mDeferredLight.bindTexture(0, channel); + mRT->deferredLight.bindTexture(0, channel); } gGL.begin(LLRender::TRIANGLE_STRIP); @@ -7933,18 +7941,18 @@ void LLPipeline::renderFinalize() gGL.flush(); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); shader->unbind(); - mFXAABuffer.flush(); + mRT->fxaaBuffer.flush(); shader = &gFXAAProgram; shader->bind(); - channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mFXAABuffer.getUsage()); + channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); if (channel > -1) { - mFXAABuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; @@ -7953,8 +7961,8 @@ void LLPipeline::renderFinalize() gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - F32 scale_x = (F32) width / mFXAABuffer.getWidth(); - F32 scale_y = (F32) height / mFXAABuffer.getHeight(); + F32 scale_x = (F32) width / mRT->fxaaBuffer.getWidth(); + F32 scale_y = (F32) height / mRT->fxaaBuffer.getHeight(); shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f / width * scale_x, 1.f / height * scale_y); shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f / width * scale_x, -0.5f / height * scale_y, @@ -8005,7 +8013,7 @@ void LLPipeline::renderFinalize() gGlowCombineProgram.bind(); gGL.getTexUnit(0)->bind(&mGlow[1]); - gGL.getTexUnit(1)->bind(&mScreen); + gGL.getTexUnit(1)->bind(&mRT->screen); LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); @@ -8048,10 +8056,10 @@ void LLPipeline::renderFinalize() gSplatTextureRectProgram.unbind(); } - if (LLRenderTarget::sUseFBO) - { // copy depth buffer from mScreen to framebuffer - LLRenderTarget::copyContentsToFramebuffer(mScreen, 0, 0, mScreen.getWidth(), mScreen.getHeight(), 0, 0, - mScreen.getWidth(), mScreen.getHeight(), + if (LLRenderTarget::sUseFBO && !gCubeSnapshot) + { // copy depth buffer from mRT->screen to framebuffer + LLRenderTarget::copyContentsToFramebuffer(mRT->screen, 0, 0, mRT->screen.getWidth(), mRT->screen.getHeight(), 0, 0, + mRT->screen.getWidth(), mRT->screen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); } @@ -8069,10 +8077,10 @@ void LLPipeline::renderFinalize() void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - - LLRenderTarget* deferred_target = &mDeferredScreen; - LLRenderTarget* deferred_depth_target = &mDeferredDepth; - LLRenderTarget* deferred_light_target = &mDeferredLight; + LL_PROFILE_GPU_ZONE("bindDeferredShader"); + LLRenderTarget* deferred_target = &mRT->deferredScreen; + LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget* deferred_light_target = &mRT->deferredLight; shader.bind(); S32 channel = 0; @@ -8304,8 +8312,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); - shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mShadow[0].getWidth(), mShadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mRT->shadow[4].getWidth(), mRT->shadow[4].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); @@ -8341,14 +8349,15 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f) void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("renderDeferredLighting"); if (!sCull) { return; } - LLRenderTarget *deferred_target = &mDeferredScreen; - LLRenderTarget *deferred_depth_target = &mDeferredDepth; - LLRenderTarget *deferred_light_target = &mDeferredLight; + LLRenderTarget *deferred_target = &mRT->deferredScreen; + LLRenderTarget *deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget *deferred_light_target = &mRT->deferredLight; { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); @@ -8415,6 +8424,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) if (RenderDeferredSSAO || RenderShadowDetail > 0) { + LL_PROFILE_GPU_ZONE("sun program"); deferred_light_target->bindTarget(); { // paint shadow/SSAO light map (direct lighting lightmap) LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - sun shadow"); @@ -8475,6 +8485,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { // soften direct lighting lightmap LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); + LL_PROFILE_GPU_ZONE("soften shadow"); // blur lightmap screen_target->bindTarget(); glClearColor(1, 1, 1, 1); @@ -8554,6 +8565,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) LLGLSLShader &soften_shader = LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram; LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - atmospherics"); + LL_PROFILE_GPU_ZONE("atmospherics"); bindDeferredShader(soften_shader); LLEnvironment &environment = LLEnvironment::instance(); @@ -8623,6 +8635,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - local lights"); + LL_PROFILE_GPU_ZONE("local lights"); bindDeferredShader(gDeferredLightProgram); if (mCubeVB.isNull()) @@ -8729,6 +8742,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) if (!spot_lights.empty()) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - projectors"); + LL_PROFILE_GPU_ZONE("projectors"); LLGLDepthTest depth(GL_TRUE, GL_FALSE); bindDeferredShader(gDeferredSpotLightProgram); @@ -8775,7 +8789,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - fullscreen lights"); LLGLDepthTest depth(GL_FALSE); - + LL_PROFILE_GPU_ZONE("fullscreen lights"); // full screen blit gGL.pushMatrix(); gGL.loadIdentity(); @@ -8871,6 +8885,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gGL.loadIdentity(); { + LL_PROFILE_GPU_ZONE("gamma correct"); LLGLDepthTest depth(GL_FALSE, GL_FALSE); LLVector2 tc1(0, 0); @@ -9114,9 +9129,9 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { - LLRenderTarget* deferred_target = &mDeferredScreen; - LLRenderTarget* deferred_depth_target = &mDeferredDepth; - LLRenderTarget* deferred_light_target = &mDeferredLight; + LLRenderTarget* deferred_target = &mRT->deferredScreen; + LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget* deferred_light_target = &mRT->deferredLight; stop_glerror(); shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); @@ -9653,7 +9668,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowCubeProgram.bind(); } - LLRenderTarget& occlusion_target = mShadowOcclusion[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_target = mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - 1]; occlusion_target.bindTarget(); updateCull(shadow_cam, result); @@ -9797,7 +9812,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_source = mRT->shadow[LLViewerCamera::sCurCameraID - 1]; if (occlude > 1) { @@ -10023,7 +10038,8 @@ void LLPipeline::generateHighlight(LLCamera& camera) { mHighlightSet.insert(HighlightItem(mHighlightObject)); } - + llassert(!gCubeSnapshot); + if (!mHighlightSet.empty()) { F32 transition = gFrameIntervalSeconds.value()/RenderHighlightFadeTime; @@ -10073,7 +10089,7 @@ void LLPipeline::generateHighlight(LLCamera& camera) LLRenderTarget* LLPipeline::getShadowTarget(U32 i) { - return &mShadow[i]; + return &mRT->shadow[i]; } static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); @@ -10327,9 +10343,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) for (S32 j = 0; j < 4; j++) { - mShadow[j].bindTarget(); - mShadow[j].clear(); - mShadow[j].flush(); + mRT->shadow[j].bindTarget(); + mRT->shadow[j].clear(); + mRT->shadow[j].flush(); } } else @@ -10341,9 +10357,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) dist[1] = dist[2] = dist[3] = dist[4] = 64.f; for (S32 j = 1; j < 4; j++) { - mShadow[j].bindTarget(); - mShadow[j].clear(); - mShadow[j].flush(); + mRT->shadow[j].bindTarget(); + mRT->shadow[j].clear(); + mRT->shadow[j].flush(); } }*/ @@ -10409,12 +10425,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowCamera[j+4] = shadow_cam; } - mShadow[j].bindTarget(); + mRT->shadow[j].bindTarget(); { LLGLDepthTest depth(GL_TRUE); - mShadow[j].clear(); + mRT->shadow[j].clear(); } - mShadow[j].flush(); + mRT->shadow[j].flush(); mShadowError.mV[j] = 0.f; mShadowFOV.mV[j] = 0.f; @@ -10701,18 +10717,18 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mShadow[j].bindTarget(); - mShadow[j].getViewport(gGLViewport); - mShadow[j].clear(); + mRT->shadow[j].bindTarget(); + mRT->shadow[j].getViewport(gGLViewport); + mRT->shadow[j].clear(); - U32 target_width = mShadow[j].getWidth(); + U32 target_width = mRT->shadow[j].getWidth(); { static LLCullResult result[4]; renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, FALSE, target_width); } - mShadow[j].flush(); + mRT->shadow[j].flush(); if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) { @@ -10847,11 +10863,11 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mShadow[i + 4].bindTarget(); - mShadow[i + 4].getViewport(gGLViewport); - mShadow[i + 4].clear(); + mRT->shadow[i + 4].bindTarget(); + mRT->shadow[i + 4].getViewport(gGLViewport); + mRT->shadow[i + 4].clear(); - U32 target_width = mShadow[i + 4].getWidth(); + U32 target_width = mRT->shadow[i + 4].getWidth(); static LLCullResult result[2]; @@ -10863,7 +10879,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = nullptr; - mShadow[i + 4].flush(); + mRT->shadow[i + 4].flush(); } } } -- cgit v1.2.3 From 0940e8871894e08da80730d11c31cbd252a05b35 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 24 May 2022 10:34:47 -0500 Subject: SL-17472 Add checkbox to preferences for enabling "PBR" that uses "class3" deferred shaders. Move reflection probe shaders to class3 and restore class2 shaders to non-reflection probe versions. --- indra/newview/pipeline.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2790628a46..55819449c6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -351,6 +351,7 @@ bool LLPipeline::sRenderFrameTest = false; bool LLPipeline::sRenderAttachedLights = true; bool LLPipeline::sRenderAttachedParticles = true; bool LLPipeline::sRenderDeferred = false; +bool LLPipeline::sRenderPBR = false; S32 LLPipeline::sVisibleLightCount = 0; bool LLPipeline::sRenderingHUDs; F32 LLPipeline::sDistortionWaterClipPlaneMargin = 1.0125f; @@ -541,6 +542,7 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("UseOcclusion"); connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders"); connectRefreshCachedSettingsSafe("RenderDeferred"); + connectRefreshCachedSettingsSafe("RenderPBR"); connectRefreshCachedSettingsSafe("RenderDeferredSunWash"); connectRefreshCachedSettingsSafe("RenderFSAASamples"); connectRefreshCachedSettingsSafe("RenderResolutionDivisor"); @@ -1025,6 +1027,7 @@ void LLPipeline::updateRenderDeferred() LLPipeline::sRenderBump && WindLightUseAtmosShaders && (bool) LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"); + sRenderPBR = sRenderDeferred && gSavedSettings.getBOOL("RenderPBR"); } // static @@ -2597,6 +2600,7 @@ void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderT void LLPipeline::doOcclusion(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("doOcclusion"); if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { @@ -9633,7 +9637,7 @@ static LLTrace::BlockTimerStatHandle FTM_SHADOW_FULLBRIGHT_ALPHA_MASKED("Fullbri void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult& result, bool use_shader, bool use_occlusion, U32 target_width) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_SHADOW_RENDER); - + LL_PROFILE_GPU_ZONE("renderShadow"); //disable occlusion culling for shadow passes (save setting to restore later) S32 occlude = LLPipeline::sUseOcclusion; if (!use_occlusion) @@ -9720,7 +9724,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera } LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow simple"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE); - + LL_PROFILE_GPU_ZONE("shadow simple"); gGL.getTexUnit(0)->disable(); for (U32 i = 0; i < sizeof(types) / sizeof(U32); ++i) { @@ -9753,7 +9757,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); - + LL_PROFILE_GPU_ZONE("shadow alpha"); for (int i = 0; i < 2; ++i) { bool rigged = i == 1; -- cgit v1.2.3 From 0d9c23372bf8b34387b7d9de89234d3e9a5fd879 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 14:09:33 -0500 Subject: SL-17551 Add "Select Reflection Probes" menu option and make invisible objects less annoying when alt-zooming in edit mode. --- indra/newview/pipeline.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3332185bfd..20a21a685c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6988,7 +6988,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, face_hit, &position, NULL, NULL, NULL); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, face_hit, &position, NULL, NULL, NULL); if (hit) { drawable = hit; @@ -7016,6 +7016,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -7049,7 +7050,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(j); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7106,7 +7107,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { LLVector4a delta; @@ -7194,7 +7195,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, face_hit, intersection, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7695,7 +7696,7 @@ void LLPipeline::renderFinalize() LLVector4a result; result.clear(); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, NULL, &result); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); focus_point.set(result.getF32ptr()); } -- cgit v1.2.3 From 03d85bfb33f53e658256d8bedcf0b4262226cf90 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 19:43:21 -0500 Subject: SL-17573 Add "dynamic" checkbox, also followup on SL-17551 and do "Select Invisible Objects" checkbox instead of "Select Reflection Probes" --- indra/newview/pipeline.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 20a21a685c..28dc3781ba 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6734,15 +6734,6 @@ void LLPipeline::toggleRenderType(U32 type) //static void LLPipeline::toggleRenderTypeControl(U32 type) { - U32 bit = (1< Date: Fri, 10 Jun 2022 01:13:41 -0500 Subject: SL-17574 Add probe detail combo box to advanced graphics preferences. Fix spot light shadows not working in probes. --- indra/newview/pipeline.cpp | 387 ++++++++++++++++++++++++--------------------- 1 file changed, 210 insertions(+), 177 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 28dc3781ba..8bac5131cf 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -739,7 +739,8 @@ void LLPipeline::requestResizeShadowTexture() void LLPipeline::resizeShadowTexture() { - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); allocateShadowBuffer(mRT->width, mRT->height); gResizeShadowTexture = FALSE; } @@ -754,7 +755,8 @@ void LLPipeline::resizeScreenTexture() if (gResizeScreenTexture || (resX != mRT->screen.getWidth()) || (resY != mRT->screen.getHeight())) { releaseScreenBuffers(); - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); allocateScreenBuffer(resX,resY); gResizeScreenTexture = FALSE; } @@ -913,7 +915,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { mRT->deferredLight.release(); - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); mRT->fxaaBuffer.release(); mRT->screen.release(); @@ -942,66 +945,66 @@ inline U32 BlurHappySize(U32 x, F32 scale) { return U32( x * scale + 16.0f) & ~0 bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - if (LLPipeline::sRenderDeferred) - { - S32 shadow_detail = RenderShadowDetail; + if (LLPipeline::sRenderDeferred) + { + S32 shadow_detail = RenderShadowDetail; - const U32 occlusion_divisor = 3; + const U32 occlusion_divisor = 3; - F32 scale = llmax(0.f,RenderShadowResolutionScale); - U32 sun_shadow_map_width = BlurHappySize(resX, scale); - U32 sun_shadow_map_height = BlurHappySize(resY, scale); + F32 scale = llmax(0.f, RenderShadowResolutionScale); + U32 sun_shadow_map_width = BlurHappySize(resX, scale); + U32 sun_shadow_map_height = BlurHappySize(resY, scale); - if (shadow_detail > 0) - { //allocate 4 sun shadow maps - for (U32 i = 0; i < 4; i++) - { - if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (shadow_detail > 0) + { //allocate 4 sun shadow maps + for (U32 i = 0; i < 4; i++) + { + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width / occlusion_divisor, sun_shadow_map_height / occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - } - } - else - { - for (U32 i = 0; i < 4; i++) - { - releaseShadowTarget(i); - } - } + } + } + else + { + for (U32 i = 0; i < 4; i++) + { + releaseSunShadowTarget(i); + } + } - U32 width = (U32) (resX*scale); - U32 height = width; + if (!gCubeSnapshot) // hack to not allocate spot shadow maps during ReflectionMapManager init + { + U32 width = (U32)(resX * scale); + U32 height = width; - if (shadow_detail > 1) - { //allocate two spot shadow maps - U32 spot_shadow_map_width = width; - U32 spot_shadow_map_height = height; - for (U32 i = 4; i < 6; i++) - { - if (!mRT->shadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) - { - return false; - } - if (!mRT->shadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) - { - return false; - } - } + if (shadow_detail > 1) + { //allocate two spot shadow maps + U32 spot_shadow_map_width = width; + U32 spot_shadow_map_height = height; + for (U32 i = 0; i < 2; i++) + { + if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) + { + return false; + } + if (!mSpotShadowOcclusion[i].allocate(spot_shadow_map_width / occlusion_divisor, height / occlusion_divisor, 0, TRUE, FALSE)) + { + return false; + } + } + } + else + { + releaseSpotShadowTargets(); + } } - else - { - for (U32 i = 4; i < 6; i++) - { - releaseShadowTarget(i); - } - } - } + } return true; } @@ -1175,7 +1178,8 @@ void LLPipeline::releaseLUTBuffers() void LLPipeline::releaseShadowBuffers() { - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); } void LLPipeline::releaseScreenBuffers() @@ -1191,20 +1195,33 @@ void LLPipeline::releaseScreenBuffers() } -void LLPipeline::releaseShadowTarget(U32 index) +void LLPipeline::releaseSunShadowTarget(U32 index) { + llassert(index < 4); mRT->shadow[index].release(); mRT->shadowOcclusion[index].release(); } -void LLPipeline::releaseShadowTargets() +void LLPipeline::releaseSunShadowTargets() { - for (U32 i = 0; i < 6; i++) + for (U32 i = 0; i < 4; i++) { - releaseShadowTarget(i); + releaseSunShadowTarget(i); } } +void LLPipeline::releaseSpotShadowTargets() +{ + if (!gCubeSnapshot) // hack to avoid freeing spot shadows during ReflectionMapManager init + { + for (U32 i = 0; i < 2; i++) + { + mSpotShadow[i].release(); + mSpotShadowOcclusion[i].release(); + } + } +} + void LLPipeline::createGLBuffers() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -8162,7 +8179,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ for (U32 i = 0; i < 4; i++) { - LLRenderTarget* shadow_target = getShadowTarget(i); + LLRenderTarget* shadow_target = getSunShadowTarget(i); if (shadow_target) { channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE); @@ -8170,7 +8187,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ if (channel > -1) { stop_glerror(); - gGL.getTexUnit(channel)->bind(getShadowTarget(i), TRUE); + gGL.getTexUnit(channel)->bind(getSunShadowTarget(i), TRUE); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); @@ -8182,27 +8199,27 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - for (U32 i = 4; i < 6; i++) - { - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i); - stop_glerror(); - if (channel > -1) - { - stop_glerror(); - LLRenderTarget* shadow_target = getShadowTarget(i); - if (shadow_target) - { - gGL.getTexUnit(channel)->bind(shadow_target, TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - stop_glerror(); - } - } - } + for (U32 i = 4; i < 6; i++) + { + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i); + stop_glerror(); + if (channel > -1) + { + stop_glerror(); + LLRenderTarget* shadow_target = getSpotShadowTarget(i-4); + if (shadow_target) + { + gGL.getTexUnit(channel)->bind(shadow_target, TRUE); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + stop_glerror(); + } + } + } stop_glerror(); @@ -8313,7 +8330,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mRT->shadow[4].getWidth(), mRT->shadow[4].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mSpotShadow[0].getWidth(), mSpotShadow[0].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); @@ -9077,7 +9094,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } - if (!gCubeSnapshot) + //if (!gCubeSnapshot) { LLDrawable* potential = drawablep; //determine if this is a good light for casting shadows @@ -9668,7 +9685,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowCubeProgram.bind(); } - LLRenderTarget& occlusion_target = mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_target = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? + mSpotShadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : + mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; occlusion_target.bindTarget(); updateCull(shadow_cam, result); @@ -9812,7 +9831,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLRenderTarget& occlusion_source = mRT->shadow[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_source = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? + mSpotShadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : + mRT->shadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; if (occlude > 1) { @@ -10087,11 +10108,18 @@ void LLPipeline::generateHighlight(LLCamera& camera) } } -LLRenderTarget* LLPipeline::getShadowTarget(U32 i) +LLRenderTarget* LLPipeline::getSunShadowTarget(U32 i) { + llassert(i < 4); return &mRT->shadow[i]; } +LLRenderTarget* LLPipeline::getSpotShadowTarget(U32 i) +{ + llassert(i < 2); + return &mSpotShadow[i]; +} + static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_RENDER("Spot Shadow Render"); @@ -10371,7 +10399,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowFrustPoints[j].clear(); } - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SUN_SHADOW0+j); //restore render matrices set_current_modelview(saved_view); @@ -10745,116 +10773,119 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); - - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); - - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } - - for (S32 i = 0; i < 2; i++) - { - set_current_modelview(saved_view); - set_current_projection(saved_proj); + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i] + fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i] - fade_amt, 0.f); - if (mShadowSpotLight[i].isNull()) - { - continue; + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i + 1) % 2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } } + } + } - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + if (mShadowSpotLight[i].isNull()) + { + continue; + } - LLDrawable* drawable = mShadowSpotLight[i]; + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + LLDrawable* drawable = mShadowSpotLight[i]; - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); - at_axis *= quat; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLVector3 np = center + at_axis; - at_axis.normVec(); + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); + at_axis *= quat; - LLVector3 origin = np - at_axis * dist; + LLVector3 np = center + at_axis; + at_axis.normVec(); - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); - view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); + LLVector3 origin = np - at_axis * dist; - view[i + 4] = view[i + 4].inverse(); + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - //get perspective matrix - F32 near_clip = dist + 0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist + volume->getLightRadius() * 1.5f; + view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width / height; + view[i + 4] = view[i + 4].inverse(); - proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); + //get perspective matrix + F32 near_clip = dist + 0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist + volume->getLightRadius() * 1.5f; - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width / height; - set_current_modelview(view[i + 4]); - set_current_projection(proj[i + 4]); + proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); - mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; - gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; - } + set_current_modelview(view[i + 4]); + set_current_projection(proj[i + 4]); - mShadowModelview[i + 4] = view[i + 4]; - mShadowProjection[i + 4] = proj[i + 4]; + mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; + gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; + } + + mShadowModelview[i + 4] = view[i + 4]; + mShadowProjection[i + 4] = proj[i + 4]; + + if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates + { LLCamera shadow_cam = camera; shadow_cam.setFar(far_clip); shadow_cam.setOrigin(origin); @@ -10863,15 +10894,17 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mRT->shadow[i + 4].bindTarget(); - mRT->shadow[i + 4].getViewport(gGLViewport); - mRT->shadow[i + 4].clear(); + // + + mSpotShadow[i].bindTarget(); + mSpotShadow[i].getViewport(gGLViewport); + mSpotShadow[i].clear(); - U32 target_width = mRT->shadow[i + 4].getWidth(); + U32 target_width = mSpotShadow[i].getWidth(); static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); RenderSpotLight = drawable; @@ -10879,7 +10912,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = nullptr; - mRT->shadow[i + 4].flush(); + mSpotShadow[i].flush(); } } } -- cgit v1.2.3 From fb5ff6a5388dc9622089e9937e8d81bc319cf3dd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 17 Jun 2022 14:05:18 -0500 Subject: SL-17287 Slightly less hacky and much less crash cube snapshot render target allocation. --- indra/newview/pipeline.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8bac5131cf..028a0db95c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -436,7 +436,7 @@ void LLPipeline::init() { refreshCachedSettings(); - mRT = new RenderTargetPack(); + mRT = &mMainRT; gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); @@ -696,9 +696,6 @@ void LLPipeline::cleanup() mDeferredVB = NULL; mCubeVB = NULL; - - delete mRT; - mRT = nullptr; } //============================================================================ @@ -840,6 +837,16 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + if (mRT == &mMainRT) + { // hacky -- allocate auxillary buffer + gCubeSnapshot = TRUE; + mRT = &mAuxillaryRT; + U32 res = LL_REFLECTION_PROBE_RESOLUTION * 2; + allocateScreenBuffer(res, res, 0); + mRT = &mMainRT; + gCubeSnapshot = FALSE; + } + // remember these dimensions mRT->width = resX; mRT->height = resY; -- cgit v1.2.3 From 36d9fa90150d30a0a0851cc0da87531014c1d93d Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 21 Jun 2022 16:31:35 -0700 Subject: SL-17274: Add view_dir uniform --- indra/newview/pipeline.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 028a0db95c..1981f48500 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8596,6 +8596,12 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + if(LLPipeline::sRenderPBR) + { + LLVector3 cameraAtAxis = LLViewerCamera::getInstance()->getAtAxis(); + soften_shader.uniform3fv(LLShaderMgr::DEFERRED_VIEW_DIR, 1, cameraAtAxis.mV); + } + { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From d0d1b832d4983f35ab29947eb6fda54a8aa48f8a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Jun 2022 13:25:50 -0500 Subject: SL-17600 Proper irradiance probes. --- indra/newview/pipeline.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 028a0db95c..06c9d3c136 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9205,10 +9205,22 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) { S32 channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); + bool bound = false; if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - // see comments in class2/deferred/softenLightF.glsl for what these uniforms mean mReflectionMapManager.mTexture->bind(channel); + bound = true; + } + + channel = shader.enableTexture(LLShaderMgr::IRRADIANCE_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); + if (channel > -1 && mReflectionMapManager.mIrradianceMaps.notNull()) + { + mReflectionMapManager.mIrradianceMaps->bind(channel); + bound = true; + } + + if (bound) + { mReflectionMapManager.setUniforms(); F32* m = gGLModelView; -- cgit v1.2.3 From 033705e89efed1648a87f130a59da78c377a56aa Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 23 Jun 2022 14:04:33 -0700 Subject: SL-17273: Fix off-by-one bug in gPoolNames, fix formatting so it can't happen in the future --- indra/newview/pipeline.cpp | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 030c7b450d..21171701e1 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -281,29 +281,33 @@ static LLStaticHashedString sKern("kern"); static LLStaticHashedString sKernScale("kern_scale"); //---------------------------------------- -std::string gPoolNames[] = +#if 0 +std::string gPoolNames[LLDrawPool::NUM_POOL_TYPES] = { // Correspond to LLDrawpool enum render type - "NONE", - "POOL_SIMPLE", - "POOL_GROUND", - "POOL_FULLBRIGHT", - "POOL_BUMP", - "POOL_MATERIALS", - "POOL_TERRAIN," - "POOL_SKY", - "POOL_WL_SKY", - "POOL_TREE", - "POOL_ALPHA_MASK", - "POOL_FULLBRIGHT_ALPHA_MASK", - "POOL_GRASS", - "POOL_INVISIBLE", - "POOL_AVATAR", - "POOL_VOIDWATER", - "POOL_WATER", - "POOL_GLOW", - "POOL_ALPHA" + "NONE" + , "POOL_SIMPLE" + , "POOL_GROUND" + , "POOL_FULLBRIGHT" + , "POOL_BUMP" + , "POOL_MATERIALS" + , "POOL_TERRAIN" + , "POOL_SKY" + , "POOL_WL_SKY" + , "POOL_TREE" + , "POOL_ALPHA_MASK" + , "POOL_FULLBRIGHT_ALPHA_MASK" + , "POOL_GRASS" + , "POOL_INVISIBLE" + , "POOL_AVATAR" + , "POOL_CONTROL_AV" // Animesh + , "POOL_VOIDWATER" + , "POOL_WATER" + , "POOL_GLOW" + , "POOL_ALPHA" + , "POOL_PBR_OPAQUE" }; +#endif void drawBox(const LLVector4a& c, const LLVector4a& r); void drawBoxOutline(const LLVector3& pos, const LLVector3& size); -- cgit v1.2.3 From 6c678648e0649ca1be62c79af792ffd85ce379a8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Jun 2022 16:40:48 -0500 Subject: SL-17653 Last commit was accidentally partial --- indra/newview/pipeline.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 030c7b450d..c9f3eb9076 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1647,6 +1647,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } LLMaterial* mat = te->getMaterialParams().get(); + LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); bool color_alpha = te->getColor().mV[3] < 0.999f; bool alpha = color_alpha; @@ -1680,6 +1681,10 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima { return LLDrawPool::POOL_BUMP; } + else if (gltf_mat && !alpha) + { + return LLDrawPool::POOL_PBR_OPAQUE; + } else if (mat && !alpha) { return LLDrawPool::POOL_MATERIALS; -- cgit v1.2.3 From a68b6087deb68a824c2b9e8ccb1111c6c8b70045 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 24 Jun 2022 08:02:53 -0700 Subject: SL-17273: Expand GBuffer for PBR emissive --- indra/newview/pipeline.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 82a5b28576..ac9c385405 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -372,8 +372,12 @@ void validate_framebuffer_object(); // for_impostor -- whether or not these render targets are for an impostor (if true, avoids implicit sRGB conversions) bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) { - return target.addColorAttachment(for_impostor ? GL_RGBA : GL_SRGB8_ALPHA8) && //specular - target.addColorAttachment(GL_RGB10_A2); //normal+z + bool pbr = gSavedSettings.getBOOL("RenderPBR"); + bool valid = true + && target.addColorAttachment(for_impostor ? GL_RGBA : GL_SRGB8_ALPHA8) // frag-data[1] specular or PBR packed OcclusionRoughnessMetal + && target.addColorAttachment(GL_RGB10_A2) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight + && (pbr ? target.addColorAttachment(GL_RGBA) : true); // frag_data[3] emissive + return valid; } LLPipeline::LLPipeline() : -- cgit v1.2.3 From 254bbc86e5d1d3ec094779f46619c109d027da18 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Jun 2022 15:39:04 -0500 Subject: Add emissiveRect to softenLightF.glsl --- indra/newview/pipeline.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ac9c385405..db5e352ae5 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8139,6 +8139,12 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); } + channel = shader.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); + if (channel > -1) + { + deferred_target->bindTexture(3, channel, LLTexUnit::TFO_POINT); + } + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); if (channel > -1) { @@ -9180,6 +9186,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage()); shader.disableTexture(LLShaderMgr::DIFFUSE_MAP); -- cgit v1.2.3 From 6369180eae30f2a4dfa7dc4a10149c632d69c4c3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 6 Jul 2022 12:29:19 -0700 Subject: SL-17682 PBR: Fix Occlusion Roughness Metal not being in linear space; removes need for redundant linear/sRGB conversions. --- indra/newview/pipeline.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 88ee6ea860..bf0d074fcc 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -374,9 +374,9 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) { bool pbr = gSavedSettings.getBOOL("RenderPBR"); bool valid = true - && target.addColorAttachment(for_impostor ? GL_RGBA : GL_SRGB8_ALPHA8) // frag-data[1] specular or PBR packed OcclusionRoughnessMetal + && target.addColorAttachment(for_impostor ? GL_RGBA : GL_SRGB8_ALPHA8) // frag-data[1] specular or PBR sRGB Emissive && target.addColorAttachment(GL_RGB10_A2) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && (pbr ? target.addColorAttachment(GL_RGBA) : true); // frag_data[3] emissive + && (pbr ? target.addColorAttachment(GL_RGBA) : true); // frag_data[3] PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl return valid; } @@ -8124,25 +8124,27 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(0,channel, LLTexUnit::TFO_POINT); + deferred_target->bindTexture(0,channel, LLTexUnit::TFO_POINT); // frag_data[0] } + // NOTE: PBR sRGB Emissive -- See: C++: addDeferredAttachments(), GLSL: pbropaqueF.glsl channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(1, channel, LLTexUnit::TFO_POINT); + deferred_target->bindTexture(1, channel, LLTexUnit::TFO_POINT); // frag_data[1] } channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); + deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); // frag_data[2] } + // NOTE: PBR linear packed Occlusion, Roughness, Metal -- See: C++: addDeferredAttachments(), GLSL: pbropaqueF.glsl channel = shader.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(3, channel, LLTexUnit::TFO_POINT); + deferred_target->bindTexture(3, channel, LLTexUnit::TFO_POINT); // frag_data[3] } channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); -- cgit v1.2.3 From 51d69631820250dbae90867b1b4085c6cf69a4ee Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 6 Jul 2022 20:42:35 -0700 Subject: SL-17703: PBR: Fix PBR objects to cast shadows --- indra/newview/pipeline.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bf0d074fcc..6f65b3c5dd 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9720,6 +9720,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderPass::PASS_NORMMAP_EMISSIVE, LLRenderPass::PASS_NORMSPEC, LLRenderPass::PASS_NORMSPEC_EMISSIVE, + LLRenderPass::PASS_PBR_OPAQUE, // NOTE: Assumes PASS_PBR_OPAQUE_RIGGED is consecutive + //LLRenderPass::PASS_PBR_OPAQUE_RIGGED, }; LLGLEnable cull(GL_CULL_FACE); @@ -10261,6 +10263,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_PASS_NORMSPEC_BLEND_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_MASK_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED, + LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE, + //LLRenderPass::PASS_PBR_OPAQUE_RIGGED, END_RENDER_TYPES); gGL.setColorMask(false, false); -- cgit v1.2.3 From cf4b14f69108ef3079338c49cc7156056eedfce3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Aug 2022 12:34:06 -0500 Subject: SL-17706 Remove ability to disable deferred rendering and default PBR to on for mid and higher. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6f65b3c5dd..b23c1fe741 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -850,7 +850,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) gCubeSnapshot = TRUE; mRT = &mAuxillaryRT; U32 res = LL_REFLECTION_PROBE_RESOLUTION * 2; - allocateScreenBuffer(res, res, 0); + allocateScreenBuffer(res, res, samples); mRT = &mMainRT; gCubeSnapshot = FALSE; } -- cgit v1.2.3 From d048795fce3ab83989cb909fde02014f1442cc84 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 5 Aug 2022 16:58:22 -0500 Subject: SL-17870 Nudge PBR material textures so they start downloading. (and add missing validation code for reflection probes network data). --- indra/newview/pipeline.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b23c1fe741..017bb808c4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3766,6 +3766,7 @@ void LLPipeline::touchTextures(LLDrawInfo* info) touchTexture(info->mTexture, info->mVSize); touchTexture(info->mSpecularMap, info->mVSize); touchTexture(info->mNormalMap, info->mVSize); + touchTexture(info->mEmissiveMap, info->mVSize); } void LLPipeline::postSort(LLCamera& camera) -- cgit v1.2.3 From 963566821d95d30856cd028983d929fab89f542a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 8 Aug 2022 14:55:15 -0500 Subject: SL-17927 Keep people from shooting themselves in the foot by twiddling deprecated settings. --- indra/newview/pipeline.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 06a76942c3..24296363a9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -449,7 +449,7 @@ void LLPipeline::init() gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); - sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); + sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); @@ -548,8 +548,8 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderAvatarMaxNonImpostors"); connectRefreshCachedSettingsSafe("RenderDelayVBUpdate"); connectRefreshCachedSettingsSafe("UseOcclusion"); - connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders"); - connectRefreshCachedSettingsSafe("RenderDeferred"); + // DEPRECATED -- connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders"); + // DEPRECATED -- connectRefreshCachedSettingsSafe("RenderDeferred"); connectRefreshCachedSettingsSafe("RenderPBR"); connectRefreshCachedSettingsSafe("RenderDeferredSunWash"); connectRefreshCachedSettingsSafe("RenderFSAASamples"); @@ -1033,7 +1033,7 @@ void LLPipeline::updateRenderTransparentWater() //static void LLPipeline::updateRenderBump() { - sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); + sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); } // static @@ -1043,8 +1043,7 @@ void LLPipeline::updateRenderDeferred() RenderDeferred && LLRenderTarget::sUseFBO && LLPipeline::sRenderBump && - WindLightUseAtmosShaders && - (bool) LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"); + WindLightUseAtmosShaders; sRenderPBR = sRenderDeferred && gSavedSettings.getBOOL("RenderPBR"); } @@ -1065,8 +1064,8 @@ void LLPipeline::refreshCachedSettings() && gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery) ? 2 : 0; - WindLightUseAtmosShaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); - RenderDeferred = gSavedSettings.getBOOL("RenderDeferred"); + WindLightUseAtmosShaders = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("WindLightUseAtmosShaders"); + RenderDeferred = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderDeferred"); RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash"); RenderFSAASamples = gSavedSettings.getU32("RenderFSAASamples"); RenderResolutionDivisor = gSavedSettings.getU32("RenderResolutionDivisor"); -- cgit v1.2.3 From c790bf7f49328b479f1bcbfe0268ca0bec6e2376 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 11 Aug 2022 11:10:25 -0700 Subject: SL-17005: (WIP) (Debug) Add logging and debug settings to assist in understanding Windows 8 failure modes. Most of this should be removed later --- indra/newview/pipeline.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9ec3418132..d4e667bcc6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -434,6 +434,7 @@ void LLPipeline::connectRefreshCachedSettingsSafe(const std::string name) void LLPipeline::init() { + LL_WARNS() << "Begin pipeline initialization" << LL_ENDL; // TODO: Remove after testing refreshCachedSettings(); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); @@ -450,6 +451,7 @@ void LLPipeline::init() mInitialized = true; stop_glerror(); + LL_WARNS() << "No GL errors yet. Pipeline initialization will continue." << LL_ENDL; // TODO: Remove after testing //create render pass pools getPool(LLDrawPool::POOL_ALPHA); @@ -510,7 +512,9 @@ void LLPipeline::init() // Enable features + LL_WARNS() << "Shader initialization start" << LL_ENDL; // TODO: Remove after testing LLViewerShaderMgr::instance()->setShaders(); + LL_WARNS() << "Shader initialization end" << LL_ENDL; // TODO: Remove after testing stop_glerror(); -- cgit v1.2.3 From 90bdeddb8f62560e0982e7e4c9917f1a62c7d88f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 15 Aug 2022 13:15:25 -0500 Subject: SL-17940 Fix for rigged attachments with PBR materials not rendering. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 24296363a9..9161b43159 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10264,7 +10264,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_PASS_NORMSPEC_MASK_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED, LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE, - //LLRenderPass::PASS_PBR_OPAQUE_RIGGED, + LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE_RIGGED, END_RENDER_TYPES); gGL.setColorMask(false, false); -- cgit v1.2.3 From a02f6217008dc9a82995fba705d129796fe3014c Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 18 Aug 2022 16:29:52 -0700 Subject: SL-17005: Clean up debug code --- indra/newview/pipeline.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d4e667bcc6..9ec3418132 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -434,7 +434,6 @@ void LLPipeline::connectRefreshCachedSettingsSafe(const std::string name) void LLPipeline::init() { - LL_WARNS() << "Begin pipeline initialization" << LL_ENDL; // TODO: Remove after testing refreshCachedSettings(); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); @@ -451,7 +450,6 @@ void LLPipeline::init() mInitialized = true; stop_glerror(); - LL_WARNS() << "No GL errors yet. Pipeline initialization will continue." << LL_ENDL; // TODO: Remove after testing //create render pass pools getPool(LLDrawPool::POOL_ALPHA); @@ -512,9 +510,7 @@ void LLPipeline::init() // Enable features - LL_WARNS() << "Shader initialization start" << LL_ENDL; // TODO: Remove after testing LLViewerShaderMgr::instance()->setShaders(); - LL_WARNS() << "Shader initialization end" << LL_ENDL; // TODO: Remove after testing stop_glerror(); -- cgit v1.2.3 From 8eaee1f033d9dac892e749cc65416e149021d8f6 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 30 Aug 2022 20:35:15 -0700 Subject: SL-17703: PBR: Fix albedo being in wrong color space, add support for debug default_irradiance.png --- indra/newview/pipeline.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 91d276c8df..67f0ea68c1 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8643,6 +8643,11 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + if (!LLPipeline::sUnderWaterRender && LLPipeline::sRenderPBR) + { + soften_shader.bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, LLViewerFetchedTexture::sDefaultIrradiancePBRp); // PBR: irradiance + } + if(LLPipeline::sRenderPBR) { LLVector3 cameraAtAxis = LLViewerCamera::getInstance()->getAtAxis(); -- cgit v1.2.3 From 2082443220fe344bb027c3acbf50fea0a99159c3 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 10:58:27 -0700 Subject: SL-17967 - Git rid of ARB that is in core --- indra/newview/pipeline.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 91d276c8df..2f6ff19100 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -731,7 +731,7 @@ void LLPipeline::destroyGL() if (mMeshDirtyQueryObject) { - glDeleteQueriesARB(1, &mMeshDirtyQueryObject); + glDeleteQueries(1, &mMeshDirtyQueryObject); mMeshDirtyQueryObject = 0; } } @@ -1293,7 +1293,7 @@ void LLPipeline::createGLBuffers() LLImageGL::generateTextures(1, &mNoiseMap); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } @@ -1308,7 +1308,7 @@ void LLPipeline::createGLBuffers() LLImageGL::generateTextures(1, &mTrueNoiseMap); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } @@ -3918,11 +3918,11 @@ void LLPipeline::postSort(LLCamera& camera) if (!mMeshDirtyQueryObject) { - glGenQueriesARB(1, &mMeshDirtyQueryObject); + glGenQueries(1, &mMeshDirtyQueryObject); } - glBeginQueryARB(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, mMeshDirtyQueryObject); + glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, mMeshDirtyQueryObject); }*/ //pack vertex buffers for groups that chose to delay their updates @@ -3933,7 +3933,7 @@ void LLPipeline::postSort(LLCamera& camera) /*if (use_transform_feedback) { - glEndQueryARB(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); + glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); }*/ mMeshDirtyGroup.clear(); @@ -11333,7 +11333,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) if (LLPipeline::sRenderDeferred) { GLuint buff = GL_COLOR_ATTACHMENT0; - glDrawBuffersARB(1, &buff); + glDrawBuffers(1, &buff); } LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From 01d03edd8512580575da515401a42021577c3c57 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 13:38:22 -0700 Subject: SL-17967 - _ARB constant removal --- indra/newview/pipeline.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2f6ff19100..3918770849 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -536,7 +536,7 @@ void LLPipeline::init() if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); @@ -2418,7 +2418,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { if (mCubeVB.isNull()) { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); } @@ -2677,7 +2677,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) if (mCubeVB.isNull()) { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -4063,7 +4063,7 @@ void render_hud_elements() if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { - LLGLEnable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() // Draw the tracking overlays @@ -4371,7 +4371,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) gGL.matrixMode(LLRender::MM_MODELVIEW); LLGLSPipeline gls_pipeline; - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2); @@ -4592,7 +4592,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) } } - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); LLVertexBuffer::unbind(); @@ -4682,7 +4682,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) LLGLEnable cull(GL_CULL_FACE); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); calcNearbyLights(camera); setupHWLights(NULL); @@ -8078,7 +8078,7 @@ void LLPipeline::renderFinalize() gGL.getTexUnit(0)->bind(&mGlow[1]); gGL.getTexUnit(1)->bind(&mRT->screen); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); buff->setBuffer(mask); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); @@ -8246,8 +8246,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); stop_glerror(); } } @@ -8268,8 +8268,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); stop_glerror(); } } @@ -8448,7 +8448,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) GL_NEAREST); } - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { @@ -8717,7 +8717,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -9224,7 +9224,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); } } @@ -9232,7 +9232,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); } } -- cgit v1.2.3 From 049fc419d1d1f41ac05e424d599a89366cee7ca7 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 9 Sep 2022 03:28:12 -0700 Subject: SL-17701: PBR: WIP Alpha Blending --- indra/newview/pipeline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 67f0ea68c1..abf0d457e2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1684,7 +1684,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } } - if (alpha) + if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) { return LLDrawPool::POOL_ALPHA; } @@ -1692,7 +1692,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima { return LLDrawPool::POOL_BUMP; } - else if (gltf_mat && !alpha) + else if (gltf_mat) { return LLDrawPool::POOL_PBR_OPAQUE; } -- cgit v1.2.3 From cb902bf9a97177322c222a032715262987c98eb9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 9 Sep 2022 15:34:02 -0700 Subject: SL-17701: Fix enum compare using wrong types which broke macOS build --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index abf0d457e2..5398243f55 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1684,7 +1684,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } } - if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) + if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)) { return LLDrawPool::POOL_ALPHA; } -- cgit v1.2.3 From ff3a28422dc65afe4cf3131daf953d0567711b8a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 13 Sep 2022 17:07:30 -0500 Subject: SL-17701 WIP -- Parity for point lights between opaque and transparent PBR materials --- indra/newview/pipeline.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d66f11d247..160a1680c1 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6381,6 +6381,9 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light_state->setDiffuse(light_color); light_state->setAmbient(LLColor4::black); light_state->setConstantAttenuation(0.f); + light_state->setSize(light->getLightRadius() * 1.5f); + light_state->setFalloff(light->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); + if (sRenderDeferred) { light_state->setLinearAttenuation(linatten); -- cgit v1.2.3 From 2ce39f3ad98fe855fb126dc29c82145751434421 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Sep 2022 16:24:20 -0500 Subject: SL-17701 Fix for shadow passes not respecting double sided and alpha parameters for PBR materials. --- indra/newview/pipeline.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 160a1680c1..858cc90d04 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9753,9 +9753,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderPass::PASS_NORMMAP, LLRenderPass::PASS_NORMMAP_EMISSIVE, LLRenderPass::PASS_NORMSPEC, - LLRenderPass::PASS_NORMSPEC_EMISSIVE, - LLRenderPass::PASS_PBR_OPAQUE, // NOTE: Assumes PASS_PBR_OPAQUE_RIGGED is consecutive - //LLRenderPass::PASS_PBR_OPAQUE_RIGGED, + LLRenderPass::PASS_NORMSPEC_EMISSIVE }; LLGLEnable cull(GL_CULL_FACE); @@ -9839,7 +9837,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera if (use_shader) { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); gDeferredShadowProgram.unbind(); renderGeomShadow(shadow_cam); @@ -9848,13 +9846,13 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera } else { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); renderGeomShadow(shadow_cam); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); for (int i = 0; i < 2; ++i) { @@ -9870,19 +9868,19 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLVertexBuffer::MAP_TEXTURE_INDEX; { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_MASKED); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE, rigged); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_BLEND); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); renderAlphaObjects(mask, TRUE, TRUE, rigged); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_FULLBRIGHT_ALPHA_MASKED); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); @@ -9891,7 +9889,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_GRASS); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); if (i == 0) { @@ -9904,6 +9902,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_PBR_OPAQUE, no_idx_mask, true, false, rigged); } } } -- cgit v1.2.3 From 8dc59e5ef37836b15d478fb0d04e3043a9f986de Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Sep 2022 16:25:26 -0500 Subject: SL-18128 Clear out much OpenGL cruft and switch to core profile on AMD --- indra/newview/pipeline.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 858cc90d04..f8ab68e57d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -892,16 +892,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; - GLuint screenFormat = GL_RGBA16; - if (gGLManager.mIsAMD) - { - screenFormat = GL_RGBA12; - } - - if (gGLManager.mGLVersion < 4.f && gGLManager.mIsNVIDIA) - { - screenFormat = GL_RGBA16F_ARB; - } + GLuint screenFormat = GL_RGBA; if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) @@ -1065,8 +1056,7 @@ void LLPipeline::refreshCachedSettings() LLPipeline::sUseOcclusion = (!gUseWireframe && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") - && gSavedSettings.getBOOL("UseOcclusion") - && gGLManager.mHasOcclusionQuery) ? 2 : 0; + && gSavedSettings.getBOOL("UseOcclusion")) ? 2 : 0; WindLightUseAtmosShaders = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("WindLightUseAtmosShaders"); RenderDeferred = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderDeferred"); @@ -2355,8 +2345,7 @@ static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* planep) { static LLCachedControl use_occlusion(gSavedSettings,"UseOcclusion"); - static bool can_use_occlusion = LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") - && gGLManager.mHasOcclusionQuery; + static bool can_use_occlusion = LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion"); LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); @@ -9759,7 +9748,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLEnable cull(GL_CULL_FACE); //enable depth clamping if available - LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); + //LLGLEnable depth_clamp(GL_DEPTH_CLAMP); if (use_shader) { -- cgit v1.2.3 From ae17d1e9a02769b352d03446ce7f7b7ccd800aec Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Sep 2022 17:11:02 -0500 Subject: SL-18128 Restore 16-bit precision in screen render target. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f8ab68e57d..7f42fb71e4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -892,7 +892,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; - GLuint screenFormat = GL_RGBA; + GLuint screenFormat = GL_RGBA16; if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) -- cgit v1.2.3 From b2cf07f53ca9f0ab82d466063af8307631c50f31 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2022 01:12:52 -0500 Subject: WIP - switch PBR implementations --- indra/newview/pipeline.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7f42fb71e4..f07d809495 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1182,6 +1182,8 @@ void LLPipeline::releaseLUTBuffers() LLImageGL::deleteTextures(1, &mLightFunc); mLightFunc = 0; } + + mPbrBrdfLut.release(); } void LLPipeline::releaseShadowBuffers() @@ -1363,6 +1365,21 @@ void LLPipeline::createLUTBuffers() delete [] ls; } + + mPbrBrdfLut.allocate(512, 512, GL_RGB16, false, false); + mPbrBrdfLut.bindTarget(); + gDeferredGenBrdfLutProgram.bind(); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex2f(-1, -1); + gGL.vertex2f(-1, 1); + gGL.vertex2f(1, -1); + gGL.vertex2f(1, 1); + gGL.end(); + gGL.flush(); + + gDeferredGenBrdfLutProgram.unbind(); + mPbrBrdfLut.flush(); } } @@ -8165,6 +8182,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ deferred_target->bindTexture(3, channel, LLTexUnit::TFO_POINT); // frag_data[3] } + channel = shader.enableTexture(LLShaderMgr::DEFERRED_BRDF_LUT, LLTexUnit::TT_TEXTURE); + if (channel > -1) + { + mPbrBrdfLut.bindTexture(0, channel); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); if (channel > -1) { @@ -8304,7 +8328,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } bindReflectionProbes(shader); - + if (gAtmosphere) { // bind precomputed textures necessary for calculating sun and sky luminance @@ -9212,6 +9236,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_BRDF_LUT); shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage()); shader.disableTexture(LLShaderMgr::DIFFUSE_MAP); -- cgit v1.2.3 From 99fbb2e19c7cd3b7d8588800d8cab34e98a4580b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2022 21:02:31 -0500 Subject: RG16F PBR BRDF LUT --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f07d809495..dd15b63fab 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1366,7 +1366,7 @@ void LLPipeline::createLUTBuffers() delete [] ls; } - mPbrBrdfLut.allocate(512, 512, GL_RGB16, false, false); + mPbrBrdfLut.allocate(512, 512, GL_RG16F, false, false); mPbrBrdfLut.bindTarget(); gDeferredGenBrdfLutProgram.bind(); -- cgit v1.2.3 From c466e44334fd60c8270b68c70b8ae999b8dbd395 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 20 Sep 2022 19:09:26 -0500 Subject: SL-18190 Reduce banding (stay in linear space as much as possible, increase precision of reflection probes). Faster radiance and irradiance map generation. --- indra/newview/pipeline.cpp | 123 +++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 60 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dd15b63fab..177d712f4b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -369,14 +369,13 @@ void validate_framebuffer_object(); // Add color attachments for deferred rendering // target -- RenderTarget to add attachments to -// for_impostor -- whether or not these render targets are for an impostor (if true, avoids implicit sRGB conversions) bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) { bool pbr = gSavedSettings.getBOOL("RenderPBR"); bool valid = true - && target.addColorAttachment(for_impostor ? GL_RGBA : GL_SRGB8_ALPHA8) // frag-data[1] specular or PBR sRGB Emissive + && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM && target.addColorAttachment(GL_RGB10_A2) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && (pbr ? target.addColorAttachment(GL_RGBA) : true); // frag_data[3] PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl + && (pbr ? target.addColorAttachment(GL_RGBA) : true); // frag_data[3] PBR emissive return valid; } @@ -887,7 +886,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 occlusion_divisor = 3; //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; @@ -8162,7 +8161,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ deferred_target->bindTexture(0,channel, LLTexUnit::TFO_POINT); // frag_data[0] } - // NOTE: PBR sRGB Emissive -- See: C++: addDeferredAttachments(), GLSL: pbropaqueF.glsl channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); if (channel > -1) { @@ -8175,7 +8173,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); // frag_data[2] } - // NOTE: PBR linear packed Occlusion, Roughness, Metal -- See: C++: addDeferredAttachments(), GLSL: pbropaqueF.glsl channel = shader.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); if (channel > -1) { @@ -8974,60 +8971,6 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) screen_target->flush(); - // gamma correct lighting - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - - { - LL_PROFILE_GPU_ZONE("gamma correct"); - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - LLVector2 tc1(0, 0); - LLVector2 tc2((F32) screen_target->getWidth() * 2, (F32) screen_target->getHeight() * 2); - - screen_target->bindTarget(); - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); - if (channel > -1) - { - screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); - - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); - - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); - - gGL.end(); - - gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - screen_target->flush(); - } - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - screen_target->bindTarget(); { // render non-deferred geometry (alpha, fullbright, glow) @@ -9063,6 +9006,66 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) popRenderTypeMask(); } + screen_target->flush(); + + if (!gCubeSnapshot) + { + // gamma correct lighting + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + { + LL_PROFILE_GPU_ZONE("gamma correct"); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + LLVector2 tc1(0, 0); + LLVector2 tc2((F32)screen_target->getWidth() * 2, (F32)screen_target->getHeight() * 2); + + screen_target->bindTarget(); + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); + // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); + if (channel > -1) + { + screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); + + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); + + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); + + gGL.end(); + + gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); + screen_target->flush(); + } + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } + if (!gCubeSnapshot) { // render highlights, etc. -- cgit v1.2.3 From e5d463ca200bdfa93b8c65e588d490c2f23e3918 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 22 Sep 2022 17:27:18 -0500 Subject: SL-17705 Backwards compatibility pass. Support OpenGL pre-4.0 by disabling reflection probes and anti-aliasing. Get render parity with current release viewer when reflection probes are disabled. --- indra/newview/pipeline.cpp | 59 +++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 17 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 177d712f4b..b14ceedac8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -355,6 +355,7 @@ bool LLPipeline::sRenderFrameTest = false; bool LLPipeline::sRenderAttachedLights = true; bool LLPipeline::sRenderAttachedParticles = true; bool LLPipeline::sRenderDeferred = false; +bool LLPipeline::sReflectionProbesEnabled = false; bool LLPipeline::sRenderPBR = false; S32 LLPipeline::sVisibleLightCount = 0; bool LLPipeline::sRenderingHUDs; @@ -371,11 +372,10 @@ void validate_framebuffer_object(); // target -- RenderTarget to add attachments to bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) { - bool pbr = gSavedSettings.getBOOL("RenderPBR"); bool valid = true && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM && target.addColorAttachment(GL_RGB10_A2) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && (pbr ? target.addColorAttachment(GL_RGBA) : true); // frag_data[3] PBR emissive + && target.addColorAttachment(GL_RGBA); // frag_data[3] PBR emissive return valid; } @@ -553,7 +553,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("UseOcclusion"); // DEPRECATED -- connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders"); // DEPRECATED -- connectRefreshCachedSettingsSafe("RenderDeferred"); - connectRefreshCachedSettingsSafe("RenderPBR"); connectRefreshCachedSettingsSafe("RenderDeferredSunWash"); connectRefreshCachedSettingsSafe("RenderFSAASamples"); connectRefreshCachedSettingsSafe("RenderResolutionDivisor"); @@ -1033,12 +1032,10 @@ void LLPipeline::updateRenderBump() // static void LLPipeline::updateRenderDeferred() { - sRenderDeferred = !gUseWireframe && - RenderDeferred && - LLRenderTarget::sUseFBO && - LLPipeline::sRenderBump && - WindLightUseAtmosShaders; - sRenderPBR = sRenderDeferred && gSavedSettings.getBOOL("RenderPBR"); + sRenderDeferred = !gUseWireframe; + sRenderPBR = sRenderDeferred; + static LLCachedControl sProbeDetail(gSavedSettings, "RenderReflectionProbeDetail", -1); + sReflectionProbesEnabled = sProbeDetail >= 0 && gGLManager.mGLVersion > 3.99f; } // static @@ -6238,6 +6235,22 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) } } +void LLPipeline::adjustAmbient(const LLSettingsSky* sky, LLColor4& ambient) +{ + //bump ambient based on reflection probe ambiance of probes are disabled + // so sky settings that rely on probes for ambiance don't go completely dark + // on low end hardware + if (!LLPipeline::sReflectionProbesEnabled) + { + F32 ambiance = linearTosRGB(sky->getReflectionProbeAmbiance()); + + for (int i = 0; i < 3; ++i) + { + ambient.mV[i] = llmax(ambient.mV[i], ambiance); + } + } +} + void LLPipeline::setupHWLights(LLDrawPool* pool) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; @@ -6248,7 +6261,9 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) // Ambient LLColor4 ambient = psky->getTotalAmbient(); - gGL.setAmbientLightColor(ambient); + adjustAmbient(psky.get(), ambient); + + gGL.setAmbientLightColor(ambient); bool sun_up = environment.getIsSunUp(); bool moon_up = environment.getIsMoonUp(); @@ -9281,8 +9296,24 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) shader.unbind(); } +void LLPipeline::setEnvMat(LLGLSLShader& shader) +{ + F32* m = gGLModelView; + + F32 mat[] = { m[0], m[1], m[2], + m[4], m[5], m[6], + m[8], m[9], m[10] }; + + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); +} + void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) { + if (!sReflectionProbesEnabled) + { + return; + } + S32 channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); bool bound = false; if (channel > -1 && mReflectionMapManager.mTexture.notNull()) @@ -9302,13 +9333,7 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) { mReflectionMapManager.setUniforms(); - F32* m = gGLModelView; - - F32 mat[] = { m[0], m[1], m[2], - m[4], m[5], m[6], - m[8], m[9], m[10] }; - - shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); + setEnvMat(shader); } } -- cgit v1.2.3 From f4d49f887e0a7b8e0230faa22ce5b2efc026c54d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 23 Sep 2022 17:48:45 -0500 Subject: SL-18190 Reduce banding. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b14ceedac8..26989a477a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7731,7 +7731,7 @@ void LLPipeline::renderFinalize() RenderDepthOfField && !gCubeSnapshot; - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; gViewerWindow->setup3DViewport(); -- cgit v1.2.3 From 725d042640f5b0474b58e6a1af0a4063c7e5cfc2 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 26 Sep 2022 17:17:34 -0500 Subject: SL-18190 WIP - Windlight to linear space proof of concept, better parity between release viewer and materials viewer when reflections disabled. Avoid run-away probe ambiance. --- indra/newview/pipeline.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 26989a477a..325a370f43 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6235,22 +6235,6 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) } } -void LLPipeline::adjustAmbient(const LLSettingsSky* sky, LLColor4& ambient) -{ - //bump ambient based on reflection probe ambiance of probes are disabled - // so sky settings that rely on probes for ambiance don't go completely dark - // on low end hardware - if (!LLPipeline::sReflectionProbesEnabled) - { - F32 ambiance = linearTosRGB(sky->getReflectionProbeAmbiance()); - - for (int i = 0; i < 3; ++i) - { - ambient.mV[i] = llmax(ambient.mV[i], ambiance); - } - } -} - void LLPipeline::setupHWLights(LLDrawPool* pool) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; @@ -6261,8 +6245,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) // Ambient LLColor4 ambient = psky->getTotalAmbient(); - adjustAmbient(psky.get(), ambient); - + gGL.setAmbientLightColor(ambient); bool sun_up = environment.getIsSunUp(); -- cgit v1.2.3 From aaf7b17db047f0cb2630b479d5468062e6ca815e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 27 Sep 2022 23:32:02 -0500 Subject: SL-18190 WIP -- Take 2 on linear space windlight (more methodical approach -- make desired interface but brute force color conversions). Placeholder PBR water and move to deprecate forward rendering shaders. --- indra/newview/pipeline.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 325a370f43..92cca190fd 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4412,6 +4412,8 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) } { + bool occlude = sUseOcclusion > 1; +#if 1 // DEPRECATED -- requires forward rendering LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pools"); //LL_RECORD_BLOCK_TIME(FTM_POOLS); // HACK: don't calculate local lights if we're rendering the HUD! @@ -4423,7 +4425,6 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) setupHWLights(NULL); } - bool occlude = sUseOcclusion > 1; U32 cur_type = 0; pool_set_t::iterator iter1 = mPools.begin(); @@ -4445,6 +4446,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) doOcclusion(camera); } + pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumPasses() > 0) { @@ -4492,12 +4494,13 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) } iter1 = iter2; stop_glerror(); + } LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPoolsEnd"); LLVertexBuffer::unbind(); - +#endif gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -9376,7 +9379,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) glh::matrix4f saved_projection = get_current_projection(); glh::matrix4f mat; +#if 1 // relies on forward rendering, which is deprecated -- TODO - make a deferred implementation of transparent/reflective water S32 reflection_detail = RenderReflectionDetail; +#else + S32 reflection_detail = WATER_REFLECT_NONE_WATER_TRANSPARENT; +#endif F32 water_height = gAgent.getRegion()->getWaterHeight(); F32 camera_height = camera_in.getOrigin().mV[VZ]; @@ -9602,12 +9609,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) mWaterDis.clear(); gGL.setColorMask(true, false); +#if 0 // DEPRECATED - requires forward rendering, TODO - make a deferred implementation if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) { updateCull(camera, mRefractedObjects, &plane); stateSort(camera, mRefractedObjects); renderGeom(camera); } +#endif + gUIProgram.bind(); -- cgit v1.2.3 From 1900df361558313f10e8b27ada03bcefd41241d9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 4 Oct 2022 12:20:19 -0500 Subject: SL-18293, SL-18190 -- Fix for debug displays not showing up (wireframe still busted). WIP on reflection probe/PBR driven water shader. --- indra/newview/pipeline.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 92cca190fd..0da2faae29 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1032,7 +1032,6 @@ void LLPipeline::updateRenderBump() // static void LLPipeline::updateRenderDeferred() { - sRenderDeferred = !gUseWireframe; sRenderPBR = sRenderDeferred; static LLCachedControl sProbeDetail(gSavedSettings, "RenderReflectionProbeDetail", -1); sReflectionProbesEnabled = sProbeDetail >= 0 && gGLManager.mGLVersion > 3.99f; @@ -4326,6 +4325,7 @@ U32 LLPipeline::sCurRenderPoolType = 0 ; void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) { +#if 0 LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeom"); assertInitialized(); @@ -4575,6 +4575,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) LLGLState::checkStates(); // LLGLState::checkTextureChannels(); // LLGLState::checkClientArrays(); +#endif } void LLPipeline::renderGeomDeferred(LLCamera& camera) @@ -4774,6 +4775,16 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); } + + if (!gCubeSnapshot) + { + // debug displays + renderHighlights(); + mHighlightFaces.clear(); + + renderDebug(); + } + } void LLPipeline::renderGeomShadow(LLCamera& camera) @@ -8692,6 +8703,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); } +#if 0 { // render non-deferred geometry (fullbright, alpha, etc) LLGLDisable blend(GL_BLEND); LLGLDisable stencil(GL_STENCIL_TEST); @@ -8707,6 +8719,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); gPipeline.popRenderTypeMask(); } +#endif bool render_local = RenderLocalLights; // && !gCubeSnapshot; @@ -8970,10 +8983,6 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gGL.setColorMask(true, true); } - screen_target->flush(); - - screen_target->bindTarget(); - { // render non-deferred geometry (alpha, fullbright, glow) LLGLDisable blend(GL_BLEND); LLGLDisable stencil(GL_STENCIL_TEST); @@ -9001,6 +9010,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) LLPipeline::RENDER_TYPE_CONTROL_AV, LLPipeline::RENDER_TYPE_ALPHA_MASK, LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_WATER, END_RENDER_TYPES); renderGeomPostDeferred(*LLViewerCamera::getInstance()); @@ -9065,16 +9075,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gGL.popMatrix(); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - } - - if (!gCubeSnapshot) - { - // render highlights, etc. - renderHighlights(); - mHighlightFaces.clear(); - - renderDebug(); - + LLVertexBuffer::unbind(); if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) @@ -9346,6 +9347,7 @@ inline float sgn(float a) void LLPipeline::generateWaterReflection(LLCamera& camera_in) { +#if 0 LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("generateWaterReflection"); @@ -9684,6 +9686,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.popRenderTypeMask(); } } +#endif } glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) -- cgit v1.2.3 From 30bcc7d6d5fa4ceedfec28cc0973c253364c555e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 5 Oct 2022 08:11:33 -0500 Subject: SL-18190 WIP - Add refraction to water without splitting scene between above and below water --- indra/newview/pipeline.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0da2faae29..08c99266f8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8442,7 +8442,7 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f) return v; } -void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) +void LLPipeline::renderDeferredLighting() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("renderDeferredLighting"); @@ -8451,6 +8451,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) return; } + LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget *deferred_target = &mRT->deferredScreen; LLRenderTarget *deferred_depth_target = &mRT->deferredDepth; LLRenderTarget *deferred_light_target = &mRT->deferredLight; -- cgit v1.2.3 From 9448db5d4af7bba094e5bc51f85e5c2491d3f5a1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 6 Oct 2022 18:40:01 -0500 Subject: SL-18190 Water shader WIP. Better parallax correction for sphere probes. Reduce probe memory footprint. Remove framebuffer copies and move to deprecate stencil buffer usage. --- indra/newview/pipeline.cpp | 90 ++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 34 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 08c99266f8..7eaa3a065c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -885,14 +885,17 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 occlusion_divisor = 3; //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + //if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16; if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + + mRT->deferredScreen.shareDepthBuffer(mRT->screen); + if (samples > 0) { if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; @@ -929,17 +932,12 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mRT->fxaaBuffer.release(); mRT->screen.release(); mRT->deferredScreen.release(); //make sure to release any render targets that share a depth buffer with mRT->deferredScreen first - mRT->deferredDepth.release(); + //mRT->deferredDepth.release(); mRT->occlusionDepth.release(); if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; } - if (LLPipeline::sRenderDeferred) - { //share depth buffer between deferred targets - mRT->deferredScreen.shareDepthBuffer(mRT->screen); - } - gGL.getTexUnit(0)->disable(); stop_glerror(); @@ -2575,6 +2573,7 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d if (scratch_space) { GLint bits = 0; + llassert(!source.hasStencil()); // stencil buffer usage is deprecated bits |= (source.hasStencil() && dest.hasStencil()) ? GL_STENCIL_BUFFER_BIT : 0; bits |= GL_DEPTH_BUFFER_BIT; scratch_space->copyContents(source, @@ -2632,10 +2631,17 @@ void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderT { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; llassert(!gCubeSnapshot); +#if 0 downsampleDepthBuffer(source, dest, scratch_space); dest.bindTarget(); doOcclusion(camera); dest.flush(); +#else + // none of the above shenanigans should matter (enough) because we've preserved hierarchical Z before issuing occlusion queries + //source.bindTarget(); + doOcclusion(camera); + //source.flush(); +#endif } void LLPipeline::doOcclusion(LLCamera& camera) @@ -4052,10 +4058,10 @@ void render_hud_elements() LLGLDisable fog(GL_FOG); LLGLSUIDefault gls_ui; - LLGLEnable stencil(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 255, 0xFFFFFFFF); - glStencilMask(0xFFFFFFFF); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + //LLGLEnable stencil(GL_STENCIL_TEST); + //glStencilFunc(GL_ALWAYS, 255, 0xFFFFFFFF); + //glStencilMask(0xFFFFFFFF); + //glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); gGL.color4f(1,1,1,1); @@ -4112,14 +4118,15 @@ void LLPipeline::renderHighlights() LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); LLGLDisable test(GL_ALPHA_TEST); - LLGLEnable stencil(GL_STENCIL_TEST); + //LLGLEnable stencil(GL_STENCIL_TEST); gGL.flush(); - glStencilMask(0xFFFFFFFF); - glClearStencil(1); - glClear(GL_STENCIL_BUFFER_BIT); + // stencil ops are deprecated + //glStencilMask(0xFFFFFFFF); + //glClearStencil(1); + //glClear(GL_STENCIL_BUFFER_BIT); - glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); - glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + //glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); + //glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); gGL.setColorMask(false, false); @@ -4131,8 +4138,8 @@ void LLPipeline::renderHighlights() } gGL.setColorMask(true, false); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); + //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // deprecated + //glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); //gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); @@ -4711,7 +4718,8 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); LLGLSLShader::bindNoShader(); - doOcclusion(camera, mRT->screen, mRT->occlusionDepth, &mRT->deferredDepth); + //doOcclusion(camera, mRT->screen, mRT->occlusionDepth, &mRT->deferredDepth); + doOcclusion(camera, mRT->screen, mRT->occlusionDepth); gGL.setColorMask(true, false); } @@ -4990,7 +4998,7 @@ void LLPipeline::renderDebug() const LLColor4 clearColor = gSavedSettings.getColor4("PathfindingNavMeshClear"); gGL.setColorMask(true, true); glClearColor(clearColor.mV[0],clearColor.mV[1],clearColor.mV[2],0); - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // no stencil -- deprecated | GL_STENCIL_BUFFER_BIT); gGL.setColorMask(true, false); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } @@ -8063,6 +8071,7 @@ void LLPipeline::renderFinalize() shader->unbind(); } } +#if 0 // DEPRECATED else // not deferred { U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1; @@ -8105,7 +8114,7 @@ void LLPipeline::renderFinalize() gGlowCombineProgram.unbind(); } - +#endif gGL.setSceneBlendType(LLRender::BT_ALPHA); if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) @@ -8139,12 +8148,12 @@ void LLPipeline::renderFinalize() gSplatTextureRectProgram.unbind(); } - if (LLRenderTarget::sUseFBO && !gCubeSnapshot) + /*if (LLRenderTarget::sUseFBO && !gCubeSnapshot) { // copy depth buffer from mRT->screen to framebuffer LLRenderTarget::copyContentsToFramebuffer(mRT->screen, 0, 0, mRT->screen.getWidth(), mRT->screen.getHeight(), 0, 0, mRT->screen.getWidth(), mRT->screen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); - } + }*/ gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); @@ -8162,7 +8171,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("bindDeferredShader"); LLRenderTarget* deferred_target = &mRT->deferredScreen; - LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; + //LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; shader.bind(); @@ -8198,12 +8207,21 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } +#if 0 channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); if (channel > -1) { gGL.getTexUnit(channel)->bind(deferred_depth_target, TRUE); stop_glerror(); } +#else + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_target->getUsage()); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(deferred_target, TRUE); + stop_glerror(); + } +#endif glh::matrix4f projection = get_current_projection(); glh::matrix4f inv_proj = projection.inverse(); @@ -8452,13 +8470,15 @@ void LLPipeline::renderDeferredLighting() } LLRenderTarget *screen_target = &mRT->screen; - LLRenderTarget *deferred_target = &mRT->deferredScreen; - LLRenderTarget *deferred_depth_target = &mRT->deferredDepth; - LLRenderTarget *deferred_light_target = &mRT->deferredLight; + //LLRenderTarget *deferred_target = &mRT->deferredScreen; + //LLRenderTarget *deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget* deferred_light_target = &mRT->deferredLight; { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); LLViewerCamera *camera = LLViewerCamera::getInstance(); + +#if 0 { LLGLDepthTest depth(GL_TRUE); deferred_depth_target->copyContents(*deferred_target, @@ -8473,6 +8493,7 @@ void LLPipeline::renderDeferredLighting() GL_DEPTH_BUFFER_BIT, GL_NEAREST); } +#endif LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); @@ -8482,7 +8503,7 @@ void LLPipeline::renderDeferredLighting() } // ati doesn't seem to love actually using the stencil buffer on FBO's - LLGLDisable stencil(GL_STENCIL_TEST); + //LLGLDisable stencil(GL_STENCIL_TEST); // glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); // glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); @@ -8707,7 +8728,7 @@ void LLPipeline::renderDeferredLighting() #if 0 { // render non-deferred geometry (fullbright, alpha, etc) LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); + //LLGLDisable stencil(GL_STENCIL_TEST); gGL.setSceneBlendType(LLRender::BT_ALPHA); gPipeline.pushRenderTypeMask(); @@ -8986,7 +9007,7 @@ void LLPipeline::renderDeferredLighting() { // render non-deferred geometry (alpha, fullbright, glow) LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); + //LLGLDisable stencil(GL_STENCIL_TEST); pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, @@ -9234,7 +9255,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { LLRenderTarget* deferred_target = &mRT->deferredScreen; - LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; + //LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; stop_glerror(); @@ -9243,7 +9264,8 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_BRDF_LUT); - shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); + //shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_target->getUsage()); shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage()); shader.disableTexture(LLShaderMgr::DIFFUSE_MAP); shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM); -- cgit v1.2.3 From 176f34791bf26e3cb14c05260e538e7107329f7a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Oct 2022 10:05:44 -0500 Subject: SL-18190 Fix for mac build --- indra/newview/pipeline.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7eaa3a065c..b8df8bb95f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -132,12 +132,12 @@ // NOTE: Keep in sync with indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml // NOTE: Unused consts are commented out since some compilers (on macOS) may complain about unused variables. // const S32 WATER_REFLECT_NONE_WATER_OPAQUE = -2; - const S32 WATER_REFLECT_NONE_WATER_TRANSPARENT = -1; - const S32 WATER_REFLECT_MINIMAL = 0; + //const S32 WATER_REFLECT_NONE_WATER_TRANSPARENT = -1; + //const S32 WATER_REFLECT_MINIMAL = 0; // const S32 WATER_REFLECT_TERRAIN = 1; - const S32 WATER_REFLECT_STATIC_OBJECTS = 2; - const S32 WATER_REFLECT_AVATARS = 3; - const S32 WATER_REFLECT_EVERYTHING = 4; + //const S32 WATER_REFLECT_STATIC_OBJECTS = 2; + //const S32 WATER_REFLECT_AVATARS = 3; + //const S32 WATER_REFLECT_EVERYTHING = 4; bool gShiftFrame = false; -- cgit v1.2.3 From 26f99409d247a0c872239d73ac05451ef8531ff4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Oct 2022 12:52:43 -0500 Subject: SL-18190 Temporarily disable occlusion culling by default -- not compatible with depth buffer management changes. --- indra/newview/pipeline.cpp | 47 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b8df8bb95f..c360a7fc63 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2538,6 +2538,13 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) sCull->pushVisibleGroup(group); } + if (group->needsUpdate() || + group->getVisible(LLViewerCamera::sCurCameraID) < LLDrawable::getCurrentFrame() - 1) + { + // include this group in occlusion groups, not because it is an occluder, but because we want to run + // an occlusion query to find out if it's an occluder + markOccluder(group); + } mNumVisibleNodes++; } @@ -4585,12 +4592,14 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) #endif } -void LLPipeline::renderGeomDeferred(LLCamera& camera) +void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) { LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; + { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); //LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS); @@ -4630,6 +4639,17 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) cur_type = poolp->getType(); + if (occlude && cur_type >= LLDrawPool::POOL_GRASS) + { + llassert(!gCubeSnapshot); // never do occlusion culling on cube snapshots + occlude = false; + gGLLastMatrix = NULL; + gGL.loadMatrix(gGLModelView); + LLGLSLShader::bindNoShader(); + doOcclusion(camera); + gGL.setColorMask(true, false); + } + pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0) { @@ -4686,7 +4706,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) } // Tracy ZoneScoped } -void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) +void LLPipeline::renderGeomPostDeferred(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLS); LL_PROFILE_GPU_ZONE("renderGeomPostDeferred"); @@ -4703,7 +4723,6 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) gGL.setColorMask(true, false); pool_set_t::iterator iter1 = mPools.begin(); - bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; while ( iter1 != mPools.end() ) { @@ -4711,18 +4730,6 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) cur_type = poolp->getType(); - if (occlude && cur_type >= LLDrawPool::POOL_GRASS) - { - llassert(!gCubeSnapshot); // never do occlusion culling on cube snapshots - occlude = false; - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); - //doOcclusion(camera, mRT->screen, mRT->occlusionDepth, &mRT->deferredDepth); - doOcclusion(camera, mRT->screen, mRT->occlusionDepth); - gGL.setColorMask(true, false); - } - pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0) { @@ -4774,16 +4781,6 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); - if (occlude) - { - occlude = false; - LLGLSLShader::bindNoShader(); - doOcclusion(camera); - gGLLastMatrix = NULL; - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(gGLModelView); - } - if (!gCubeSnapshot) { // debug displays -- cgit v1.2.3 From 4a4b0f8ee8834de01e52d32aecdb0479ed5fb7a9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Oct 2022 13:25:40 -0500 Subject: SL-18190 Rearrange render order so 3D UI has access to the depth buffer. --- indra/newview/pipeline.cpp | 140 ++++++++++++++++++++++----------------------- 1 file changed, 70 insertions(+), 70 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c360a7fc63..87a5cd9cc8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7599,6 +7599,76 @@ void LLPipeline::renderFinalize() gGL.setColorMask(true, true); glClearColor(0, 0, 0, 0); + if (!gCubeSnapshot) + { + // gamma correct lighting + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + { + LL_PROFILE_GPU_ZONE("gamma correct"); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + LLRenderTarget* screen_target = &mRT->screen; + + LLVector2 tc1(0, 0); + LLVector2 tc2((F32)screen_target->getWidth() * 2, (F32)screen_target->getHeight() * 2); + + screen_target->bindTarget(); + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); + // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); + if (channel > -1) + { + screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); + + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); + + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); + + gGL.end(); + + gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); + screen_target->flush(); + } + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + + LLVertexBuffer::unbind(); + + if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + { + // Render debugging beacons. + gObjectList.renderObjectBeacons(); + gObjectList.resetObjectBeacons(); + gSky.addSunMoonBeacons(); + } + } + if (sRenderGlow) { LL_PROFILE_GPU_ZONE("glow"); @@ -9037,76 +9107,6 @@ void LLPipeline::renderDeferredLighting() } screen_target->flush(); - - if (!gCubeSnapshot) - { - // gamma correct lighting - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - - { - LL_PROFILE_GPU_ZONE("gamma correct"); - - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - LLVector2 tc1(0, 0); - LLVector2 tc2((F32)screen_target->getWidth() * 2, (F32)screen_target->getHeight() * 2); - - screen_target->bindTarget(); - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); - if (channel > -1) - { - screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); - - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); - - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); - - gGL.end(); - - gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - screen_target->flush(); - } - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - LLVertexBuffer::unbind(); - - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) - { - // Render debugging beacons. - gObjectList.renderObjectBeacons(); - gObjectList.resetObjectBeacons(); - gSky.addSunMoonBeacons(); - } - } - - screen_target->flush(); } void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) -- cgit v1.2.3 From 07bca31e06e4219401f82ae04539418c65e22ea8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 10 Oct 2022 18:53:43 -0500 Subject: SL-18190 Fix alpha not playing nice with water surface by split LLDrawPoolAlpha into two passes, one above water, one below water, and clip against water plane. Currently brute forces two complete alpha passes, still need to cull against water plane and add support for fullbright shaders. --- indra/newview/pipeline.cpp | 92 +++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 54 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 87a5cd9cc8..2f4ab3ac45 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -281,33 +281,6 @@ static LLStaticHashedString sKern("kern"); static LLStaticHashedString sKernScale("kern_scale"); //---------------------------------------- -#if 0 -std::string gPoolNames[LLDrawPool::NUM_POOL_TYPES] = -{ - // Correspond to LLDrawpool enum render type - "NONE" - , "POOL_SIMPLE" - , "POOL_GROUND" - , "POOL_FULLBRIGHT" - , "POOL_BUMP" - , "POOL_MATERIALS" - , "POOL_TERRAIN" - , "POOL_SKY" - , "POOL_WL_SKY" - , "POOL_TREE" - , "POOL_ALPHA_MASK" - , "POOL_FULLBRIGHT_ALPHA_MASK" - , "POOL_GRASS" - , "POOL_INVISIBLE" - , "POOL_AVATAR" - , "POOL_CONTROL_AV" // Animesh - , "POOL_VOIDWATER" - , "POOL_WATER" - , "POOL_GLOW" - , "POOL_ALPHA" - , "POOL_PBR_OPAQUE" -}; -#endif void drawBox(const LLVector4a& c, const LLVector4a& r); void drawBoxOutline(const LLVector3& pos, const LLVector3& size); @@ -397,21 +370,6 @@ LLPipeline::LLPipeline() : mGroupQ2Locked(false), mResetVertexBuffers(false), mLastRebuildPool(NULL), - mAlphaPool(NULL), - mSkyPool(NULL), - mTerrainPool(NULL), - mWaterPool(NULL), - mGroundPool(NULL), - mSimplePool(NULL), - mGrassPool(NULL), - mAlphaMaskPool(NULL), - mFullbrightAlphaMaskPool(NULL), - mFullbrightPool(NULL), - mInvisiblePool(NULL), - mGlowPool(NULL), - mBumpPool(NULL), - mMaterialsPool(NULL), - mWLSkyPool(NULL), mLightMask(0), mLightMovingMask(0), mLightingDetail(0) @@ -463,7 +421,8 @@ void LLPipeline::init() LL_WARNS() << "No GL errors yet. Pipeline initialization will continue." << LL_ENDL; // TODO: Remove after testing //create render pass pools - getPool(LLDrawPool::POOL_ALPHA); + getPool(LLDrawPool::POOL_ALPHA_PRE_WATER); + getPool(LLDrawPool::POOL_ALPHA_POST_WATER); getPool(LLDrawPool::POOL_SIMPLE); getPool(LLDrawPool::POOL_ALPHA_MASK); getPool(LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK); @@ -671,8 +630,10 @@ void LLPipeline::cleanup() LL_WARNS() << "Tree Pools not cleaned up" << LL_ENDL; } - delete mAlphaPool; - mAlphaPool = NULL; + delete mAlphaPoolPreWater; + mAlphaPoolPreWater = nullptr; + delete mAlphaPoolPostWater; + mAlphaPoolPostWater = nullptr; delete mSkyPool; mSkyPool = NULL; delete mTerrainPool; @@ -1589,9 +1550,12 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) case LLDrawPool::POOL_MATERIALS: poolp = mMaterialsPool; break; - case LLDrawPool::POOL_ALPHA: - poolp = mAlphaPool; + case LLDrawPool::POOL_ALPHA_PRE_WATER: + poolp = mAlphaPoolPreWater; break; + case LLDrawPool::POOL_ALPHA_POST_WATER: + poolp = mAlphaPoolPostWater; + break; case LLDrawPool::POOL_AVATAR: case LLDrawPool::POOL_CONTROL_AV: @@ -5733,17 +5697,28 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) mMaterialsPool = new_poolp; } break; - case LLDrawPool::POOL_ALPHA: - if( mAlphaPool ) + case LLDrawPool::POOL_ALPHA_PRE_WATER: + if( mAlphaPoolPreWater ) { llassert(0); - LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha pool" << LL_ENDL; + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha pre-water pool" << LL_ENDL; } else { - mAlphaPool = (LLDrawPoolAlpha*) new_poolp; + mAlphaPoolPreWater = (LLDrawPoolAlpha*) new_poolp; } break; + case LLDrawPool::POOL_ALPHA_POST_WATER: + if (mAlphaPoolPostWater) + { + llassert(0); + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha post-water pool" << LL_ENDL; + } + else + { + mAlphaPoolPostWater = (LLDrawPoolAlpha*)new_poolp; + } + break; case LLDrawPool::POOL_AVATAR: case LLDrawPool::POOL_CONTROL_AV: @@ -5901,10 +5876,15 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mMaterialsPool = NULL; break; - case LLDrawPool::POOL_ALPHA: - llassert( poolp == mAlphaPool ); - mAlphaPool = NULL; + case LLDrawPool::POOL_ALPHA_PRE_WATER: + llassert( poolp == mAlphaPoolPreWater ); + mAlphaPoolPreWater = nullptr; break; + + case LLDrawPool::POOL_ALPHA_POST_WATER: + llassert(poolp == mAlphaPoolPostWater); + mAlphaPoolPostWater = nullptr; + break; case LLDrawPool::POOL_AVATAR: case LLDrawPool::POOL_CONTROL_AV: @@ -9078,6 +9058,8 @@ void LLPipeline::renderDeferredLighting() pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER, + LLPipeline::RENDER_TYPE_ALPHA_POST_WATER, LLPipeline::RENDER_TYPE_FULLBRIGHT, LLPipeline::RENDER_TYPE_VOLUME, LLPipeline::RENDER_TYPE_GLOW, @@ -10296,6 +10278,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE, LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER, + LLPipeline::RENDER_TYPE_ALPHA_POST_WATER, LLPipeline::RENDER_TYPE_GRASS, LLPipeline::RENDER_TYPE_FULLBRIGHT, LLPipeline::RENDER_TYPE_BUMP, -- cgit v1.2.3 From b6e576c7c2a1cb395092cc66b1836157872b131f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 11 Oct 2022 20:20:39 -0500 Subject: SL-18190 Cleanup -- convert some vec4's to vec3's (as they really are), remove some unused glsl files. --- indra/newview/pipeline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2f4ab3ac45..d8af012cc0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8484,8 +8484,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } - shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); + shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); LLEnvironment& environment = LLEnvironment::instance(); LLSettingsSky::ptr_t sky = environment.getCurrentSky(); @@ -8735,7 +8735,7 @@ void LLPipeline::renderDeferredLighting() LLEnvironment &environment = LLEnvironment::instance(); soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); if (!LLPipeline::sUnderWaterRender && LLPipeline::sRenderPBR) { -- cgit v1.2.3 From 42ec639c860e172803753b9cb41ae9483305f2f8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 12 Oct 2022 14:46:51 -0500 Subject: SL-18190 Remove water reflection detail combo box and reimplement "Transparent Water" checkbox. --- indra/newview/pipeline.cpp | 362 +-------------------------------------------- 1 file changed, 1 insertion(+), 361 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d8af012cc0..93ae6e99a5 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -203,7 +203,6 @@ F32 LLPipeline::RenderEdgeNormCutoff; LLVector3 LLPipeline::RenderShadowGaussian; F32 LLPipeline::RenderShadowBlurDistFactor; bool LLPipeline::RenderDeferredAtmospheric; -S32 LLPipeline::RenderReflectionDetail; F32 LLPipeline::RenderHighlightFadeTime; LLVector3 LLPipeline::RenderShadowClipPlanes; LLVector3 LLPipeline::RenderShadowOrthoClipPlanes; @@ -316,7 +315,6 @@ bool LLPipeline::sNoAlpha = false; bool LLPipeline::sUseTriStrips = true; bool LLPipeline::sUseFarClip = true; bool LLPipeline::sShadowRender = false; -bool LLPipeline::sWaterReflections = false; bool LLPipeline::sRenderGlow = false; bool LLPipeline::sReflectionRender = false; bool LLPipeline::sDistortionRender = false; @@ -570,7 +568,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderShadowGaussian"); connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor"); connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric"); - connectRefreshCachedSettingsSafe("RenderReflectionDetail"); connectRefreshCachedSettingsSafe("RenderHighlightFadeTime"); connectRefreshCachedSettingsSafe("RenderShadowClipPlanes"); connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes"); @@ -1072,7 +1069,6 @@ void LLPipeline::refreshCachedSettings() RenderShadowGaussian = gSavedSettings.getVector3("RenderShadowGaussian"); RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric"); - RenderReflectionDetail = gSavedSettings.getS32("RenderReflectionDetail"); RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime"); RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes"); RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); @@ -1193,10 +1189,9 @@ void LLPipeline::createGLBuffers() assertInitialized(); updateRenderDeferred(); - if (LLPipeline::sWaterReflections) + if (LLPipeline::sRenderTransparentWater) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE); } @@ -2427,17 +2422,6 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla stop_glerror(); } - if (hasRenderType(LLPipeline::RENDER_TYPE_GROUND) && - !gPipeline.canUseWindLightShaders() && - gSky.mVOGroundp.notNull() && - gSky.mVOGroundp->mDrawable.notNull() && - !LLPipeline::sWaterReflections) - { - gSky.mVOGroundp->mDrawable->setVisible(camera); - sCull->pushDrawable(gSky.mVOGroundp->mDrawable); - } - - if (hasRenderType(LLPipeline::RENDER_TYPE_WL_SKY) && gPipeline.canUseWindLightShaders() && gSky.mVOWLSkyp.notNull() && @@ -9347,350 +9331,6 @@ inline float sgn(float a) return (0.0F); } -void LLPipeline::generateWaterReflection(LLCamera& camera_in) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - LL_PROFILE_GPU_ZONE("generateWaterReflection"); - - if (!assertInitialized() || gCubeSnapshot) - { - return; - } - - if (LLPipeline::sWaterReflections && LLDrawPoolWater::sNeedsReflectionUpdate) - { - //disable occlusion culling for reflection/refraction passes (save setting to restore later) - S32 occlude = LLPipeline::sUseOcclusion; - LLPipeline::sUseOcclusion = 0; - - bool skip_avatar_update = false; - if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) - { - skip_avatar_update = true; - } - - LLCamera camera = camera_in; - camera.setFar(camera_in.getFar() * 0.75f); - - bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - - LLPipeline::sReflectionRender = true; - - gPipeline.pushRenderTypeMask(); - - glh::matrix4f saved_modelview = get_current_modelview(); - glh::matrix4f saved_projection = get_current_projection(); - glh::matrix4f mat; - -#if 1 // relies on forward rendering, which is deprecated -- TODO - make a deferred implementation of transparent/reflective water - S32 reflection_detail = RenderReflectionDetail; -#else - S32 reflection_detail = WATER_REFLECT_NONE_WATER_TRANSPARENT; -#endif - - F32 water_height = gAgent.getRegion()->getWaterHeight(); - F32 camera_height = camera_in.getOrigin().mV[VZ]; - F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height); - - LLVector3 reflection_offset = LLVector3(0, 0, distance_to_water * 2.0f); - LLVector3 camera_look_at = camera_in.getAtAxis(); - LLVector3 reflection_look_at = LLVector3(camera_look_at.mV[VX], camera_look_at.mV[VY], -camera_look_at.mV[VZ]); - LLVector3 reflect_origin = camera_in.getOrigin() - reflection_offset; - LLVector3 reflect_interest_point = reflect_origin + (reflection_look_at * 5.0f); - - camera.setOriginAndLookAt(reflect_origin, LLVector3::z_axis, reflect_interest_point); - - //plane params - LLPlane plane; - LLVector3 pnorm; - - if (camera_is_underwater) - { - //camera is below water, cull above water - pnorm.setVec(0, 0, 1); - } - else - { - //camera is above water, cull below water - pnorm = LLVector3(0, 0, -1); - } - - plane.setVec(LLVector3(0, 0, water_height), pnorm); - - if (!camera_is_underwater) - { - //generate planar reflection map - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0; - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - - mat.set_scale(glh::vec3f(1, 1, -1)); - mat.set_translate(glh::vec3f(0,0,water_height*2.f)); - mat = saved_modelview * mat; - - - mReflectionModelView = mat; - - set_current_modelview(mat); - gGL.loadMatrix(mat.m); - - LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); - - glh::vec3f origin(0, 0, 0); - glh::matrix4f inv_mat = mat.inverse(); - inv_mat.mult_matrix_vec(origin); - - camera.setOrigin(origin.v); - - glCullFace(GL_FRONT); - - if (LLDrawPoolWater::sNeedsReflectionUpdate) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glClearColor(0,0,0,0); - mWaterRef.bindTarget(); - - gGL.setColorMask(true, true); - mWaterRef.clear(); - gGL.setColorMask(true, false); - mWaterRef.getViewport(gGLViewport); - - //initial sky pass (no user clip plane) - //mask out everything but the sky - gPipeline.pushRenderTypeMask(); - { - if (reflection_detail >= WATER_REFLECT_MINIMAL) - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); - } - else - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - } - - updateCull(camera, mSky); - stateSort(camera, mSky); - renderGeom(camera, TRUE); - } - gPipeline.popRenderTypeMask(); - - if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) - { - gPipeline.pushRenderTypeMask(); - { - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_GROUND, - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); - - if (reflection_detail > WATER_REFLECT_MINIMAL) - { //mask out selected geometry based on reflection detail - if (reflection_detail < WATER_REFLECT_EVERYTHING) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES); - if (reflection_detail < WATER_REFLECT_AVATARS) - { - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_CONTROL_AV, - END_RENDER_TYPES); - if (reflection_detail < WATER_REFLECT_STATIC_OBJECTS) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES); - } - } - } - - LLGLUserClipPlane clip_plane(plane, mReflectionModelView, saved_projection); - LLGLDisable cull(GL_CULL_FACE); - updateCull(camera, mReflectedObjects, &plane); - stateSort(camera, mReflectedObjects); - renderGeom(camera); - } - } - gPipeline.popRenderTypeMask(); - } - - mWaterRef.flush(); - } - - glCullFace(GL_BACK); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - set_current_modelview(saved_modelview); - } - - camera.setOrigin(camera_in.getOrigin()); - //render distortion map - static bool last_update = true; - if (last_update) - { - gPipeline.pushRenderTypeMask(); - - camera.setFar(camera_in.getFar()); - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_GROUND, - END_RENDER_TYPES); - - // intentionally inverted so that distortion map contents (objects under the water when we're above it) - // will properly include water fog effects - LLPipeline::sUnderWaterRender = !camera_is_underwater; - - if (LLPipeline::sUnderWaterRender) - { - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_GROUND, - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - END_RENDER_TYPES); - } - LLViewerCamera::updateFrustumPlanes(camera); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - if (LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsDistortionUpdate) - { - LLPipeline::sDistortionRender = true; - - LLColor3 col = LLEnvironment::instance().getCurrentWater()->getWaterFogColor(); - glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); - - // HACK FIX -- pretend underwater camera is the world camera to fix weird visibility artifacts - // during distortion render (doesn't break main render because the camera is the same perspective - // as world camera and occlusion culling is disabled for this pass) - //LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - - mWaterDis.bindTarget(); - mWaterDis.getViewport(gGLViewport); - - gGL.setColorMask(true, true); - mWaterDis.clear(); - gGL.setColorMask(true, false); - - F32 water_dist = water_height; - - //clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself, - // but not so much as to clip out parts of avatars that should be seen under the water in the distortion map - LLPlane plane; - - if (camera_is_underwater) - { - //nudge clip plane below water to avoid visible holes in objects intersecting water surface - water_dist /= LLPipeline::sDistortionWaterClipPlaneMargin; - //camera is below water, clip plane points up - pnorm.setVec(0, 0, -1); - } - else - { - //nudge clip plane above water to avoid visible holes in objects intersecting water surface - water_dist *= LLPipeline::sDistortionWaterClipPlaneMargin; - //camera is above water, clip plane points down - pnorm = LLVector3(0, 0, 1); - } - - plane.setVec(LLVector3(0, 0, water_dist), pnorm); - - LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection); - - gGL.setColorMask(true, true); - mWaterDis.clear(); - gGL.setColorMask(true, false); - -#if 0 // DEPRECATED - requires forward rendering, TODO - make a deferred implementation - if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) - { - updateCull(camera, mRefractedObjects, &plane); - stateSort(camera, mRefractedObjects); - renderGeom(camera); - } -#endif - - - gUIProgram.bind(); - - LLWorld::getInstance()->renderPropertyLines(); - - gUIProgram.unbind(); - - mWaterDis.flush(); - } - - LLPipeline::sDistortionRender = false; - - gPipeline.popRenderTypeMask(); - } - last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; - - gPipeline.popRenderTypeMask(); - - LLPipeline::sUnderWaterRender = false; - LLPipeline::sReflectionRender = false; - - LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; - LLDrawPoolWater::sNeedsDistortionUpdate = FALSE; - - if (!LLRenderTarget::sUseFBO) - { - glClear(GL_DEPTH_BUFFER_BIT); - } - glClearColor(0.f, 0.f, 0.f, 0.f); - gViewerWindow->setup3DViewport(); - - LLGLState::checkStates(); - - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); - } - - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - - // restore occlusion culling - LLPipeline::sUseOcclusion = occlude; - } - else - { - // Initial sky pass is still needed even if water reflection is not rendering - bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - if (!camera_is_underwater) - { - gPipeline.pushRenderTypeMask(); - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - LLCamera camera = camera_in; - camera.setFar(camera_in.getFar() * 0.75f); - - updateCull(camera, mSky); - stateSort(camera, mSky); - renderGeom(camera, TRUE); - } - gPipeline.popRenderTypeMask(); - } - } -#endif -} - glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) { glh::matrix4f ret; -- cgit v1.2.3 From 0e3f8db632e2f616b0ab9bd3363c20d2f1acb549 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 Oct 2022 11:20:23 -0500 Subject: SL-18190 Fix for blurry name tags. --- indra/newview/pipeline.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 93ae6e99a5..ef7ebda834 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4010,7 +4010,6 @@ void render_hud_elements() LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI); gPipeline.disableLights(); - LLGLDisable fog(GL_FOG); LLGLSUIDefault gls_ui; //LLGLEnable stencil(GL_STENCIL_TEST); @@ -4038,9 +4037,6 @@ void render_hud_elements() } LLViewerParcelMgr::getInstance()->render(); LLViewerParcelMgr::getInstance()->renderParcelCollision(); - - // Render name tags. - LLHUDObject::renderAll(); } else if (gForceRenderLandFence) { @@ -4053,7 +4049,6 @@ void render_hud_elements() } gUIProgram.unbind(); - gGL.flush(); } void LLPipeline::renderHighlights() -- cgit v1.2.3 From a2b09df2db69ba8a2e6b587d839d509fbe5abebb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 14 Oct 2022 15:52:44 -0500 Subject: SL-18293 Fix for broken wireframe mode. --- indra/newview/pipeline.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ef7ebda834..0c27296440 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4541,6 +4541,11 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; { @@ -4647,6 +4652,11 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) gGL.setColorMask(true, false); } // Tracy ZoneScoped + + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } } void LLPipeline::renderGeomPostDeferred(LLCamera& camera) @@ -4654,6 +4664,11 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLS); LL_PROFILE_GPU_ZONE("renderGeomPostDeferred"); + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -4733,6 +4748,10 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) renderDebug(); } + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } } void LLPipeline::renderGeomShadow(LLCamera& camera) @@ -7528,11 +7547,6 @@ void LLPipeline::renderFinalize() assertInitialized(); - if (gUseWireframe) - { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - LLVector2 tc1(0, 0); LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); -- cgit v1.2.3 From de4c018499ddaebbe466fb5a8938554a2d4a3b19 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 19 Oct 2022 14:41:17 -0500 Subject: SL-18105 Hook up render pipe directly to LLTextureEntry::mGLTFMaterial and add LLViewerFetchedTextures to LLFetchedGLTFMaterial. Lower reflection probe resolution to 128x128 per side. --- indra/newview/pipeline.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0c27296440..cb54cec165 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3723,15 +3723,26 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) void LLPipeline::touchTextures(LLDrawInfo* info) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - for (int i = 0; i < info->mTextureList.size(); ++i) + + auto& mat = info->mGLTFMaterial; + if (mat.notNull()) { - touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + touchTexture(mat->mBaseColorTexture, info->mVSize); + touchTexture(mat->mNormalTexture, info->mVSize); + touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); + touchTexture(mat->mEmissiveTexture, info->mVSize); } + else + { + for (int i = 0; i < info->mTextureList.size(); ++i) + { + touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + } - touchTexture(info->mTexture, info->mVSize); - touchTexture(info->mSpecularMap, info->mVSize); - touchTexture(info->mNormalMap, info->mVSize); - touchTexture(info->mEmissiveMap, info->mVSize); + touchTexture(info->mTexture, info->mVSize); + touchTexture(info->mSpecularMap, info->mVSize); + touchTexture(info->mNormalMap, info->mVSize); + } } void LLPipeline::postSort(LLCamera& camera) -- cgit v1.2.3 From 8741c05cc10d3f39f272bb4739e7313309539d07 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 19 Oct 2022 17:23:54 -0500 Subject: SL-18105 Hook up TE override material to render pipe by way of render material. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cb54cec165..b6d9e5fd36 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1617,7 +1617,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } LLMaterial* mat = te->getMaterialParams().get(); - LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); + LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); bool color_alpha = te->getColor().mV[3] < 0.999f; bool alpha = color_alpha; -- cgit v1.2.3 From 0451d51f4da9780e2f650b67672a29b3d07cb386 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 27 Oct 2022 11:27:21 -0500 Subject: SL-18459 WIP -- fix for assert in setGLTFMaterial --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b60b64ed1f..a0fec90f87 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6150,7 +6150,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) // FIND NEW LIGHTS THAT ARE IN RANGE light_set_t new_nearby_lights; - for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); + for (LLDrawable::ordered_drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) { LLDrawable* drawable = *iter; -- cgit v1.2.3 From 81553613551ffc7c8253d67a3fb3a24137d19d51 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 28 Oct 2022 11:19:43 -0500 Subject: SL-18453 WIP -- Use GLTF draw pool to render shadows. Still need a GLTF specific shadow shader to multiply alpha. --- indra/newview/pipeline.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a0fec90f87..aacf6fa73e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -428,7 +428,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); - getPool(LLDrawPool::POOL_PBR_OPAQUE); + getPool(LLDrawPool::POOL_GLTF_PBR); resetFrameStats(); @@ -1568,7 +1568,7 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mWLSkyPool; break; - case LLDrawPool::POOL_PBR_OPAQUE: + case LLDrawPool::POOL_GLTF_PBR: poolp = mPBROpaquePool; break; @@ -1649,7 +1649,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } else if (gltf_mat) { - return LLDrawPool::POOL_PBR_OPAQUE; + return LLDrawPool::POOL_GLTF_PBR; } else if (mat && !alpha) { @@ -5777,7 +5777,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; - case LLDrawPool::POOL_PBR_OPAQUE: + case LLDrawPool::POOL_GLTF_PBR: if( mPBROpaquePool ) { llassert(0); @@ -5910,7 +5910,7 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mGroundPool = NULL; break; - case LLDrawPool::POOL_PBR_OPAQUE: + case LLDrawPool::POOL_GLTF_PBR: llassert( poolp == mPBROpaquePool ); mPBROpaquePool = NULL; break; @@ -9604,7 +9604,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_PBR_OPAQUE, no_idx_mask, true, false, rigged); } } } @@ -9943,6 +9942,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER, LLPipeline::RENDER_TYPE_ALPHA_POST_WATER, LLPipeline::RENDER_TYPE_GRASS, + LLPipeline::RENDER_TYPE_GLTF_PBR, LLPipeline::RENDER_TYPE_FULLBRIGHT, LLPipeline::RENDER_TYPE_BUMP, LLPipeline::RENDER_TYPE_VOLUME, @@ -10000,8 +10000,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_PASS_NORMSPEC_BLEND_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_MASK_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED, - LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE, - LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE_RIGGED, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED, END_RENDER_TYPES); gGL.setColorMask(false, false); -- cgit v1.2.3 From 8a19c8e073e6f34dc1579ed7ab2ac64f567a1793 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 11 Nov 2022 15:19:41 -0600 Subject: SL-18615 Fix for beacons not rendering and beacon highlights flickering. --- indra/newview/pipeline.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index aacf6fa73e..aa4cd38b99 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3918,7 +3918,7 @@ void LLPipeline::postSort(LLCamera& camera) LL_PUSH_CALLSTACKS(); // only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus - if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender) + if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender && !gCubeSnapshot) { if (sRenderScriptedTouchBeacons) { @@ -3971,12 +3971,12 @@ void LLPipeline::postSort(LLCamera& camera) } LL_PUSH_CALLSTACKS(); // If managing your telehub, draw beacons at telehub and currently selected spawnpoint. - if (LLFloaterTelehub::renderBeacons() && !sShadowRender) + if (LLFloaterTelehub::renderBeacons() && !sShadowRender && !gCubeSnapshot) { LLFloaterTelehub::addBeacons(); } - if (!sShadowRender) + if (!sShadowRender && !gCubeSnapshot) { mSelectedFaces.clear(); @@ -7645,14 +7645,6 @@ void LLPipeline::renderFinalize() gGL.popMatrix(); LLVertexBuffer::unbind(); - - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) - { - // Render debugging beacons. - gObjectList.renderObjectBeacons(); - gObjectList.resetObjectBeacons(); - gSky.addSunMoonBeacons(); - } } if (sRenderGlow) -- cgit v1.2.3 From 97277e74a9d966ed441e51f844f9012f55cca3dc Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Mon, 14 Nov 2022 18:12:22 +0000 Subject: Merged in SL-18332 (pull request #1194) First pass of Screen Space Reflections Approved-by: Dave Parks --- indra/newview/pipeline.cpp | 160 +++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 77 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index aa4cd38b99..dff84bda0e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -215,6 +215,7 @@ bool LLPipeline::CameraOffset; F32 LLPipeline::CameraMaxCoF; F32 LLPipeline::CameraDoFResScale; F32 LLPipeline::RenderAutoHideSurfaceAreaLimit; +bool LLPipeline::RenderScreenSpaceReflections; LLTrace::EventStatHandle LLPipeline::sStatBatchSize("renderbatchsize"); const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f; @@ -345,7 +346,7 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) { bool valid = true && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM - && target.addColorAttachment(GL_RGB10_A2) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight + && target.addColorAttachment(GL_RGBA16F) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight && target.addColorAttachment(GL_RGBA); // frag_data[3] PBR emissive return valid; } @@ -576,6 +577,7 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("CameraMaxCoF"); connectRefreshCachedSettingsSafe("CameraDoFResScale"); connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflections"); gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); } @@ -731,7 +733,7 @@ void LLPipeline::allocatePhysicsBuffer() if (mPhysicsDisplay.getWidth() != resX || mPhysicsDisplay.getHeight() != resY) { - mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE); } } @@ -825,7 +827,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (RenderUIBuffer) { - if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) + if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) { return false; } @@ -839,14 +841,14 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 occlusion_divisor = 3; //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - //if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + //if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16; - if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; mRT->deferredScreen.shareDepthBuffer(mRT->screen); @@ -861,7 +863,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa - if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false; } else { @@ -889,7 +891,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) //mRT->deferredDepth.release(); mRT->occlusionDepth.release(); - if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false; } gGL.getTexUnit(0)->disable(); @@ -1077,6 +1079,7 @@ void LLPipeline::refreshCachedSettings() CameraMaxCoF = gSavedSettings.getF32("CameraMaxCoF"); CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale"); RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit"); + RenderScreenSpaceReflections = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); RenderSpotLight = nullptr; updateRenderDeferred(); @@ -2543,7 +2546,7 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d vert[1].set(-1,-3,0); vert[2].set(3,1,0); - if (source.getUsage() == LLTexUnit::TT_RECT_TEXTURE) + if (source.getUsage() == LLTexUnit::TT_TEXTURE) { shader = &gDownsampleDepthRectProgram; shader->bind(); @@ -7573,13 +7576,6 @@ void LLPipeline::renderFinalize() enableLightsFullbright(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - LLGLDisable test(GL_ALPHA_TEST); gGL.setColorMask(true, true); @@ -7587,13 +7583,64 @@ void LLPipeline::renderFinalize() if (!gCubeSnapshot) { + if (RenderScreenSpaceReflections) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections"); + LL_PROFILE_GPU_ZONE("screen space reflections"); + LLStrider vert; + mDeferredVB->getVertexStrider(vert); + + vert[0].set(-1, 1, 0); + vert[1].set(-1, -3, 0); + vert[2].set(3, 1, 0); + + // Make sure the deferred VB is a full screen triangle. + mDeferredVB->getVertexStrider(vert); + + bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + // Provide our projection matrix. + auto camProj = LLViewerCamera::getInstance()->getProjection(); + glh::matrix4f projection = get_current_projection(); + projection.set_row(0, glh::vec4f(camProj.mMatrix[0][0], camProj.mMatrix[0][1], camProj.mMatrix[0][2], camProj.mMatrix[0][3])); + projection.set_row(0, glh::vec4f(camProj.mMatrix[1][0], camProj.mMatrix[1][1], camProj.mMatrix[1][2], camProj.mMatrix[1][3])); + projection.set_row(0, glh::vec4f(camProj.mMatrix[2][0], camProj.mMatrix[2][1], camProj.mMatrix[2][2], camProj.mMatrix[2][3])); + projection.set_row(0, glh::vec4f(camProj.mMatrix[3][0], camProj.mMatrix[3][1], camProj.mMatrix[3][2], camProj.mMatrix[3][3])); + gPostScreenSpaceReflectionProgram.uniformMatrix4fv(LLShaderMgr::PROJECTION_MATRIX, 1, FALSE, projection.m); + + // We need linear depth. + static LLStaticHashedString zfar("zFar"); + static LLStaticHashedString znear("zNear"); + float nearClip = LLViewerCamera::getInstance()->getNear(); + float farClip = LLViewerCamera::getInstance()->getFar(); + gPostScreenSpaceReflectionProgram.uniform1f(zfar, farClip); + gPostScreenSpaceReflectionProgram.uniform1f(znear, nearClip); + + LLRenderTarget *screen_target = &mRT->screen; + + screen_target->bindTarget(); + S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); + if (channel > -1) + { + screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); + + } + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + + unbindDeferredShader(gPostScreenSpaceReflectionProgram); + + screen_target->flush(); + } + // gamma correct lighting - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); { LL_PROFILE_GPU_ZONE("gamma correct"); @@ -7639,11 +7686,6 @@ void LLPipeline::renderFinalize() screen_target->flush(); } - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - LLVertexBuffer::unbind(); } @@ -7988,8 +8030,8 @@ void LLPipeline::renderFinalize() shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - shader->uniform1f(LLShaderMgr::DOF_WIDTH, dof_width - 1); - shader->uniform1f(LLShaderMgr::DOF_HEIGHT, dof_height - 1); + shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth()); + shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight()); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); @@ -8200,11 +8242,6 @@ void LLPipeline::renderFinalize() GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); }*/ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - LLVertexBuffer::unbind(); LLGLState::checkStates(); @@ -8225,24 +8262,28 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ if (channel > -1) { deferred_target->bindTexture(0,channel, LLTexUnit::TFO_POINT); // frag_data[0] + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); if (channel > -1) { deferred_target->bindTexture(1, channel, LLTexUnit::TFO_POINT); // frag_data[1] + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); if (channel > -1) { deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); // frag_data[2] + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage()); if (channel > -1) { deferred_target->bindTexture(3, channel, LLTexUnit::TFO_POINT); // frag_data[3] + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_BRDF_LUT, LLTexUnit::TT_TEXTURE); @@ -8267,14 +8308,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); } #endif - - glh::matrix4f projection = get_current_projection(); - glh::matrix4f inv_proj = projection.inverse(); - - if (shader.getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX) != -1) - { - shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); - } if (shader.getUniformLocation(LLShaderMgr::VIEWPORT) != -1) { @@ -8507,6 +8540,8 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f) void LLPipeline::renderDeferredLighting() { + + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("renderDeferredLighting"); if (!sCull) @@ -8579,12 +8614,6 @@ void LLPipeline::renderDeferredLighting() mat.mult_matrix_vec(tc_moon); mTransformedMoonDir.set(tc_moon.v); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - if (RenderDeferredSSAO || RenderShadowDetail > 0) { LL_PROFILE_GPU_ZONE("sun program"); @@ -8667,15 +8696,17 @@ void LLPipeline::renderDeferredLighting() LLVector3 gauss[32]; // xweight, yweight, offset + F32 screenPixelSize = 1.f / screen_target->getWidth(); + for (U32 i = 0; i < kern_length; i++) { gauss[i].mV[0] = llgaussian(x, go.mV[0]); gauss[i].mV[1] = llgaussian(x, go.mV[1]); gauss[i].mV[2] = x; - x += 1.f; + x += screenPixelSize; } - gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); + gDeferredBlurLightProgram.uniform2f(sDelta, screenPixelSize, 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)); @@ -8710,14 +8741,6 @@ void LLPipeline::renderDeferredLighting() } } - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - screen_target->bindTarget(); // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky glClearColor(0, 0, 0, 0); @@ -8752,19 +8775,11 @@ void LLPipeline::renderDeferredLighting() LLGLDisable test(GL_ALPHA_TEST); // full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); } unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); @@ -8966,12 +8981,6 @@ void LLPipeline::renderDeferredLighting() LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - fullscreen lights"); LLGLDepthTest depth(GL_FALSE); LL_PROFILE_GPU_ZONE("fullscreen lights"); - // full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); U32 count = 0; @@ -9040,13 +9049,10 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); unbindDeferredShader(gDeferredMultiSpotLightProgram); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); } } + gGL.setColorMask(true, true); } -- cgit v1.2.3 From 07ada65df1c72adff6e356011840ca262beb4be0 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 16 Nov 2022 07:11:13 -0800 Subject: A few tweaks to SSR while I'm in the neighborhood. Mostly just making it actually kind of work. Still needs a lot more tweaking - but can revisit later. SL-18332 --- indra/newview/pipeline.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dff84bda0e..82194163b3 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7620,7 +7620,7 @@ void LLPipeline::renderFinalize() LLRenderTarget *screen_target = &mRT->screen; screen_target->bindTarget(); - S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); + S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, screen_target->getUsage()); if (channel > -1) { screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); @@ -7628,8 +7628,9 @@ void LLPipeline::renderFinalize() } { - LLGLDisable blend(GL_BLEND); + LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); -- cgit v1.2.3 From 8d2ac419b22c8c9475f2efb312dd198ac8eb9fb7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 16 Nov 2022 14:49:17 -0600 Subject: SL-18154 Profile guided optimizations vs release viewer. Trim some unused abilities and remove some more fast timers. --- indra/newview/pipeline.cpp | 85 +++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 43 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dff84bda0e..d2c079baa6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -313,7 +313,6 @@ bool LLPipeline::sRenderTransparentWater = true; bool LLPipeline::sRenderBump = true; bool LLPipeline::sBakeSunlight = false; bool LLPipeline::sNoAlpha = false; -bool LLPipeline::sUseTriStrips = true; bool LLPipeline::sUseFarClip = true; bool LLPipeline::sShadowRender = false; bool LLPipeline::sRenderGlow = false; @@ -323,7 +322,6 @@ bool LLPipeline::sImpostorRender = false; bool LLPipeline::sImpostorRenderAlphaDepthPass = false; bool LLPipeline::sUnderWaterRender = false; bool LLPipeline::sTextureBindTest = false; -bool LLPipeline::sRenderFrameTest = false; bool LLPipeline::sRenderAttachedLights = true; bool LLPipeline::sRenderAttachedParticles = true; bool LLPipeline::sRenderDeferred = false; @@ -406,7 +404,6 @@ void LLPipeline::init() gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); - sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); @@ -3716,31 +3713,40 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) tex->addTextureStats(vsize); } } - - } + void LLPipeline::touchTextures(LLDrawInfo* info) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - - auto& mat = info->mGLTFMaterial; - if (mat.notNull()) - { - touchTexture(mat->mBaseColorTexture, info->mVSize); - touchTexture(mat->mNormalTexture, info->mVSize); - touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); - touchTexture(mat->mEmissiveTexture, info->mVSize); - } - else + if (--info->mTextureTimer == 0) { - for (int i = 0; i < info->mTextureList.size(); ++i) + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + // reset texture timer in a noisy fashion to avoid clumping of updates + const U32 MIN_WAIT_TIME = 8; + const U32 MAX_WAIT_TIME = 16; + + info->mTextureTimer = ll_rand() % (MAX_WAIT_TIME - MIN_WAIT_TIME) + MIN_WAIT_TIME; + + auto& mat = info->mGLTFMaterial; + if (mat.notNull()) { - touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + touchTexture(mat->mBaseColorTexture, info->mVSize); + touchTexture(mat->mNormalTexture, info->mVSize); + touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); + touchTexture(mat->mEmissiveTexture, info->mVSize); } + else + { + info->mTextureTimer += (U8) info->mTextureList.size(); - touchTexture(info->mTexture, info->mVSize); - touchTexture(info->mSpecularMap, info->mVSize); - touchTexture(info->mNormalMap, info->mVSize); + for (int i = 0; i < info->mTextureList.size(); ++i) + { + touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + } + + touchTexture(info->mTexture, info->mVSize); + touchTexture(info->mSpecularMap, info->mVSize); + touchTexture(info->mNormalMap, info->mVSize); + } } } @@ -3829,7 +3835,7 @@ void LLPipeline::postSort(LLCamera& camera) if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { touchTextures(info); - addTrianglesDrawn(info->mCount, info->mDrawMode); + addTrianglesDrawn(info->mCount); } } } @@ -4831,28 +4837,19 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) } -void LLPipeline::addTrianglesDrawn(S32 index_count, U32 render_type) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - assertInitialized(); - S32 count = 0; - if (render_type == LLRender::TRIANGLE_STRIP) - { - count = index_count-2; - } - else - { - count = index_count/3; - } +static U32 sIndicesDrawnCount = 0; - record(sStatBatchSize, count); - add(LLStatViewer::TRIANGLES_DRAWN, LLUnits::Triangles::fromValue(count)); +void LLPipeline::addTrianglesDrawn(S32 index_count) +{ + sIndicesDrawnCount += index_count; +} - if (LLPipeline::sRenderFrameTest) - { - gViewerWindow->getWindow()->swapBuffers(); - ms_sleep(16); - } +void LLPipeline::recordTrianglesDrawn() +{ + assertInitialized(); + U32 count = sIndicesDrawnCount / 3; + sIndicesDrawnCount = 0; + add(LLStatViewer::TRIANGLES_DRAWN, LLUnits::Triangles::fromValue(count)); } void LLPipeline::renderPhysicsDisplay() @@ -7385,7 +7382,6 @@ void LLPipeline::doResetVertexBuffers(bool forced) updateRenderBump(); updateRenderDeferred(); - sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); @@ -8246,6 +8242,9 @@ void LLPipeline::renderFinalize() LLGLState::checkStates(); LLGLState::checkTextureChannels(); + + // flush calls made to "addTrianglesDrawn" so far to stats machinery + recordTrianglesDrawn(); } void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) -- cgit v1.2.3 From b1dabc0f008bf0e6558a93bca2a2d818073a03c1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 18 Nov 2022 11:45:04 -0600 Subject: SL-18669 Fix for broken lighting on transparent faces. Optimize handling of "bindDeferredShader" and shadow map setup. --- indra/newview/pipeline.cpp | 258 +++++++++++++++++++++++++++++---------------- 1 file changed, 169 insertions(+), 89 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a2e01eec3f..b59da7ad19 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -904,26 +904,53 @@ inline U32 BlurHappySize(U32 x, F32 scale) { return U32( x * scale + 16.0f) & ~0 bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - if (LLPipeline::sRenderDeferred) - { - S32 shadow_detail = RenderShadowDetail; + S32 shadow_detail = RenderShadowDetail; + + const U32 occlusion_divisor = 3; - const U32 occlusion_divisor = 3; + F32 scale = llmax(0.f, RenderShadowResolutionScale); + U32 sun_shadow_map_width = BlurHappySize(resX, scale); + U32 sun_shadow_map_height = BlurHappySize(resY, scale); + + if (shadow_detail > 0) + { //allocate 4 sun shadow maps + for (U32 i = 0; i < 4; i++) + { + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + { + return false; + } + + if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width / occlusion_divisor, sun_shadow_map_height / occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + { + return false; + } + } + } + else + { + for (U32 i = 0; i < 4; i++) + { + releaseSunShadowTarget(i); + } + } - F32 scale = llmax(0.f, RenderShadowResolutionScale); - U32 sun_shadow_map_width = BlurHappySize(resX, scale); - U32 sun_shadow_map_height = BlurHappySize(resY, scale); + if (!gCubeSnapshot) // hack to not allocate spot shadow maps during ReflectionMapManager init + { + U32 width = (U32)(resX * scale); + U32 height = width; - if (shadow_detail > 0) - { //allocate 4 sun shadow maps - for (U32 i = 0; i < 4; i++) + if (shadow_detail > 1) + { //allocate two spot shadow maps + U32 spot_shadow_map_width = width; + U32 spot_shadow_map_height = height; + for (U32 i = 0; i < 2; i++) { - if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) { return false; } - - if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width / occlusion_divisor, sun_shadow_map_height / occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mSpotShadowOcclusion[i].allocate(spot_shadow_map_width / occlusion_divisor, height / occlusion_divisor, 0, TRUE, FALSE)) { return false; } @@ -931,36 +958,42 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) } else { - for (U32 i = 0; i < 4; i++) - { - releaseSunShadowTarget(i); - } + releaseSpotShadowTargets(); } + } - if (!gCubeSnapshot) // hack to not allocate spot shadow maps during ReflectionMapManager init + + // set up shadow map filtering and compare modes + if (shadow_detail > 0) + { + for (U32 i = 0; i < 4; i++) { - U32 width = (U32)(resX * scale); - U32 height = width; + LLRenderTarget* shadow_target = getSunShadowTarget(i); + if (shadow_target) + { + gGL.getTexUnit(0)->bind(getSunShadowTarget(i), TRUE); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - if (shadow_detail > 1) - { //allocate two spot shadow maps - U32 spot_shadow_map_width = width; - U32 spot_shadow_map_height = height; - for (U32 i = 0; i < 2; i++) - { - if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) - { - return false; - } - if (!mSpotShadowOcclusion[i].allocate(spot_shadow_map_width / occlusion_divisor, height / occlusion_divisor, 0, TRUE, FALSE)) - { - return false; - } - } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); } - else + } + } + + if (shadow_detail > 1) + { + for (U32 i = 0; i < 2; i++) + { + LLRenderTarget* shadow_target = getSpotShadowTarget(i); + if (shadow_target) { - releaseSpotShadowTargets(); + gGL.getTexUnit(0)->bind(shadow_target, TRUE); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); } } } @@ -8248,6 +8281,102 @@ void LLPipeline::renderFinalize() recordTrianglesDrawn(); } +void LLPipeline::bindLightFunc(LLGLSLShader& shader) +{ + S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); + if (channel > -1) + { + gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); + } +} + +void LLPipeline::bindShadowMaps(LLGLSLShader& shader) +{ + for (U32 i = 0; i < 4; i++) + { + LLRenderTarget* shadow_target = getSunShadowTarget(i); + if (shadow_target) + { + S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i, LLTexUnit::TT_TEXTURE); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(getSunShadowTarget(i), TRUE); + } + } + } + + for (U32 i = 4; i < 6; i++) + { + S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i); + if (channel > -1) + { + LLRenderTarget* shadow_target = getSpotShadowTarget(i - 4); + if (shadow_target) + { + gGL.getTexUnit(channel)->bind(shadow_target, TRUE); + } + } + } +} + +void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) +{ + shader.bind(); + bindLightFunc(shader); + bindShadowMaps(shader); + bindReflectionProbes(shader); + +#if 0 + shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); + shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); + + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_RADIUS, RenderSSAOScale); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, RenderSSAOMaxScale); + + F32 ssao_factor = RenderSSAOFactor; + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR, ssao_factor); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0 / ssao_factor); + + LLVector3 ssao_effect = RenderSSAOEffect; + F32 matrix_diag = (ssao_effect[0] + 2.0 * ssao_effect[1]) / 3.0; + F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1]) / 3.0; + // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by + // value factor, and scales remainder by saturation factor + F32 ssao_effect_mat[] = { matrix_diag, matrix_nondiag, matrix_nondiag, + matrix_nondiag, matrix_diag, matrix_nondiag, + matrix_nondiag, matrix_nondiag, matrix_diag }; + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_SSAO_EFFECT_MAT, 1, GL_FALSE, ssao_effect_mat); + + //F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); + F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]) / 3000.f; + F32 shadow_bias = RenderShadowBias + shadow_bias_error; + + //shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, deferred_target->getWidth(), deferred_target->getHeight()); + shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear() * 2.f); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, shadow_bias); + shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_OFFSET, RenderSpotShadowOffset); + shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_BIAS, RenderSpotShadowBias); + + shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); + shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); + shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mSpotShadow[0].getWidth(), mSpotShadow[0].getHeight()); + shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); + shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); + + if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) + { + glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); + shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); + } + + shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); + shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); +#endif +} + void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -8292,7 +8421,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ mPbrBrdfLut.bindTexture(0, channel); } - #if 0 channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); if (channel > -1) @@ -8329,11 +8457,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); - if (channel > -1) - { - gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); - } + bindLightFunc(shader); stop_glerror(); @@ -8352,49 +8476,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); - for (U32 i = 0; i < 4; i++) - { - LLRenderTarget* shadow_target = getSunShadowTarget(i); - if (shadow_target) - { - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE); - stop_glerror(); - if (channel > -1) - { - stop_glerror(); - gGL.getTexUnit(channel)->bind(getSunShadowTarget(i), TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - stop_glerror(); - } - } - } - - for (U32 i = 4; i < 6; i++) - { - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i); - stop_glerror(); - if (channel > -1) - { - stop_glerror(); - LLRenderTarget* shadow_target = getSpotShadowTarget(i-4); - if (shadow_target) - { - gGL.getTexUnit(channel)->bind(shadow_target, TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - stop_glerror(); - } - } - } + bindShadowMaps(shader); stop_glerror(); @@ -8517,11 +8599,9 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); - - LLEnvironment& environment = LLEnvironment::instance(); - LLSettingsSky::ptr_t sky = environment.getCurrentSky(); } + LLColor3 pow3f(LLColor3 v, F32 f) { v.mV[0] = powf(v.mV[0], f); -- cgit v1.2.3 From 8bdd71c4e3515d5b63301ab824821879ffb50746 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 22 Nov 2022 14:59:24 -0600 Subject: SL-18683 Fix for corruption on alpha blended PBR materials. --- indra/newview/pipeline.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b59da7ad19..0f348e4bc4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8288,6 +8288,12 @@ void LLPipeline::bindLightFunc(LLGLSLShader& shader) { gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_BRDF_LUT, LLTexUnit::TT_TEXTURE); + if (channel > -1) + { + mPbrBrdfLut.bindTexture(0, channel); + } } void LLPipeline::bindShadowMaps(LLGLSLShader& shader) @@ -8415,12 +8421,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } - channel = shader.enableTexture(LLShaderMgr::DEFERRED_BRDF_LUT, LLTexUnit::TT_TEXTURE); - if (channel > -1) - { - mPbrBrdfLut.bindTexture(0, channel); - } - #if 0 channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); if (channel > -1) -- cgit v1.2.3 From dc4f65a2ec1fdd65a77223baaadec38ba38c3bb6 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 30 Nov 2022 14:22:10 -0600 Subject: SL-18745 Fix for LLVertexBuffer assertion on shutdown. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0f348e4bc4..2d4db48ac5 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -659,6 +659,8 @@ void LLPipeline::cleanup() mDeferredVB = NULL; mCubeVB = NULL; + + mReflectionMapManager.cleanup(); } //============================================================================ -- cgit v1.2.3 From ed2b768da29f8dc4f96b463fe4d4087deab75a37 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 2 Dec 2022 09:56:42 -0600 Subject: SL-18745 Fix for assert on teleport. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2d4db48ac5..2f3aa1238e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7405,6 +7405,8 @@ void LLPipeline::doResetVertexBuffers(bool forced) LLVOPartGroup::destroyGL(); gGL.resetVertexBuffer(); + mReflectionMapManager.cleanup(); + SUBSYSTEM_CLEANUP(LLVertexBuffer); if (LLVertexBuffer::sGLCount != 0) -- cgit v1.2.3 From 188cdc50d3322423036dfe0e3af3f40724048a0e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 2 Dec 2022 11:46:42 -0600 Subject: SL-18739 Fix for some textures not loading. Remove some tabs. --- indra/newview/pipeline.cpp | 614 ++++++++++++++++++++++----------------------- 1 file changed, 303 insertions(+), 311 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2f3aa1238e..fa46b0f02a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3587,166 +3587,161 @@ void renderScriptedBeacons(LLDrawable* drawablep) } } -void renderScriptedTouchBeacons(LLDrawable* drawablep) +void renderScriptedTouchBeacons(LLDrawable *drawablep) { - LLViewerObject *vobj = drawablep->getVObj(); - if (vobj - && !vobj->isAvatar() - && !vobj->getParent() - && vobj->flagScripted() - && vobj->flagHandleTouch()) - { - if (gPipeline.sRenderBeacons) - { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 0.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); - } + LLViewerObject *vobj = drawablep->getVObj(); + if (vobj && !vobj->isAvatar() && !vobj->getParent() && vobj->flagScripted() && vobj->flagHandleTouch()) + { + if (gPipeline.sRenderBeacons) + { + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 0.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), + LLPipeline::DebugBeaconLineWidth); + } - if (gPipeline.sRenderHighlight) - { - S32 face_id; - S32 count = drawablep->getNumFaces(); - for (face_id = 0; face_id < count; face_id++) - { - LLFace * facep = drawablep->getFace(face_id); - if (facep) - { - gPipeline.mHighlightFaces.push_back(facep); - } - } - } -} + if (gPipeline.sRenderHighlight) + { + S32 face_id; + S32 count = drawablep->getNumFaces(); + for (face_id = 0; face_id < count; face_id++) + { + LLFace *facep = drawablep->getFace(face_id); + if (facep) + { + gPipeline.mHighlightFaces.push_back(facep); + } + } + } + } } -void renderPhysicalBeacons(LLDrawable* drawablep) +void renderPhysicalBeacons(LLDrawable *drawablep) { - LLViewerObject *vobj = drawablep->getVObj(); - if (vobj - && !vobj->isAvatar() - //&& !vobj->getParent() - && vobj->flagUsePhysics()) - { - if (gPipeline.sRenderBeacons) - { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(0.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); - } + LLViewerObject *vobj = drawablep->getVObj(); + if (vobj && + !vobj->isAvatar() + //&& !vobj->getParent() + && vobj->flagUsePhysics()) + { + if (gPipeline.sRenderBeacons) + { + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(0.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), + LLPipeline::DebugBeaconLineWidth); + } - if (gPipeline.sRenderHighlight) - { - S32 face_id; - S32 count = drawablep->getNumFaces(); - for (face_id = 0; face_id < count; face_id++) - { - LLFace * facep = drawablep->getFace(face_id); - if (facep) - { - gPipeline.mHighlightFaces.push_back(facep); - } - } - } -} + if (gPipeline.sRenderHighlight) + { + S32 face_id; + S32 count = drawablep->getNumFaces(); + for (face_id = 0; face_id < count; face_id++) + { + LLFace *facep = drawablep->getFace(face_id); + if (facep) + { + gPipeline.mHighlightFaces.push_back(facep); + } + } + } + } } -void renderMOAPBeacons(LLDrawable* drawablep) +void renderMOAPBeacons(LLDrawable *drawablep) { - LLViewerObject *vobj = drawablep->getVObj(); + LLViewerObject *vobj = drawablep->getVObj(); - if(!vobj || vobj->isAvatar()) - return; + if (!vobj || vobj->isAvatar()) + return; - bool beacon=false; - U8 tecount=vobj->getNumTEs(); - for(int x=0;xgetTE(x)->hasMedia()) - { - beacon=true; - break; - } - } - if(beacon) - { - if (gPipeline.sRenderBeacons) - { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 1.f, 1.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); - } + bool beacon = false; + U8 tecount = vobj->getNumTEs(); + for (int x = 0; x < tecount; x++) + { + if (vobj->getTE(x)->hasMedia()) + { + beacon = true; + break; + } + } + if (beacon) + { + if (gPipeline.sRenderBeacons) + { + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 1.f, 1.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), + LLPipeline::DebugBeaconLineWidth); + } - if (gPipeline.sRenderHighlight) - { - S32 face_id; - S32 count = drawablep->getNumFaces(); - for (face_id = 0; face_id < count; face_id++) - { - LLFace * facep = drawablep->getFace(face_id); - if (facep) - { - gPipeline.mHighlightFaces.push_back(facep); - } - } - } -} + if (gPipeline.sRenderHighlight) + { + S32 face_id; + S32 count = drawablep->getNumFaces(); + for (face_id = 0; face_id < count; face_id++) + { + LLFace *facep = drawablep->getFace(face_id); + if (facep) + { + gPipeline.mHighlightFaces.push_back(facep); + } + } + } + } } -void renderParticleBeacons(LLDrawable* drawablep) +void renderParticleBeacons(LLDrawable *drawablep) { - // Look for attachments, objects, etc. - LLViewerObject *vobj = drawablep->getVObj(); - if (vobj - && vobj->isParticleSource()) - { - if (gPipeline.sRenderBeacons) - { - LLColor4 light_blue(0.5f, 0.5f, 1.f, 0.5f); - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", light_blue, LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); - } + // Look for attachments, objects, etc. + LLViewerObject *vobj = drawablep->getVObj(); + if (vobj && vobj->isParticleSource()) + { + if (gPipeline.sRenderBeacons) + { + LLColor4 light_blue(0.5f, 0.5f, 1.f, 0.5f); + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", light_blue, LLColor4(1.f, 1.f, 1.f, 0.5f), + LLPipeline::DebugBeaconLineWidth); + } - if (gPipeline.sRenderHighlight) - { - S32 face_id; - S32 count = drawablep->getNumFaces(); - for (face_id = 0; face_id < count; face_id++) - { - LLFace * facep = drawablep->getFace(face_id); - if (facep) - { - gPipeline.mHighlightFaces.push_back(facep); - } - } - } -} + if (gPipeline.sRenderHighlight) + { + S32 face_id; + S32 count = drawablep->getNumFaces(); + for (face_id = 0; face_id < count; face_id++) + { + LLFace *facep = drawablep->getFace(face_id); + if (facep) + { + gPipeline.mHighlightFaces.push_back(facep); + } + } + } + } } -void renderSoundHighlights(LLDrawable* drawablep) +void renderSoundHighlights(LLDrawable *drawablep) { - // Look for attachments, objects, etc. - LLViewerObject *vobj = drawablep->getVObj(); - if (vobj && vobj->isAudioSource()) - { - if (gPipeline.sRenderHighlight) - { - S32 face_id; - S32 count = drawablep->getNumFaces(); - for (face_id = 0; face_id < count; face_id++) - { - LLFace * facep = drawablep->getFace(face_id); - if (facep) - { - gPipeline.mHighlightFaces.push_back(facep); - } - } - } -} + // Look for attachments, objects, etc. + LLViewerObject *vobj = drawablep->getVObj(); + if (vobj && vobj->isAudioSource()) + { + if (gPipeline.sRenderHighlight) + { + S32 face_id; + S32 count = drawablep->getNumFaces(); + for (face_id = 0; face_id < count; face_id++) + { + LLFace *facep = drawablep->getFace(face_id); + if (facep) + { + gPipeline.mHighlightFaces.push_back(facep); + } + } + } + } } void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) { if (tex) { - LLImageGL* gl_tex = tex->getGLTexture(); - if (gl_tex && gl_tex->updateBindStats()) - { - tex->setActive(); - tex->addTextureStats(vsize); - } + tex->setActive(); + tex->addTextureStats(vsize); } } @@ -3785,56 +3780,53 @@ void LLPipeline::touchTextures(LLDrawInfo* info) } } -void LLPipeline::postSort(LLCamera& camera) +void LLPipeline::postSort(LLCamera &camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - assertInitialized(); + assertInitialized(); - LL_PUSH_CALLSTACKS(); + LL_PUSH_CALLSTACKS(); if (!gCubeSnapshot) { - //rebuild drawable geometry + // rebuild drawable geometry for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) { - LLSpatialGroup* group = *i; - if (!sUseOcclusion || - !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + LLSpatialGroup *group = *i; + if (!sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { group->rebuildGeom(); } } LL_PUSH_CALLSTACKS(); - //rebuild groups + // rebuild groups sCull->assertDrawMapsEmpty(); rebuildPriorityGroups(); } - LL_PUSH_CALLSTACKS(); + LL_PUSH_CALLSTACKS(); - - //build render map - for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) - { - LLSpatialGroup* group = *i; - if ((sUseOcclusion && - group->isOcclusionState(LLSpatialGroup::OCCLUDED)) || - (RenderAutoHideSurfaceAreaLimit > 0.f && - group->mSurfaceArea > RenderAutoHideSurfaceAreaLimit*llmax(group->mObjectBoxSize, 10.f))) - { - continue; - } + // build render map + for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) + { + LLSpatialGroup *group = *i; + if ((sUseOcclusion && group->isOcclusionState(LLSpatialGroup::OCCLUDED)) || + (RenderAutoHideSurfaceAreaLimit > 0.f && + group->mSurfaceArea > RenderAutoHideSurfaceAreaLimit * llmax(group->mObjectBoxSize, 10.f))) + { + continue; + } - if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY) && !gCubeSnapshot) - { //no way this group is going to be drawable without a rebuild - group->rebuildGeom(); - } + if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY) && !gCubeSnapshot) + { // no way this group is going to be drawable without a rebuild + group->rebuildGeom(); + } for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) { - LLSpatialGroup::drawmap_elem_t& src_vec = j->second; + LLSpatialGroup::drawmap_elem_t &src_vec = j->second; if (!hasRenderType(j->first)) { continue; @@ -3864,7 +3856,7 @@ void LLPipeline::postSort(LLCamera& camera) for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) { - LLDrawInfo* info = *k; + LLDrawInfo *info = *k; sCull->pushDrawInfo(j->first, info); if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) @@ -3873,186 +3865,186 @@ void LLPipeline::postSort(LLCamera& camera) addTrianglesDrawn(info->mCount); } } - } + } - if (hasRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA)) - { - LLSpatialGroup::draw_map_t::iterator alpha = group->mDrawMap.find(LLRenderPass::PASS_ALPHA); - - if (alpha != group->mDrawMap.end()) - { //store alpha groups for sorting - LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) - { - if (bridge) - { - LLCamera trans_camera = bridge->transformCamera(camera); - group->updateDistance(trans_camera); - } - else - { - group->updateDistance(camera); - } - } - - if (hasRenderType(LLDrawPool::POOL_ALPHA)) - { - sCull->pushAlphaGroup(group); - } - } + if (hasRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA)) + { + LLSpatialGroup::draw_map_t::iterator alpha = group->mDrawMap.find(LLRenderPass::PASS_ALPHA); + + if (alpha != group->mDrawMap.end()) + { // store alpha groups for sorting + LLSpatialBridge *bridge = group->getSpatialPartition()->asBridge(); + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) + { + if (bridge) + { + LLCamera trans_camera = bridge->transformCamera(camera); + group->updateDistance(trans_camera); + } + else + { + group->updateDistance(camera); + } + } + + if (hasRenderType(LLDrawPool::POOL_ALPHA)) + { + sCull->pushAlphaGroup(group); + } + } LLSpatialGroup::draw_map_t::iterator rigged_alpha = group->mDrawMap.find(LLRenderPass::PASS_ALPHA_RIGGED); if (rigged_alpha != group->mDrawMap.end()) - { //store rigged alpha groups for LLDrawPoolAlpha prepass (skip distance update, rigged attachments use depth buffer) + { // store rigged alpha groups for LLDrawPoolAlpha prepass (skip distance update, rigged attachments use depth buffer) if (hasRenderType(LLDrawPool::POOL_ALPHA)) { sCull->pushRiggedAlphaGroup(group); } } - } - } - - //flush particle VB - if (LLVOPartGroup::sVB) - { - LLVOPartGroup::sVB->flush(); - } - else - { - LL_WARNS_ONCE() << "Missing particle buffer" << LL_ENDL; - } + } + } - /*bool use_transform_feedback = gTransformPositionProgram.mProgramObject && !mMeshDirtyGroup.empty(); + // flush particle VB + if (LLVOPartGroup::sVB) + { + LLVOPartGroup::sVB->flush(); + } + else + { + LL_WARNS_ONCE() << "Missing particle buffer" << LL_ENDL; + } - if (use_transform_feedback) - { //place a query around potential transform feedback code for synchronization - mTransformFeedbackPrimitives = 0; + /*bool use_transform_feedback = gTransformPositionProgram.mProgramObject && !mMeshDirtyGroup.empty(); - if (!mMeshDirtyQueryObject) - { - glGenQueries(1, &mMeshDirtyQueryObject); - } + if (use_transform_feedback) + { //place a query around potential transform feedback code for synchronization + mTransformFeedbackPrimitives = 0; - - glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, mMeshDirtyQueryObject); - }*/ + if (!mMeshDirtyQueryObject) + { + glGenQueries(1, &mMeshDirtyQueryObject); + } - //pack vertex buffers for groups that chose to delay their updates - for (LLSpatialGroup::sg_vector_t::iterator iter = mMeshDirtyGroup.begin(); iter != mMeshDirtyGroup.end(); ++iter) - { - (*iter)->rebuildMesh(); - } - /*if (use_transform_feedback) - { - glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); - }*/ - - mMeshDirtyGroup.clear(); + glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, mMeshDirtyQueryObject); + }*/ - if (!sShadowRender) - { + // pack vertex buffers for groups that chose to delay their updates + for (LLSpatialGroup::sg_vector_t::iterator iter = mMeshDirtyGroup.begin(); iter != mMeshDirtyGroup.end(); ++iter) + { + (*iter)->rebuildMesh(); + } + + /*if (use_transform_feedback) + { + glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); + }*/ + + mMeshDirtyGroup.clear(); + + if (!sShadowRender) + { // order alpha groups by distance - std::sort(sCull->beginAlphaGroups(), sCull->endAlphaGroups(), LLSpatialGroup::CompareDepthGreater()); + std::sort(sCull->beginAlphaGroups(), sCull->endAlphaGroups(), LLSpatialGroup::CompareDepthGreater()); // order rigged alpha groups by avatar attachment order std::sort(sCull->beginRiggedAlphaGroups(), sCull->endRiggedAlphaGroups(), LLSpatialGroup::CompareRenderOrder()); - } + } - LL_PUSH_CALLSTACKS(); - // only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus - if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender && !gCubeSnapshot) - { - if (sRenderScriptedTouchBeacons) - { - // Only show the beacon on the root object. - forAllVisibleDrawables(renderScriptedTouchBeacons); - } - else - if (sRenderScriptedBeacons) - { - // Only show the beacon on the root object. - forAllVisibleDrawables(renderScriptedBeacons); - } + LL_PUSH_CALLSTACKS(); + // only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus + if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender && !gCubeSnapshot) + { + if (sRenderScriptedTouchBeacons) + { + // Only show the beacon on the root object. + forAllVisibleDrawables(renderScriptedTouchBeacons); + } + else if (sRenderScriptedBeacons) + { + // Only show the beacon on the root object. + forAllVisibleDrawables(renderScriptedBeacons); + } - if (sRenderPhysicalBeacons) - { - // Only show the beacon on the root object. - forAllVisibleDrawables(renderPhysicalBeacons); - } + if (sRenderPhysicalBeacons) + { + // Only show the beacon on the root object. + forAllVisibleDrawables(renderPhysicalBeacons); + } - if(sRenderMOAPBeacons) - { - forAllVisibleDrawables(renderMOAPBeacons); - } + if (sRenderMOAPBeacons) + { + forAllVisibleDrawables(renderMOAPBeacons); + } - if (sRenderParticleBeacons) - { - forAllVisibleDrawables(renderParticleBeacons); - } + if (sRenderParticleBeacons) + { + forAllVisibleDrawables(renderParticleBeacons); + } - // If god mode, also show audio cues - if (sRenderSoundBeacons && gAudiop) - { - // Walk all sound sources and render out beacons for them. Note, this isn't done in the ForAllVisibleDrawables function, because some are not visible. - LLAudioEngine::source_map::iterator iter; - for (iter = gAudiop->mAllSources.begin(); iter != gAudiop->mAllSources.end(); ++iter) - { - LLAudioSource *sourcep = iter->second; + // If god mode, also show audio cues + if (sRenderSoundBeacons && gAudiop) + { + // Walk all sound sources and render out beacons for them. Note, this isn't done in the ForAllVisibleDrawables function, because + // some are not visible. + LLAudioEngine::source_map::iterator iter; + for (iter = gAudiop->mAllSources.begin(); iter != gAudiop->mAllSources.end(); ++iter) + { + LLAudioSource *sourcep = iter->second; - LLVector3d pos_global = sourcep->getPositionGlobal(); - LLVector3 pos = gAgent.getPosAgentFromGlobal(pos_global); - if (gPipeline.sRenderBeacons) - { - //pos += LLVector3(0.f, 0.f, 0.2f); - gObjectList.addDebugBeacon(pos, "", LLColor4(1.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), DebugBeaconLineWidth); - } - } - // now deal with highlights for all those seeable sound sources - forAllVisibleDrawables(renderSoundHighlights); - } - } - LL_PUSH_CALLSTACKS(); - // If managing your telehub, draw beacons at telehub and currently selected spawnpoint. - if (LLFloaterTelehub::renderBeacons() && !sShadowRender && !gCubeSnapshot) - { - LLFloaterTelehub::addBeacons(); - } + LLVector3d pos_global = sourcep->getPositionGlobal(); + LLVector3 pos = gAgent.getPosAgentFromGlobal(pos_global); + if (gPipeline.sRenderBeacons) + { + // pos += LLVector3(0.f, 0.f, 0.2f); + gObjectList.addDebugBeacon(pos, "", LLColor4(1.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), DebugBeaconLineWidth); + } + } + // now deal with highlights for all those seeable sound sources + forAllVisibleDrawables(renderSoundHighlights); + } + } + LL_PUSH_CALLSTACKS(); + // If managing your telehub, draw beacons at telehub and currently selected spawnpoint. + if (LLFloaterTelehub::renderBeacons() && !sShadowRender && !gCubeSnapshot) + { + LLFloaterTelehub::addBeacons(); + } - if (!sShadowRender && !gCubeSnapshot) - { - mSelectedFaces.clear(); + if (!sShadowRender && !gCubeSnapshot) + { + mSelectedFaces.clear(); - if (!gNonInteractive) - { - LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit()); - } + if (!gNonInteractive) + { + LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit()); + } - // Draw face highlights for selected faces. - if (LLSelectMgr::getInstance()->getTEMode()) - { - struct f : public LLSelectedTEFunctor - { - virtual bool apply(LLViewerObject* object, S32 te) - { - if (object->mDrawable) - { - LLFace * facep = object->mDrawable->getFace(te); - if (facep) - { - gPipeline.mSelectedFaces.push_back(facep); - } - } - return true; - } - } func; - LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); - } - } + // Draw face highlights for selected faces. + if (LLSelectMgr::getInstance()->getTEMode()) + { + struct f : public LLSelectedTEFunctor + { + virtual bool apply(LLViewerObject *object, S32 te) + { + if (object->mDrawable) + { + LLFace *facep = object->mDrawable->getFace(te); + if (facep) + { + gPipeline.mSelectedFaces.push_back(facep); + } + } + return true; + } + } func; + LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); + } + } - //LLSpatialGroup::sNoDelete = FALSE; - LL_PUSH_CALLSTACKS(); + // LLSpatialGroup::sNoDelete = FALSE; + LL_PUSH_CALLSTACKS(); } -- cgit v1.2.3 From c489481ec5edd0470553eca9b7c4cecfe994926c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 6 Dec 2022 09:59:30 -0600 Subject: SL-18785 Fix for corrupt reflection probes on various preference changes. Add UI for Screen Space Reflections. --- indra/newview/pipeline.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index fa46b0f02a..b41a02d491 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -410,7 +410,7 @@ void LLPipeline::init() sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); - mInitialized = true; + mInitialized = true; stop_glerror(); @@ -1019,8 +1019,6 @@ void LLPipeline::updateRenderBump() void LLPipeline::updateRenderDeferred() { sRenderPBR = sRenderDeferred; - static LLCachedControl sProbeDetail(gSavedSettings, "RenderReflectionProbeDetail", -1); - sReflectionProbesEnabled = sProbeDetail >= 0 && gGLManager.mGLVersion > 3.99f; } // static @@ -1112,7 +1110,9 @@ void LLPipeline::refreshCachedSettings() CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale"); RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit"); RenderScreenSpaceReflections = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + sReflectionProbesEnabled = gSavedSettings.getBOOL("RenderReflectionsEnabled"); RenderSpotLight = nullptr; + updateRenderDeferred(); if (gNonInteractive) @@ -7397,8 +7397,6 @@ void LLPipeline::doResetVertexBuffers(bool forced) LLVOPartGroup::destroyGL(); gGL.resetVertexBuffer(); - mReflectionMapManager.cleanup(); - SUBSYSTEM_CLEANUP(LLVertexBuffer); if (LLVertexBuffer::sGLCount != 0) -- cgit v1.2.3 From 03da83f23513fdca2073203eddafeef3662e4be1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 6 Dec 2022 10:18:46 -0600 Subject: SL-18788 Fix for legacy shiny not working until after restart when reflections probes are disabled. --- indra/newview/pipeline.cpp | 54 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b41a02d491..d0ebc7645c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8489,24 +8489,27 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); - channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) - { - LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; - if (cube_map) - { - cube_map->enable(channel); - cube_map->bind(); - } + if (!LLPipeline::sReflectionProbesEnabled) + { + channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + if (channel > -1) + { + LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; + if (cube_map) + { + cube_map->enable(channel); + cube_map->bind(); + } - F32* m = gGLModelView; + F32* m = gGLModelView; - F32 mat[] = { m[0], m[1], m[2], - m[4], m[5], m[6], - m[8], m[9], m[10] }; + F32 mat[] = { m[0], m[1], m[2], + m[4], m[5], m[6], + m[8], m[9], m[10] }; - shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); - } + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat); + } + } bindReflectionProbes(shader); @@ -9346,15 +9349,18 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) shader.disableTexture(LLShaderMgr::DEFERRED_NOISE); shader.disableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); - S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) - { - LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; - if (cube_map) - { - cube_map->disable(); - } - } + if (!LLPipeline::sReflectionProbesEnabled) + { + S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + if (channel > -1) + { + LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; + if (cube_map) + { + cube_map->disable(); + } + } + } unbindReflectionProbes(shader); -- cgit v1.2.3 From e9e37aa2ad2315611f262b2b090fe9672f6fee04 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 6 Dec 2022 16:15:27 -0600 Subject: SL-18784 Refactor physics shape display to not require its own render target. Remove "Hover Glow Objects" to free up a superfluous render target. --- indra/newview/pipeline.cpp | 277 +++++++-------------------------------------- 1 file changed, 44 insertions(+), 233 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d0ebc7645c..0ca9d2d12b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -725,17 +725,6 @@ void LLPipeline::resizeScreenTexture() } } -void LLPipeline::allocatePhysicsBuffer() -{ - GLuint resX = gViewerWindow->getWorldViewWidthRaw(); - GLuint resY = gViewerWindow->getWorldViewHeightRaw(); - - if (mPhysicsDisplay.getWidth() != resX || mPhysicsDisplay.getHeight() != resY) - { - mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE); - } -} - bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; @@ -1143,7 +1132,6 @@ void LLPipeline::releaseGLBuffers() mWaterRef.release(); mWaterDis.release(); mBake.release(); - mHighlight.release(); for (U32 i = 0; i < 3; i++) { @@ -1178,7 +1166,6 @@ void LLPipeline::releaseScreenBuffers() mRT->uiScreen.release(); mRT->screen.release(); mRT->fxaaBuffer.release(); - mPhysicsDisplay.release(); mRT->deferredScreen.release(); mRT->deferredDepth.release(); mRT->deferredLight.release(); @@ -1229,8 +1216,6 @@ void LLPipeline::createGLBuffers() // Use FBO for bake tex mBake.allocate(512, 512, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, true); // SL-12781 Build > Upload > Model; 3D Preview - mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE); - stop_glerror(); GLuint resX = gViewerWindow->getWorldViewWidthRaw(); @@ -1762,14 +1747,6 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable) } } - HighlightItem item(drawablep); - mHighlightSet.erase(item); - - if (mHighlightObject == drawablep) - { - mHighlightObject = NULL; - } - for (U32 i = 0; i < 2; ++i) { if (mShadowSpotLight[i] == drawablep) @@ -4105,107 +4082,6 @@ void LLPipeline::renderHighlights() LLGLEnable color_mat(GL_COLOR_MATERIAL); disableLights(); - if (!hasRenderType(LLPipeline::RENDER_TYPE_HUD) && !mHighlightSet.empty()) - { //draw blurry highlight image over screen - LLGLEnable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - LLGLDisable test(GL_ALPHA_TEST); - - //LLGLEnable stencil(GL_STENCIL_TEST); - gGL.flush(); - // stencil ops are deprecated - //glStencilMask(0xFFFFFFFF); - //glClearStencil(1); - //glClear(GL_STENCIL_BUFFER_BIT); - - //glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); - //glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); - - gGL.setColorMask(false, false); - - gHighlightProgram.bind(); - - for (std::set::iterator iter = mHighlightSet.begin(); iter != mHighlightSet.end(); ++iter) - { - renderHighlight(iter->mItem->getVObj(), 1.f); - } - gGL.setColorMask(true, false); - - //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // deprecated - //glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); - - //gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - gGL.getTexUnit(0)->bind(&mHighlight); - - LLVector2 tc1; - LLVector2 tc2; - - tc1.setVec(0,0); - tc2.setVec(2,2); - - gGL.begin(LLRender::TRIANGLES); - - F32 scale = RenderHighlightBrightness; - LLColor4 color = RenderHighlightColor; - F32 thickness = RenderHighlightThickness; - - for (S32 pass = 0; pass < 2; ++pass) - { - if (pass == 0) - { - gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - } - else - { - gGL.setSceneBlendType(LLRender::BT_ALPHA); - } - - for (S32 i = 0; i < 8; ++i) - { - for (S32 j = 0; j < 8; ++j) - { - LLVector2 tc(i-4+0.5f, j-4+0.5f); - - F32 dist = 1.f-(tc.length()/sqrtf(32.f)); - dist *= scale/64.f; - - tc *= thickness; - tc.mV[0] = (tc.mV[0])/mHighlight.getWidth(); - tc.mV[1] = (tc.mV[1])/mHighlight.getHeight(); - - gGL.color4f(color.mV[0], - color.mV[1], - color.mV[2], - color.mV[3]*dist); - - gGL.texCoord2f(tc.mV[0]+tc1.mV[0], tc.mV[1]+tc2.mV[1]); - gGL.vertex2f(-1,3); - - gGL.texCoord2f(tc.mV[0]+tc1.mV[0], tc.mV[1]+tc1.mV[1]); - gGL.vertex2f(-1,-1); - - gGL.texCoord2f(tc.mV[0]+tc2.mV[0], tc.mV[1]+tc1.mV[1]); - gGL.vertex2f(3,-1); - } - } - } - - gGL.end(); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - //gGL.setSceneBlendType(LLRender::BT_ALPHA); - } - if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightProgram.bind(); @@ -4886,40 +4762,56 @@ void LLPipeline::renderPhysicsDisplay() return; } - allocatePhysicsBuffer(); + gGL.flush(); + gDebugProgram.bind(); - gGL.flush(); - mPhysicsDisplay.bindTarget(); - glClearColor(0,0,0,1); - gGL.setColorMask(true, true); - mPhysicsDisplay.clear(); - glClearColor(0,0,0,0); + LLGLEnable(GL_POLYGON_OFFSET_LINE); + glPolygonOffset(3.f, 3.f); + glLineWidth(3.f); + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_ALPHA); - gGL.setColorMask(true, false); + for (int pass = 0; pass < 3; ++pass) + { + // pass 0 - depth write enabled, color write disabled, fill + // pass 1 - depth write disabled, color write enabled, fill + // pass 2 - depth write disabled, color write enabled, wireframe + gGL.setColorMask(pass >= 1, false); + LLGLDepthTest depth(GL_TRUE, pass == 0); - gDebugProgram.bind(); + bool wireframe = (pass == 2); - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) - { - LLViewerRegion* region = *iter; - for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) - { - LLSpatialPartition* part = region->getSpatialPartition(i); - if (part) - { - if (hasRenderType(part->mDrawableType)) - { - part->renderPhysicsShapes(); - } - } - } - } + if (wireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } - gGL.flush(); + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); + iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + { + LLViewerRegion* region = *iter; + for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) + { + LLSpatialPartition* part = region->getSpatialPartition(i); + if (part) + { + if (hasRenderType(part->mDrawableType)) + { + part->renderPhysicsShapes(wireframe); + } + } + } + } + gGL.flush(); + if (wireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + } + glLineWidth(1.f); gDebugProgram.unbind(); - mPhysicsDisplay.flush(); + } extern std::set visible_selected_groups; @@ -8230,33 +8122,7 @@ void LLPipeline::renderFinalize() if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) { - gSplatTextureRectProgram.bind(); - - gGL.setColorMask(true, false); - - LLVector2 tc1(0, 0); - LLVector2 tc2((F32) gViewerWindow->getWorldViewWidthRaw() * 2, - (F32) gViewerWindow->getWorldViewHeightRaw() * 2); - - LLGLEnable blend(GL_BLEND); - gGL.color4f(1, 1, 1, 0.75f); - - gGL.getTexUnit(0)->bind(&mPhysicsDisplay); - - gGL.begin(LLRender::TRIANGLES); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); - - gGL.end(); - gGL.flush(); - - gSplatTextureRectProgram.unbind(); + renderPhysicsDisplay(); } /*if (LLRenderTarget::sUseFBO && !gCubeSnapshot) @@ -9913,61 +9779,6 @@ void LLPipeline::renderHighlight(const LLViewerObject* obj, F32 fade) } } -void LLPipeline::generateHighlight(LLCamera& camera) -{ - //render highlighted object as white into offscreen render target - if (mHighlightObject.notNull()) - { - mHighlightSet.insert(HighlightItem(mHighlightObject)); - } - llassert(!gCubeSnapshot); - - if (!mHighlightSet.empty()) - { - F32 transition = gFrameIntervalSeconds.value()/RenderHighlightFadeTime; - - LLGLDisable test(GL_ALPHA_TEST); - LLGLDepthTest depth(GL_FALSE); - mHighlight.bindTarget(); - disableLights(); - gGL.setColorMask(true, true); - mHighlight.clear(); - - gHighlightProgram.bind(); - - gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); - for (std::set::iterator iter = mHighlightSet.begin(); iter != mHighlightSet.end(); ) - { - std::set::iterator cur_iter = iter++; - - if (cur_iter->mItem.isNull()) - { - mHighlightSet.erase(cur_iter); - continue; - } - - if (cur_iter->mItem == mHighlightObject) - { - cur_iter->incrFade(transition); - } - else - { - cur_iter->incrFade(-transition); - if (cur_iter->mFade <= 0.f) - { - mHighlightSet.erase(cur_iter); - continue; - } - } - - renderHighlight(cur_iter->mItem->getVObj(), cur_iter->mFade); - } - - mHighlight.flush(); - gGL.setColorMask(true, false); - gViewerWindow->setup3DViewport(); - } -} LLRenderTarget* LLPipeline::getSunShadowTarget(U32 i) { -- cgit v1.2.3 From e6b5481cad3f81f18ff04ff6af86bd7ad5b9c5da Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Dec 2022 11:00:31 -0600 Subject: SL-18782 WIP -- stub for reflection probe display. --- indra/newview/pipeline.cpp | 80 +++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 30 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5c3a830322..9d792d0801 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -338,6 +338,18 @@ static LLCullResult* sCull = NULL; void validate_framebuffer_object(); +// override the projection_matrix uniform on the given shader to that which would be set by the main camera +void set_camera_projection_matrix(LLGLSLShader& shader) +{ + auto camProj = LLViewerCamera::getInstance()->getProjection(); + glh::matrix4f projection = get_current_projection(); + projection.set_row(0, glh::vec4f(camProj.mMatrix[0][0], camProj.mMatrix[0][1], camProj.mMatrix[0][2], camProj.mMatrix[0][3])); + projection.set_row(0, glh::vec4f(camProj.mMatrix[1][0], camProj.mMatrix[1][1], camProj.mMatrix[1][2], camProj.mMatrix[1][3])); + projection.set_row(0, glh::vec4f(camProj.mMatrix[2][0], camProj.mMatrix[2][1], camProj.mMatrix[2][2], camProj.mMatrix[2][3])); + projection.set_row(0, glh::vec4f(camProj.mMatrix[3][0], camProj.mMatrix[3][1], camProj.mMatrix[3][2], camProj.mMatrix[3][3])); + shader.uniformMatrix4fv(LLShaderMgr::PROJECTION_MATRIX, 1, FALSE, projection.m); +} + // Add color attachments for deferred rendering // target -- RenderTarget to add attachments to bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) @@ -491,7 +503,21 @@ void LLPipeline::init() mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); mDeferredVB->allocateBuffer(8, 0, true); - setLightingDetail(-1); + + { + mScreenTriangleVB = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mScreenTriangleVB->allocateBuffer(3, 0, true); + LLStrider vert; + mScreenTriangleVB->getVertexStrider(vert); + + vert[0].set(-1, 1, 0); + vert[1].set(-1, -3, 0); + vert[2].set(3, 1, 0); + + mScreenTriangleVB->flush(); + } + + setLightingDetail(-1); // // Update all settings to trigger a cached settings refresh @@ -659,6 +685,7 @@ void LLPipeline::cleanup() mInitialized = false; mDeferredVB = NULL; + mScreenTriangleVB = nullptr; mCubeVB = NULL; @@ -5210,6 +5237,21 @@ void LLPipeline::renderDebug() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES) && !hud_only) { mReflectionMapManager.renderDebug(); + + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display"); + + bindDeferredShader(gReflectionProbeDisplayProgram, NULL); + mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + // Provide our projection matrix. + set_camera_projection_matrix(gReflectionProbeDisplayProgram); + + LLGLEnable blend(GL_BLEND); + LLGLDepthTest depth(GL_FALSE); + + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(gReflectionProbeDisplayProgram); } gUIProgram.bind(); @@ -7513,31 +7555,18 @@ void LLPipeline::renderFinalize() if (!gCubeSnapshot) { + LLRenderTarget* screen_target = &mRT->screen; + screen_target->bindTarget(); + if (RenderScreenSpaceReflections) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections"); LL_PROFILE_GPU_ZONE("screen space reflections"); - LLStrider vert; - mDeferredVB->getVertexStrider(vert); - - vert[0].set(-1, 1, 0); - vert[1].set(-1, -3, 0); - vert[2].set(3, 1, 0); - - // Make sure the deferred VB is a full screen triangle. - mDeferredVB->getVertexStrider(vert); bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - // Provide our projection matrix. - auto camProj = LLViewerCamera::getInstance()->getProjection(); - glh::matrix4f projection = get_current_projection(); - projection.set_row(0, glh::vec4f(camProj.mMatrix[0][0], camProj.mMatrix[0][1], camProj.mMatrix[0][2], camProj.mMatrix[0][3])); - projection.set_row(0, glh::vec4f(camProj.mMatrix[1][0], camProj.mMatrix[1][1], camProj.mMatrix[1][2], camProj.mMatrix[1][3])); - projection.set_row(0, glh::vec4f(camProj.mMatrix[2][0], camProj.mMatrix[2][1], camProj.mMatrix[2][2], camProj.mMatrix[2][3])); - projection.set_row(0, glh::vec4f(camProj.mMatrix[3][0], camProj.mMatrix[3][1], camProj.mMatrix[3][2], camProj.mMatrix[3][3])); - gPostScreenSpaceReflectionProgram.uniformMatrix4fv(LLShaderMgr::PROJECTION_MATRIX, 1, FALSE, projection.m); + set_camera_projection_matrix(gPostScreenSpaceReflectionProgram); // We need linear depth. static LLStaticHashedString zfar("zFar"); @@ -7547,14 +7576,10 @@ void LLPipeline::renderFinalize() gPostScreenSpaceReflectionProgram.uniform1f(zfar, farClip); gPostScreenSpaceReflectionProgram.uniform1f(znear, nearClip); - LLRenderTarget *screen_target = &mRT->screen; - - screen_target->bindTarget(); S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, screen_target->getUsage()); if (channel > -1) { screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } { @@ -7567,23 +7592,17 @@ void LLPipeline::renderFinalize() } unbindDeferredShader(gPostScreenSpaceReflectionProgram); - - screen_target->flush(); } // gamma correct lighting - { LL_PROFILE_GPU_ZONE("gamma correct"); LLGLDepthTest depth(GL_FALSE, GL_FALSE); - LLRenderTarget* screen_target = &mRT->screen; - LLVector2 tc1(0, 0); LLVector2 tc2((F32)screen_target->getWidth() * 2, (F32)screen_target->getHeight() * 2); - screen_target->bindTarget(); // Apply gamma correction to the frame here. gDeferredPostGammaCorrectProgram.bind(); // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -7614,9 +7633,10 @@ void LLPipeline::renderFinalize() gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); gDeferredPostGammaCorrectProgram.unbind(); - screen_target->flush(); } + screen_target->flush(); + LLVertexBuffer::unbind(); } -- cgit v1.2.3 From 4d0bd020a0e3ce87731478bbb74e93b96a64b74e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Dec 2022 16:17:48 -0600 Subject: SL-18782 WIP -- Functional Build->Options->Show Reflection Probe Volumes --- indra/newview/pipeline.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9d792d0801..7bc819d553 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5237,7 +5237,10 @@ void LLPipeline::renderDebug() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES) && !hud_only) { mReflectionMapManager.renderDebug(); + } + if (gSavedSettings.getBOOL("RenderReflectionProbeVolumes")) + { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display"); bindDeferredShader(gReflectionProbeDisplayProgram, NULL); -- cgit v1.2.3 From 6f7eeecdb33c14cb3044118a9d6e2eea900af55e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 15 Dec 2022 17:52:31 -0600 Subject: SL-18782 Fix fir assert when enabling SSR --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7bc819d553..633c86ad28 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7590,7 +7590,7 @@ void LLPipeline::renderFinalize() LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); } -- cgit v1.2.3 From d27d23ab269f6d22483c4b4dc1db1664cf3e441e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Dec 2022 11:12:06 -0600 Subject: SL-18852 Refactor GLTF material rendering to not be special compared to other types. Hook GLTF alpha masking up to highlight transparent. --- indra/newview/pipeline.cpp | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 633c86ad28..3aa6551202 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9437,7 +9437,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderPass::PASS_NORMMAP, LLRenderPass::PASS_NORMMAP_EMISSIVE, LLRenderPass::PASS_NORMSPEC, - LLRenderPass::PASS_NORMSPEC_EMISSIVE + LLRenderPass::PASS_NORMSPEC_EMISSIVE, + LLRenderPass::PASS_GLTF_PBR }; LLGLEnable cull(GL_CULL_FACE); @@ -9538,6 +9539,12 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); + + U32 mask = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_COLOR | + LLVertexBuffer::MAP_TEXTURE_INDEX; + for (int i = 0; i < 2; ++i) { bool rigged = i == 1; @@ -9546,11 +9553,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - U32 mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_COLOR | - LLVertexBuffer::MAP_TEXTURE_INDEX; - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE, rigged); @@ -9562,7 +9564,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderAlphaObjects(mask, TRUE, TRUE, rigged); } - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); @@ -9571,7 +9572,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE, rigged); } - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); @@ -9588,9 +9588,32 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); } } - } - //glCullFace(GL_BACK); + for (int i = 0; i < 2; ++i) + { + bool rigged = i == 1; + gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + + U32 type = LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK; + + if (rigged) + { + mAlphaMaskPool->pushRiggedGLTFBatches(type + 1, mask); + } + else + { + mAlphaMaskPool->pushGLTFBatches(type, mask); + } + + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + } + } gDeferredShadowCubeProgram.bind(); gGLLastMatrix = NULL; @@ -9929,6 +9952,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED, END_RENDER_TYPES); gGL.setColorMask(false, false); -- cgit v1.2.3 From 89f21f276fe369e6c28abb6ff44200e2cb8098c8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Dec 2022 14:58:02 -0600 Subject: SL-18719 GL 3.0/3.1 compatibility pass. --- indra/newview/pipeline.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3aa6551202..744d21b2c9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8363,7 +8363,14 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, light_target->getUsage()); if (channel > -1) { - light_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); + if (light_target->isComplete()) + { + light_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + else + { + gGL.getTexUnit(channel)->bindFast(LLViewerFetchedTexture::sWhiteImagep); + } } channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); -- cgit v1.2.3 From 003e34190f314cd159f8ec227ef32c2400e90f48 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 2 Jan 2023 05:38:29 -0800 Subject: Refactor post processing a smidge Fixes SL-18484. --- indra/newview/pipeline.cpp | 955 ++++++++++++++++++++++++--------------------- 1 file changed, 515 insertions(+), 440 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 744d21b2c9..4edc092271 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -880,7 +880,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa - if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false; + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false; } else { @@ -7530,500 +7530,541 @@ void LLPipeline::bindScreenToTexture() static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Bloom"); -void LLPipeline::renderFinalize() +void LLPipeline::renderPostProcess() { - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); + LLVertexBuffer::unbind(); + LLGLState::checkStates(); + LLGLState::checkTextureChannels(); - assertInitialized(); + assertInitialized(); - LLVector2 tc1(0, 0); - LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); + LLVector2 tc1(0, 0); + LLVector2 tc2((F32)mRT->screen.getWidth() * 2, (F32)mRT->screen.getHeight() * 2); - LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); - LL_PROFILE_GPU_ZONE("renderFinalize"); + LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); + LL_PROFILE_GPU_ZONE("renderPostProcess"); - gGL.color4f(1, 1, 1, 1); - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable cull(GL_CULL_FACE); + gGL.color4f(1, 1, 1, 1); + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable cull(GL_CULL_FACE); - enableLightsFullbright(); + enableLightsFullbright(); - LLGLDisable test(GL_ALPHA_TEST); + LLGLDisable test(GL_ALPHA_TEST); - gGL.setColorMask(true, true); - glClearColor(0, 0, 0, 0); + gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); - if (!gCubeSnapshot) - { - LLRenderTarget* screen_target = &mRT->screen; - screen_target->bindTarget(); + if (sRenderGlow) + { + LL_PROFILE_GPU_ZONE("glow"); + mGlow[2].bindTarget(); + mGlow[2].clear(); - if (RenderScreenSpaceReflections) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections"); - LL_PROFILE_GPU_ZONE("screen space reflections"); + gGlowExtractProgram.bind(); + F32 minLum = llmax((F32)RenderGlowMinLuminance, 0.0f); + F32 maxAlpha = RenderGlowMaxExtractAlpha; + F32 warmthAmount = RenderGlowWarmthAmount; + LLVector3 lumWeights = RenderGlowLumWeights; + LLVector3 warmthWeights = RenderGlowWarmthWeights; - bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); - mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, minLum); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], + lumWeights.mV[2]); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], + warmthWeights.mV[2]); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); - set_camera_projection_matrix(gPostScreenSpaceReflectionProgram); + { + LLGLEnable blend_on(GL_BLEND); + LLGLEnable test(GL_ALPHA_TEST); - // We need linear depth. - static LLStaticHashedString zfar("zFar"); - static LLStaticHashedString znear("zNear"); - float nearClip = LLViewerCamera::getInstance()->getNear(); - float farClip = LLViewerCamera::getInstance()->getFar(); - gPostScreenSpaceReflectionProgram.uniform1f(zfar, farClip); - gPostScreenSpaceReflectionProgram.uniform1f(znear, nearClip); + gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, screen_target->getUsage()); - if (channel > -1) - { - screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } + mRT->screen.bindTexture(0, 0, LLTexUnit::TFO_POINT); - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + gGL.color4f(1, 1, 1, 1); + gPipeline.enableLightsFullbright(); + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); - stop_glerror(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); - unbindDeferredShader(gPostScreenSpaceReflectionProgram); - } + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); - // gamma correct lighting - { - LL_PROFILE_GPU_ZONE("gamma correct"); + gGL.end(); - LLGLDepthTest depth(GL_FALSE, GL_FALSE); + gGL.getTexUnit(0)->unbind(mRT->screen.getUsage()); - LLVector2 tc1(0, 0); - LLVector2 tc2((F32)screen_target->getWidth() * 2, (F32)screen_target->getHeight() * 2); + mGlow[2].flush(); - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); - if (channel > -1) - { - screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } + tc1.setVec(0, 0); + tc2.setVec(2, 2); + } - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); + // power of two between 1 and 1024 + U32 glowResPow = RenderGlowResolutionPow; + const U32 glow_res = llmax(1, llmin(1024, 1 << glowResPow)); - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + S32 kernel = RenderGlowIterations * 2; + F32 delta = RenderGlowWidth / glow_res; + // Use half the glow width if we have the res set to less than 9 so that it looks + // almost the same in either case. + if (glowResPow < 9) + { + delta *= 0.5f; + } + F32 strength = RenderGlowStrength; - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); + gGlowProgram.bind(); + gGlowProgram.uniform1f(LLShaderMgr::GLOW_STRENGTH, strength); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + for (S32 i = 0; i < kernel; i++) + { + mGlow[i % 2].bindTarget(); + mGlow[i % 2].clear(); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + if (i == 0) + { + gGL.getTexUnit(0)->bind(&mGlow[2]); + } + else + { + gGL.getTexUnit(0)->bind(&mGlow[(i - 1) % 2]); + } - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + if (i % 2 == 0) + { + gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, delta, 0); + } + else + { + gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta); + } - gGL.end(); + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); - gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - } + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); - screen_target->flush(); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); - LLVertexBuffer::unbind(); - } + gGL.end(); - if (sRenderGlow) - { - LL_PROFILE_GPU_ZONE("glow"); - mGlow[2].bindTarget(); - mGlow[2].clear(); - - gGlowExtractProgram.bind(); - F32 minLum = llmax((F32) RenderGlowMinLuminance, 0.0f); - F32 maxAlpha = RenderGlowMaxExtractAlpha; - F32 warmthAmount = RenderGlowWarmthAmount; - LLVector3 lumWeights = RenderGlowLumWeights; - LLVector3 warmthWeights = RenderGlowWarmthWeights; - - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, minLum); - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); - gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], - lumWeights.mV[2]); - gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], - warmthWeights.mV[2]); - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); - - { - LLGLEnable blend_on(GL_BLEND); - LLGLEnable test(GL_ALPHA_TEST); + mGlow[i % 2].flush(); + } - gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); + gGlowProgram.unbind(); + } + else // !sRenderGlow, skip the glow ping-pong and just clear the result target + { + mGlow[1].bindTarget(); + mGlow[1].clear(); + mGlow[1].flush(); + } - mRT->screen.bindTexture(0, 0, LLTexUnit::TFO_POINT); + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - gGL.color4f(1, 1, 1, 1); - gPipeline.enableLightsFullbright(); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + tc2.setVec((F32)mRT->screen.getWidth(), (F32)mRT->screen.getHeight()); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + gGL.flush(); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + LLVertexBuffer::unbind(); - gGL.end(); + if (LLPipeline::sRenderDeferred) + { + bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && + (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && + RenderDepthOfField && + !gCubeSnapshot; - gGL.getTexUnit(0)->unbind(mRT->screen.getUsage()); + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; - mGlow[2].flush(); + gViewerWindow->setup3DViewport(); - tc1.setVec(0, 0); - tc2.setVec(2, 2); - } + if (dof_enabled) + { + LL_PROFILE_GPU_ZONE("dof"); + LLGLSLShader* shader = &gDeferredPostProgram; + LLGLDisable blend(GL_BLEND); - // power of two between 1 and 1024 - U32 glowResPow = RenderGlowResolutionPow; - const U32 glow_res = llmax(1, llmin(1024, 1 << glowResPow)); + // depth of field focal plane calculations + static F32 current_distance = 16.f; + static F32 start_distance = 16.f; + static F32 transition_time = 1.f; - S32 kernel = RenderGlowIterations * 2; - F32 delta = RenderGlowWidth / glow_res; - // Use half the glow width if we have the res set to less than 9 so that it looks - // almost the same in either case. - if (glowResPow < 9) - { - delta *= 0.5f; - } - F32 strength = RenderGlowStrength; + LLVector3 focus_point; - gGlowProgram.bind(); - gGlowProgram.uniform1f(LLShaderMgr::GLOW_STRENGTH, strength); + LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); + if (obj && obj->mDrawable && obj->isSelected()) + { // focus on selected media object + S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); + if (obj && obj->mDrawable) + { + LLFace* face = obj->mDrawable->getFace(face_idx); + if (face) + { + focus_point = face->getPositionAgent(); + } + } + } - for (S32 i = 0; i < kernel; i++) - { - mGlow[i % 2].bindTarget(); - mGlow[i % 2].clear(); + if (focus_point.isExactlyZero()) + { + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { // focus on point under cursor + focus_point.set(gDebugRaycastIntersection.getF32ptr()); + } + else if (gAgentCamera.cameraMouselook()) + { // focus on point under mouselook crosshairs + LLVector4a result; + result.clear(); - if (i == 0) - { - gGL.getTexUnit(0)->bind(&mGlow[2]); - } - else - { - gGL.getTexUnit(0)->bind(&mGlow[(i - 1) % 2]); - } + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); - if (i % 2 == 0) - { - gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, delta, 0); - } - else - { - gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta); - } + focus_point.set(result.getF32ptr()); + } + else + { + // focus on alt-zoom target + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + } + } + } - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + LLVector3 eye = LLViewerCamera::getInstance()->getOrigin(); + F32 target_distance = 16.f; + if (!focus_point.isExactlyZero()) + { + target_distance = LLViewerCamera::getInstance()->getAtAxis() * (focus_point - eye); + } - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + if (transition_time >= 1.f && fabsf(current_distance - target_distance) / current_distance > 0.01f) + { // large shift happened, interpolate smoothly to new target distance + transition_time = 0.f; + start_distance = current_distance; + } + else if (transition_time < 1.f) + { // currently in a transition, continue interpolating + transition_time += 1.f / CameraFocusTransitionTime * gFrameIntervalSeconds.value(); + transition_time = llmin(transition_time, 1.f); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + F32 t = cosf(transition_time * F_PI + F_PI) * 0.5f + 0.5f; + current_distance = start_distance + (target_distance - start_distance) * t; + } + else + { // small or no change, just snap to target distance + current_distance = target_distance; + } - gGL.end(); + // convert to mm + F32 subject_distance = current_distance * 1000.f; + F32 fnumber = CameraFNumber; + F32 default_focal_length = CameraFocalLength; - mGlow[i % 2].flush(); - } + F32 fov = LLViewerCamera::getInstance()->getView(); - gGlowProgram.unbind(); - } - else // !sRenderGlow, skip the glow ping-pong and just clear the result target - { - mGlow[1].bindTarget(); - mGlow[1].clear(); - mGlow[1].flush(); - } + const F32 default_fov = CameraFieldOfView * F_PI / 180.f; - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + // F32 aspect_ratio = (F32) mRT->screen.getWidth()/(F32)mRT->screen.getHeight(); - tc2.setVec((F32) mRT->screen.getWidth(), (F32) mRT->screen.getHeight()); + F32 dv = 2.f * default_focal_length * tanf(default_fov / 2.f); - gGL.flush(); + F32 focal_length = dv / (2 * tanf(fov / 2.f)); - LLVertexBuffer::unbind(); + // F32 tan_pixel_angle = tanf(LLDrawable::sCurPixelAngle); - if (LLPipeline::sRenderDeferred) - { - bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && - (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField && - !gCubeSnapshot; + // from wikipedia -- c = |s2-s1|/s2 * f^2/(N(S1-f)) + // where N = fnumber + // s2 = dot distance + // s1 = subject distance + // f = focal length + // - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; + F32 blur_constant = focal_length * focal_length / (fnumber * (subject_distance - focal_length)); + blur_constant /= 1000.f; // convert to meters for shader + F32 magnification = focal_length / (subject_distance - focal_length); - gViewerWindow->setup3DViewport(); + { // build diffuse+bloom+CoF + mRT->deferredLight.bindTarget(); + shader = &gDeferredCoFProgram; - if (dof_enabled) - { - LL_PROFILE_GPU_ZONE("dof"); - LLGLSLShader *shader = &gDeferredPostProgram; - LLGLDisable blend(GL_BLEND); + bindDeferredShader(*shader); - // depth of field focal plane calculations - static F32 current_distance = 16.f; - static F32 start_distance = 16.f; - static F32 transition_time = 1.f; + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + if (channel > -1) + { + mRT->screen.bindTexture(0, channel); + } - LLVector3 focus_point; + shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); + shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); + shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); + shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - LLViewerObject *obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); - if (obj && obj->mDrawable && obj->isSelected()) - { // focus on selected media object - S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); - if (obj && obj->mDrawable) - { - LLFace *face = obj->mDrawable->getFace(face_idx); - if (face) - { - focus_point = face->getPositionAgent(); - } - } - } + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); - if (focus_point.isExactlyZero()) - { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { // focus on point under cursor - focus_point.set(gDebugRaycastIntersection.getF32ptr()); - } - else if (gAgentCamera.cameraMouselook()) - { // focus on point under mouselook crosshairs - LLVector4a result; - result.clear(); + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); - focus_point.set(result.getF32ptr()); - } - else - { - // focus on alt-zoom target - LLViewerRegion *region = gAgent.getRegion(); - if (region) - { - focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); - } - } - } + gGL.end(); - LLVector3 eye = LLViewerCamera::getInstance()->getOrigin(); - F32 target_distance = 16.f; - if (!focus_point.isExactlyZero()) - { - target_distance = LLViewerCamera::getInstance()->getAtAxis() * (focus_point - eye); - } + unbindDeferredShader(*shader); + mRT->deferredLight.flush(); + } - if (transition_time >= 1.f && fabsf(current_distance - target_distance) / current_distance > 0.01f) - { // large shift happened, interpolate smoothly to new target distance - transition_time = 0.f; - start_distance = current_distance; - } - else if (transition_time < 1.f) - { // currently in a transition, continue interpolating - transition_time += 1.f / CameraFocusTransitionTime * gFrameIntervalSeconds.value(); - transition_time = llmin(transition_time, 1.f); + U32 dof_width = (U32)(mRT->screen.getWidth() * CameraDoFResScale); + U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); - F32 t = cosf(transition_time * F_PI + F_PI) * 0.5f + 0.5f; - current_distance = start_distance + (target_distance - start_distance) * t; - } - else - { // small or no change, just snap to target distance - current_distance = target_distance; - } + { // perform DoF sampling at half-res (preserve alpha channel) + mRT->screen.bindTarget(); + glViewport(0, 0, dof_width, dof_height); + gGL.setColorMask(true, false); - // convert to mm - F32 subject_distance = current_distance * 1000.f; - F32 fnumber = CameraFNumber; - F32 default_focal_length = CameraFocalLength; + shader = &gDeferredPostProgram; + bindDeferredShader(*shader); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); + if (channel > -1) + { + mRT->deferredLight.bindTexture(0, channel); + } - F32 fov = LLViewerCamera::getInstance()->getView(); + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - const F32 default_fov = CameraFieldOfView * F_PI / 180.f; + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); - // F32 aspect_ratio = (F32) mRT->screen.getWidth()/(F32)mRT->screen.getHeight(); + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); - F32 dv = 2.f * default_focal_length * tanf(default_fov / 2.f); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); - F32 focal_length = dv / (2 * tanf(fov / 2.f)); + gGL.end(); - // F32 tan_pixel_angle = tanf(LLDrawable::sCurPixelAngle); + unbindDeferredShader(*shader); + mRT->screen.flush(); + gGL.setColorMask(true, true); + } - // from wikipedia -- c = |s2-s1|/s2 * f^2/(N(S1-f)) - // where N = fnumber - // s2 = dot distance - // s1 = subject distance - // f = focal length - // + { // combine result based on alpha + if (multisample) + { + mRT->deferredLight.bindTarget(); + glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); + } + else + { + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + } - F32 blur_constant = focal_length * focal_length / (fnumber * (subject_distance - focal_length)); - blur_constant /= 1000.f; // convert to meters for shader - F32 magnification = focal_length / (subject_distance - focal_length); + shader = &gDeferredDoFCombineProgram; + bindDeferredShader(*shader); - { // build diffuse+bloom+CoF - mRT->deferredLight.bindTarget(); - shader = &gDeferredCoFProgram; + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + if (channel > -1) + { + mRT->screen.bindTexture(0, channel); + } - bindDeferredShader(*shader); + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth()); + shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight()); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel); - } + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); - shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); - shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); - shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); - shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + gGL.end(); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + unbindDeferredShader(*shader); - gGL.end(); + if (multisample) + { + mRT->deferredLight.flush(); + } + } + } + else + { + LL_PROFILE_GPU_ZONE("no dof"); + if (multisample) + { + mRT->deferredLight.bindTarget(); + } + LLGLSLShader* shader = &gDeferredPostNoDoFProgram; - unbindDeferredShader(*shader); - mRT->deferredLight.flush(); - } + bindDeferredShader(*shader); - U32 dof_width = (U32)(mRT->screen.getWidth() * CameraDoFResScale); - U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + if (channel > -1) + { + mRT->screen.bindTexture(0, channel); + } - { // perform DoF sampling at half-res (preserve alpha channel) - mRT->screen.bindTarget(); - glViewport(0, 0, dof_width, dof_height); - gGL.setColorMask(true, false); + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1, -1); - shader = &gDeferredPostProgram; - bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); - if (channel > -1) - { - mRT->deferredLight.bindTexture(0, channel); - } + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1, 3); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3, -1); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + gGL.end(); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + unbindDeferredShader(*shader); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + if (multisample) + { + mRT->deferredLight.flush(); + } + } + } +} - gGL.end(); +LLRenderTarget* LLPipeline::screenTarget() { - unbindDeferredShader(*shader); - mRT->screen.flush(); - gGL.setColorMask(true, true); - } + bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && + (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && + RenderDepthOfField && + !gCubeSnapshot; - { // combine result based on alpha - if (multisample) - { - mRT->deferredLight.bindTarget(); - glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); - } - else - { - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - } + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; - shader = &gDeferredDoFCombineProgram; - bindDeferredShader(*shader); + if (multisample || dof_enabled) + return &mRT->deferredLight; + + return &mRT->screen; +} - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel); - } +void LLPipeline::renderFinalize() +{ + LLVertexBuffer::unbind(); + LLGLState::checkStates(); + LLGLState::checkTextureChannels(); + + assertInitialized(); + + LLVector2 tc1(0, 0); + LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth()); - shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight()); + LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); + LL_PROFILE_GPU_ZONE("renderFinalize"); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + gGL.color4f(1, 1, 1, 1); + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable cull(GL_CULL_FACE); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + enableLightsFullbright(); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + LLGLDisable test(GL_ALPHA_TEST); - gGL.end(); + gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); - unbindDeferredShader(*shader); + if (!gCubeSnapshot) + { + screenTarget()->bindTarget(); - if (multisample) - { - mRT->deferredLight.flush(); - } - } - } - else + if (RenderScreenSpaceReflections) { - LL_PROFILE_GPU_ZONE("no dof"); - if (multisample) + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections"); + LL_PROFILE_GPU_ZONE("screen space reflections"); + + bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); + mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + set_camera_projection_matrix(gPostScreenSpaceReflectionProgram); + + // We need linear depth. + static LLStaticHashedString zfar("zFar"); + static LLStaticHashedString znear("zNear"); + float nearClip = LLViewerCamera::getInstance()->getNear(); + float farClip = LLViewerCamera::getInstance()->getFar(); + gPostScreenSpaceReflectionProgram.uniform1f(zfar, farClip); + gPostScreenSpaceReflectionProgram.uniform1f(znear, nearClip); + + S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, screenTarget()->getUsage()); + if (channel > -1) { - mRT->deferredLight.bindTarget(); + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } - LLGLSLShader *shader = &gDeferredPostNoDoFProgram; - bindDeferredShader(*shader); + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + + stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + unbindDeferredShader(gPostScreenSpaceReflectionProgram); + } + + // gamma correct lighting + { + LL_PROFILE_GPU_ZONE("gamma correct"); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + LLVector2 tc1(0, 0); + LLVector2 tc2((F32)screenTarget()->getWidth() * 2, (F32)screenTarget()->getHeight() * 2); + + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); + // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); if (channel > -1) { - mRT->screen.bindTexture(0, channel); + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); gGL.vertex2f(-1, -1); @@ -8036,82 +8077,116 @@ void LLPipeline::renderFinalize() gGL.end(); - unbindDeferredShader(*shader); - - if (multisample) - { - mRT->deferredLight.flush(); - } + gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); } - if (multisample) - { - LL_PROFILE_GPU_ZONE("aa"); - // bake out texture2D with RGBL for FXAA shader - mRT->fxaaBuffer.bindTarget(); + screenTarget()->flush(); - S32 width = mRT->screen.getWidth(); - S32 height = mRT->screen.getHeight(); - glViewport(0, 0, width, height); + LLVertexBuffer::unbind(); + } - LLGLSLShader *shader = &gGlowCombineFXAAProgram; + if (RenderDeferred) + { + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; + LLGLSLShader* shader = &gGlowCombineProgram; - shader->bind(); - shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); + S32 width = mRT->screen.getWidth(); + S32 height = mRT->screen.getHeight(); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); - if (channel > -1) - { - mRT->deferredLight.bindTexture(0, channel); - } + S32 channel = -1; - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 3); - gGL.vertex2f(3, -1); - gGL.end(); + // Present everything. + if (multisample) + { + LL_PROFILE_GPU_ZONE("aa"); + // bake out texture2D with RGBL for FXAA shader + mRT->fxaaBuffer.bindTarget(); - gGL.flush(); + glViewport(0, 0, width, height); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); - shader->unbind(); + shader = &gGlowCombineFXAAProgram; - mRT->fxaaBuffer.flush(); + shader->bind(); + shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - shader = &gFXAAProgram; - shader->bind(); + channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); + if (channel > -1) + { + mRT->deferredLight.bindTexture(0, channel); + } - channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); - if (channel > -1) - { - mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); - } + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex2f(-1, -1); + gGL.vertex2f(-1, 3); + gGL.vertex2f(3, -1); + gGL.end(); - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - - F32 scale_x = (F32) width / mRT->fxaaBuffer.getWidth(); - F32 scale_y = (F32) height / mRT->fxaaBuffer.getHeight(); - shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); - shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f / width * scale_x, 1.f / height * scale_y); - shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f / width * scale_x, -0.5f / height * scale_y, - 0.5f / width * scale_x, 0.5f / height * scale_y); - shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f / width * scale_x, -2.f / height * scale_y, - 2.f / width * scale_x, 2.f / height * scale_y); + gGL.flush(); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 3); - gGL.vertex2f(3, -1); - gGL.end(); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); + shader->unbind(); - gGL.flush(); - shader->unbind(); - } - } + mRT->fxaaBuffer.flush(); + + shader = &gFXAAProgram; + shader->bind(); + + channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); + if (channel > -1) + { + mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + + F32 scale_x = (F32)width / mRT->fxaaBuffer.getWidth(); + F32 scale_y = (F32)height / mRT->fxaaBuffer.getHeight(); + shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); + shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f / width * scale_x, 1.f / height * scale_y); + shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f / width * scale_x, -0.5f / height * scale_y, + 0.5f / width * scale_x, 0.5f / height * scale_y); + shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f / width * scale_x, -2.f / height * scale_y, + 2.f / width * scale_x, 2.f / height * scale_y); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex2f(-1, -1); + gGL.vertex2f(-1, 3); + gGL.vertex2f(3, -1); + gGL.end(); + + gGL.flush(); + shader->unbind(); + } + else + { + shader->bind(); + + + gGL.getTexUnit(0)->bind(&mGlow[1]); + gGL.getTexUnit(1)->bind(screenTarget()); + + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex2f(-1, -1); + gGL.vertex2f(-1, 3); + gGL.vertex2f(3, -1); + gGL.end(); + + gGL.flush(); + shader->unbind(); + } + } + #if 0 // DEPRECATED else // not deferred { -- cgit v1.2.3 From b3fc82ff1da0c869f0b1dd841647a120a1ae56af Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 9 Jan 2023 13:05:32 -0600 Subject: SL-18869 Optimizations -- decruftify LLVertexBuffer and make an optimal "renderShadowSimple" utility function for pushing vertex buffers only. --- indra/newview/pipeline.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4edc092271..10c271cddc 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7396,6 +7396,49 @@ void LLPipeline::renderObjects(U32 type, U32 mask, bool texture, bool batch_text gGLLastMatrix = NULL; } +void LLPipeline::renderShadowSimple(U32 type) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + assertInitialized(); + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + + LLVertexBuffer* last_vb = nullptr; + + LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); + LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); + + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) + { + LLDrawInfo& params = **i; + + ++i; + + if (i != end) + { + _mm_prefetch((char*) (*i)->mVertexBuffer.get(), _MM_HINT_NTA); + + auto* ni = i + 1; + if (ni != end) + { + _mm_prefetch((char*)*ni, _MM_HINT_NTA); + } + } + + LLVertexBuffer* vb = params.mVertexBuffer; + if (vb != last_vb) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("push shadow simple"); + mSimplePool->applyModelMatrix(params); + vb->setBufferFast(LLVertexBuffer::MAP_VERTEX); + vb->drawRangeFast(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); + vb = last_vb; + } + } + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; +} + void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -9561,8 +9604,16 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLEnvironment& environment = LLEnvironment::instance(); - LLVertexBuffer::unbind(); + struct CompareVertexBuffer + { + bool operator()(const LLDrawInfo* const& lhs, const LLDrawInfo* const& rhs) + { + return lhs->mVertexBuffer > rhs->mVertexBuffer; + } + }; + + LLVertexBuffer::unbind(); for (int j = 0; j < 2; ++j) // 0 -- static, 1 -- rigged { bool rigged = j == 1; @@ -9589,17 +9640,29 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow simple"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE); LL_PROFILE_GPU_ZONE("shadow simple"); gGL.getTexUnit(0)->disable(); - for (U32 i = 0; i < sizeof(types) / sizeof(U32); ++i) + + for (U32 type : types) { - renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE, FALSE, rigged); + if (rigged) + { + renderObjects(type, LLVertexBuffer::MAP_VERTEX, FALSE, FALSE, rigged); + } + else + { + //{ sort should not be necessary because each entry in sCull should already + // be sorted by vertex buffer + // LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("sort shadow simple"); + // std::sort(sCull->beginRenderMap(type), sCull->endRenderMap(type), CompareVertexBuffer()); + //} + renderShadowSimple(type); + } } + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); if (!use_shader) { gOcclusionProgram.unbind(); } - - } if (use_shader) -- cgit v1.2.3 From a710bf9067bd4c4217b9febc0ad277a1636ec882 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 9 Jan 2023 15:18:57 -0600 Subject: SL-18869 Optimizations -- Use _mm_prefetch to cut down on cache misses when iterating over render batches. --- indra/newview/pipeline.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 10c271cddc..9851d4bc6a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2863,6 +2863,8 @@ void LLPipeline::clearRebuildDrawables() void LLPipeline::rebuildPriorityGroups() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("rebuildPriorityGroups"); + LLTimer update_timer; assertInitialized(); @@ -7412,18 +7414,7 @@ void LLPipeline::renderShadowSimple(U32 type) { LLDrawInfo& params = **i; - ++i; - - if (i != end) - { - _mm_prefetch((char*) (*i)->mVertexBuffer.get(), _MM_HINT_NTA); - - auto* ni = i + 1; - if (ni != end) - { - _mm_prefetch((char*)*ni, _MM_HINT_NTA); - } - } + LLCullResult::increment_iterator(i, end); LLVertexBuffer* vb = params.mVertexBuffer; if (vb != last_vb) @@ -7448,11 +7439,16 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, U32 type = LLRenderPass::PASS_ALPHA; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; if (pparams) { + LLCullResult::increment_iterator(i, end); + if (rigged) { if (pparams->mAvatar != nullptr) -- cgit v1.2.3 From a2d17d3c1e5a62f10ab3922b6b12f909f1cd4682 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 9 Jan 2023 18:12:54 -0600 Subject: SL-18869 Optimizations -- Decruftify LLRenderTarget, use a shader to copy color/depth instead of glCopyTexSubImage or glBlitFrameBuffer --- indra/newview/pipeline.cpp | 163 ++++++--------------------------------------- 1 file changed, 21 insertions(+), 142 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9851d4bc6a..b5271a6ca1 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -858,14 +858,12 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 occlusion_divisor = 3; //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; - //if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; - if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true, true, LLTexUnit::TT_TEXTURE, false, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16; - if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, true, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; mRT->deferredScreen.shareDepthBuffer(mRT->screen); @@ -905,9 +903,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mRT->fxaaBuffer.release(); mRT->screen.release(); mRT->deferredScreen.release(); //make sure to release any render targets that share a depth buffer with mRT->deferredScreen first - //mRT->deferredDepth.release(); - mRT->occlusionDepth.release(); - + if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false; } @@ -926,8 +922,6 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; S32 shadow_detail = RenderShadowDetail; - const U32 occlusion_divisor = 3; - F32 scale = llmax(0.f, RenderShadowResolutionScale); U32 sun_shadow_map_width = BlurHappySize(resX, scale); U32 sun_shadow_map_height = BlurHappySize(resY, scale); @@ -936,12 +930,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { //allocate 4 sun shadow maps for (U32 i = 0; i < 4; i++) { - if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) - { - return false; - } - - if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width / occlusion_divisor, sun_shadow_map_height / occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, true, true, LLTexUnit::TT_TEXTURE)) { return false; } @@ -966,11 +955,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) U32 spot_shadow_map_height = height; for (U32 i = 0; i < 2; i++) { - if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) - { - return false; - } - if (!mSpotShadowOcclusion[i].allocate(spot_shadow_map_width / occlusion_divisor, height / occlusion_divisor, 0, TRUE, FALSE)) + if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, true, true)) { return false; } @@ -1001,7 +986,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) } } - if (shadow_detail > 1) + if (shadow_detail > 1 && !gCubeSnapshot) { for (U32 i = 0; i < 2; i++) { @@ -1198,7 +1183,6 @@ void LLPipeline::releaseScreenBuffers() mRT->deferredScreen.release(); mRT->deferredDepth.release(); mRT->deferredLight.release(); - mRT->occlusionDepth.release(); } @@ -1206,7 +1190,6 @@ void LLPipeline::releaseSunShadowTarget(U32 index) { llassert(index < 4); mRT->shadow[index].release(); - mRT->shadowOcclusion[index].release(); } void LLPipeline::releaseSunShadowTargets() @@ -1224,7 +1207,6 @@ void LLPipeline::releaseSpotShadowTargets() for (U32 i = 0; i < 2; i++) { mSpotShadow[i].release(); - mSpotShadowOcclusion[i].release(); } } } @@ -1239,7 +1221,7 @@ void LLPipeline::createGLBuffers() if (LLPipeline::sRenderTransparentWater) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE); + mWaterDis.allocate(res,res,GL_RGBA,true,true,LLTexUnit::TT_TEXTURE); } // Use FBO for bake tex @@ -2355,9 +2337,6 @@ static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* planep) { - static LLCachedControl use_occlusion(gSavedSettings,"UseOcclusion"); - static bool can_use_occlusion = LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion"); - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); if (planep != nullptr) @@ -2373,56 +2352,6 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla sCull->clear(); - bool to_texture = LLPipeline::sUseOcclusion > 1 && gPipeline.shadersLoaded(); - - if (to_texture) - { - if (LLPipeline::sRenderDeferred && can_use_occlusion) - { - mRT->occlusionDepth.bindTarget(); - } - else - { - mRT->screen.bindTarget(); - } - } - - if (sUseOcclusion > 1) - { - gGL.setColorMask(false, false); - } - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadMatrix(gGLLastProjection); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLLastModelView); - - LLGLDisable blend(GL_BLEND); - LLGLDisable test(GL_ALPHA_TEST); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - - bool bound_shader = false; - if (gPipeline.shadersLoaded() && LLGLSLShader::sCurBoundShader == 0) - { //if no shader is currently bound, use the occlusion shader instead of fixed function if we can - // (shadow render uses a special shader that clamps to clip planes) - bound_shader = true; - gOcclusionCubeProgram.bind(); - } - - if (sUseOcclusion > 1) - { - if (mCubeVB.isNull()) - { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); - } - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - } - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -2444,16 +2373,10 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla LLVOCachePartition* vo_part = region->getVOCachePartition(); if(vo_part) { - bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe; - vo_part->cull(camera, do_occlusion_cull); + vo_part->cull(camera, sUseOcclusion > 0); } } - if (bound_shader) - { - gOcclusionCubeProgram.unbind(); - } - if (hasRenderType(LLPipeline::RENDER_TYPE_SKY) && gSky.mVOSkyp.notNull() && gSky.mVOSkyp->mDrawable.notNull()) @@ -2479,28 +2402,6 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { LLWorld::getInstance()->precullWaterObjects(camera, sCull, render_water); } - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - if (sUseOcclusion > 1) - { - gGL.setColorMask(true, false); - } - - if (to_texture) - { - if (LLPipeline::sRenderDeferred && can_use_occlusion) - { - mRT->occlusionDepth.flush(); - } - else - { - mRT->screen.flush(); - } - } } void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) @@ -2563,6 +2464,9 @@ void LLPipeline::markOccluder(LLSpatialGroup* group) void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("downsampleDepthBuffer"); + LLGLSLShader* last_shader = LLGLSLShader::sCurBoundShaderPtr; LLGLSLShader* shader = NULL; @@ -2570,12 +2474,12 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d if (scratch_space) { GLint bits = 0; - llassert(!source.hasStencil()); // stencil buffer usage is deprecated - bits |= (source.hasStencil() && dest.hasStencil()) ? GL_STENCIL_BUFFER_BIT : 0; - bits |= GL_DEPTH_BUFFER_BIT; + bits = GL_DEPTH_BUFFER_BIT; +#if 0 // TODO -- restore occlusion culling functionality scratch_space->copyContents(source, 0, 0, source.getWidth(), source.getHeight(), 0, 0, scratch_space->getWidth(), scratch_space->getHeight(), bits, GL_NEAREST); +#endif } dest.bindTarget(); @@ -2624,23 +2528,6 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d } } -void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - llassert(!gCubeSnapshot); -#if 0 - downsampleDepthBuffer(source, dest, scratch_space); - dest.bindTarget(); - doOcclusion(camera); - dest.flush(); -#else - // none of the above shenanigans should matter (enough) because we've preserved hierarchical Z before issuing occlusion queries - //source.bindTarget(); - doOcclusion(camera); - //source.flush(); -#endif -} - void LLPipeline::doOcclusion(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -9572,13 +9459,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowCubeProgram.bind(); } - LLRenderTarget& occlusion_target = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? - mSpotShadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : - mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; - - occlusion_target.bindTarget(); + updateCull(shadow_cam, result); - occlusion_target.flush(); stateSort(shadow_cam, result); @@ -9661,6 +9543,12 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera } } + if (occlude > 1) + { // do occlusion culling against non-masked only to take advantage of hierarchical Z + doOcclusion(shadow_cam); + } + + if (use_shader) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); @@ -9760,15 +9648,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLRenderTarget& occlusion_source = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? - mSpotShadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : - mRT->shadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; - - if (occlude > 1) - { - doOcclusion(shadow_cam, occlusion_source, occlusion_target); - } - if (use_shader) { gDeferredShadowProgram.unbind(); -- cgit v1.2.3 From 4abf39c968c31a9da943a53434388102b99d487f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 10 Jan 2023 11:42:12 -0600 Subject: SL-18869 Optimizations -- Bring back water plane clipping for above/below water where applicable. --- indra/newview/pipeline.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b5271a6ca1..5e585852f4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2335,13 +2335,34 @@ bool LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); -void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* planep) +void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); - if (planep != nullptr) + bool water_clip = !sRenderTransparentWater; + + if (water_clip) { - camera.setUserClipPlane(*planep); + + LLVector3 pnorm; + + F32 water_height = LLEnvironment::instance().getWaterHeight(); + + if (sUnderWaterRender) + { + //camera is below water, cull above water + pnorm.setVec(0, 0, 1); + } + else + { + //camera is above water, cull below water + pnorm = LLVector3(0, 0, -1); + } + + LLPlane plane; + plane.setVec(LLVector3(0, 0, water_height), pnorm); + + camera.setUserClipPlane(plane); } else { -- cgit v1.2.3 From d224fa0b62877368fb9bae210063850bd853f6b6 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Tue, 10 Jan 2023 14:43:12 -0800 Subject: Fix mac build for DRTVWR-559 --- indra/newview/pipeline.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5e585852f4..832c7b8b43 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -855,8 +855,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) S32 shadow_detail = RenderShadowDetail; bool ssao = RenderDeferredSSAO; - const U32 occlusion_divisor = 3; - //allocate deferred rendering color buffers if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true, true, LLTexUnit::TT_TEXTURE, false, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; @@ -2494,10 +2492,10 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d if (scratch_space) { +#if 0 // TODO -- restore occlusion culling functionality GLint bits = 0; bits = GL_DEPTH_BUFFER_BIT; -#if 0 // TODO -- restore occlusion culling functionality - scratch_space->copyContents(source, + scratch_space->copyContents(source, 0, 0, source.getWidth(), source.getHeight(), 0, 0, scratch_space->getWidth(), scratch_space->getHeight(), bits, GL_NEAREST); #endif -- cgit v1.2.3 From fdc0ea64f050ad09a84442f40396bb9e6497ce52 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 10 Jan 2023 17:36:05 -0600 Subject: SL-18869 Optimizations -- LLVertexBuffer overhaul and shuffle of shadow map rendering to a place where the main camera has taken a stab at object updates for this frame before shadow map rendering has at them. --- indra/newview/pipeline.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5e585852f4..d56b31a372 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2338,6 +2338,7 @@ static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); + LL_PROFILE_GPU_ZONE("updateCull"); // should always be zero GPU time, but drop a timer to flush stuff out bool water_clip = !sRenderTransparentWater; @@ -2649,10 +2650,6 @@ void LLPipeline::updateGL() LLGLUpdate::sGLQ.pop_front(); } } - - { //seed VBO Pools - LLVertexBuffer::seedPools(); - } } void LLPipeline::clearRebuildGroups() @@ -3229,6 +3226,7 @@ void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags f void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("stateSort"); if (hasAnyRenderType(LLPipeline::RENDER_TYPE_AVATAR, LLPipeline::RENDER_TYPE_CONTROL_AV, @@ -3837,6 +3835,7 @@ void LLPipeline::postSort(LLCamera &camera) // flush particle VB if (LLVOPartGroup::sVB) { + LL_PROFILE_GPU_ZONE("flush particle vb"); LLVOPartGroup::sVB->flush(); } else @@ -3860,9 +3859,12 @@ void LLPipeline::postSort(LLCamera &camera) }*/ // pack vertex buffers for groups that chose to delay their updates - for (LLSpatialGroup::sg_vector_t::iterator iter = mMeshDirtyGroup.begin(); iter != mMeshDirtyGroup.end(); ++iter) { - (*iter)->rebuildMesh(); + LL_PROFILE_GPU_ZONE("rebuildMesh"); + for (LLSpatialGroup::sg_vector_t::iterator iter = mMeshDirtyGroup.begin(); iter != mMeshDirtyGroup.end(); ++iter) + { + (*iter)->rebuildMesh(); + } } /*if (use_transform_feedback) @@ -7259,8 +7261,6 @@ void LLPipeline::doResetVertexBuffers(bool forced) LLVOPartGroup::destroyGL(); gGL.resetVertexBuffer(); - SUBSYSTEM_CLEANUP(LLVertexBuffer); - if (LLVertexBuffer::sGLCount != 0) { LL_WARNS() << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << LL_ENDL; @@ -7280,7 +7280,6 @@ void LLPipeline::doResetVertexBuffers(bool forced) sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha"); LLPipeline::sTextureBindTest = gSavedSettings.getBOOL("RenderDebugTextureBind"); - LLVertexBuffer::initClass(LLVertexBuffer::sEnableVBOs, LLVertexBuffer::sDisableVBOMapping); gGL.initVertexBuffer(); mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); -- cgit v1.2.3 From 493d501cde13abf1ac4164cd77286f068da3a62c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 10 Jan 2023 19:49:18 -0600 Subject: SL-18869 Optimizations -- Revive "Frame Profile" and GL_DEPTH_CLAMP. Remove usage of gl_FragDepth from shadow shaders. --- indra/newview/pipeline.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6ac059df91..5f90fae25f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9470,7 +9470,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLEnable cull(GL_CULL_FACE); //enable depth clamping if available - //LLGLEnable depth_clamp(GL_DEPTH_CLAMP); + LLGLEnable depth_clamp(GL_DEPTH_CLAMP); + + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_LESS); if (use_shader) { @@ -9513,15 +9515,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera for (int j = 0; j < 2; ++j) // 0 -- static, 1 -- rigged { bool rigged = j == 1; - if (!use_shader) - { //occlusion program is general purpose depth-only no-textures - gOcclusionProgram.bind(rigged); - } - else - { - gDeferredShadowProgram.bind(rigged); - LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - } + gDeferredShadowProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); gGL.diffuseColor4f(1, 1, 1, 1); @@ -9555,10 +9550,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera } gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - if (!use_shader) - { - gOcclusionProgram.unbind(); - } } if (occlude > 1) -- cgit v1.2.3 From b4f53334141b179bdb1762636ce313f14d9e2b10 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 11 Jan 2023 11:28:45 -0600 Subject: SL-18869 Touch up -- Prune "post_pos" from shadow shaders that don't need it and fix non-standard gl_Position z values --- indra/newview/pipeline.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5f90fae25f..66083470e2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7350,30 +7350,28 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; - if (pparams) - { - LLCullResult::increment_iterator(i, end); + LLCullResult::increment_iterator(i, end); - if (rigged) + if (rigged) + { + if (pparams->mAvatar != nullptr) { - if (pparams->mAvatar != nullptr) + if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { - if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) - { - mSimplePool->uploadMatrixPalette(*pparams); - lastAvatar = pparams->mAvatar; - lastMeshId = pparams->mSkinInfo->mHash; - } - - mSimplePool->pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_texture); + mSimplePool->uploadMatrixPalette(*pparams); + lastAvatar = pparams->mAvatar; + lastMeshId = pparams->mSkinInfo->mHash; } - } - else if (pparams->mAvatar == nullptr) - { - mSimplePool->pushBatch(*pparams, mask, texture, batch_texture); + + mSimplePool->pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_texture); } } + else if (pparams->mAvatar == nullptr) + { + mSimplePool->pushBatch(*pparams, mask, texture, batch_texture); + } } + gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; } -- cgit v1.2.3 From b9a4d81d5140b34199a6582b1189473b6a2e72fb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 11 Jan 2023 16:20:24 -0600 Subject: SL-18869 Optimizations -- Revive LLVBOPool and fix silly typo in renderShadowSimple --- indra/newview/pipeline.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 66083470e2..cedbe4d117 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7328,7 +7328,7 @@ void LLPipeline::renderShadowSimple(U32 type) mSimplePool->applyModelMatrix(params); vb->setBufferFast(LLVertexBuffer::MAP_VERTEX); vb->drawRangeFast(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); - vb = last_vb; + last_vb = vb; } } gGL.loadMatrix(gGLModelView); @@ -9538,11 +9538,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera } else { - //{ sort should not be necessary because each entry in sCull should already - // be sorted by vertex buffer - // LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("sort shadow simple"); - // std::sort(sCull->beginRenderMap(type), sCull->endRenderMap(type), CompareVertexBuffer()); - //} renderShadowSimple(type); } } -- cgit v1.2.3 From 7bd9d21e19b923096ba2b5ea3cbc8be3e13d7aa0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 19 Jan 2023 09:13:45 -0600 Subject: Optimizations, decruft, and intel compatibility pass (#53) SL-18869, SL-18772 Overhaul VBO management, restore occlusion culling, intel compatibility pass, etc --- indra/newview/pipeline.cpp | 618 +++++++-------------------------------------- 1 file changed, 86 insertions(+), 532 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cedbe4d117..beaa3cdb69 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -285,7 +285,7 @@ static LLStaticHashedString sKernScale("kern_scale"); void drawBox(const LLVector4a& c, const LLVector4a& r); void drawBoxOutline(const LLVector3& pos, const LLVector3& size); U32 nhpo2(U32 v); -LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage); +LLVertexBuffer* ll_create_cube_vb(U32 type_mask); void display_update_camera(); //---------------------------------------- @@ -416,9 +416,6 @@ void LLPipeline::init() gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); - LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); - LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); - LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); @@ -498,15 +495,15 @@ void LLPipeline::init() if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); } - mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); - mDeferredVB->allocateBuffer(8, 0, true); + mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK); + mDeferredVB->allocateBuffer(8, 0); { - mScreenTriangleVB = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); - mScreenTriangleVB->allocateBuffer(3, 0, true); + mScreenTriangleVB = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->allocateBuffer(3, 0); LLStrider vert; mScreenTriangleVB->getVertexStrider(vert); @@ -514,7 +511,7 @@ void LLPipeline::init() vert[1].set(-1, -3, 0); vert[2].set(3, 1, 0); - mScreenTriangleVB->flush(); + mScreenTriangleVB->unmapBuffer(); } setLightingDetail(-1); @@ -706,11 +703,6 @@ void LLPipeline::destroyGL() releaseGLBuffers(); - if (LLVertexBuffer::sEnableVBOs) - { - LLVertexBuffer::sEnableVBOs = FALSE; - } - if (mMeshDirtyQueryObject) { glDeleteQueries(1, &mMeshDirtyQueryObject); @@ -2505,14 +2497,6 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d dest.bindTarget(); dest.clear(GL_DEPTH_BUFFER_BIT); - LLStrider vert; - mDeferredVB->getVertexStrider(vert); - LLStrider tc0; - - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - if (source.getUsage() == LLTexUnit::TT_TEXTURE) { shader = &gDownsampleDepthRectProgram; @@ -2532,8 +2516,8 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d { LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } dest.flush(); @@ -2552,6 +2536,8 @@ void LLPipeline::doOcclusion(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("doOcclusion"); + llassert(!gCubeSnapshot); + if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { @@ -2572,25 +2558,13 @@ void LLPipeline::doOcclusion(LLCamera& camera) LLGLDisable cull(GL_CULL_FACE); - - bool bind_shader = (LLGLSLShader::sCurBoundShader == 0); - if (bind_shader) - { - if (LLPipeline::sShadowRender) - { - gDeferredShadowCubeProgram.bind(); - } - else - { - gOcclusionCubeProgram.bind(); - } - } + gOcclusionCubeProgram.bind(); if (mCubeVB.isNull()) { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); } - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mCubeVB->setBuffer(); for (LLCullResult::sg_iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter) { @@ -2610,19 +2584,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) } } - if (bind_shader) - { - if (LLPipeline::sShadowRender) - { - gDeferredShadowCubeProgram.unbind(); - } - else - { - gOcclusionCubeProgram.unbind(); - } - } - - gGL.setColorMask(true, false); + gGL.setColorMask(true, true); } } @@ -3661,50 +3623,6 @@ void renderSoundHighlights(LLDrawable *drawablep) } } -void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) -{ - if (tex) - { - tex->setActive(); - tex->addTextureStats(vsize); - } -} - -void LLPipeline::touchTextures(LLDrawInfo* info) -{ - if (--info->mTextureTimer == 0) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - // reset texture timer in a noisy fashion to avoid clumping of updates - const U32 MIN_WAIT_TIME = 8; - const U32 MAX_WAIT_TIME = 16; - - info->mTextureTimer = ll_rand() % (MAX_WAIT_TIME - MIN_WAIT_TIME) + MIN_WAIT_TIME; - - auto& mat = info->mGLTFMaterial; - if (mat.notNull()) - { - touchTexture(mat->mBaseColorTexture, info->mVSize); - touchTexture(mat->mNormalTexture, info->mVSize); - touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); - touchTexture(mat->mEmissiveTexture, info->mVSize); - } - else - { - info->mTextureTimer += (U8) info->mTextureList.size(); - - for (int i = 0; i < info->mTextureList.size(); ++i) - { - touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); - } - - touchTexture(info->mTexture, info->mVSize); - touchTexture(info->mSpecularMap, info->mVSize); - touchTexture(info->mNormalMap, info->mVSize); - } - } -} - void LLPipeline::postSort(LLCamera &camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -3757,28 +3675,6 @@ void LLPipeline::postSort(LLCamera &camera) continue; } - // DEBUG -- force a texture virtual size update every frame - /*if (group->getSpatialPartition()->mDrawableType == LLPipeline::RENDER_TYPE_VOLUME) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("plps - update vsize"); - auto& entries = group->getData(); - for (auto& entry : entries) - { - if (entry) - { - auto* data = entry->getDrawable(); - if (data) - { - LLVOVolume* volume = ((LLDrawable*)data)->getVOVolume(); - if (volume) - { - volume->updateTextureVirtualSize(true); - } - } - } - } - }*/ - for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) { LLDrawInfo *info = *k; @@ -3786,7 +3682,6 @@ void LLPipeline::postSort(LLCamera &camera) sCull->pushDrawInfo(j->first, info); if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { - touchTextures(info); addTrianglesDrawn(info->mCount); } } @@ -3830,17 +3725,6 @@ void LLPipeline::postSort(LLCamera &camera) } } - // flush particle VB - if (LLVOPartGroup::sVB) - { - LL_PROFILE_GPU_ZONE("flush particle vb"); - LLVOPartGroup::sVB->flush(); - } - else - { - LL_WARNS_ONCE() << "Missing particle buffer" << LL_ENDL; - } - /*bool use_transform_feedback = gTransformPositionProgram.mProgramObject && !mMeshDirtyGroup.empty(); if (use_transform_feedback) @@ -3989,9 +3873,8 @@ void render_hud_elements() //glStencilMask(0xFFFFFFFF); //glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - gGL.color4f(1,1,1,1); - gUIProgram.bind(); + gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_TRUE, GL_FALSE); if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) @@ -4151,261 +4034,6 @@ void LLPipeline::renderHighlights() //debug use U32 LLPipeline::sCurRenderPoolType = 0 ; -void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); - LL_PROFILE_GPU_ZONE("renderGeom"); - assertInitialized(); - - F32 saved_modelview[16]; - F32 saved_projection[16]; - - //HACK: preserve/restore matrices around HUD render - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - for (U32 i = 0; i < 16; i++) - { - saved_modelview[i] = gGLModelView[i]; - saved_projection[i] = gGLProjection[i]; - } - } - - /////////////////////////////////////////// - // - // Sync and verify GL state - // - // - - stop_glerror(); - - LLVertexBuffer::unbind(); - - // Do verification of GL state - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - if (mRenderDebugMask & RENDER_DEBUG_VERIFY) - { - if (!verify()) - { - LL_ERRS() << "Pipeline verification failed!" << LL_ENDL; - } - } - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:ForceVBO"); - - // Initialize lots of GL state to "safe" values - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - LLGLSPipeline gls_pipeline; - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - - LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2); - - // Toggle backface culling for debugging - LLGLEnable cull_face(mBackfaceCull ? GL_CULL_FACE : 0); - // Set fog - bool use_fog = hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG); - LLGLEnable fog_enable(use_fog && - !gPipeline.canUseWindLightShadersOnObjects() ? GL_FOG : 0); - gSky.updateFog(camera.getFar()); - if (!use_fog) - { - sUnderWaterRender = false; - } - - gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sDefaultImagep); - LLViewerFetchedTexture::sDefaultImagep->setAddressMode(LLTexUnit::TAM_WRAP); - - - ////////////////////////////////////////////// - // - // Actually render all of the geometry - // - // - stop_glerror(); - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPools"); - - for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) - { - LLDrawPool *poolp = *iter; - if (hasRenderType(poolp->getType())) - { - poolp->prerender(); - } - } - - { - bool occlude = sUseOcclusion > 1; -#if 1 // DEPRECATED -- requires forward rendering - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pools"); //LL_RECORD_BLOCK_TIME(FTM_POOLS); - - // HACK: don't calculate local lights if we're rendering the HUD! - // Removing this check will cause bad flickering when there are - // HUD elements being rendered AND the user is in flycam mode -nyx - if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - calcNearbyLights(camera); - setupHWLights(NULL); - } - - U32 cur_type = 0; - - pool_set_t::iterator iter1 = mPools.begin(); - while ( iter1 != mPools.end() ) - { - LLDrawPool *poolp = *iter1; - - cur_type = poolp->getType(); - - //debug use - sCurRenderPoolType = cur_type ; - - if (occlude && cur_type >= LLDrawPool::POOL_GRASS) - { - occlude = false; - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); - doOcclusion(camera); - } - - - pool_set_t::iterator iter2 = iter1; - if (hasRenderType(poolp->getType()) && poolp->getNumPasses() > 0) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pool render"); //LL_RECORD_BLOCK_TIME(FTM_POOLRENDER); - - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - - for( S32 i = 0; i < poolp->getNumPasses(); i++ ) - { - LLVertexBuffer::unbind(); - poolp->beginRenderPass(i); - for (iter2 = iter1; iter2 != mPools.end(); iter2++) - { - LLDrawPool *p = *iter2; - if (p->getType() != cur_type) - { - break; - } - - if ( !p->getSkipRenderFlag() ) { p->render(i); } - } - poolp->endRenderPass(i); - LLVertexBuffer::unbind(); - if (gDebugGL) - { - std::string msg = llformat("pass %d", i); - LLGLState::checkStates(msg); - //LLGLState::checkTextureChannels(msg); - //LLGLState::checkClientArrays(msg); - } - } - } - else - { - // Skip all pools of this type - for (iter2 = iter1; iter2 != mPools.end(); iter2++) - { - LLDrawPool *p = *iter2; - if (p->getType() != cur_type) - { - break; - } - } - } - iter1 = iter2; - stop_glerror(); - - } - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPoolsEnd"); - - LLVertexBuffer::unbind(); -#endif - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - - if (occlude) - { // catch uncommon condition where pools at drawpool grass and later are disabled - occlude = false; - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); - doOcclusion(camera); - } - } - - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - - if (!LLPipeline::sImpostorRender) - { - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderHighlights"); - - if (!sReflectionRender) - { - renderHighlights(); - } - - // Contains a list of the faces of objects that are physical or - // have touch-handlers. - mHighlightFaces.clear(); - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDebug"); - - renderDebug(); - - LLVertexBuffer::unbind(); - - if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred) - { - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) - { - // Render debugging beacons. - gObjectList.renderObjectBeacons(); - gObjectList.resetObjectBeacons(); - gSky.addSunMoonBeacons(); - } - else - { - // Make sure particle effects disappear - LLHUDObject::renderAllForTimer(); - } - } - else - { - // Make sure particle effects disappear - LLHUDObject::renderAllForTimer(); - } - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd"); - - //HACK: preserve/restore matrices around HUD render - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - for (U32 i = 0; i < 16; i++) - { - gGLModelView[i] = saved_modelview[i]; - gGLProjection[i] = saved_projection[i]; - } - } - } - - LLVertexBuffer::unbind(); - - LLGLState::checkStates(); -// LLGLState::checkTextureChannels(); -// LLGLState::checkClientArrays(); -#endif -} - void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) { LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); @@ -4438,7 +4066,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); if (LLViewerShaderMgr::instance()->mShaderLevel[LLViewerShaderMgr::SHADER_DEFERRED] > 1) { @@ -4464,9 +4091,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); doOcclusion(camera); - gGL.setColorMask(true, false); } pool_set_t::iterator iter2 = iter1; @@ -4586,7 +4211,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) if (gDebugGL || gDebugPipeline) { - LLGLState::checkStates(); + LLGLState::checkStates(GL_FALSE); } } } @@ -4667,8 +4292,6 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) } poolp->endShadowPass(i); LLVertexBuffer::unbind(); - - LLGLState::checkStates(); } } else @@ -5049,8 +4672,6 @@ void LLPipeline::renderDebug() } } - gGL.color4f(1,1,1,1); - gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); gGL.setColorMask(true, false); @@ -5059,6 +4680,7 @@ void LLPipeline::renderDebug() if (!hud_only && !mDebugBlips.empty()) { //render debug blips gUIProgram.bind(); + gGL.color4f(1, 1, 1, 1); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep, true); @@ -5154,7 +4776,7 @@ void LLPipeline::renderDebug() LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display"); bindDeferredShader(gReflectionProbeDisplayProgram, NULL); - mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); // Provide our projection matrix. set_camera_projection_matrix(gReflectionProbeDisplayProgram); @@ -7259,45 +6881,35 @@ void LLPipeline::doResetVertexBuffers(bool forced) LLVOPartGroup::destroyGL(); gGL.resetVertexBuffer(); - if (LLVertexBuffer::sGLCount != 0) - { - LL_WARNS() << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << LL_ENDL; - } - LLVertexBuffer::unbind(); updateRenderBump(); updateRenderDeferred(); - LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); - LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); - LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); - LLVertexBuffer::sEnableVBOs = gSavedSettings.getBOOL("RenderVBOEnable"); - LLVertexBuffer::sDisableVBOMapping = LLVertexBuffer::sEnableVBOs && gSavedSettings.getBOOL("RenderVBOMappingDisable") ; sBakeSunlight = gSavedSettings.getBOOL("RenderBakeSunlight"); sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha"); LLPipeline::sTextureBindTest = gSavedSettings.getBOOL("RenderDebugTextureBind"); gGL.initVertexBuffer(); - mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); - mDeferredVB->allocateBuffer(8, 0, true); + mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK); + mDeferredVB->allocateBuffer(8, 0); LLVOPartGroup::restoreGL(); } -void LLPipeline::renderObjects(U32 type, U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; if (rigged) { - mSimplePool->pushRiggedBatches(type + 1, mask, texture, batch_texture); + mSimplePool->pushRiggedBatches(type + 1, texture, batch_texture); } else { - mSimplePool->pushBatches(type, mask, texture, batch_texture); + mSimplePool->pushBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -7326,8 +6938,8 @@ void LLPipeline::renderShadowSimple(U32 type) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("push shadow simple"); mSimplePool->applyModelMatrix(params); - vb->setBufferFast(LLVertexBuffer::MAP_VERTEX); - vb->drawRangeFast(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); + vb->setBuffer(); + vb->drawRange(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); last_vb = vb; } } @@ -7335,7 +6947,7 @@ void LLPipeline::renderShadowSimple(U32 type) gGLLastMatrix = NULL; } -void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; assertInitialized(); @@ -7363,12 +6975,12 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_texture); + mSimplePool->pushBatch(*pparams, texture, batch_texture); } } else if (pparams->mAvatar == nullptr) { - mSimplePool->pushBatch(*pparams, mask, texture, batch_texture); + mSimplePool->pushBatch(*pparams, texture, batch_texture); } } @@ -7376,35 +6988,35 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, gGLLastMatrix = NULL; } -void LLPipeline::renderMaskedObjects(U32 type, U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; if (rigged) { - mAlphaMaskPool->pushRiggedMaskBatches(type+1, mask, texture, batch_texture); + mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); } else { - mAlphaMaskPool->pushMaskBatches(type, mask, texture, batch_texture); + mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; } -void LLPipeline::renderFullbrightMaskedObjects(U32 type, U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; if (rigged) { - mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, mask, texture, batch_texture); + mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); } else { - mFullbrightAlphaMaskPool->pushMaskBatches(type, mask, texture, batch_texture); + mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -7476,7 +7088,6 @@ void LLPipeline::renderPostProcess() { LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); assertInitialized(); @@ -7486,7 +7097,6 @@ void LLPipeline::renderPostProcess() LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); LL_PROFILE_GPU_ZONE("renderPostProcess"); - gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); LLGLDisable cull(GL_CULL_FACE); @@ -7605,6 +7215,7 @@ void LLPipeline::renderPostProcess() } gGlowProgram.unbind(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); } else // !sRenderGlow, skip the glow ping-pong and just clear the result target { @@ -7920,7 +7531,6 @@ void LLPipeline::renderFinalize() { LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); assertInitialized(); @@ -7952,7 +7562,7 @@ void LLPipeline::renderFinalize() LL_PROFILE_GPU_ZONE("screen space reflections"); bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); - mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); set_camera_projection_matrix(gPostScreenSpaceReflectionProgram); @@ -7993,7 +7603,7 @@ void LLPipeline::renderFinalize() // Apply gamma correction to the frame here. gDeferredPostGammaCorrectProgram.bind(); - // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); if (channel > -1) @@ -8134,7 +7744,7 @@ void LLPipeline::renderFinalize() { U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1; LLPointer buff = new LLVertexBuffer(mask, 0); - buff->allocateBuffer(3, 0, TRUE); + buff->allocateBuffer(3, 0); LLStrider v; LLStrider uv1; @@ -8167,7 +7777,7 @@ void LLPipeline::renderFinalize() LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - buff->setBuffer(mask); + buff->setBuffer(); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); gGlowCombineProgram.unbind(); @@ -8190,7 +7800,6 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); // flush calls made to "addTrianglesDrawn" so far to stats machinery recordTrianglesDrawn(); @@ -8301,7 +7910,6 @@ void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - LL_PROFILE_GPU_ZONE("bindDeferredShader"); LLRenderTarget* deferred_target = &mRT->deferredScreen; //LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8602,13 +8210,6 @@ void LLPipeline::renderDeferredLighting() glh::matrix4f mat = copy_matrix(gGLModelView); - LLStrider vert; - mDeferredVB->getVertexStrider(vert); - - vert[0].set(-1, 1, 0); - vert[1].set(-1, -3, 0); - vert[2].set(3, 1, 0); - setupHWLights(NULL); // to set mSun/MoonDir; glh::vec4f tc(mSunDir.mV); @@ -8626,7 +8227,7 @@ void LLPipeline::renderDeferredLighting() { // paint shadow/SSAO light map (direct lighting lightmap) LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - sun shadow"); bindDeferredShader(gDeferredSunProgram, deferred_light_target); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); glClearColor(1, 1, 1, 1); deferred_light_target->clear(GL_COLOR_BUFFER_BIT); glClearColor(0, 0, 0, 0); @@ -8658,9 +8259,7 @@ void LLPipeline::renderDeferredLighting() { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } unbindDeferredShader(gDeferredSunProgram); @@ -8690,7 +8289,7 @@ void LLPipeline::renderDeferredLighting() glClearColor(0, 0, 0, 0); bindDeferredShader(gDeferredBlurLightProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); LLVector3 go = RenderShadowGaussian; const U32 kern_length = 4; F32 blur_size = RenderShadowBlurSize; @@ -8719,9 +8318,7 @@ void LLPipeline::renderDeferredLighting() { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } screen_target->flush(); @@ -8729,7 +8326,7 @@ void LLPipeline::renderDeferredLighting() bindDeferredShader(gDeferredBlurLightProgram, screen_target); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); deferred_light_target->bindTarget(); gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); @@ -8737,9 +8334,7 @@ void LLPipeline::renderDeferredLighting() { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } deferred_light_target->flush(); unbindDeferredShader(gDeferredBlurLightProgram); @@ -8781,9 +8376,8 @@ void LLPipeline::renderDeferredLighting() // full screen blit - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } @@ -8836,10 +8430,10 @@ void LLPipeline::renderDeferredLighting() if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); } - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mCubeVB->setBuffer(); LLGLDepthTest depth(GL_TRUE, GL_FALSE); // mNearbyLights already includes distance calculation and excludes muted avatars. @@ -8942,7 +8536,7 @@ void LLPipeline::renderDeferredLighting() LLGLDepthTest depth(GL_TRUE, GL_FALSE); bindDeferredShader(gDeferredSpotLightProgram); - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mCubeVB->setBuffer(); gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); @@ -8976,12 +8570,6 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(gDeferredSpotLightProgram); } - // reset mDeferredVB to fullscreen triangle - mDeferredVB->getVertexStrider(vert); - vert[0].set(-1, 1, 0); - vert[1].set(-1, -3, 0); - vert[2].set(3, 1, 0); - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - fullscreen lights"); LLGLDepthTest depth(GL_FALSE); @@ -9014,8 +8602,8 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } @@ -9024,7 +8612,7 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) { @@ -9049,7 +8637,7 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, light_falloff_final); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); @@ -9098,6 +8686,8 @@ void LLPipeline::renderDeferredLighting() } screen_target->flush(); + + gGL.setColorMask(true, true); } void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) @@ -9534,7 +9124,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { if (rigged) { - renderObjects(type, LLVertexBuffer::MAP_VERTEX, FALSE, FALSE, rigged); + renderObjects(type, false, false, rigged); } else { @@ -9571,11 +9161,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); - U32 mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_COLOR | - LLVertexBuffer::MAP_TEXTURE_INDEX; - for (int i = 0; i < 2; ++i) { bool rigged = i == 1; @@ -9586,37 +9171,44 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); - renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE, rigged); + LL_PROFILE_GPU_ZONE("shadow alpha masked"); + renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); + LL_PROFILE_GPU_ZONE("shadow alpha blend"); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); - renderAlphaObjects(mask, TRUE, TRUE, rigged); + renderAlphaObjects(true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); + LL_PROFILE_GPU_ZONE("shadow alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE, rigged); + renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); + LL_PROFILE_GPU_ZONE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); if (i == 0) { LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); - renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); + renderObjects(LLRenderPass::PASS_GRASS, true); } - U32 no_idx_mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX; - renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha material"); + LL_PROFILE_GPU_ZONE("shadow alpha material"); + renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, true, false, rigged); + } } } @@ -9634,11 +9226,11 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera if (rigged) { - mAlphaMaskPool->pushRiggedGLTFBatches(type + 1, mask); + mAlphaMaskPool->pushRiggedGLTFBatches(type + 1); } else { - mAlphaMaskPool->pushGLTFBatches(type, mask); + mAlphaMaskPool->pushGLTFBatches(type); } gGL.loadMatrix(gGLModelView); @@ -9891,7 +9483,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) bool skip_avatar_update = false; if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) { - skip_avatar_update = true; } @@ -10005,12 +9596,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) clip = RenderShadowOrthoClipPlanes; mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); - //if (gCubeSnapshot) - { //always do a single 64m shadow in reflection maps - mSunClipPlanes.set(64.f, 128.f, 256.f); - mSunOrthoClipPlanes.set(64.f, 128.f, 256.f); - } - //currently used for amount to extrude frusta corners for constructing shadow frusta //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; @@ -10515,7 +10100,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { static LLCullResult result[4]; - renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, FALSE, target_width); + renderShadow(view[j], proj[j], shadow_cam, result[j], true, true, target_width); } mRT->shadow[j].flush(); @@ -10670,7 +10255,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = drawable; - renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], FALSE, FALSE, target_width); + renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], false, true, target_width); RenderSpotLight = nullptr; @@ -10698,7 +10283,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) gGL.loadMatrix(proj[1].m); gGL.matrixMode(LLRender::MM_MODELVIEW); } - gGL.setColorMask(true, false); + gGL.setColorMask(true, true); for (U32 i = 0; i < 16; i++) { @@ -10714,7 +10299,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } } -void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture) +void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, bool texture) { for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) { @@ -10724,12 +10309,12 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool textu gPipeline.hasRenderType(group->getSpatialPartition()->mDrawableType) && group->mDrawMap.find(type) != group->mDrawMap.end()) { - pass->renderGroup(group,type,mask,texture); + pass->renderGroup(group,type,texture); } } } -void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture) +void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) { for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) { @@ -10739,7 +10324,7 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, U32 mask, bool gPipeline.hasRenderType(group->getSpatialPartition()->mDrawableType) && group->mDrawMap.find(type) != group->mDrawMap.end()) { - pass->renderRiggedGroup(group, type, mask, texture); + pass->renderRiggedGroup(group, type, texture); } } } @@ -10751,7 +10336,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); LL_PROFILE_GPU_ZONE("generateImpostor"); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); static LLCullResult result; result.clear(); @@ -10977,17 +10561,10 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) if (preview_avatar) { // previews don't care about imposters - if (LLPipeline::sRenderDeferred) - { - renderGeomDeferred(camera); - renderGeomPostDeferred(camera); - } - else - { - renderGeom(camera); - } + renderGeomDeferred(camera); + renderGeomPostDeferred(camera); } - else if (LLPipeline::sRenderDeferred) + else { avatar->mImpostor.clear(); renderGeomDeferred(camera); @@ -11009,28 +10586,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) sImpostorRenderAlphaDepthPass = false; } - else - { - LLGLEnable scissor(GL_SCISSOR_TEST); - glScissor(0, 0, resX, resY); - avatar->mImpostor.clear(); - renderGeom(camera); - - // Shameless hack time: render it all again, - // this time writing the depth - // values we need to generate the alpha mask below - // while preserving the alpha-sorted color rendering - // from the previous pass - // - sImpostorRenderAlphaDepthPass = true; - - // depth-only here... - // - gGL.setColorMask(false,false); - renderGeom(camera); - - sImpostorRenderAlphaDepthPass = false; - } LLDrawPoolAvatar::sMinimumAlpha = old_alpha; @@ -11121,7 +10676,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); } bool LLPipeline::hasRenderBatches(const U32 type) const -- cgit v1.2.3 From c83e66414848e468cce01d36c1054b2e9314baf9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 Jan 2023 13:00:40 -0600 Subject: SL-18869 GL 3 compatibility pass and minor decruft. --- indra/newview/pipeline.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index beaa3cdb69..2a55a299ac 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -326,7 +326,6 @@ bool LLPipeline::sRenderAttachedLights = true; bool LLPipeline::sRenderAttachedParticles = true; bool LLPipeline::sRenderDeferred = false; bool LLPipeline::sReflectionProbesEnabled = false; -bool LLPipeline::sRenderPBR = false; S32 LLPipeline::sVisibleLightCount = 0; bool LLPipeline::sRenderingHUDs; F32 LLPipeline::sDistortionWaterClipPlaneMargin = 1.0125f; @@ -1008,12 +1007,6 @@ void LLPipeline::updateRenderBump() sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); } -// static -void LLPipeline::updateRenderDeferred() -{ - sRenderPBR = sRenderDeferred; -} - // static void LLPipeline::refreshCachedSettings() { @@ -1103,11 +1096,9 @@ void LLPipeline::refreshCachedSettings() CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale"); RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit"); RenderScreenSpaceReflections = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); - sReflectionProbesEnabled = gSavedSettings.getBOOL("RenderReflectionsEnabled"); + sReflectionProbesEnabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionsEnabled") && gSavedSettings.getBOOL("RenderReflectionsEnabled"); RenderSpotLight = nullptr; - updateRenderDeferred(); - if (gNonInteractive) { LLVOAvatar::sMaxNonImpostors = 1; @@ -1207,7 +1198,6 @@ void LLPipeline::createGLBuffers() stop_glerror(); assertInitialized(); - updateRenderDeferred(); if (LLPipeline::sRenderTransparentWater) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); @@ -6881,10 +6871,9 @@ void LLPipeline::doResetVertexBuffers(bool forced) LLVOPartGroup::destroyGL(); gGL.resetVertexBuffer(); - LLVertexBuffer::unbind(); + LLVertexBuffer::unbind(); updateRenderBump(); - updateRenderDeferred(); sBakeSunlight = gSavedSettings.getBOOL("RenderBakeSunlight"); sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha"); @@ -8358,17 +8347,6 @@ void LLPipeline::renderDeferredLighting() soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); - if (!LLPipeline::sUnderWaterRender && LLPipeline::sRenderPBR) - { - soften_shader.bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, LLViewerFetchedTexture::sDefaultIrradiancePBRp); // PBR: irradiance - } - - if(LLPipeline::sRenderPBR) - { - LLVector3 cameraAtAxis = LLViewerCamera::getInstance()->getAtAxis(); - soften_shader.uniform3fv(LLShaderMgr::DEFERRED_VIEW_DIR, 1, cameraAtAxis.mV); - } - { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From 7067a9585ae8fcaf7a5f02398130fce14995df2a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 Jan 2023 14:40:45 -0600 Subject: SL-18869 Followup -- fix for sky being black in probes and too bright outside probes. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2a55a299ac..aeb7341411 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4037,6 +4037,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; + setupHWLights(nullptr); + { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); //LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS); -- cgit v1.2.3 From 8bad6ccde406566cd6859db69c45c06eb6001386 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 23 Jan 2023 12:24:06 -0600 Subject: SL-19015 Fix gamma correct shader noise parameters (remove banding) --- indra/newview/pipeline.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index aeb7341411..e534523d3c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7608,17 +7608,8 @@ void LLPipeline::renderFinalize() gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); - - gGL.end(); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); gDeferredPostGammaCorrectProgram.unbind(); -- cgit v1.2.3 From a78e03da6e2a36107b036c4d5dd94724f6a15376 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 23 Jan 2023 13:27:13 -0600 Subject: SL-19015 Fix for spot light shadows. --- indra/newview/pipeline.cpp | 47 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e534523d3c..379ab55354 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8997,16 +8997,11 @@ static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_TREE("Alpha Tree"); static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_GRASS("Alpha Grass"); static LLTrace::BlockTimerStatHandle FTM_SHADOW_FULLBRIGHT_ALPHA_MASKED("Fullbright Alpha Masked"); -void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult& result, bool use_shader, bool use_occlusion, U32 target_width) +void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult& result, bool depth_clamp) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_SHADOW_RENDER); LL_PROFILE_GPU_ZONE("renderShadow"); - //disable occlusion culling for shadow passes (save setting to restore later) - S32 occlude = LLPipeline::sUseOcclusion; - if (!use_occlusion) - { - LLPipeline::sUseOcclusion = 0; - } + LLPipeline::sShadowRender = true; static const U32 types[] = { @@ -9029,21 +9024,14 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLEnable cull(GL_CULL_FACE); //enable depth clamping if available - LLGLEnable depth_clamp(GL_DEPTH_CLAMP); + LLGLEnable clamp_depth(depth_clamp ? GL_DEPTH_CLAMP : 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_LESS); - if (use_shader) - { - gDeferredShadowCubeProgram.bind(); - } - - updateCull(shadow_cam, result); stateSort(shadow_cam, result); - //generate shadow map gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); @@ -9106,25 +9094,14 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); } - if (occlude > 1) + if (LLPipeline::sUseOcclusion > 1) { // do occlusion culling against non-masked only to take advantage of hierarchical Z doOcclusion(shadow_cam); } - if (use_shader) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); - - gDeferredShadowProgram.unbind(); - renderGeomShadow(shadow_cam); - gDeferredShadowProgram.bind(); - gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - } - else - { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); - renderGeomShadow(shadow_cam); } @@ -9132,6 +9109,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); + U32 target_width = LLRenderTarget::sCurResX; + for (int i = 0; i < 2; ++i) { bool rigged = i == 1; @@ -9213,11 +9192,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - if (use_shader) - { - gDeferredShadowProgram.unbind(); - } - gGL.setColorMask(true, true); gGL.matrixMode(LLRender::MM_PROJECTION); @@ -9226,7 +9200,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGL.popMatrix(); gGLLastMatrix = NULL; - LLPipeline::sUseOcclusion = occlude; LLPipeline::sShadowRender = false; } @@ -10067,11 +10040,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mRT->shadow[j].getViewport(gGLViewport); mRT->shadow[j].clear(); - U32 target_width = mRT->shadow[j].getWidth(); - { static LLCullResult result[4]; - renderShadow(view[j], proj[j], shadow_cam, result[j], true, true, target_width); + renderShadow(view[j], proj[j], shadow_cam, result[j], true); } mRT->shadow[j].flush(); @@ -10218,15 +10189,13 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mSpotShadow[i].getViewport(gGLViewport); mSpotShadow[i].clear(); - U32 target_width = mSpotShadow[i].getWidth(); - static LLCullResult result[2]; LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); RenderSpotLight = drawable; - renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], false, true, target_width); + renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], false); RenderSpotLight = nullptr; -- cgit v1.2.3 From 6419e7f9f96ddee14c33a97eef4860efff2b2923 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 23 Jan 2023 16:17:12 -0600 Subject: SL-19015 Fix for ugly SSAO --- indra/newview/pipeline.cpp | 150 ++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 104 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 379ab55354..1ba139cd50 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8135,8 +8135,6 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f) void LLPipeline::renderDeferredLighting() { - - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("renderDeferredLighting"); if (!sCull) @@ -8145,31 +8143,12 @@ void LLPipeline::renderDeferredLighting() } LLRenderTarget *screen_target = &mRT->screen; - //LLRenderTarget *deferred_target = &mRT->deferredScreen; - //LLRenderTarget *deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); LLViewerCamera *camera = LLViewerCamera::getInstance(); -#if 0 - { - LLGLDepthTest depth(GL_TRUE); - deferred_depth_target->copyContents(*deferred_target, - 0, - 0, - deferred_target->getWidth(), - deferred_target->getHeight(), - 0, - 0, - deferred_depth_target->getWidth(), - deferred_depth_target->getHeight(), - GL_DEPTH_BUFFER_BIT, - GL_NEAREST); - } -#endif - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) @@ -8177,11 +8156,6 @@ void LLPipeline::renderDeferredLighting() gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); } - // ati doesn't seem to love actually using the stencil buffer on FBO's - //LLGLDisable stencil(GL_STENCIL_TEST); - // glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); - // glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - gGL.setColorMask(true, true); // draw a cube around every light @@ -8251,76 +8225,64 @@ void LLPipeline::renderDeferredLighting() if (RenderDeferredSSAO) { - /*if (gCubeSnapshot) - { // SSAO and shadows disabled in reflection maps - deferred_light_target->bindTarget(); - glClearColor(1, 1, 1, 1); - deferred_light_target->clear(); - glClearColor(0, 0, 0, 0); - deferred_light_target->flush(); - } - else*/ - { - // soften direct lighting lightmap - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); - LL_PROFILE_GPU_ZONE("soften shadow"); - // blur lightmap - screen_target->bindTarget(); - glClearColor(1, 1, 1, 1); - screen_target->clear(GL_COLOR_BUFFER_BIT); - glClearColor(0, 0, 0, 0); + // soften direct lighting lightmap + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); + LL_PROFILE_GPU_ZONE("soften shadow"); + // blur lightmap + screen_target->bindTarget(); + glClearColor(1, 1, 1, 1); + screen_target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0, 0, 0, 0); - bindDeferredShader(gDeferredBlurLightProgram); - mScreenTriangleVB->setBuffer(); - LLVector3 go = RenderShadowGaussian; - const U32 kern_length = 4; - F32 blur_size = RenderShadowBlurSize; - F32 dist_factor = RenderShadowBlurDistFactor; + bindDeferredShader(gDeferredBlurLightProgram); - // sample symmetrically with the middle sample falling exactly on 0.0 - F32 x = 0.f; + LLVector3 go = RenderShadowGaussian; + const U32 kern_length = 4; + F32 blur_size = RenderShadowBlurSize; + F32 dist_factor = RenderShadowBlurDistFactor; - LLVector3 gauss[32]; // xweight, yweight, offset + // sample symmetrically with the middle sample falling exactly on 0.0 + F32 x = 0.f; - F32 screenPixelSize = 1.f / screen_target->getWidth(); + LLVector3 gauss[32]; // xweight, yweight, offset - for (U32 i = 0; i < kern_length; i++) - { - gauss[i].mV[0] = llgaussian(x, go.mV[0]); - gauss[i].mV[1] = llgaussian(x, go.mV[1]); - gauss[i].mV[2] = x; - x += screenPixelSize; - } + for (U32 i = 0; i < kern_length; i++) + { + gauss[i].mV[0] = llgaussian(x, go.mV[0]); + gauss[i].mV[1] = llgaussian(x, go.mV[1]); + gauss[i].mV[2] = x; + x += 1.f; + } - gDeferredBlurLightProgram.uniform2f(sDelta, screenPixelSize, 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)); + 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); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } - screen_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); + screen_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); - bindDeferredShader(gDeferredBlurLightProgram, screen_target); + bindDeferredShader(gDeferredBlurLightProgram, screen_target); - mScreenTriangleVB->setBuffer(); - deferred_light_target->bindTarget(); + deferred_light_target->bindTarget(); - gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - deferred_light_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } + deferred_light_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); } screen_target->bindTarget(); @@ -8346,33 +8308,13 @@ void LLPipeline::renderDeferredLighting() LLGLDisable test(GL_ALPHA_TEST); // full screen blit - mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); } -#if 0 - { // render non-deferred geometry (fullbright, alpha, etc) - LLGLDisable blend(GL_BLEND); - //LLGLDisable stencil(GL_STENCIL_TEST); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gPipeline.pushRenderTypeMask(); - - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); - gPipeline.popRenderTypeMask(); - } -#endif - bool render_local = RenderLocalLights; // && !gCubeSnapshot; if (render_local) -- cgit v1.2.3 From a851aa83e705fa4a1c78919cfcac6709cfb1a875 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 24 Jan 2023 12:50:17 -0600 Subject: SL-18958 Fix for broken water distortion map and depth buffer. Incidental decruft. --- indra/newview/pipeline.cpp | 76 ++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 46 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1ba139cd50..f0644cbbf5 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -841,62 +841,46 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) } } - if (LLPipeline::sRenderDeferred) - { - S32 shadow_detail = RenderShadowDetail; - bool ssao = RenderDeferredSSAO; + S32 shadow_detail = RenderShadowDetail; + bool ssao = RenderDeferredSSAO; - //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true, true, LLTexUnit::TT_TEXTURE, false, samples)) return false; - if (!addDeferredAttachments(mRT->deferredScreen)) return false; + //allocate deferred rendering color buffers + if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true, true, LLTexUnit::TT_TEXTURE, false, samples)) return false; + if (!addDeferredAttachments(mRT->deferredScreen)) return false; - GLuint screenFormat = GL_RGBA16; + GLuint screenFormat = GL_RGBA16; - if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, true, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, true, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; - mRT->deferredScreen.shareDepthBuffer(mRT->screen); + mRT->deferredScreen.shareDepthBuffer(mRT->screen); - if (samples > 0) - { - if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; - } - else - { - mRT->fxaaBuffer.release(); - } + if (samples > 0) + { + if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + } + else + { + mRT->fxaaBuffer.release(); + } - if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) - { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa - if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false; - } - else - { - mRT->deferredLight.release(); - } + if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) + { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false; + } + else + { + mRT->deferredLight.release(); + } - allocateShadowBuffer(resX, resY); + allocateShadowBuffer(resX, resY); - //HACK make screenbuffer allocations start failing after 30 seconds - if (gSavedSettings.getBOOL("SimulateFBOFailure")) - { - return false; - } - } - else + //HACK make screenbuffer allocations start failing after 30 seconds + if (gSavedSettings.getBOOL("SimulateFBOFailure")) { - mRT->deferredLight.release(); - - releaseSunShadowTargets(); - releaseSpotShadowTargets(); + return false; + } - mRT->fxaaBuffer.release(); - mRT->screen.release(); - mRT->deferredScreen.release(); //make sure to release any render targets that share a depth buffer with mRT->deferredScreen first - - if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false; - } - - gGL.getTexUnit(0)->disable(); + gGL.getTexUnit(0)->disable(); stop_glerror(); -- cgit v1.2.3 From 3ef31cb9b28f7b026e109eab69d383dddc922850 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 27 Jan 2023 17:24:22 -0600 Subject: SL-19203 et al -- Integrate SSR with reflection probes, tweak probe blending. (#63) * SL-19203 WIP -- Integrate SSR with reflection probes. Decruft LLRenderTarget. * SL-19203 WIP -- Re-integrate SSR. Incidental decruft. * SL-19203 WIP -- SSR frame delta correction (still broken for Z) * SL-19203 WIP -- SSR frame delta Z fix * SL-19203 WIP -- Make SSR toggleable again and disable SSR in cube snapshots. * SL-19203 WIP -- Soften sphere probe transitions and fix reflections on void water (make fallback probe a simple terrain+water+sky probe). Remove parallax correction for automatic probes to reduce artifacts. * SL-19203 Tune probe blending. * SL-19203 Cleanup. --- indra/newview/pipeline.cpp | 172 +++++++++++++++++++++++++-------------------- 1 file changed, 94 insertions(+), 78 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f0644cbbf5..64f7535f05 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -479,14 +479,9 @@ void LLPipeline::init() mBackfaceCull = true; - stop_glerror(); - // Enable features - LLViewerShaderMgr::instance()->setShaders(); - stop_glerror(); - for (U32 i = 0; i < 2; ++i) { mSpotLightFade[i] = 1.f; @@ -835,7 +830,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (RenderUIBuffer) { - if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) + if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA)) { return false; } @@ -845,18 +840,18 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) bool ssao = RenderDeferredSSAO; //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true, true, LLTexUnit::TT_TEXTURE, false, samples)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16; - if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, true, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->screen.allocate(resX, resY, screenFormat)) return false; mRT->deferredScreen.shareDepthBuffer(mRT->screen); if (samples > 0) { - if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA)) return false; } else { @@ -865,7 +860,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa - if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false; + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16)) return false; } else { @@ -874,6 +869,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) allocateShadowBuffer(resX, resY); + if (!gCubeSnapshot && RenderScreenSpaceReflections) // hack to not allocate mSceneMap for cube snapshots + { + mSceneMap.allocate(resX, resY, GL_RGB, true); + } + //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -903,7 +903,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { //allocate 4 sun shadow maps for (U32 i = 0; i < 4; i++) { - if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, true, true, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, true)) { return false; } @@ -928,7 +928,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) U32 spot_shadow_map_height = height; for (U32 i = 0; i < 2; i++) { - if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, true, true)) + if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, true)) { return false; } @@ -1112,6 +1112,8 @@ void LLPipeline::releaseGLBuffers() mWaterDis.release(); mBake.release(); + mSceneMap.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -1185,11 +1187,11 @@ void LLPipeline::createGLBuffers() if (LLPipeline::sRenderTransparentWater) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - mWaterDis.allocate(res,res,GL_RGBA,true,true,LLTexUnit::TT_TEXTURE); + mWaterDis.allocate(res,res,GL_RGBA,true); } // Use FBO for bake tex - mBake.allocate(512, 512, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, true); // SL-12781 Build > Upload > Model; 3D Preview + mBake.allocate(512, 512, GL_RGBA, true); // SL-12781 Build > Upload > Model; 3D Preview stop_glerror(); @@ -1200,7 +1202,7 @@ void LLPipeline::createGLBuffers() const U32 glow_res = llmax(1, llmin(512, 1 << gSavedSettings.getS32("RenderGlowResolutionPow"))); for (U32 i = 0; i < 3; i++) { - mGlow[i].allocate(512, glow_res, GL_RGBA, FALSE, FALSE); + mGlow[i].allocate(512, glow_res, GL_RGBA); } allocateScreenBuffer(resX, resY); @@ -1306,7 +1308,7 @@ void LLPipeline::createLUTBuffers() delete [] ls; } - mPbrBrdfLut.allocate(512, 512, GL_RG16F, false, false); + mPbrBrdfLut.allocate(512, 512, GL_RG16F); mPbrBrdfLut.bindTarget(); gDeferredGenBrdfLutProgram.bind(); @@ -4019,6 +4021,26 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } + if (&camera == LLViewerCamera::getInstance()) + { // a bit hacky, this is the start of the main render frame, figure out delta between last modelview matrix and + // current modelview matrix + glh::matrix4f last_modelview(gGLLastModelView); + glh::matrix4f cur_modelview(gGLModelView); + + // goal is to have a matrix here that goes from the last frame's camera space to the current frame's camera space + glh::matrix4f m = last_modelview.inverse(); // last camera space to world space + m.mult_left(cur_modelview); // world space to camera space + + glh::matrix4f n = m.inverse(); + + for (U32 i = 0; i < 16; ++i) + { + gGLDeltaModelView[i] = m.m[i]; + gGLInverseDeltaModelView[i] = n.m[i]; + } + + } + bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; setupHWLights(nullptr); @@ -7529,10 +7551,11 @@ void LLPipeline::renderFinalize() if (!gCubeSnapshot) { - screenTarget()->bindTarget(); + LLRenderTarget* screen_target = screenTarget(); - if (RenderScreenSpaceReflections) + if (RenderScreenSpaceReflections && !gCubeSnapshot) { +#if 0 LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections"); LL_PROFILE_GPU_ZONE("screen space reflections"); @@ -7565,8 +7588,33 @@ void LLPipeline::renderFinalize() } unbindDeferredShader(gPostScreenSpaceReflectionProgram); +#else + LL_PROFILE_GPU_ZONE("ssr copy"); + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + + LLRenderTarget& src = *screen_target; + LLRenderTarget& depth_src = mRT->deferredScreen; + LLRenderTarget& dst = mSceneMap; + + dst.bindTarget(); + dst.clear(); + gCopyDepthProgram.bind(); + + S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP); + S32 depth_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); + + gGL.getTexUnit(diff_map)->bind(&src); + gGL.getTexUnit(depth_map)->bind(&depth_src, true); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + dst.flush(); +#endif } + screenTarget()->bindTarget(); + // gamma correct lighting { LL_PROFILE_GPU_ZONE("gamma correct"); @@ -7821,56 +7869,6 @@ void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) bindLightFunc(shader); bindShadowMaps(shader); bindReflectionProbes(shader); - -#if 0 - shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); - shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); - shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); - - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_RADIUS, RenderSSAOScale); - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, RenderSSAOMaxScale); - - F32 ssao_factor = RenderSSAOFactor; - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR, ssao_factor); - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0 / ssao_factor); - - LLVector3 ssao_effect = RenderSSAOEffect; - F32 matrix_diag = (ssao_effect[0] + 2.0 * ssao_effect[1]) / 3.0; - F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1]) / 3.0; - // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by - // value factor, and scales remainder by saturation factor - F32 ssao_effect_mat[] = { matrix_diag, matrix_nondiag, matrix_nondiag, - matrix_nondiag, matrix_diag, matrix_nondiag, - matrix_nondiag, matrix_nondiag, matrix_diag }; - shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_SSAO_EFFECT_MAT, 1, GL_FALSE, ssao_effect_mat); - - //F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); - F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]) / 3000.f; - F32 shadow_bias = RenderShadowBias + shadow_bias_error; - - //shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, deferred_target->getWidth(), deferred_target->getHeight()); - shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear() * 2.f); - shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error); - shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, shadow_bias); - shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_OFFSET, RenderSpotShadowOffset); - shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_BIAS, RenderSpotShadowBias); - - shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); - shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); - shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mSpotShadow[0].getWidth(), mSpotShadow[0].getHeight()); - shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); - shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - - if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) - { - glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); - shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); - } - - shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); -#endif } void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) @@ -7910,21 +7908,24 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } -#if 0 - channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); - if (channel > -1) - { - gGL.getTexUnit(channel)->bind(deferred_depth_target, TRUE); - stop_glerror(); - } -#else channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_target->getUsage()); if (channel > -1) { gGL.getTexUnit(channel)->bind(deferred_target, TRUE); stop_glerror(); } -#endif + + channel = shader.enableTexture(LLShaderMgr::SCENE_MAP); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(&mSceneMap); + } + + channel = shader.enableTexture(LLShaderMgr::SCENE_DEPTH); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(&mSceneMap, true); + } if (shader.getUniformLocation(LLShaderMgr::VIEWPORT) != -1) { @@ -8090,6 +8091,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); + shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, gGLDeltaModelView); + shader.uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, gGLInverseDeltaModelView); + + shader.uniform1i(LLShaderMgr::CUBE_SNAPSHOT, gCubeSnapshot ? 1 : 0); + if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) { glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); @@ -8584,6 +8590,16 @@ void LLPipeline::renderDeferredLighting() screen_target->flush(); + if (!gCubeSnapshot) + { + // this is the end of the 3D scene render, grab a copy of the modelview and projection + // matrix for use in off-by-one-frame effects in the next frame + for (U32 i = 0; i < 16; i++) + { + gGLLastModelView[i] = gGLModelView[i]; + gGLLastProjection[i] = gGLProjection[i]; + } + } gGL.setColorMask(true, true); } @@ -10398,7 +10414,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) if (!avatar->mImpostor.isComplete()) { - avatar->mImpostor.allocate(resX, resY, GL_RGBA, TRUE, FALSE); + avatar->mImpostor.allocate(resX, resY, GL_RGBA, true); if (LLPipeline::sRenderDeferred) { -- cgit v1.2.3 From 10b8dcc497599042655dcc4037c9ae98d494bd6f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 30 Jan 2023 18:56:19 -0600 Subject: SL-19015 Bump probe resolution back to 256 by default (drop to 128 if vram < 2GB), remove irradiance map feedback loop (one bounce, but but more stable and allows for much brighter first bounce), make sky contribution to irradiance not tint the world blue. Make irradiance that appears in radiance maps match world irradiance. --- indra/newview/pipeline.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 64f7535f05..03ffe5da48 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -806,11 +806,12 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - if (mRT == &mMainRT) + if (mRT == &mMainRT && sReflectionProbesEnabled) { // hacky -- allocate auxillary buffer gCubeSnapshot = TRUE; + mReflectionMapManager.initReflectionMaps(); mRT = &mAuxillaryRT; - U32 res = LL_REFLECTION_PROBE_RESOLUTION * 2; + U32 res = mReflectionMapManager.mProbeResolution * 2; //multiply by 2 because probes will be super sampled allocateScreenBuffer(res, res, samples); mRT = &mMainRT; gCubeSnapshot = FALSE; @@ -4172,10 +4173,16 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) calcNearbyLights(camera); setupHWLights(NULL); + gGL.setSceneBlendType(LLRender::BT_ALPHA); gGL.setColorMask(true, false); pool_set_t::iterator iter1 = mPools.begin(); + if (gDebugGL || gDebugPipeline) + { + LLGLState::checkStates(GL_FALSE); + } + while ( iter1 != mPools.end() ) { LLDrawPool *poolp = *iter1; @@ -8104,6 +8111,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + + shader.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mReflectionMapManager.mMaxProbeLOD); } -- cgit v1.2.3 From c9d56e212aa0117661f9c76545ca84b39412bae7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 31 Jan 2023 15:01:05 -0600 Subject: SL-19015 Balance sun/sky ambiance with punctual light ambiance. Prevent irradiance maps from being brighter than the environment. --- indra/newview/pipeline.cpp | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 03ffe5da48..641df44aeb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4023,7 +4023,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) } if (&camera == LLViewerCamera::getInstance()) - { // a bit hacky, this is the start of the main render frame, figure out delta between last modelview matrix and + { // a bit hacky, this is the start of the main render frame, figure out delta between last modelview matrix and // current modelview matrix glh::matrix4f last_modelview(gGLLastModelView); glh::matrix4f cur_modelview(gGLModelView); @@ -4039,7 +4039,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) gGLDeltaModelView[i] = m.m[i]; gGLInverseDeltaModelView[i] = n.m[i]; } - } bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; @@ -4047,7 +4046,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) setupHWLights(nullptr); { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); //LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS); + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); LLGLEnable cull(GL_CULL_FACE); @@ -4096,7 +4095,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0) { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pool render"); //LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLRENDER); + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pool render"); gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -4156,7 +4155,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) void LLPipeline::renderGeomPostDeferred(LLCamera& camera) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLS); + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LL_PROFILE_GPU_ZONE("renderGeomPostDeferred"); if (gUseWireframe) @@ -4192,7 +4191,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0) { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred poolrender"); //LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLRENDER); + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred poolrender"); gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -5766,6 +5765,15 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) // Ambient LLColor4 ambient = psky->getTotalAmbient(); + static LLCachedControl ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); + + F32 light_scale = 1.f; + + if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) + { //darken local lights based on brightening of sky lighting + light_scale = 1.f / ambiance_scale; + } + gGL.setAmbientLightColor(ambient); bool sun_up = environment.getIsSunUp(); @@ -5859,7 +5867,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) } //send linear light color to shader - LLColor4 light_color = light->getLightLinearColor(); + LLColor4 light_color = light->getLightLinearColor()*light_scale; light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -8141,6 +8149,15 @@ void LLPipeline::renderDeferredLighting() return; } + static LLCachedControl ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); + + F32 light_scale = 1.f; + + if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) + { //darken local lights based on brightening of sky lighting + light_scale = 1.f / ambiance_scale; + } + LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8374,7 +8391,7 @@ void LLPipeline::renderDeferredLighting() F32 s = volume->getLightRadius() * 1.5f; // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor()*light_scale; if (col.magVecSquared() < 0.001f) { @@ -8468,7 +8485,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8543,7 +8560,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); @@ -8955,12 +8972,16 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLPipeline::sShadowRender = true; + // disable occlusion culling during shadow render + U32 saved_occlusion = sUseOcclusion; + sUseOcclusion = 0; + static const U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY, LLRenderPass::PASS_BUMP, - LLRenderPass::PASS_FULLBRIGHT_SHINY , + LLRenderPass::PASS_FULLBRIGHT_SHINY, LLRenderPass::PASS_MATERIAL, LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE, LLRenderPass::PASS_SPECMAP, @@ -9151,6 +9172,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGL.popMatrix(); gGLLastMatrix = NULL; + // reset occlusion culling flag + sUseOcclusion = saved_occlusion; LLPipeline::sShadowRender = false; } -- cgit v1.2.3 From 6f136d403b6bbccae80661c6585f29e1caed3a7c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 Feb 2023 17:09:34 -0600 Subject: SL-19000 Fix various 3D UI components not respecting depth buffer. Incidental decruft. Do I get a prize for 1000th jira? --- indra/newview/pipeline.cpp | 118 ++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 76 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 641df44aeb..325d01ff1b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -757,6 +757,9 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) // - if not multisampled, shrink resolution and try again (favor X resolution over Y) // Make sure to call "releaseScreenBuffers" after each failure to cleanup the partially loaded state + // refresh cached settings here to protect against inconsistent event handling order + refreshCachedSettings(); + U32 samples = RenderFSAASamples; eFBOStatus ret = FBO_SUCCESS_FULLRES; @@ -1145,15 +1148,13 @@ void LLPipeline::releaseShadowBuffers() void LLPipeline::releaseScreenBuffers() { - mRT->uiScreen.release(); - mRT->screen.release(); - mRT->fxaaBuffer.release(); - mRT->deferredScreen.release(); - mRT->deferredDepth.release(); - mRT->deferredLight.release(); + mRT->uiScreen.release(); + mRT->screen.release(); + mRT->fxaaBuffer.release(); + mRT->deferredScreen.release(); + mRT->deferredLight.release(); } - - + void LLPipeline::releaseSunShadowTarget(U32 index) { llassert(index < 4); @@ -7248,9 +7249,8 @@ void LLPipeline::renderPostProcess() LLVertexBuffer::unbind(); - if (LLPipeline::sRenderDeferred) - { - bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && + { + bool dof_enabled = (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && RenderDepthOfField && !gCubeSnapshot; @@ -7667,9 +7667,9 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); } - if (RenderDeferred) { - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; + llassert(!gCubeSnapshot); + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); LLGLSLShader* shader = &gGlowCombineProgram; S32 width = mRT->screen.getWidth(); @@ -7697,11 +7697,11 @@ void LLPipeline::renderFinalize() mRT->deferredLight.bindTexture(0, channel); } - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 3); - gGL.vertex2f(3, -1); - gGL.end(); + { + LLGLDepthTest depth_test(GL_FALSE, GL_FALSE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } gGL.flush(); @@ -7734,22 +7734,36 @@ void LLPipeline::renderFinalize() shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f / width * scale_x, -2.f / height * scale_y, 2.f / width * scale_x, 2.f / height * scale_y); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 3); - gGL.vertex2f(3, -1); - gGL.end(); + { + // at this point we should pointed at the backbuffer + llassert(LLRenderTarget::sCurFBO == 0); - gGL.flush(); + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); + gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + shader->unbind(); } else { + // at this point we should pointed at the backbuffer + llassert(LLRenderTarget::sCurFBO == 0); + + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + shader->bind(); + S32 glow_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_EMISSIVE); + S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE); + S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.getTexUnit(0)->bind(&mGlow[1]); - gGL.getTexUnit(1)->bind(screenTarget()); + gGL.getTexUnit(glow_channel)->bind(&mGlow[1]); + gGL.getTexUnit(screen_channel)->bind(screenTarget()); + gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; @@ -7757,61 +7771,15 @@ void LLPipeline::renderFinalize() gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 3); - gGL.vertex2f(3, -1); - gGL.end(); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); gGL.flush(); shader->unbind(); } } -#if 0 // DEPRECATED - else // not deferred - { - U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1; - LLPointer buff = new LLVertexBuffer(mask, 0); - buff->allocateBuffer(3, 0); - - LLStrider v; - LLStrider uv1; - LLStrider uv2; - - buff->getVertexStrider(v); - buff->getTexCoord0Strider(uv1); - buff->getTexCoord1Strider(uv2); - uv1[0] = LLVector2(0, 0); - uv1[1] = LLVector2(0, 2); - uv1[2] = LLVector2(2, 0); - - uv2[0] = LLVector2(0, 0); - uv2[1] = LLVector2(0, tc2.mV[1] * 2.f); - uv2[2] = LLVector2(tc2.mV[0] * 2.f, 0); - - v[0] = LLVector3(-1, -1, 0); - v[1] = LLVector3(-1, 3, 0); - v[2] = LLVector3(3, -1, 0); - - buff->flush(); - - LLGLDisable blend(GL_BLEND); - - gGlowCombineProgram.bind(); - - gGL.getTexUnit(0)->bind(&mGlow[1]); - gGL.getTexUnit(1)->bind(&mRT->screen); - - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - - buff->setBuffer(); - buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); - - gGlowCombineProgram.unbind(); - } -#endif gGL.setSceneBlendType(LLRender::BT_ALPHA); if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) @@ -7890,7 +7858,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LLRenderTarget* deferred_target = &mRT->deferredScreen; - //LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; shader.bind(); @@ -8772,7 +8739,6 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { LLRenderTarget* deferred_target = &mRT->deferredScreen; - //LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; stop_glerror(); -- cgit v1.2.3 From 830cb6b66551025285120fb628f0b5ebf3841756 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Feb 2023 17:18:39 -0600 Subject: SL-19148 Decruft some forward shaders and drawpools. Fix HUDs being in wrong color space. --- indra/newview/pipeline.cpp | 57 ---------------------------------------------- 1 file changed, 57 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 325d01ff1b..c602b71679 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -55,7 +55,6 @@ #include "lldrawable.h" #include "lldrawpoolalpha.h" #include "lldrawpoolavatar.h" -#include "lldrawpoolground.h" #include "lldrawpoolbump.h" #include "lldrawpooltree.h" #include "lldrawpoolwater.h" @@ -86,7 +85,6 @@ #include "llviewerwindow.h" // For getSpinAxis #include "llvoavatarself.h" #include "llvocache.h" -#include "llvoground.h" #include "llvosky.h" #include "llvowlsky.h" #include "llvotree.h" @@ -430,7 +428,6 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK); getPool(LLDrawPool::POOL_GRASS); getPool(LLDrawPool::POOL_FULLBRIGHT); - getPool(LLDrawPool::POOL_INVISIBLE); getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); @@ -459,12 +456,6 @@ void LLPipeline::init() else { setAllRenderTypes(); // By default, all rendering types start enabled - // Don't turn on ground when this is set - // Mac Books with intel 950s need this - if(!gSavedSettings.getBOOL("RenderGround")) - { - toggleRenderType(RENDER_TYPE_GROUND); - } } // make sure RenderPerformanceTest persists (hackity hack hack) @@ -649,14 +640,10 @@ void LLPipeline::cleanup() mTerrainPool = NULL; delete mWaterPool; mWaterPool = NULL; - delete mGroundPool; - mGroundPool = NULL; delete mSimplePool; mSimplePool = NULL; delete mFullbrightPool; mFullbrightPool = NULL; - delete mInvisiblePool; - mInvisiblePool = NULL; delete mGlowPool; mGlowPool = NULL; delete mBumpPool; @@ -1518,10 +1505,6 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mFullbrightPool; break; - case LLDrawPool::POOL_INVISIBLE: - poolp = mInvisiblePool; - break; - case LLDrawPool::POOL_GLOW: poolp = mGlowPool; break; @@ -1559,10 +1542,6 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mWaterPool; break; - case LLDrawPool::POOL_GROUND: - poolp = mGroundPool; - break; - case LLDrawPool::POOL_WL_SKY: poolp = mWLSkyPool; break; @@ -3168,7 +3147,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) if (hasAnyRenderType(LLPipeline::RENDER_TYPE_AVATAR, LLPipeline::RENDER_TYPE_CONTROL_AV, - LLPipeline::RENDER_TYPE_GROUND, LLPipeline::RENDER_TYPE_TERRAIN, LLPipeline::RENDER_TYPE_TREE, LLPipeline::RENDER_TYPE_SKY, @@ -5164,18 +5142,6 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; - case LLDrawPool::POOL_INVISIBLE: - if (mInvisiblePool) - { - llassert(0); - LL_WARNS() << "Ignoring duplicate simple pool." << LL_ENDL; - } - else - { - mInvisiblePool = (LLRenderPass*) new_poolp; - } - break; - case LLDrawPool::POOL_GLOW: if (mGlowPool) { @@ -5269,18 +5235,6 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; - case LLDrawPool::POOL_GROUND: - if( mGroundPool ) - { - llassert(0); - LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Ground Pool" << LL_ENDL; - } - else - { - mGroundPool = new_poolp; - } - break; - case LLDrawPool::POOL_WL_SKY: if( mWLSkyPool ) { @@ -5350,11 +5304,6 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mFullbrightPool = NULL; break; - case LLDrawPool::POOL_INVISIBLE: - llassert(mInvisiblePool == poolp); - mInvisiblePool = NULL; - break; - case LLDrawPool::POOL_WL_SKY: llassert(mWLSkyPool == poolp); mWLSkyPool = NULL; @@ -5421,11 +5370,6 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mWaterPool = NULL; break; - case LLDrawPool::POOL_GROUND: - llassert( poolp == mGroundPool ); - mGroundPool = NULL; - break; - case LLDrawPool::POOL_GLTF_PBR: llassert( poolp == mPBROpaquePool ); mPBROpaquePool = NULL; @@ -10255,7 +10199,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) clearRenderTypeMask( RENDER_TYPE_SKY, RENDER_TYPE_WL_SKY, - RENDER_TYPE_GROUND, RENDER_TYPE_TERRAIN, RENDER_TYPE_GRASS, RENDER_TYPE_CONTROL_AV, // Animesh -- cgit v1.2.3 From 1c2410b8af62254e96d60b2ae2e411d4756215e4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Feb 2023 19:45:31 -0600 Subject: SL-19148 Decruft followthrough -- decruft shader tree and some remaining forward rendering code. --- indra/newview/pipeline.cpp | 64 ++-------------------------------------------- 1 file changed, 2 insertions(+), 62 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c602b71679..c1bab49747 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1343,14 +1343,12 @@ bool LLPipeline::shadersLoaded() bool LLPipeline::canUseWindLightShaders() const { - return (gWLSkyProgram.mProgramObject != 0 && - LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1); + return true; } bool LLPipeline::canUseWindLightShadersOnObjects() const { - return (canUseWindLightShaders() - && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0); + return true; } bool LLPipeline::canUseAntiAliasing() const @@ -2431,64 +2429,6 @@ void LLPipeline::markOccluder(LLSpatialGroup* group) } } -void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - LL_PROFILE_GPU_ZONE("downsampleDepthBuffer"); - - LLGLSLShader* last_shader = LLGLSLShader::sCurBoundShaderPtr; - - LLGLSLShader* shader = NULL; - - if (scratch_space) - { -#if 0 // TODO -- restore occlusion culling functionality - GLint bits = 0; - bits = GL_DEPTH_BUFFER_BIT; - scratch_space->copyContents(source, - 0, 0, source.getWidth(), source.getHeight(), - 0, 0, scratch_space->getWidth(), scratch_space->getHeight(), bits, GL_NEAREST); -#endif - } - - dest.bindTarget(); - dest.clear(GL_DEPTH_BUFFER_BIT); - - if (source.getUsage() == LLTexUnit::TT_TEXTURE) - { - shader = &gDownsampleDepthRectProgram; - shader->bind(); - shader->uniform2f(sDelta, 1.f, 1.f); - shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight()); - } - else - { - shader = &gDownsampleDepthProgram; - shader->bind(); - shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight()); - shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f); - } - - gGL.getTexUnit(0)->bind(scratch_space ? scratch_space : &source, TRUE); - - { - LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - dest.flush(); - - if (last_shader) - { - last_shader->bind(); - } - else - { - shader->unbind(); - } -} - void LLPipeline::doOcclusion(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; -- cgit v1.2.3 From b52699091da791a1349daf66d405f27ca2568ea9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Feb 2023 11:40:56 -0600 Subject: SL-19147 Water quality pass. Remove gl_FragDepth writes from sky rendering (optimization). Incidental decruft. --- indra/newview/pipeline.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c1bab49747..6905450e26 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -819,6 +819,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) resY /= res_mod; } + if (LLPipeline::sRenderTransparentWater) + { //water reflection texture + mWaterDis.allocate(resX, resY, GL_RGBA, true); + } + if (RenderUIBuffer) { if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA)) @@ -1099,7 +1104,6 @@ void LLPipeline::releaseGLBuffers() releaseLUTBuffers(); - mWaterRef.release(); mWaterDis.release(); mBake.release(); @@ -1173,12 +1177,6 @@ void LLPipeline::createGLBuffers() stop_glerror(); assertInitialized(); - if (LLPipeline::sRenderTransparentWater) - { //water reflection texture - U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - mWaterDis.allocate(res,res,GL_RGBA,true); - } - // Use FBO for bake tex mBake.allocate(512, 512, GL_RGBA, true); // SL-12781 Build > Upload > Model; 3D Preview -- cgit v1.2.3 From a2647e953aeee26ef99e62e0146adcd37c8afca1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Feb 2023 18:25:22 -0600 Subject: SL-18229 Fix for PBR materials on HUDs misbehaving. Incidental decruft. --- indra/newview/pipeline.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6905450e26..039ad9cf8f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3934,6 +3934,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + llassert(!sRenderingHUDs); + if (gUseWireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -7998,6 +8000,8 @@ void LLPipeline::renderDeferredLighting() return; } + llassert(!sRenderingHUDs); + static LLCachedControl ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); F32 light_scale = 1.f; -- cgit v1.2.3 From 577f6a46f02ecfa4efabc0b379e44e4f53a0b391 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Feb 2023 17:00:36 -0600 Subject: SL-19181 Modulate "glow" by PBR emissive. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 039ad9cf8f..65d9d4e060 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8443,6 +8443,7 @@ void LLPipeline::renderDeferredLighting() LLPipeline::RENDER_TYPE_VOLUME, LLPipeline::RENDER_TYPE_GLOW, LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_SIMPLE, LLPipeline::RENDER_TYPE_PASS_ALPHA, LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, @@ -8452,6 +8453,7 @@ void LLPipeline::renderDeferredLighting() LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, LLPipeline::RENDER_TYPE_PASS_GLOW, + LLPipeline::RENDER_TYPE_PASS_GLTF_GLOW, LLPipeline::RENDER_TYPE_PASS_GRASS, LLPipeline::RENDER_TYPE_PASS_SHINY, LLPipeline::RENDER_TYPE_PASS_INVISIBLE, -- cgit v1.2.3 From 579fc82f8a5c3e2a3a7834541f0cb0c3de8d4d91 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Feb 2023 14:19:09 -0600 Subject: SL-19187 Fix for occlusion and shadow frusta debug displays not working as expected. --- indra/newview/pipeline.cpp | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 65d9d4e060..f911aea9cd 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2438,14 +2438,8 @@ void LLPipeline::doOcclusion(LLCamera& camera) { LLVertexBuffer::unbind(); - if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) - { - gGL.setColorMask(true, false, false, false); - } - else - { - gGL.setColorMask(false, false); - } + gGL.setColorMask(false, false); + LLGLDisable blend(GL_BLEND); LLGLDisable test(GL_ALPHA_TEST); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -9417,7 +9411,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (fp.empty()) { - if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) + if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowCamera[0] = main_camera; mShadowExtents[0][0] = min; @@ -9497,23 +9491,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - /*if (gCubeSnapshot) - { - // do one shadow split for cube snapshots, clear the rest - mSunClipPlanes.set(64.f, 64.f, 64.f); - dist[1] = dist[2] = dist[3] = dist[4] = 64.f; - for (S32 j = 1; j < 4; j++) - { - mRT->shadow[j].bindTarget(); - mRT->shadow[j].clear(); - mRT->shadow[j].flush(); - } - }*/ - - //for (S32 j = 0; j < (gCubeSnapshot ? 1 : 4); j++) for (S32 j = 0; j < 4; j++) { - if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) + if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowFrustPoints[j].clear(); } @@ -9555,7 +9535,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) shadow_cam.calcAgentFrustumPlanes(frust); shadow_cam.mFrustumCornerDist = 0.f; - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowCamera[j] = shadow_cam; } @@ -9565,7 +9545,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (!gPipeline.getVisiblePointCloud(shadow_cam, min, max, fp, lightDir)) { //no possible shadow receivers - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowExtents[j][0] = LLVector3(); mShadowExtents[j][1] = LLVector3(); @@ -9585,7 +9565,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) continue; } - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowExtents[j][0] = min; mShadowExtents[j][1] = max; @@ -9812,7 +9792,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) eye = LLVector3(origin_agent.v); - if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowFrustOrigin[j] = eye; } @@ -9875,7 +9855,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mRT->shadow[j].flush(); - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowCamera[j+4] = shadow_cam; } -- cgit v1.2.3 From 68c4ff7dce2bd519431238f6209238aba46dc0ba Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 14 Feb 2023 10:10:12 -0600 Subject: SL-18762 Fix for broken local lights on alpha when wearing a HUD attachment. Also fix stuck sun/moon and incidental decruft. --- indra/newview/pipeline.cpp | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f911aea9cd..388dee00db 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2272,7 +2272,6 @@ bool LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& } LLViewerCamera::sCurCameraID = saved_camera_id; - return res; } @@ -3956,7 +3955,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; - setupHWLights(nullptr); + setupHWLights(); { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); @@ -4083,7 +4082,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); calcNearbyLights(camera); - setupHWLights(NULL); + setupHWLights(); gGL.setSceneBlendType(LLRender::BT_ALPHA); gGL.setColorMask(true, false); @@ -5452,7 +5451,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); - if (LLPipeline::sReflectionRender || gCubeSnapshot) + if (LLPipeline::sReflectionRender || gCubeSnapshot || LLPipeline::sRenderingHUDs) { return; } @@ -5633,11 +5632,16 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) } } -void LLPipeline::setupHWLights(LLDrawPool* pool) +void LLPipeline::setupHWLights() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); + if (LLPipeline::sRenderingHUDs) + { + return; + } + LLEnvironment& environment = LLEnvironment::instance(); LLSettingsSky::ptr_t psky = environment.getCurrentSky(); @@ -8029,7 +8033,7 @@ void LLPipeline::renderDeferredLighting() glh::matrix4f mat = copy_matrix(gGLModelView); - setupHWLights(NULL); // to set mSun/MoonDir; + setupHWLights(); // to set mSun/MoonDir; glh::vec4f tc(mSunDir.mV); mat.mult_matrix_vec(tc); @@ -9236,6 +9240,24 @@ LLRenderTarget* LLPipeline::getSpotShadowTarget(U32 i) static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_RENDER("Spot Shadow Render"); +// helper class for disabling occlusion culling for the current stack frame +class LLDisableOcclusionCulling +{ +public: + S32 mUseOcclusion; + + LLDisableOcclusionCulling() + { + mUseOcclusion = LLPipeline::sUseOcclusion; + LLPipeline::sUseOcclusion = 0; + } + + ~LLDisableOcclusionCulling() + { + LLPipeline::sUseOcclusion = mUseOcclusion; + } +}; + void LLPipeline::generateSunShadow(LLCamera& camera) { if (!sRenderDeferred || RenderShadowDetail <= 0) @@ -9246,6 +9268,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW); LL_PROFILE_GPU_ZONE("generateSunShadow"); + LLDisableOcclusionCulling no_occlusion; + bool skip_avatar_update = false; if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) { @@ -9479,7 +9503,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; if (mSunDiffuse == LLColor4::black) - { //sun diffuse is totally shadows don't matter + { //sun diffuse is totally black shadows don't matter LLGLDepthTest depth(GL_TRUE); for (S32 j = 0; j < 4; j++) @@ -9989,8 +10013,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - stop_glerror(); - // mSpotShadow[i].bindTarget(); -- cgit v1.2.3 From 9630a1a2bcc80a930d0dda661d8c17db88541f35 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 15 Feb 2023 09:51:19 -0600 Subject: SL-18568 Fix for only one projector casting shadows. --- indra/newview/pipeline.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 388dee00db..c934803a38 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8572,10 +8572,13 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } - //if (!gCubeSnapshot) + // make sure we're not already targeting the same spot light with both shadow maps + llassert(mTargetShadowSpotLight[0] != mTargetShadowSpotLight[1] || mTargetShadowSpotLight[0].isNull()); + + if (!gCubeSnapshot) { LLDrawable* potential = drawablep; - //determine if this is a good light for casting shadows + //determine if this light is higher priority than one of the existing spot shadows F32 m_pri = volume->getSpotLightPriority(); for (U32 i = 0; i < 2; i++) @@ -8584,7 +8587,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) if (mTargetShadowSpotLight[i].notNull()) { - pri = mTargetShadowSpotLight[i]->getVOVolume()->getSpotLightPriority(); + pri = mTargetShadowSpotLight[i]->getVOVolume()->getSpotLightPriority(); } if (m_pri > pri) @@ -8597,6 +8600,9 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) } } + // make sure we didn't end up targeting the same spot light with both shadow maps + llassert(mTargetShadowSpotLight[0] != mTargetShadowSpotLight[1] || mTargetShadowSpotLight[0].isNull()); + LLViewerTexture* img = volume->getLightTexture(); if (img == NULL) @@ -9898,6 +9904,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) F32 fade_amt = gFrameIntervalSeconds.value() * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + // should never happen + llassert(mTargetShadowSpotLight[0] != mTargetShadowSpotLight[1] || mTargetShadowSpotLight[0].isNull()); + //update shadow targets for (U32 i = 0; i < 2; i++) { //for each current shadow @@ -9928,6 +9937,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } } + // this should never happen + llassert(mShadowSpotLight[0] != mShadowSpotLight[1] || mShadowSpotLight[0].isNull()); + for (S32 i = 0; i < 2; i++) { set_current_modelview(saved_view); -- cgit v1.2.3 From b4332012ab0c97785bcf8aa283aa7e2b1a052f86 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 15 Feb 2023 10:57:29 -0600 Subject: SL-19219 Fix for reflection probe display rendering during HUD render (also shadow frusta) --- indra/newview/pipeline.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c934803a38..e814b77725 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4687,7 +4687,7 @@ void LLPipeline::renderDebug() mReflectionMapManager.renderDebug(); } - if (gSavedSettings.getBOOL("RenderReflectionProbeVolumes")) + if (gSavedSettings.getBOOL("RenderReflectionProbeVolumes") && !hud_only) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display"); @@ -4740,7 +4740,7 @@ void LLPipeline::renderDebug() } } - if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !hud_only) { LLVertexBuffer::unbind(); @@ -9892,7 +9892,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } } - //hack to disable projector shadows bool gen_shadow = RenderShadowDetail > 1; -- cgit v1.2.3 From 131d116ffd21ef1e726e21c8fe2e6b7068c6c3d9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Feb 2023 15:40:20 -0600 Subject: SL-19239 Day after three day quality pass - add ACES tone mapping to address "haziness" (and also fix banding in emissive materials) --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e814b77725..69b149f82d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -354,7 +354,7 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) bool valid = true && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM && target.addColorAttachment(GL_RGBA16F) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && target.addColorAttachment(GL_RGBA); // frag_data[3] PBR emissive + && target.addColorAttachment(GL_RGB16); // frag_data[3] PBR emissive return valid; } -- cgit v1.2.3 From 19f7497d9a01731cbd82be4b522d8b879cdcb8a0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Feb 2023 20:42:25 -0600 Subject: DRTVWR-559 WIP -- occlusion culling for reflection probes -- has a defect for objects close to the camera at some angles and leaks query objects, will follow up. --- indra/newview/pipeline.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 69b149f82d..d0688d26a9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -432,6 +432,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); getPool(LLDrawPool::POOL_GLTF_PBR); + getPool(LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK); resetFrameStats(); @@ -1545,6 +1546,9 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) case LLDrawPool::POOL_GLTF_PBR: poolp = mPBROpaquePool; break; + case LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK: + poolp = mPBRAlphaMaskPool; + break; default: llassert(0); @@ -2432,6 +2436,26 @@ void LLPipeline::doOcclusion(LLCamera& camera) LL_PROFILE_GPU_ZONE("doOcclusion"); llassert(!gCubeSnapshot); + if (sReflectionProbesEnabled && sUseOcclusion > 1 && !LLPipeline::sShadowRender && !gCubeSnapshot) + { + gGL.setColorMask(false, false); + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + LLGLDisable cull(GL_CULL_FACE); + + gOcclusionCubeProgram.bind(); + + if (mCubeVB.isNull()) + { //cube VB will be used for issuing occlusion queries + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); + } + mCubeVB->setBuffer(); + + mReflectionMapManager.doOcclusion(); + gOcclusionCubeProgram.unbind(); + + gGL.setColorMask(true, true); + } + if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { @@ -5192,6 +5216,19 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; + case LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK: + if (mPBRAlphaMaskPool) + { + llassert(0); + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate PBR Alpha Mask Pool" << LL_ENDL; + } + else + { + mPBRAlphaMaskPool = new_poolp; + } + break; + + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::addPool()" << LL_ENDL; @@ -5308,6 +5345,11 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mPBROpaquePool = NULL; break; + case LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK: + llassert(poolp == mPBRAlphaMaskPool); + mPBRAlphaMaskPool = NULL; + break; + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL; -- cgit v1.2.3 From 0336c1a06de89937d5c0f971e06270afc868ddfa Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Feb 2023 22:13:08 -0600 Subject: DRTVWR-559 Fix SSR on transparent PBR surfaces. --- indra/newview/pipeline.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d0688d26a9..a4578c0e98 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7821,18 +7821,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); } - channel = shader.enableTexture(LLShaderMgr::SCENE_MAP); - if (channel > -1) - { - gGL.getTexUnit(channel)->bind(&mSceneMap); - } - - channel = shader.enableTexture(LLShaderMgr::SCENE_DEPTH); - if (channel > -1) - { - gGL.getTexUnit(channel)->bind(&mSceneMap, true); - } - if (shader.getUniformLocation(LLShaderMgr::VIEWPORT) != -1) { shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0], @@ -8765,6 +8753,21 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) setEnvMat(shader); } + + // reflection probe shaders generally sample the scene map as well for SSR + channel = shader.enableTexture(LLShaderMgr::SCENE_MAP); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(&mSceneMap); + } + + channel = shader.enableTexture(LLShaderMgr::SCENE_DEPTH); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(&mSceneMap, true); + } + + } void LLPipeline::unbindReflectionProbes(LLGLSLShader& shader) -- cgit v1.2.3 From e5e94b5fa832c62dc0df239fdb4aefc23e559c0c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Feb 2023 11:47:24 -0600 Subject: DRTVWR-559 Fix for irradiance maps going black at 128x128 radiance map resolution. Improve radiance map anti-aliasing and default to 128x128 everywhere. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a4578c0e98..0ef89afe61 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -802,7 +802,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) gCubeSnapshot = TRUE; mReflectionMapManager.initReflectionMaps(); mRT = &mAuxillaryRT; - U32 res = mReflectionMapManager.mProbeResolution * 2; //multiply by 2 because probes will be super sampled + U32 res = mReflectionMapManager.mProbeResolution * 4; //multiply by 4 because probes will be 16x super sampled allocateScreenBuffer(res, res, samples); mRT = &mMainRT; gCubeSnapshot = FALSE; -- cgit v1.2.3 From 63ae47d8fd479a3cb05ff1d2364d683975e1b052 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Feb 2023 15:19:56 -0600 Subject: SL-19236 Fix for HUDs not rendering when transparent water is disabled. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0ef89afe61..8d9a2a876e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2286,7 +2286,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result) LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); LL_PROFILE_GPU_ZONE("updateCull"); // should always be zero GPU time, but drop a timer to flush stuff out - bool water_clip = !sRenderTransparentWater; + bool water_clip = !sRenderTransparentWater && !sRenderingHUDs; if (water_clip) { -- cgit v1.2.3 From 9606f2afbb3ca81d184c6b7decbbe4f3ae360272 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 24 Feb 2023 15:41:51 -0600 Subject: DRTVWR-559 Add controls for tonemapper to advanced preferences. --- indra/newview/pipeline.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8d9a2a876e..9522f804d6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7575,9 +7575,13 @@ void LLPipeline::renderFinalize() gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); + F32 e = llclamp(exposure(), 0.5f, 4.f); + + static LLStaticHashedString s_exposure("exposure"); + + gDeferredPostGammaCorrectProgram.uniform1f(s_exposure, e); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); -- cgit v1.2.3 From 4ec8844f012f27ddd0ab9aa6a3098273c7bb0ac1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Feb 2023 10:42:53 -0600 Subject: DRTVWR-559 Fix for occlusion culling going off the rails when settings change -- remove LLPipeline::resetVertexBuffers and add a sanity check to how long we wait for a query to be "available". --- indra/newview/pipeline.cpp | 84 ---------------------------------------------- 1 file changed, 84 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9522f804d6..b5b5d9ef7f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -681,8 +681,6 @@ void LLPipeline::destroyGL() resetDrawOrders(); - resetVertexBuffers(); - releaseGLBuffers(); if (mMeshDirtyQueryObject) @@ -6753,88 +6751,6 @@ void LLPipeline::resetVertexBuffers(LLDrawable* drawable) } } -void LLPipeline::resetVertexBuffers() -{ - mResetVertexBuffers = true; -} - -void LLPipeline::doResetVertexBuffers(bool forced) -{ - if (!mResetVertexBuffers) - { - return; - } - if(!forced && LLSpatialPartition::sTeleportRequested) - { - if(gAgent.getTeleportState() != LLAgent::TELEPORT_NONE) - { - return; //wait for teleporting to finish - } - else - { - //teleporting aborted - LLSpatialPartition::sTeleportRequested = FALSE; - mResetVertexBuffers = false; - return; - } - } - - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - mResetVertexBuffers = false; - - mCubeVB = NULL; - mDeferredVB = NULL; - - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) - { - LLViewerRegion* region = *iter; - for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) - { - LLSpatialPartition* part = region->getSpatialPartition(i); - if (part) - { - part->resetVertexBuffers(); - } - } - } - if(LLSpatialPartition::sTeleportRequested) - { - LLSpatialPartition::sTeleportRequested = FALSE; - - LLWorld::getInstance()->clearAllVisibleObjects(); - clearRebuildDrawables(); - } - - resetDrawOrders(); - - gSky.resetVertexBuffers(); - - LLVOPartGroup::destroyGL(); - - if ( LLPathingLib::getInstance() ) - { - LLPathingLib::getInstance()->cleanupVBOManager(); - } - LLVOPartGroup::destroyGL(); - gGL.resetVertexBuffer(); - - LLVertexBuffer::unbind(); - - updateRenderBump(); - - sBakeSunlight = gSavedSettings.getBOOL("RenderBakeSunlight"); - sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha"); - LLPipeline::sTextureBindTest = gSavedSettings.getBOOL("RenderDebugTextureBind"); - - gGL.initVertexBuffer(); - - mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK); - mDeferredVB->allocateBuffer(8, 0); - - LLVOPartGroup::restoreGL(); -} - void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); -- cgit v1.2.3 From bc7856098f70371dd392c74689df267cce819aa7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Mar 2023 16:36:03 -0600 Subject: SL-19281 Unify handling of haze and gamma between fullbright and not and move haze back to sRGB color space to stay consistent with sky colors. Also fix broken "roughness" stuck at 0.2. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b5b5d9ef7f..fffccc72ea 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8119,6 +8119,8 @@ void LLPipeline::renderDeferredLighting() soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + soften_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); + { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From b9b913a60ada97fc61bf2176e443dc72c8359ccb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Mar 2023 09:38:43 -0600 Subject: SL-19349 Fix for hang on bulk upload of materials, add bulk upload option to material selector, incidental decruft. --- indra/newview/pipeline.cpp | 50 ---------------------------------------------- 1 file changed, 50 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index fffccc72ea..deafa6900e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -335,18 +335,6 @@ static LLCullResult* sCull = NULL; void validate_framebuffer_object(); -// override the projection_matrix uniform on the given shader to that which would be set by the main camera -void set_camera_projection_matrix(LLGLSLShader& shader) -{ - auto camProj = LLViewerCamera::getInstance()->getProjection(); - glh::matrix4f projection = get_current_projection(); - projection.set_row(0, glh::vec4f(camProj.mMatrix[0][0], camProj.mMatrix[0][1], camProj.mMatrix[0][2], camProj.mMatrix[0][3])); - projection.set_row(0, glh::vec4f(camProj.mMatrix[1][0], camProj.mMatrix[1][1], camProj.mMatrix[1][2], camProj.mMatrix[1][3])); - projection.set_row(0, glh::vec4f(camProj.mMatrix[2][0], camProj.mMatrix[2][1], camProj.mMatrix[2][2], camProj.mMatrix[2][3])); - projection.set_row(0, glh::vec4f(camProj.mMatrix[3][0], camProj.mMatrix[3][1], camProj.mMatrix[3][2], camProj.mMatrix[3][3])); - shader.uniformMatrix4fv(LLShaderMgr::PROJECTION_MATRIX, 1, FALSE, projection.m); -} - // Add color attachments for deferred rendering // target -- RenderTarget to add attachments to bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) @@ -4716,9 +4704,6 @@ void LLPipeline::renderDebug() bindDeferredShader(gReflectionProbeDisplayProgram, NULL); mScreenTriangleVB->setBuffer(); - // Provide our projection matrix. - set_camera_projection_matrix(gReflectionProbeDisplayProgram); - LLGLEnable blend(GL_BLEND); LLGLDepthTest depth(GL_FALSE); @@ -7410,40 +7395,6 @@ void LLPipeline::renderFinalize() if (RenderScreenSpaceReflections && !gCubeSnapshot) { -#if 0 - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections"); - LL_PROFILE_GPU_ZONE("screen space reflections"); - - bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); - mScreenTriangleVB->setBuffer(); - - set_camera_projection_matrix(gPostScreenSpaceReflectionProgram); - - // We need linear depth. - static LLStaticHashedString zfar("zFar"); - static LLStaticHashedString znear("zNear"); - float nearClip = LLViewerCamera::getInstance()->getNear(); - float farClip = LLViewerCamera::getInstance()->getFar(); - gPostScreenSpaceReflectionProgram.uniform1f(zfar, farClip); - gPostScreenSpaceReflectionProgram.uniform1f(znear, nearClip); - - S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, screenTarget()->getUsage()); - if (channel > -1) - { - screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - - stop_glerror(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } - - unbindDeferredShader(gPostScreenSpaceReflectionProgram); -#else LL_PROFILE_GPU_ZONE("ssr copy"); LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); @@ -7465,7 +7416,6 @@ void LLPipeline::renderFinalize() mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); dst.flush(); -#endif } screenTarget()->bindTarget(); -- cgit v1.2.3 From 25ede8638209fac8dde5b71bece4bc1dfa30ea16 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Mar 2023 10:52:35 -0600 Subject: SL-19172 Texture streaming tune up. Incidental decruft. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index deafa6900e..b053af3f96 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4319,6 +4319,8 @@ extern std::set visible_selected_groups; void LLPipeline::renderDebug() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + assertInitialized(); bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD); -- cgit v1.2.3 From bd4b03de8b73ecb888f8e3111bada7c643f7fcfd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Mar 2023 13:33:36 -0600 Subject: DRTVWR-559 Fix for assert in LLVertexBuffer, incidental decruft. --- indra/newview/pipeline.cpp | 172 ++++++++++++++++++++------------------------- 1 file changed, 77 insertions(+), 95 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b053af3f96..ffb314c013 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -308,7 +308,6 @@ bool LLPipeline::sDelayVBUpdate = true; bool LLPipeline::sAutoMaskAlphaDeferred = true; bool LLPipeline::sAutoMaskAlphaNonDeferred = false; bool LLPipeline::sRenderTransparentWater = true; -bool LLPipeline::sRenderBump = true; bool LLPipeline::sBakeSunlight = false; bool LLPipeline::sNoAlpha = false; bool LLPipeline::sUseFarClip = true; @@ -400,7 +399,6 @@ void LLPipeline::init() gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); - sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); @@ -968,12 +966,6 @@ void LLPipeline::updateRenderTransparentWater() sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); } -//static -void LLPipeline::updateRenderBump() -{ - sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); -} - // static void LLPipeline::refreshCachedSettings() { @@ -1183,46 +1175,44 @@ void LLPipeline::createGLBuffers() mRT->width = 0; mRT->height = 0; - if (sRenderDeferred) - { - if (!mNoiseMap) - { - const U32 noiseRes = 128; - LLVector3 noise[noiseRes*noiseRes]; + + if (!mNoiseMap) + { + const U32 noiseRes = 128; + LLVector3 noise[noiseRes*noiseRes]; - F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f; - for (U32 i = 0; i < noiseRes*noiseRes; ++i) - { - noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f); - noise[i].normVec(); - noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f; - } + F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f; + for (U32 i = 0; i < noiseRes*noiseRes; ++i) + { + noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f); + noise[i].normVec(); + noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f; + } - LLImageGL::generateTextures(1, &mNoiseMap); + LLImageGL::generateTextures(1, &mNoiseMap); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } - if (!mTrueNoiseMap) + if (!mTrueNoiseMap) + { + const U32 noiseRes = 128; + F32 noise[noiseRes*noiseRes*3]; + for (U32 i = 0; i < noiseRes*noiseRes*3; i++) { - const U32 noiseRes = 128; - F32 noise[noiseRes*noiseRes*3]; - for (U32 i = 0; i < noiseRes*noiseRes*3; i++) - { - noise[i] = ll_frand()*2.0-1.0; - } - - LLImageGL::generateTextures(1, &mTrueNoiseMap); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + noise[i] = ll_frand()*2.0-1.0; } - createLUTBuffers(); + LLImageGL::generateTextures(1, &mTrueNoiseMap); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } + createLUTBuffers(); + gBumpImageList.restoreGL(); } @@ -1233,70 +1223,67 @@ F32 lerpf(F32 a, F32 b, F32 w) void LLPipeline::createLUTBuffers() { - if (sRenderDeferred) + if (!mLightFunc) { - if (!mLightFunc) + U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); + U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); + F32* ls = new F32[lightResX*lightResY]; + F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); + // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) + for (U32 y = 0; y < lightResY; ++y) { - U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); - U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); - F32* ls = new F32[lightResX*lightResY]; - F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); - // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) - for (U32 y = 0; y < lightResY; ++y) + for (U32 x = 0; x < lightResX; ++x) { - for (U32 x = 0; x < lightResX; ++x) - { - ls[y*lightResX+x] = 0; - F32 sa = (F32) x/(lightResX-1); - F32 spec = (F32) y/(lightResY-1); - F32 n = spec * spec * specExp; + ls[y*lightResX+x] = 0; + F32 sa = (F32) x/(lightResX-1); + F32 spec = (F32) y/(lightResY-1); + F32 n = spec * spec * specExp; - // Nothing special here. Just your typical blinn-phong term. - spec = powf(sa, n); + // Nothing special here. Just your typical blinn-phong term. + spec = powf(sa, n); - // Apply our normalization function. - // Note: This is the full equation that applies the full normalization curve, not an approximation. - // This is fine, given we only need to create our LUT once per buffer initialization. - spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); - - // Since we use R16F, we no longer have a dynamic range issue we need to work around here. - // Though some older drivers may not like this, newer drivers shouldn't have this problem. - ls[y*lightResX+x] = spec; - } + // Apply our normalization function. + // Note: This is the full equation that applies the full normalization curve, not an approximation. + // This is fine, given we only need to create our LUT once per buffer initialization. + spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); + + // Since we use R16F, we no longer have a dynamic range issue we need to work around here. + // Though some older drivers may not like this, newer drivers shouldn't have this problem. + ls[y*lightResX+x] = spec; } + } - U32 pix_format = GL_R16F; + U32 pix_format = GL_R16F; #if LL_DARWIN - // Need to work around limited precision with 10.6.8 and older drivers - // - pix_format = GL_R32F; + // Need to work around limited precision with 10.6.8 and older drivers + // + pix_format = GL_R32F; #endif - LLImageGL::generateTextures(1, &mLightFunc); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + LLImageGL::generateTextures(1, &mLightFunc); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - delete [] ls; - } + delete [] ls; + } - mPbrBrdfLut.allocate(512, 512, GL_RG16F); - mPbrBrdfLut.bindTarget(); - gDeferredGenBrdfLutProgram.bind(); + mPbrBrdfLut.allocate(512, 512, GL_RG16F); + mPbrBrdfLut.bindTarget(); + gDeferredGenBrdfLutProgram.bind(); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 1); - gGL.vertex2f(1, -1); - gGL.vertex2f(1, 1); - gGL.end(); - gGL.flush(); + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex2f(-1, -1); + gGL.vertex2f(-1, 1); + gGL.vertex2f(1, -1); + gGL.vertex2f(1, 1); + gGL.end(); + gGL.flush(); - gDeferredGenBrdfLutProgram.unbind(); - mPbrBrdfLut.flush(); - } + gDeferredGenBrdfLutProgram.unbind(); + mPbrBrdfLut.flush(); } @@ -1331,11 +1318,6 @@ bool LLPipeline::canUseWindLightShaders() const return true; } -bool LLPipeline::canUseWindLightShadersOnObjects() const -{ - return true; -} - bool LLPipeline::canUseAntiAliasing() const { return true; -- cgit v1.2.3 From f3ce17701e8dbbbc7a0e8e73c740b161bb2f36c0 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 13 Mar 2023 08:05:33 -0700 Subject: Make sure the glow combine only happens in the gamma correct shader. --- indra/newview/pipeline.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b5b5d9ef7f..466a5d2995 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7489,6 +7489,12 @@ void LLPipeline::renderFinalize() screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7516,8 +7522,8 @@ void LLPipeline::renderFinalize() bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); LLGLSLShader* shader = &gGlowCombineProgram; - S32 width = mRT->screen.getWidth(); - S32 height = mRT->screen.getHeight(); + S32 width = screenTarget()->getWidth(); + S32 height = screenTarget()->getHeight(); S32 channel = -1; @@ -7535,10 +7541,10 @@ void LLPipeline::renderFinalize() shader->bind(); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); + channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); if (channel > -1) { - mRT->deferredLight.bindTexture(0, channel); + screenTarget()->bindTexture(0, channel); } { @@ -7549,7 +7555,7 @@ void LLPipeline::renderFinalize() gGL.flush(); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); shader->unbind(); mRT->fxaaBuffer.flush(); @@ -7601,11 +7607,9 @@ void LLPipeline::renderFinalize() shader->bind(); - S32 glow_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_EMISSIVE); S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.getTexUnit(glow_channel)->bind(&mGlow[1]); gGL.getTexUnit(screen_channel)->bind(screenTarget()); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); @@ -7622,7 +7626,6 @@ void LLPipeline::renderFinalize() shader->unbind(); } } - gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -7779,12 +7782,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); - if (channel > -1) - { - mGlow[1].bindTexture(0, channel); - } - stop_glerror(); bindShadowMaps(shader); -- cgit v1.2.3 From 8d263197f0649e3b49044d6f7c12277c2361bdba Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 13 Mar 2023 11:16:23 -0500 Subject: SL-19371 Fix for occlusion culling getting stuck after teleport. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e6ad42c23b..18b0192346 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2424,7 +2424,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) gGL.setColorMask(true, true); } - if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && + if (LLPipeline::sUseOcclusion > 1 && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { LLVertexBuffer::unbind(); -- cgit v1.2.3 From df9d2b6e9613d15d39e3e870fc09686e41b6c37f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 24 Mar 2023 10:31:32 -0500 Subject: SL-19321 Optimization pass -- reduce occlusion culling frame stalls, reduce shadow draw distance in probes. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 18b0192346..f059c87c91 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9419,7 +9419,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < 4; j++) + for (S32 j = 0; j < (gCubeSnapshot ? 3 : 4); j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { -- cgit v1.2.3 From 5882215a6d53f5a20779be78805392f4e38c3669 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 24 Mar 2023 14:33:41 -0500 Subject: SL-19321 Optimization pass -- Remove another shadow split from probe render, incidental decruft. --- indra/newview/pipeline.cpp | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f059c87c91..a53b3aac8e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -202,9 +202,6 @@ LLVector3 LLPipeline::RenderShadowGaussian; F32 LLPipeline::RenderShadowBlurDistFactor; bool LLPipeline::RenderDeferredAtmospheric; F32 LLPipeline::RenderHighlightFadeTime; -LLVector3 LLPipeline::RenderShadowClipPlanes; -LLVector3 LLPipeline::RenderShadowOrthoClipPlanes; -LLVector3 LLPipeline::RenderShadowNearDist; F32 LLPipeline::RenderFarClip; LLVector3 LLPipeline::RenderShadowSplitExponent; F32 LLPipeline::RenderShadowErrorCutoff; @@ -558,9 +555,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor"); connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric"); connectRefreshCachedSettingsSafe("RenderHighlightFadeTime"); - connectRefreshCachedSettingsSafe("RenderShadowClipPlanes"); - connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes"); - connectRefreshCachedSettingsSafe("RenderShadowNearDist"); connectRefreshCachedSettingsSafe("RenderFarClip"); connectRefreshCachedSettingsSafe("RenderShadowSplitExponent"); connectRefreshCachedSettingsSafe("RenderShadowErrorCutoff"); @@ -1043,9 +1037,6 @@ void LLPipeline::refreshCachedSettings() RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric"); RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime"); - RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes"); - RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); - RenderShadowNearDist = gSavedSettings.getVector3("RenderShadowNearDist"); RenderFarClip = gSavedSettings.getF32("RenderFarClip"); RenderShadowSplitExponent = gSavedSettings.getVector3("RenderShadowSplitExponent"); RenderShadowErrorCutoff = gSavedSettings.getF32("RenderShadowErrorCutoff"); @@ -9277,27 +9268,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) glh::matrix4f view[6]; glh::matrix4f proj[6]; - //clip contains parallel split distances for 3 splits - LLVector3 clip = RenderShadowClipPlanes; - LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir); - //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold"); - - //far clip on last split is minimum of camera view distance and 128 - mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); - - clip = RenderShadowOrthoClipPlanes; - mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); - - //currently used for amount to extrude frusta corners for constructing shadow frusta - //LLVector3 n = RenderShadowNearDist; - //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; - //put together a universal "near clip" plane for shadow frusta LLPlane shadow_near_clip; { - LLVector3 p = gAgent.getPositionAgent(); + LLVector3 p = camera.getOrigin(); // gAgent.getPositionAgent(); p += caster_dir * RenderFarClip*2.f; shadow_near_clip.setVec(p, caster_dir); } @@ -9318,9 +9294,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) up = camera.getUpAxis(); } - /*LLVector3 left = up%at; - up = at%left;*/ - up.normVec(); at.normVec(); @@ -9403,6 +9376,14 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding } + if (gCubeSnapshot) + { // stretch clip planes for reflection probe renders to reduce number of shadow passes + mSunClipPlanes.mV[1] = mSunClipPlanes.mV[2]; + mSunClipPlanes.mV[2] = mSunClipPlanes.mV[3]; + mSunClipPlanes.mV[3] *= 1.5f; + } + + // convenience array of 4 near clip plane distances F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; @@ -9419,7 +9400,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < (gCubeSnapshot ? 3 : 4); j++) + for (S32 j = 0; j < (gCubeSnapshot ? 2 : 4); j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { -- cgit v1.2.3 From 366bae14963151905cae7a08c4c77d422223b9e1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Mar 2023 18:22:53 -0500 Subject: DRTVWR-559 Fix for off-white metal not looking chromed when it should (fake hacky HDR sky reflections). --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a53b3aac8e..7a5443825d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -338,7 +338,7 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) bool valid = true && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM && target.addColorAttachment(GL_RGBA16F) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && target.addColorAttachment(GL_RGB16); // frag_data[3] PBR emissive + && target.addColorAttachment(GL_RGB16F); // frag_data[3] PBR emissive return valid; } -- cgit v1.2.3 From 10f66c05190585e9de2e85831712323c297d81c4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Mar 2023 14:30:59 -0500 Subject: DRTVWR-559 Dynamically adjust exposure. --- indra/newview/pipeline.cpp | 58 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7a5443825d..7b72d7f987 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -849,6 +849,13 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mSceneMap.allocate(resX, resY, GL_RGB, true); } + mPostMap.allocate(resX, resY, GL_RGBA); + + mExposureMap.allocate(1, 1, GL_R16F); + mExposureMap.bindTarget(); + mExposureMap.clear(); + mExposureMap.flush(); + //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1079,6 +1086,10 @@ void LLPipeline::releaseGLBuffers() mSceneMap.release(); + mExposureMap.release(); + + mPostMap.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -7393,7 +7404,36 @@ void LLPipeline::renderFinalize() dst.flush(); } - screenTarget()->bindTarget(); + // exposure sample + { + LL_PROFILE_GPU_ZONE("exposure sample"); + mExposureMap.bindTarget(); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gExposureProgram.bind(); + + S32 channel = 0; + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + if (channel > -1) + { + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + static LLStaticHashedString dt("dt"); + gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); + gExposureProgram.unbind(); + mExposureMap.flush(); + } + + mPostMap.bindTarget(); // gamma correct lighting { @@ -7420,6 +7460,12 @@ void LLPipeline::renderFinalize() mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP, mExposureMap.getUsage()); + if (channel > -1) + { + mExposureMap.bindTexture(0, channel); + } + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7437,7 +7483,7 @@ void LLPipeline::renderFinalize() gDeferredPostGammaCorrectProgram.unbind(); } - screenTarget()->flush(); + mPostMap.flush(); LLVertexBuffer::unbind(); } @@ -7466,10 +7512,10 @@ void LLPipeline::renderFinalize() shader->bind(); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); if (channel > -1) { - screenTarget()->bindTexture(0, channel); + mPostMap.bindTexture(0, channel); } { @@ -7480,7 +7526,7 @@ void LLPipeline::renderFinalize() gGL.flush(); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); shader->unbind(); mRT->fxaaBuffer.flush(); @@ -7535,7 +7581,7 @@ void LLPipeline::renderFinalize() S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.getTexUnit(screen_channel)->bind(screenTarget()); + gGL.getTexUnit(screen_channel)->bind(&mPostMap); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; -- cgit v1.2.3 From 81c440a4a962a314d85cee854365e6593b72e87c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Mar 2023 15:51:29 -0500 Subject: DRTVWR-559 Dynamic exposure followup -- balance moon brightness and add glow to exposure sample. --- indra/newview/pipeline.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7b72d7f987..da8c46de83 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7422,6 +7422,12 @@ void LLPipeline::renderFinalize() screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + static LLStaticHashedString dt("dt"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); -- cgit v1.2.3 From b130831106d058f0be5414a9a3bcaa99636c7bc0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 Mar 2023 13:24:07 -0500 Subject: DRTVWR-559 Dynamic exposure followup -- stochastic sampling, weight based on luminance and distance to center of screen, rebalance night, don't rely on blending not clamping R16F. --- indra/newview/pipeline.cpp | 83 ++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 40 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index da8c46de83..eaec698f84 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -116,27 +116,7 @@ #include "llenvironment.h" #include "llsettingsvo.h" -#ifdef _DEBUG -// Debug indices is disabled for now for debug performance - djs 4/24/02 -//#define DEBUG_INDICES -#else -//#define DEBUG_INDICES -#endif - -// Expensive and currently broken -// -#define MATERIALS_IN_REFLECTIONS 0 - -// NOTE: Keep in sync with indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml -// NOTE: Unused consts are commented out since some compilers (on macOS) may complain about unused variables. -// const S32 WATER_REFLECT_NONE_WATER_OPAQUE = -2; - //const S32 WATER_REFLECT_NONE_WATER_TRANSPARENT = -1; - //const S32 WATER_REFLECT_MINIMAL = 0; -// const S32 WATER_REFLECT_TERRAIN = 1; - //const S32 WATER_REFLECT_STATIC_OBJECTS = 2; - //const S32 WATER_REFLECT_AVATARS = 3; - //const S32 WATER_REFLECT_EVERYTHING = 4; - +extern BOOL gSnapshot; bool gShiftFrame = false; //cached settings @@ -851,11 +831,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mPostMap.allocate(resX, resY, GL_RGBA); - mExposureMap.allocate(1, 1, GL_R16F); - mExposureMap.bindTarget(); - mExposureMap.clear(); - mExposureMap.flush(); - //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1086,8 +1061,6 @@ void LLPipeline::releaseGLBuffers() mSceneMap.release(); - mExposureMap.release(); - mPostMap.release(); for (U32 i = 0; i < 3; i++) @@ -1110,6 +1083,10 @@ void LLPipeline::releaseLUTBuffers() } mPbrBrdfLut.release(); + + mExposureMap.release(); + mLastExposure.release(); + } void LLPipeline::releaseShadowBuffers() @@ -1286,6 +1263,13 @@ void LLPipeline::createLUTBuffers() gDeferredGenBrdfLutProgram.unbind(); mPbrBrdfLut.flush(); + + mExposureMap.allocate(1, 1, GL_R16F); + mExposureMap.bindTarget(); + mExposureMap.clear(); + mExposureMap.flush(); + + mLastExposure.allocate(1, 1, GL_R16F); } @@ -7407,30 +7391,50 @@ void LLPipeline::renderFinalize() // exposure sample { LL_PROFILE_GPU_ZONE("exposure sample"); + + { + // copy last frame's exposure into mLastExposure + mLastExposure.bindTarget(); + gCopyProgram.bind(); + gGL.getTexUnit(0)->bind(&mExposureMap); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + mLastExposure.flush(); + } + + mExposureMap.bindTarget(); LLGLDepthTest depth(GL_FALSE, GL_FALSE); - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - + gExposureProgram.bind(); S32 channel = 0; - channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); if (channel > -1) { screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); if (channel > -1) { - mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mGlow[1].bindTexture(0, channel); + } + + channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); + if (channel > -1) + { + mLastExposure.bindTexture(0, channel); } static LLStaticHashedString dt("dt"); + static LLStaticHashedString noiseVec("noiseVec"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); - + gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); + mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7562,9 +7566,8 @@ void LLPipeline::renderFinalize() 2.f / width * scale_x, 2.f / height * scale_y); { - // at this point we should pointed at the backbuffer - llassert(LLRenderTarget::sCurFBO == 0); - + // at this point we should pointed at the backbuffer (or a snapshot render target) + llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); @@ -7577,8 +7580,8 @@ void LLPipeline::renderFinalize() } else { - // at this point we should pointed at the backbuffer - llassert(LLRenderTarget::sCurFBO == 0); + // at this point we should pointed at the backbuffer (or a snapshot render target) + llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); -- cgit v1.2.3 From b44ad50f75724a5d9e53bd52d2724111568caf24 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 31 Mar 2023 10:54:19 -0700 Subject: Move glow extract to be after tonemapping. SL-19513 --- indra/newview/pipeline.cpp | 251 +++++++++++++++++++-------------------------- 1 file changed, 106 insertions(+), 145 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index eaec698f84..8ea1b19f34 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -148,7 +148,6 @@ LLColor4 LLPipeline::PreviewSpecular2; LLVector3 LLPipeline::PreviewDirection0; LLVector3 LLPipeline::PreviewDirection1; LLVector3 LLPipeline::PreviewDirection2; -F32 LLPipeline::RenderGlowMinLuminance; F32 LLPipeline::RenderGlowMaxExtractAlpha; F32 LLPipeline::RenderGlowWarmthAmount; LLVector3 LLPipeline::RenderGlowLumWeights; @@ -502,7 +501,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("PreviewDirection0"); connectRefreshCachedSettingsSafe("PreviewDirection1"); connectRefreshCachedSettingsSafe("PreviewDirection2"); - connectRefreshCachedSettingsSafe("RenderGlowMinLuminance"); connectRefreshCachedSettingsSafe("RenderGlowMaxExtractAlpha"); connectRefreshCachedSettingsSafe("RenderGlowWarmthAmount"); connectRefreshCachedSettingsSafe("RenderGlowLumWeights"); @@ -986,7 +984,6 @@ void LLPipeline::refreshCachedSettings() PreviewDirection0 = gSavedSettings.getVector3("PreviewDirection0"); PreviewDirection1 = gSavedSettings.getVector3("PreviewDirection1"); PreviewDirection2 = gSavedSettings.getVector3("PreviewDirection2"); - RenderGlowMinLuminance = gSavedSettings.getF32("RenderGlowMinLuminance"); RenderGlowMaxExtractAlpha = gSavedSettings.getF32("RenderGlowMaxExtractAlpha"); RenderGlowWarmthAmount = gSavedSettings.getF32("RenderGlowWarmthAmount"); RenderGlowLumWeights = gSavedSettings.getVector3("RenderGlowLumWeights"); @@ -6916,122 +6913,6 @@ void LLPipeline::renderPostProcess() gGL.setColorMask(true, true); glClearColor(0, 0, 0, 0); - if (sRenderGlow) - { - LL_PROFILE_GPU_ZONE("glow"); - mGlow[2].bindTarget(); - mGlow[2].clear(); - - gGlowExtractProgram.bind(); - F32 minLum = llmax((F32)RenderGlowMinLuminance, 0.0f); - F32 maxAlpha = RenderGlowMaxExtractAlpha; - F32 warmthAmount = RenderGlowWarmthAmount; - LLVector3 lumWeights = RenderGlowLumWeights; - LLVector3 warmthWeights = RenderGlowWarmthWeights; - - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, minLum); - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); - gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], - lumWeights.mV[2]); - gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], - warmthWeights.mV[2]); - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); - - { - LLGLEnable blend_on(GL_BLEND); - LLGLEnable test(GL_ALPHA_TEST); - - gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - - mRT->screen.bindTexture(0, 0, LLTexUnit::TFO_POINT); - - gGL.color4f(1, 1, 1, 1); - gPipeline.enableLightsFullbright(); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); - - gGL.end(); - - gGL.getTexUnit(0)->unbind(mRT->screen.getUsage()); - - mGlow[2].flush(); - - tc1.setVec(0, 0); - tc2.setVec(2, 2); - } - - // power of two between 1 and 1024 - U32 glowResPow = RenderGlowResolutionPow; - const U32 glow_res = llmax(1, llmin(1024, 1 << glowResPow)); - - S32 kernel = RenderGlowIterations * 2; - F32 delta = RenderGlowWidth / glow_res; - // Use half the glow width if we have the res set to less than 9 so that it looks - // almost the same in either case. - if (glowResPow < 9) - { - delta *= 0.5f; - } - F32 strength = RenderGlowStrength; - - gGlowProgram.bind(); - gGlowProgram.uniform1f(LLShaderMgr::GLOW_STRENGTH, strength); - - for (S32 i = 0; i < kernel; i++) - { - mGlow[i % 2].bindTarget(); - mGlow[i % 2].clear(); - - if (i == 0) - { - gGL.getTexUnit(0)->bind(&mGlow[2]); - } - else - { - gGL.getTexUnit(0)->bind(&mGlow[(i - 1) % 2]); - } - - if (i % 2 == 0) - { - gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, delta, 0); - } - else - { - gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta); - } - - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); - - gGL.end(); - - mGlow[i % 2].flush(); - } - - gGlowProgram.unbind(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - } - else // !sRenderGlow, skip the glow ping-pong and just clear the result target - { - mGlow[1].bindTarget(); - mGlow[1].clear(); - mGlow[1].flush(); - } - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); @@ -7341,9 +7222,6 @@ void LLPipeline::renderFinalize() assertInitialized(); - LLVector2 tc1(0, 0); - LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); - LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); LL_PROFILE_GPU_ZONE("renderFinalize"); @@ -7451,30 +7329,14 @@ void LLPipeline::renderFinalize() LLGLDepthTest depth(GL_FALSE, GL_FALSE); - LLVector2 tc1(0, 0); - LLVector2 tc2((F32)screenTarget()->getWidth() * 2, (F32)screenTarget()->getHeight() * 2); - // Apply gamma correction to the frame here. gDeferredPostGammaCorrectProgram.bind(); S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); - if (channel > -1) - { - screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); - if (channel > -1) - { - mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); - } + gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget(), false, LLTexUnit::TFO_POINT); - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP, mExposureMap.getUsage()); - if (channel > -1) - { - mExposureMap.bindTexture(0, channel); - } + gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); @@ -7498,6 +7360,101 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); } + if (sRenderGlow) + { + LL_PROFILE_GPU_ZONE("glow"); + mGlow[2].bindTarget(); + mGlow[2].clear(); + + gGlowExtractProgram.bind(); + F32 maxAlpha = RenderGlowMaxExtractAlpha; + F32 warmthAmount = RenderGlowWarmthAmount; + LLVector3 lumWeights = RenderGlowLumWeights; + LLVector3 warmthWeights = RenderGlowWarmthWeights; + + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, 9999); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], + lumWeights.mV[2]); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], + warmthWeights.mV[2]); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); + + { + LLGLEnable blend_on(GL_BLEND); + LLGLEnable test(GL_ALPHA_TEST); + + gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); + + gGlowExtractProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, &mPostMap); + + gGL.color4f(1, 1, 1, 1); + gPipeline.enableLightsFullbright(); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + mGlow[2].flush(); + } + + gGlowExtractProgram.unbind(); + + // power of two between 1 and 1024 + U32 glowResPow = RenderGlowResolutionPow; + const U32 glow_res = llmax(1, llmin(1024, 1 << glowResPow)); + + S32 kernel = RenderGlowIterations * 2; + F32 delta = RenderGlowWidth / glow_res; + // Use half the glow width if we have the res set to less than 9 so that it looks + // almost the same in either case. + if (glowResPow < 9) + { + delta *= 0.5f; + } + F32 strength = RenderGlowStrength; + + gGlowProgram.bind(); + gGlowProgram.uniform1f(LLShaderMgr::GLOW_STRENGTH, strength); + + for (S32 i = 0; i < kernel; i++) + { + mGlow[i % 2].bindTarget(); + mGlow[i % 2].clear(); + + if (i == 0) + { + gGlowProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, &mGlow[2]); + } + else + { + gGlowProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, &mGlow[(i - 1) % 2]); + } + + if (i % 2 == 0) + { + gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, delta, 0); + } + else + { + gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta); + } + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + mGlow[i % 2].flush(); + } + + gGlowProgram.unbind(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + } + else // !sRenderGlow, skip the glow ping-pong and just clear the result target + { + mGlow[1].bindTarget(); + mGlow[1].clear(); + mGlow[1].flush(); + } + { llassert(!gCubeSnapshot); bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); @@ -7528,6 +7485,12 @@ void LLPipeline::renderFinalize() mPostMap.bindTexture(0, channel); } + channel = shader->enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, mGlow[1].getUsage()); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + { LLGLDepthTest depth_test(GL_FALSE, GL_FALSE, GL_ALWAYS); mScreenTriangleVB->setBuffer(); @@ -7587,11 +7550,9 @@ void LLPipeline::renderFinalize() shader->bind(); - S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE); - S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - - gGL.getTexUnit(screen_channel)->bind(&mPostMap); - gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); + shader->bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mPostMap); + shader->bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + shader->bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; -- cgit v1.2.3 From 698966f8e7ddcc0b123a83d7c4e381778f8cd8ab Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 4 Apr 2023 12:29:12 -0500 Subject: =?UTF-8?q?SL-19538=20Remove=20hacky=20ambiance=20scale=20and=20ta?= =?UTF-8?q?ke=20the=20mittens=20off=20probe=20a=E2=80=A6=20(#151)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SL-19538 Remove hacky ambiance scale and take the mittens off probe ambiance values. Fix for sky brightening being done in sRGB space. --- indra/newview/pipeline.cpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dfe365b737..11deff5bff 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5637,15 +5637,6 @@ void LLPipeline::setupHWLights() // Ambient LLColor4 ambient = psky->getTotalAmbient(); - static LLCachedControl ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - - F32 light_scale = 1.f; - - if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) - { //darken local lights based on brightening of sky lighting - light_scale = 1.f / ambiance_scale; - } - gGL.setAmbientLightColor(ambient); bool sun_up = environment.getIsSunUp(); @@ -5739,7 +5730,7 @@ void LLPipeline::setupHWLights() } //send linear light color to shader - LLColor4 light_color = light->getLightLinearColor()*light_scale; + LLColor4 light_color = light->getLightLinearColor(); light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -7885,15 +7876,6 @@ void LLPipeline::renderDeferredLighting() llassert(!sRenderingHUDs); - static LLCachedControl ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - - F32 light_scale = 1.f; - - if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) - { //darken local lights based on brightening of sky lighting - light_scale = 1.f / ambiance_scale; - } - LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8129,7 +8111,7 @@ void LLPipeline::renderDeferredLighting() F32 s = volume->getLightRadius() * 1.5f; // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor()*light_scale; + LLColor3 col = volume->getLightLinearColor(); if (col.magVecSquared() < 0.001f) { @@ -8223,7 +8205,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor() * light_scale; + LLColor3 col = volume->getLightLinearColor(); gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8298,7 +8280,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor() * light_scale; + LLColor3 col = volume->getLightLinearColor(); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); -- cgit v1.2.3 From 1f79379bf215c5368337c64b4f72c7c9ef3e09c2 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 5 Apr 2023 11:55:51 -0500 Subject: SL-19538 Followup -- tune exposure parameters and clamp local light ambiance. Make render targets 16F and scrube NaNs (thanks Rye). Update midday. (#154) --- indra/newview/pipeline.cpp | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 11deff5bff..1222613c66 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -796,7 +796,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; - GLuint screenFormat = GL_RGBA16; + GLuint screenFormat = GL_RGBA16F; if (!mRT->screen.allocate(resX, resY, screenFormat)) return false; @@ -813,7 +813,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa - if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16)) return false; + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16F)) return false; } else { @@ -5631,6 +5631,14 @@ void LLPipeline::setupHWLights() return; } + F32 light_scale = 1.f; + + if (gCubeSnapshot) + { //darken local lights when probe ambiance is above 1 + light_scale = mReflectionMapManager.mLightScale; + } + + LLEnvironment& environment = LLEnvironment::instance(); LLSettingsSky::ptr_t psky = environment.getCurrentSky(); @@ -5730,7 +5738,7 @@ void LLPipeline::setupHWLights() } //send linear light color to shader - LLColor4 light_color = light->getLightLinearColor(); + LLColor4 light_color = light->getLightLinearColor() * light_scale; light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -7277,6 +7285,7 @@ void LLPipeline::renderFinalize() gExposureProgram.bind(); + S32 channel = 0; channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); if (channel > -1) @@ -7296,11 +7305,17 @@ void LLPipeline::renderFinalize() mLastExposure.bindTexture(0, channel); } + static LLCachedControl dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); + static LLCachedControl dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); + static LLCachedControl dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); + static LLStaticHashedString dt("dt"); static LLStaticHashedString noiseVec("noiseVec"); + static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); - + gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max); + mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7876,6 +7891,13 @@ void LLPipeline::renderDeferredLighting() llassert(!sRenderingHUDs); + F32 light_scale = 1.f; + + if (gCubeSnapshot) + { //darken local lights when probe ambiance is above 1 + light_scale = mReflectionMapManager.mLightScale; + } + LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8032,9 +8054,13 @@ void LLPipeline::renderDeferredLighting() LL_PROFILE_GPU_ZONE("atmospherics"); bindDeferredShader(soften_shader); + static LLCachedControl sky_scale(gSavedSettings, "RenderSkyHDRScale", 1.f); + static LLStaticHashedString sky_hdr_scale("sky_hdr_scale"); + LLEnvironment &environment = LLEnvironment::instance(); soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + soften_shader.uniform1f(sky_hdr_scale, sky_scale); soften_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); @@ -8111,7 +8137,7 @@ void LLPipeline::renderDeferredLighting() F32 s = volume->getLightRadius() * 1.5f; // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; if (col.magVecSquared() < 0.001f) { @@ -8205,7 +8231,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8280,7 +8306,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); -- cgit v1.2.3 From 5bf60f5d9e722f6210572fd92e79e9994abd2ec1 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 5 Apr 2023 16:48:34 -0500 Subject: =?UTF-8?q?SL-19538=20Followup=20--=20fix=20for=20dynamic=20exposu?= =?UTF-8?q?re=20having=20large=20gaps=20in=20it=E2=80=A6=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SL-19538 Followup -- fix for dynamic exposure having large gaps in its luminance sampling. * SL-19538 Followup -- review feedback changes. --- indra/newview/pipeline.cpp | 53 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1222613c66..4ab6483c88 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1082,6 +1082,7 @@ void LLPipeline::releaseLUTBuffers() mPbrBrdfLut.release(); mExposureMap.release(); + mLuminanceMap.release(); mLastExposure.release(); } @@ -1266,6 +1267,8 @@ void LLPipeline::createLUTBuffers() mExposureMap.clear(); mExposureMap.flush(); + mLuminanceMap.allocate(256, 256, GL_R16F); + mLastExposure.allocate(1, 1, GL_R16F); } @@ -7262,6 +7265,43 @@ void LLPipeline::renderFinalize() dst.flush(); } + // luminance sample and mipmap generation + { + LL_PROFILE_GPU_ZONE("luminance sample"); + + mLuminanceMap.bindTarget(); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + gLuminanceProgram.bind(); + + + S32 channel = 0; + channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); + if (channel > -1) + { + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel); + } + + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mLuminanceMap.flush(); + + mLuminanceMap.bindTexture(0, 0, LLTexUnit::TFO_TRILINEAR); + glGenerateMipmap(GL_TEXTURE_2D); + + // note -- unbind AFTER the glGenerateMipMap so time in generatemipmap can be profiled under "Luminance" + // also note -- keep an eye on the performance of glGenerateMipmap, might need to replace it with a mip generation shader + gLuminanceProgram.unbind(); + } + // exposure sample { LL_PROFILE_GPU_ZONE("exposure sample"); @@ -7278,25 +7318,16 @@ void LLPipeline::renderFinalize() mLastExposure.flush(); } - mExposureMap.bindTarget(); LLGLDepthTest depth(GL_FALSE, GL_FALSE); gExposureProgram.bind(); - - S32 channel = 0; - channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); - if (channel > -1) - { - screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - - channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); + S32 channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); if (channel > -1) { - mGlow[1].bindTexture(0, channel); + mLuminanceMap.bindTexture(0, channel, LLTexUnit::TFO_TRILINEAR); } channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); -- cgit v1.2.3 From bb79718c8f0050569c80a1bfe4dd428321706d1a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 6 Apr 2023 13:21:25 -0500 Subject: SL-19538 Followup -- scrub all possible sources of NaNs, make dynamic exposure controls not persist, limit exposure range, and do a debug gl pass. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4ab6483c88..e4ffa5b6b0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3928,7 +3928,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) } } - bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; + bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion && !LLGLSLShader::sProfileEnabled; setupHWLights(); -- cgit v1.2.3 From 82ba39d2ff6eb0067bcb384246541eb54e206cd9 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sat, 8 Apr 2023 19:30:58 -0700 Subject: Start moving our post process into methods. Lets make post processing make sense again. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 989 ++++++++++++++++++++++----------------------- 1 file changed, 484 insertions(+), 505 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e4ffa5b6b0..a1183ccb0f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6924,514 +6924,219 @@ void LLPipeline::renderPostProcess() LLVertexBuffer::unbind(); - { - bool dof_enabled = - (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField && - !gCubeSnapshot; + +} - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; +LLRenderTarget* LLPipeline::screenTarget() { - gViewerWindow->setup3DViewport(); + bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && + (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && + RenderDepthOfField && + !gCubeSnapshot; - if (dof_enabled) - { - LL_PROFILE_GPU_ZONE("dof"); - LLGLSLShader* shader = &gDeferredPostProgram; - LLGLDisable blend(GL_BLEND); + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; - // depth of field focal plane calculations - static F32 current_distance = 16.f; - static F32 start_distance = 16.f; - static F32 transition_time = 1.f; + if (multisample || dof_enabled) + return &mRT->deferredLight; + + return &mRT->screen; +} - LLVector3 focus_point; +void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst) { + // luminance sample and mipmap generation + { + LL_PROFILE_GPU_ZONE("luminance sample"); - LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); - if (obj && obj->mDrawable && obj->isSelected()) - { // focus on selected media object - S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); - if (obj && obj->mDrawable) - { - LLFace* face = obj->mDrawable->getFace(face_idx); - if (face) - { - focus_point = face->getPositionAgent(); - } - } - } + dst->bindTarget(); - if (focus_point.isExactlyZero()) - { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { // focus on point under cursor - focus_point.set(gDebugRaycastIntersection.getF32ptr()); - } - else if (gAgentCamera.cameraMouselook()) - { // focus on point under mouselook crosshairs - LLVector4a result; - result.clear(); + LLGLDepthTest depth(GL_FALSE, GL_FALSE); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); + gLuminanceProgram.bind(); - focus_point.set(result.getF32ptr()); - } - else - { - // focus on alt-zoom target - LLViewerRegion* region = gAgent.getRegion(); - if (region) - { - focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); - } - } - } - LLVector3 eye = LLViewerCamera::getInstance()->getOrigin(); - F32 target_distance = 16.f; - if (!focus_point.isExactlyZero()) - { - target_distance = LLViewerCamera::getInstance()->getAtAxis() * (focus_point - eye); - } + S32 channel = 0; + channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); + if (channel > -1) + { + src->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } - if (transition_time >= 1.f && fabsf(current_distance - target_distance) / current_distance > 0.01f) - { // large shift happened, interpolate smoothly to new target distance - transition_time = 0.f; - start_distance = current_distance; - } - else if (transition_time < 1.f) - { // currently in a transition, continue interpolating - transition_time += 1.f / CameraFocusTransitionTime * gFrameIntervalSeconds.value(); - transition_time = llmin(transition_time, 1.f); + channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel); + } - F32 t = cosf(transition_time * F_PI + F_PI) * 0.5f + 0.5f; - current_distance = start_distance + (target_distance - start_distance) * t; - } - else - { // small or no change, just snap to target distance - current_distance = target_distance; - } - // convert to mm - F32 subject_distance = current_distance * 1000.f; - F32 fnumber = CameraFNumber; - F32 default_focal_length = CameraFocalLength; + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + dst->flush(); - F32 fov = LLViewerCamera::getInstance()->getView(); + dst->bindTexture(0, 0, LLTexUnit::TFO_TRILINEAR); + glGenerateMipmap(GL_TEXTURE_2D); - const F32 default_fov = CameraFieldOfView * F_PI / 180.f; + // note -- unbind AFTER the glGenerateMipMap so time in generatemipmap can be profiled under "Luminance" + // also note -- keep an eye on the performance of glGenerateMipmap, might need to replace it with a mip generation shader + gLuminanceProgram.unbind(); + } +} - // F32 aspect_ratio = (F32) mRT->screen.getWidth()/(F32)mRT->screen.getHeight(); +void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst) { + // exposure sample + { + LL_PROFILE_GPU_ZONE("exposure sample"); - F32 dv = 2.f * default_focal_length * tanf(default_fov / 2.f); + { + // copy last frame's exposure into mLastExposure + mLastExposure.bindTarget(); + gCopyProgram.bind(); + gGL.getTexUnit(0)->bind(&mExposureMap); - F32 focal_length = dv / (2 * tanf(fov / 2.f)); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - // F32 tan_pixel_angle = tanf(LLDrawable::sCurPixelAngle); + mLastExposure.flush(); + } - // from wikipedia -- c = |s2-s1|/s2 * f^2/(N(S1-f)) - // where N = fnumber - // s2 = dot distance - // s1 = subject distance - // f = focal length - // + dst->bindTarget(); - F32 blur_constant = focal_length * focal_length / (fnumber * (subject_distance - focal_length)); - blur_constant /= 1000.f; // convert to meters for shader - F32 magnification = focal_length / (subject_distance - focal_length); + LLGLDepthTest depth(GL_FALSE, GL_FALSE); - { // build diffuse+bloom+CoF - mRT->deferredLight.bindTarget(); - shader = &gDeferredCoFProgram; + gExposureProgram.bind(); - bindDeferredShader(*shader); + S32 channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); + if (channel > -1) + { + src->bindTexture(0, channel, LLTexUnit::TFO_TRILINEAR); + } - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel); - } + channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); + if (channel > -1) + { + mLastExposure.bindTexture(0, channel); + } - shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); - shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); - shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); - shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + static LLCachedControl dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); + static LLCachedControl dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); + static LLCachedControl dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + static LLStaticHashedString dt("dt"); + static LLStaticHashedString noiseVec("noiseVec"); + static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); + gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); + gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); + gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); + gExposureProgram.unbind(); + dst->flush(); + } +} - gGL.end(); +void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { + dst->bindTarget(); + // gamma correct lighting + { + LL_PROFILE_GPU_ZONE("gamma correct"); - unbindDeferredShader(*shader); - mRT->deferredLight.flush(); - } + LLGLDepthTest depth(GL_FALSE, GL_FALSE); - U32 dof_width = (U32)(mRT->screen.getWidth() * CameraDoFResScale); - U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); - { // perform DoF sampling at half-res (preserve alpha channel) - mRT->screen.bindTarget(); - glViewport(0, 0, dof_width, dof_height); - gGL.setColorMask(true, false); + S32 channel = 0; - shader = &gDeferredPostProgram; - bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); - if (channel > -1) - { - mRT->deferredLight.bindTexture(0, channel); - } + gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, src->getWidth(), src->getHeight()); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + F32 e = llclamp(exposure(), 0.5f, 4.f); - gGL.end(); + static LLStaticHashedString s_exposure("exposure"); - unbindDeferredShader(*shader); - mRT->screen.flush(); - gGL.setColorMask(true, true); - } + gDeferredPostGammaCorrectProgram.uniform1f(s_exposure, e); - { // combine result based on alpha - if (multisample) - { - mRT->deferredLight.bindTarget(); - glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); - } - else - { - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - } + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - shader = &gDeferredDoFCombineProgram; - bindDeferredShader(*shader); + gGL.getTexUnit(channel)->unbind(src->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); + } + dst->flush(); +} - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel); - } +void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst) { - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth()); - shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight()); + if (RenderScreenSpaceReflections && !gCubeSnapshot) + { + LL_PROFILE_GPU_ZONE("ssr copy"); + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + LLRenderTarget& depth_src = mRT->deferredScreen; - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + dst->bindTarget(); + dst->clear(); + gCopyDepthProgram.bind(); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP); + S32 depth_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.end(); + gGL.getTexUnit(diff_map)->bind(src); + gGL.getTexUnit(depth_map)->bind(&depth_src, true); - unbindDeferredShader(*shader); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - if (multisample) - { - mRT->deferredLight.flush(); - } - } - } - else - { - LL_PROFILE_GPU_ZONE("no dof"); - if (multisample) - { - mRT->deferredLight.bindTarget(); - } - LLGLSLShader* shader = &gDeferredPostNoDoFProgram; + dst->flush(); + } +} - bindDeferredShader(*shader); +void LLPipeline::renderGlow(LLRenderTarget* src, LLRenderTarget* dst) { + if (sRenderGlow) + { + LL_PROFILE_GPU_ZONE("glow"); + mGlow[2].bindTarget(); + mGlow[2].clear(); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel); - } + gGlowExtractProgram.bind(); + F32 maxAlpha = RenderGlowMaxExtractAlpha; + F32 warmthAmount = RenderGlowWarmthAmount; + LLVector3 lumWeights = RenderGlowLumWeights; + LLVector3 warmthWeights = RenderGlowWarmthWeights; - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1, -1); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, 9999); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], + lumWeights.mV[2]); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], + warmthWeights.mV[2]); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1, 3); + { + LLGLEnable blend_on(GL_BLEND); + LLGLEnable test(GL_ALPHA_TEST); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3, -1); + gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - gGL.end(); + gGlowExtractProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, src); - unbindDeferredShader(*shader); + gGL.color4f(1, 1, 1, 1); + gPipeline.enableLightsFullbright(); - if (multisample) - { - mRT->deferredLight.flush(); - } + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + mGlow[2].flush(); } - } -} -LLRenderTarget* LLPipeline::screenTarget() { - - bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && - (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField && - !gCubeSnapshot; - - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; - - if (multisample || dof_enabled) - return &mRT->deferredLight; - - return &mRT->screen; -} - -void LLPipeline::renderFinalize() -{ - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - - assertInitialized(); - - LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); - LL_PROFILE_GPU_ZONE("renderFinalize"); - - gGL.color4f(1, 1, 1, 1); - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable cull(GL_CULL_FACE); - - enableLightsFullbright(); - - LLGLDisable test(GL_ALPHA_TEST); - - gGL.setColorMask(true, true); - glClearColor(0, 0, 0, 0); - - if (!gCubeSnapshot) - { - LLRenderTarget* screen_target = screenTarget(); - - if (RenderScreenSpaceReflections && !gCubeSnapshot) - { - LL_PROFILE_GPU_ZONE("ssr copy"); - LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - - LLRenderTarget& src = *screen_target; - LLRenderTarget& depth_src = mRT->deferredScreen; - LLRenderTarget& dst = mSceneMap; - - dst.bindTarget(); - dst.clear(); - gCopyDepthProgram.bind(); - - S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP); - S32 depth_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - - gGL.getTexUnit(diff_map)->bind(&src); - gGL.getTexUnit(depth_map)->bind(&depth_src, true); - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - dst.flush(); - } - - // luminance sample and mipmap generation - { - LL_PROFILE_GPU_ZONE("luminance sample"); - - mLuminanceMap.bindTarget(); - - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - gLuminanceProgram.bind(); - - - S32 channel = 0; - channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); - if (channel > -1) - { - screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - - channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); - if (channel > -1) - { - mGlow[1].bindTexture(0, channel); - } - - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - mLuminanceMap.flush(); - - mLuminanceMap.bindTexture(0, 0, LLTexUnit::TFO_TRILINEAR); - glGenerateMipmap(GL_TEXTURE_2D); - - // note -- unbind AFTER the glGenerateMipMap so time in generatemipmap can be profiled under "Luminance" - // also note -- keep an eye on the performance of glGenerateMipmap, might need to replace it with a mip generation shader - gLuminanceProgram.unbind(); - } - - // exposure sample - { - LL_PROFILE_GPU_ZONE("exposure sample"); - - { - // copy last frame's exposure into mLastExposure - mLastExposure.bindTarget(); - gCopyProgram.bind(); - gGL.getTexUnit(0)->bind(&mExposureMap); - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - mLastExposure.flush(); - } - - mExposureMap.bindTarget(); - - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - gExposureProgram.bind(); - - S32 channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); - if (channel > -1) - { - mLuminanceMap.bindTexture(0, channel, LLTexUnit::TFO_TRILINEAR); - } - - channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); - if (channel > -1) - { - mLastExposure.bindTexture(0, channel); - } - - static LLCachedControl dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); - static LLCachedControl dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); - static LLCachedControl dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); - - static LLStaticHashedString dt("dt"); - static LLStaticHashedString noiseVec("noiseVec"); - static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); - gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); - gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); - gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max); - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); - gExposureProgram.unbind(); - mExposureMap.flush(); - } - - mPostMap.bindTarget(); - - // gamma correct lighting - { - LL_PROFILE_GPU_ZONE("gamma correct"); - - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - - S32 channel = 0; - - gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget(), false, LLTexUnit::TFO_POINT); - - gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); - - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); - - static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); - - F32 e = llclamp(exposure(), 0.5f, 4.f); - - static LLStaticHashedString s_exposure("exposure"); - - gDeferredPostGammaCorrectProgram.uniform1f(s_exposure, e); - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - } - - mPostMap.flush(); - - LLVertexBuffer::unbind(); - } - - if (sRenderGlow) - { - LL_PROFILE_GPU_ZONE("glow"); - mGlow[2].bindTarget(); - mGlow[2].clear(); - - gGlowExtractProgram.bind(); - F32 maxAlpha = RenderGlowMaxExtractAlpha; - F32 warmthAmount = RenderGlowWarmthAmount; - LLVector3 lumWeights = RenderGlowLumWeights; - LLVector3 warmthWeights = RenderGlowWarmthWeights; - - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, 9999); - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); - gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], - lumWeights.mV[2]); - gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], - warmthWeights.mV[2]); - gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); - - { - LLGLEnable blend_on(GL_BLEND); - LLGLEnable test(GL_ALPHA_TEST); - - gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - - gGlowExtractProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, &mPostMap); - - gGL.color4f(1, 1, 1, 1); - gPipeline.enableLightsFullbright(); - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - mGlow[2].flush(); - } - - gGlowExtractProgram.unbind(); + gGlowExtractProgram.unbind(); // power of two between 1 and 1024 U32 glowResPow = RenderGlowResolutionPow; @@ -7480,7 +7185,7 @@ void LLPipeline::renderFinalize() } gGlowProgram.unbind(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); + } else // !sRenderGlow, skip the glow ping-pong and just clear the result target { @@ -7489,16 +7194,35 @@ void LLPipeline::renderFinalize() mGlow[1].flush(); } + // Go ahead and do our glow combine here in our destination. We blit this later into the front buffer. + + dst->bindTarget(); + + { + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + + gGlowCombineProgram.bind(); + + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + dst->flush(); +} + +void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { { - llassert(!gCubeSnapshot); + llassert(!gCubeSnapshot); bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); LLGLSLShader* shader = &gGlowCombineProgram; S32 width = screenTarget()->getWidth(); S32 height = screenTarget()->getHeight(); - S32 channel = -1; - // Present everything. if (multisample) { @@ -7506,38 +7230,27 @@ void LLPipeline::renderFinalize() // bake out texture2D with RGBL for FXAA shader mRT->fxaaBuffer.bindTarget(); - glViewport(0, 0, width, height); - - shader = &gGlowCombineFXAAProgram; - + shader = &gDeferredPostNoDoFProgram; shader->bind(); - shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); + S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); if (channel > -1) { - mPostMap.bindTexture(0, channel); + src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } - channel = shader->enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, mGlow[1].getUsage()); - if (channel > -1) { - mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } - { - LLGLDepthTest depth_test(GL_FALSE, GL_FALSE, GL_ALWAYS); - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - gGL.flush(); - - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); shader->unbind(); mRT->fxaaBuffer.flush(); + dst->bindTarget(); shader = &gFXAAProgram; shader->bind(); @@ -7547,12 +7260,6 @@ void LLPipeline::renderFinalize() mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - F32 scale_x = (F32)width / mRT->fxaaBuffer.getWidth(); F32 scale_y = (F32)height / mRT->fxaaBuffer.getHeight(); shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); @@ -7562,46 +7269,318 @@ void LLPipeline::renderFinalize() shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f / width * scale_x, -2.f / height * scale_y, 2.f / width * scale_x, 2.f / height * scale_y); - { - // at this point we should pointed at the backbuffer (or a snapshot render target) - llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); - S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); + { + // at this point we should pointed at the backbuffer (or a snapshot render target) + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); + gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - shader->unbind(); + dst->flush(); } - else + } +} + +void LLPipeline::renderFinalize() +{ + LLVertexBuffer::unbind(); + LLGLState::checkStates(); + + assertInitialized(); + + LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); + LL_PROFILE_GPU_ZONE("renderFinalize"); + + gGL.color4f(1, 1, 1, 1); + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable cull(GL_CULL_FACE); + + enableLightsFullbright(); + + LLGLDisable test(GL_ALPHA_TEST); + + gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); + + if (!gCubeSnapshot) + { + + copyScreenSpaceReflections(&mSceneMap, screenTarget()); + + generateLuminance(screenTarget(), &mLuminanceMap); + + generateExposure(&mLuminanceMap, &mExposureMap); + + gammaCorrect(screenTarget(), &mPostMap); + + LLVertexBuffer::unbind(); + } + + renderGlow(&mPostMap, screenTarget()); + /* + { + bool dof_enabled = + (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && + RenderDepthOfField && + !gCubeSnapshot; + + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; + + gViewerWindow->setup3DViewport(); + + if (dof_enabled) { - // at this point we should pointed at the backbuffer (or a snapshot render target) - llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); + LL_PROFILE_GPU_ZONE("dof"); + LLGLSLShader* shader = &gDeferredPostProgram; + LLGLDisable blend(GL_BLEND); + + // depth of field focal plane calculations + static F32 current_distance = 16.f; + static F32 start_distance = 16.f; + static F32 transition_time = 1.f; - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + LLVector3 focus_point; - shader->bind(); + LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); + if (obj && obj->mDrawable && obj->isSelected()) + { // focus on selected media object + S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); + if (obj && obj->mDrawable) + { + LLFace* face = obj->mDrawable->getFace(face_idx); + if (face) + { + focus_point = face->getPositionAgent(); + } + } + } + + if (focus_point.isExactlyZero()) + { + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { // focus on point under cursor + focus_point.set(gDebugRaycastIntersection.getF32ptr()); + } + else if (gAgentCamera.cameraMouselook()) + { // focus on point under mouselook crosshairs + LLVector4a result; + result.clear(); - shader->bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mPostMap); - shader->bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); - shader->bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + focus_point.set(result.getF32ptr()); + } + else + { + // focus on alt-zoom target + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + } + } + } - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + LLVector3 eye = LLViewerCamera::getInstance()->getOrigin(); + F32 target_distance = 16.f; + if (!focus_point.isExactlyZero()) + { + target_distance = LLViewerCamera::getInstance()->getAtAxis() * (focus_point - eye); + } - gGL.flush(); - shader->unbind(); + if (transition_time >= 1.f && fabsf(current_distance - target_distance) / current_distance > 0.01f) + { // large shift happened, interpolate smoothly to new target distance + transition_time = 0.f; + start_distance = current_distance; + } + else if (transition_time < 1.f) + { // currently in a transition, continue interpolating + transition_time += 1.f / CameraFocusTransitionTime * gFrameIntervalSeconds.value(); + transition_time = llmin(transition_time, 1.f); + + F32 t = cosf(transition_time * F_PI + F_PI) * 0.5f + 0.5f; + current_distance = start_distance + (target_distance - start_distance) * t; + } + else + { // small or no change, just snap to target distance + current_distance = target_distance; + } + + // convert to mm + F32 subject_distance = current_distance * 1000.f; + F32 fnumber = CameraFNumber; + F32 default_focal_length = CameraFocalLength; + + F32 fov = LLViewerCamera::getInstance()->getView(); + + const F32 default_fov = CameraFieldOfView * F_PI / 180.f; + + // F32 aspect_ratio = (F32) mRT->screen.getWidth()/(F32)mRT->screen.getHeight(); + + F32 dv = 2.f * default_focal_length * tanf(default_fov / 2.f); + + F32 focal_length = dv / (2 * tanf(fov / 2.f)); + + // F32 tan_pixel_angle = tanf(LLDrawable::sCurPixelAngle); + + // from wikipedia -- c = |s2-s1|/s2 * f^2/(N(S1-f)) + // where N = fnumber + // s2 = dot distance + // s1 = subject distance + // f = focal length + // + + F32 blur_constant = focal_length * focal_length / (fnumber * (subject_distance - focal_length)); + blur_constant /= 1000.f; // convert to meters for shader + F32 magnification = focal_length / (subject_distance - focal_length); + + { // build diffuse+bloom+CoF + mRT->deferredLight.bindTarget(); + shader = &gDeferredCoFProgram; + + bindDeferredShader(*shader); + + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + if (channel > -1) + { + mRT->screen.bindTexture(0, channel); + } + + shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); + shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); + shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); + shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(*shader); + mRT->deferredLight.flush(); + } + + U32 dof_width = (U32)(mRT->screen.getWidth() * CameraDoFResScale); + U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); + + { // perform DoF sampling at half-res (preserve alpha channel) + mRT->screen.bindTarget(); + glViewport(0, 0, dof_width, dof_height); + gGL.setColorMask(true, false); + + shader = &gDeferredPostProgram; + bindDeferredShader(*shader); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); + if (channel > -1) + { + mRT->deferredLight.bindTexture(0, channel); + } + + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(*shader); + mRT->screen.flush(); + gGL.setColorMask(true, true); + } + + { // combine result based on alpha + if (multisample) + { + mRT->deferredLight.bindTarget(); + glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); + } + else + { + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + } + + shader = &gDeferredDoFCombineProgram; + bindDeferredShader(*shader); + + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + if (channel > -1) + { + mRT->screen.bindTexture(0, channel); + } + + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth()); + shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight()); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(*shader); + + if (multisample) + { + mRT->deferredLight.flush(); + } + } } + else + { + LL_PROFILE_GPU_ZONE("no dof"); + if (multisample) + { + mRT->deferredLight.bindTarget(); + } + LLGLSLShader* shader = &gDeferredPostNoDoFProgram; + + bindDeferredShader(*shader); + + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + if (channel > -1) + { + mRT->screen.bindTexture(0, channel); + } + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(*shader); + + if (multisample) + { + mRT->deferredLight.flush(); + } + } + }*/ + + //applyFXAA(screenTarget(), screenTarget()); + + // Present the screen target. + + gDeferredPostNoDoFProgram.bind(); + + S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + if (channel > -1) + { + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + + { + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } + gDeferredPostNoDoFProgram.unbind(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) -- cgit v1.2.3 From 5bfae438fda23d287898238ad7cbedafd81fb33a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sat, 8 Apr 2023 20:18:15 -0700 Subject: Start scrapping screenTarget(). Makes our binding flow _far more_ predictable and makes way more sense. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a1183ccb0f..15c827ffca 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7230,10 +7230,10 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { // bake out texture2D with RGBL for FXAA shader mRT->fxaaBuffer.bindTarget(); - shader = &gDeferredPostNoDoFProgram; + shader = &gGlowCombineFXAAProgram; shader->bind(); - S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); if (channel > -1) { src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); @@ -7270,7 +7270,6 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { 2.f / width * scale_x, 2.f / height * scale_y); { - // at this point we should pointed at the backbuffer (or a snapshot render target) LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); @@ -7282,6 +7281,28 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { shader->unbind(); dst->flush(); } + else { + // Just copy directly into the destination. + dst->bindTarget(); + + gDeferredPostNoDoFProgram.bind(); + + S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); + if (channel > -1) + { + src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + + { + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + gDeferredPostNoDoFProgram.unbind(); + + dst->flush(); + } } } @@ -7310,18 +7331,19 @@ void LLPipeline::renderFinalize() if (!gCubeSnapshot) { - copyScreenSpaceReflections(&mSceneMap, screenTarget()); + copyScreenSpaceReflections(&mSceneMap, &mRT->screen); - generateLuminance(screenTarget(), &mLuminanceMap); + generateLuminance(&mRT->screen, &mLuminanceMap); generateExposure(&mLuminanceMap, &mExposureMap); - gammaCorrect(screenTarget(), &mPostMap); + gammaCorrect(&mRT->screen, &mPostMap); LLVertexBuffer::unbind(); } - renderGlow(&mPostMap, screenTarget()); + renderGlow(&mPostMap, &mRT->screen); + /* { bool dof_enabled = @@ -7561,16 +7583,17 @@ void LLPipeline::renderFinalize() } }*/ - //applyFXAA(screenTarget(), screenTarget()); + applyFXAA(&mRT->screen, &mPostMap); // Present the screen target. gDeferredPostNoDoFProgram.bind(); - S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + // Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems. + S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); if (channel > -1) { - screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mPostMap.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } { -- cgit v1.2.3 From 635037ea30cfbd259c0678a04bd1d6574f5d37b4 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sat, 8 Apr 2023 23:18:34 -0700 Subject: Fix SSR. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 15c827ffca..dccbd46c8c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7331,7 +7331,7 @@ void LLPipeline::renderFinalize() if (!gCubeSnapshot) { - copyScreenSpaceReflections(&mSceneMap, &mRT->screen); + copyScreenSpaceReflections(&mRT->screen, &mSceneMap); generateLuminance(&mRT->screen, &mLuminanceMap); -- cgit v1.2.3 From 1d316c8a25bfe057032582f89b6be7d461475e55 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 10 Apr 2023 10:56:31 -0700 Subject: Get DoF moved into its own method Still broken, figuring out what's up with depth. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 172 +++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 100 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dccbd46c8c..64f9c519d2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7282,77 +7282,40 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { dst->flush(); } else { - // Just copy directly into the destination. - dst->bindTarget(); - - gDeferredPostNoDoFProgram.bind(); - - S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - if (channel > -1) - { - src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); - } - - { - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - gDeferredPostNoDoFProgram.unbind(); - - dst->flush(); + copyRenderTarget(src, dst); } } } -void LLPipeline::renderFinalize() -{ - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - - assertInitialized(); - - LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); - LL_PROFILE_GPU_ZONE("renderFinalize"); - - gGL.color4f(1, 1, 1, 1); - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable cull(GL_CULL_FACE); - - enableLightsFullbright(); - - LLGLDisable test(GL_ALPHA_TEST); - - gGL.setColorMask(true, true); - glClearColor(0, 0, 0, 0); - - if (!gCubeSnapshot) - { - - copyScreenSpaceReflections(&mRT->screen, &mSceneMap); +void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) { + dst->bindTarget(); - generateLuminance(&mRT->screen, &mLuminanceMap); + gDeferredPostNoDoFProgram.bind(); - generateExposure(&mLuminanceMap, &mExposureMap); + S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); + if (channel > -1) + { + src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } - gammaCorrect(&mRT->screen, &mPostMap); + { + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } - LLVertexBuffer::unbind(); - } + gDeferredPostNoDoFProgram.unbind(); - renderGlow(&mPostMap, &mRT->screen); + dst->flush(); +} - /* +void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { bool dof_enabled = (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && RenderDepthOfField && !gCubeSnapshot; - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; - gViewerWindow->setup3DViewport(); if (dof_enabled) @@ -7467,10 +7430,10 @@ void LLPipeline::renderFinalize() bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); if (channel > -1) { - mRT->screen.bindTexture(0, channel); + src->bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); @@ -7491,7 +7454,7 @@ void LLPipeline::renderFinalize() U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); { // perform DoF sampling at half-res (preserve alpha channel) - mRT->screen.bindTarget(); + src->bindTarget(); glViewport(0, 0, dof_width, dof_height); gGL.setColorMask(true, false); @@ -7510,90 +7473,99 @@ void LLPipeline::renderFinalize() mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(*shader); - mRT->screen.flush(); + src->flush(); gGL.setColorMask(true, true); } { // combine result based on alpha - if (multisample) - { - mRT->deferredLight.bindTarget(); - glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); - } - else + { - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + dst->bindTarget(); + glViewport(0, 0, dst->getWidth(), dst->getHeight()); } shader = &gDeferredDoFCombineProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); if (channel > -1) { - mRT->screen.bindTexture(0, channel); + src->bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth()); - shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight()); + shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)src->getWidth()); + shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)src->getHeight()); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(*shader); - if (multisample) { - mRT->deferredLight.flush(); + dst->flush(); } } } else { - LL_PROFILE_GPU_ZONE("no dof"); - if (multisample) - { - mRT->deferredLight.bindTarget(); - } - LLGLSLShader* shader = &gDeferredPostNoDoFProgram; + copyRenderTarget(src, dst); + } + } +} - bindDeferredShader(*shader); +void LLPipeline::renderFinalize() +{ + LLVertexBuffer::unbind(); + LLGLState::checkStates(); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel); - } + assertInitialized(); - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); + LL_PROFILE_GPU_ZONE("renderFinalize"); - unbindDeferredShader(*shader); + gGL.color4f(1, 1, 1, 1); + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable cull(GL_CULL_FACE); - if (multisample) - { - mRT->deferredLight.flush(); - } - } - }*/ + enableLightsFullbright(); + + LLGLDisable test(GL_ALPHA_TEST); + + gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); + + if (!gCubeSnapshot) + { + + copyScreenSpaceReflections(&mRT->screen, &mSceneMap); + + generateLuminance(&mRT->screen, &mLuminanceMap); + + generateExposure(&mLuminanceMap, &mExposureMap); + + gammaCorrect(&mRT->screen, &mPostMap); + + LLVertexBuffer::unbind(); + } + + renderGlow(&mPostMap, &mRT->screen); + + renderDoF(&mRT->screen, &mPostMap); - applyFXAA(&mRT->screen, &mPostMap); + applyFXAA(&mPostMap, &mRT->screen); // Present the screen target. gDeferredPostNoDoFProgram.bind(); // Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems. - S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); + S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mPostMap.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mRT->screen.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } { -- cgit v1.2.3 From 56b21054eb974c21c31aed0b6239f5d1a24b467f Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 10 Apr 2023 11:29:50 -0700 Subject: Get DoF working Need to fix up bloom. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 64f9c519d2..a6364ff092 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7426,27 +7426,27 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { // build diffuse+bloom+CoF mRT->deferredLight.bindTarget(); - shader = &gDeferredCoFProgram; - bindDeferredShader(*shader); + gDeferredCoFProgram.bind(); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - if (channel > -1) - { - src->bindTexture(0, channel); - } + S32 channel = gDeferredCoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); + gDeferredCoFProgram.bindTexture(channel, src); - shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); - shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); - shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); - shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + channel = gDeferredCoFProgram.enableTexture(LLShaderMgr::DEFERRED_DEPTH, mRT->deferredScreen.getUsage()); + gDeferredCoFProgram.bindTexture(channel, &mRT->deferredScreen, true); + + gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - unbindDeferredShader(*shader); + gDeferredCoFProgram.unbind(); mRT->deferredLight.flush(); } -- cgit v1.2.3 From 2b2154f0217758b27b544d066024d922ba234d51 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 11 Apr 2023 15:09:58 -0500 Subject: SL-19564 Rebalance exposure and sky. Hack legacy diffuse map saturation and brightness to allow ACES Hill all the time. --- indra/newview/pipeline.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e4ffa5b6b0..4266c16f94 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7336,13 +7336,13 @@ void LLPipeline::renderFinalize() mLastExposure.bindTexture(0, channel); } + static LLStaticHashedString dt("dt"); + static LLStaticHashedString noiseVec("noiseVec"); + static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); static LLCachedControl dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); static LLCachedControl dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); static LLCachedControl dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); - static LLStaticHashedString dt("dt"); - static LLStaticHashedString noiseVec("noiseVec"); - static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max); @@ -7370,7 +7370,7 @@ void LLPipeline::renderFinalize() gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget(), false, LLTexUnit::TFO_POINT); - gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); + gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); @@ -9466,6 +9466,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) set_current_projection(saved_proj); LLVector3 eye = camera.getOrigin(); + llassert(eye.isFinite()); //camera used for shadow cull/render LLCamera shadow_cam; @@ -9745,6 +9746,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { //get perspective projection view[j] = view[j].inverse(); + //llassert(origin.isFinite()); glh::vec3f origin_agent(origin.mV); @@ -9752,7 +9754,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) view[j].mult_matrix_vec(origin_agent); eye = LLVector3(origin_agent.v); - + //llassert(eye.isFinite()); if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowFrustOrigin[j] = eye; -- cgit v1.2.3 From d839bfe43a8a35c64906551c8ac7de3e42cd86f5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 12 Apr 2023 13:01:53 -0700 Subject: Combine glow in a separate shader. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 51 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a6364ff092..572d388b15 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7193,25 +7193,6 @@ void LLPipeline::renderGlow(LLRenderTarget* src, LLRenderTarget* dst) { mGlow[1].clear(); mGlow[1].flush(); } - - // Go ahead and do our glow combine here in our destination. We blit this later into the front buffer. - - dst->bindTarget(); - - { - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); - - gGlowCombineProgram.bind(); - - gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); - gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); - gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); - - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - dst->flush(); } void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { @@ -7288,6 +7269,8 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { } void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) { + + LL_PROFILE_GPU_ZONE("copyRenderTarget"); dst->bindTarget(); gDeferredPostNoDoFProgram.bind(); @@ -7309,6 +7292,27 @@ void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) { dst->flush(); } +void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst) { + // Go ahead and do our glow combine here in our destination. We blit this later into the front buffer. + + dst->bindTarget(); + + { + LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); + + gGlowCombineProgram.bind(); + + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + dst->flush(); +} + void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { bool dof_enabled = @@ -7539,7 +7543,6 @@ void LLPipeline::renderFinalize() if (!gCubeSnapshot) { - copyScreenSpaceReflections(&mRT->screen, &mSceneMap); generateLuminance(&mRT->screen, &mLuminanceMap); @@ -7551,11 +7554,13 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); } - renderGlow(&mPostMap, &mRT->screen); + renderGlow(&mPostMap, &mRT->screen); // We don't actually write to the screen buffer here. Should probably pass in mGlow[2] as our destination. + + renderDoF(&mPostMap, &mRT->screen); - renderDoF(&mRT->screen, &mPostMap); + applyFXAA(&mRT->screen, &mPostMap); - applyFXAA(&mPostMap, &mRT->screen); + combineGlow(&mPostMap, &mRT->screen); // Present the screen target. -- cgit v1.2.3 From 58df456675f37146d9a6cdaaf75c0f2b93f234c6 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 12 Apr 2023 14:50:14 -0700 Subject: Fixed DoF --- indra/newview/pipeline.cpp | 71 +++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 42 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 572d388b15..db477f64e3 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7098,7 +7098,7 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* } } -void LLPipeline::renderGlow(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::generateGlow(LLRenderTarget* src) { if (sRenderGlow) { LL_PROFILE_GPU_ZONE("glow"); @@ -7325,7 +7325,6 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { if (dof_enabled) { LL_PROFILE_GPU_ZONE("dof"); - LLGLSLShader* shader = &gDeferredPostProgram; LLGLDisable blend(GL_BLEND); // depth of field focal plane calculations @@ -7433,12 +7432,11 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { gDeferredCoFProgram.bind(); - S32 channel = gDeferredCoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - gDeferredCoFProgram.bindTexture(channel, src); - - channel = gDeferredCoFProgram.enableTexture(LLShaderMgr::DEFERRED_DEPTH, mRT->deferredScreen.getUsage()); - gDeferredCoFProgram.bindTexture(channel, &mRT->deferredScreen, true); + gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); + gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); @@ -7449,7 +7447,6 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - gDeferredCoFProgram.unbind(); mRT->deferredLight.flush(); } @@ -7462,54 +7459,43 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { glViewport(0, 0, dof_width, dof_height); gGL.setColorMask(true, false); - shader = &gDeferredPostProgram; - bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); - if (channel > -1) - { - mRT->deferredLight.bindTexture(0, channel); - } + gDeferredPostProgram.bind(); + gDeferredPostProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mRT->deferredLight, LLTexUnit::TFO_POINT); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gDeferredPostProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - unbindDeferredShader(*shader); + gDeferredPostProgram.unbind(); + src->flush(); gGL.setColorMask(true, true); } { // combine result based on alpha - { - dst->bindTarget(); - glViewport(0, 0, dst->getWidth(), dst->getHeight()); - } + dst->bindTarget(); + glViewport(0, 0, dst->getWidth(), dst->getHeight()); - shader = &gDeferredDoFCombineProgram; - bindDeferredShader(*shader); + gDeferredDoFCombineProgram.bind(); + gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); + gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_LIGHT, &mRT->deferredLight, LLTexUnit::TFO_POINT); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - if (channel > -1) - { - src->bindTexture(0, channel); - } - - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)src->getWidth()); - shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)src->getHeight()); + gDeferredDoFCombineProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)src->getWidth()); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)src->getHeight()); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - unbindDeferredShader(*shader); + gDeferredDoFCombineProgram.unbind(); - { - dst->flush(); - } + dst->flush(); } } else @@ -7554,13 +7540,14 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); } - renderGlow(&mPostMap, &mRT->screen); // We don't actually write to the screen buffer here. Should probably pass in mGlow[2] as our destination. + generateGlow(&mPostMap); - renderDoF(&mPostMap, &mRT->screen); + combineGlow(&mPostMap, &mRT->screen); - applyFXAA(&mRT->screen, &mPostMap); + renderDoF(&mRT->screen, &mPostMap); + + applyFXAA(&mPostMap, &mRT->screen); - combineGlow(&mPostMap, &mRT->screen); // Present the screen target. -- cgit v1.2.3 From 23365ca51aef2447efa07b0097a421ff864feec1 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 12 Apr 2023 16:58:15 -0700 Subject: Fix for nameplates, HUD text generally. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/pipeline.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3e9a1bb353..f7882b98ba 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7239,6 +7239,13 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + F32 scale_x = (F32)width / mRT->fxaaBuffer.getWidth(); F32 scale_y = (F32)height / mRT->fxaaBuffer.getHeight(); shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); @@ -7273,14 +7280,10 @@ void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) { gDeferredPostNoDoFProgram.bind(); - S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - if (channel > -1) - { - src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); - } + gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); + gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); { - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } @@ -7296,12 +7299,10 @@ void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst) { dst->bindTarget(); { - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); gGlowCombineProgram.bind(); gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); - gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); mScreenTriangleVB->setBuffer(); @@ -7455,6 +7456,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { // perform DoF sampling at half-res (preserve alpha channel) src->bindTarget(); glViewport(0, 0, dof_width, dof_height); + gGL.setColorMask(true, false); gDeferredPostProgram.bind(); @@ -7476,7 +7478,16 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { // combine result based on alpha dst->bindTarget(); - glViewport(0, 0, dst->getWidth(), dst->getHeight()); + if (RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete()) { + glViewport(0, 0, dst->getWidth(), dst->getHeight()); + } + else { + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + } gDeferredDoFCombineProgram.bind(); gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); @@ -7542,21 +7553,23 @@ void LLPipeline::renderFinalize() combineGlow(&mPostMap, &mRT->screen); + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + renderDoF(&mRT->screen, &mPostMap); applyFXAA(&mPostMap, &mRT->screen); - // Present the screen target. gDeferredPostNoDoFProgram.bind(); // Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems. - S32 channel = gDeferredPostNoDoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); - if (channel > -1) - { - mRT->screen.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); - } + gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mRT->screen); + gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); { LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); -- cgit v1.2.3 From f4274ba64e40b487dea2e7c0bfaee47232b55736 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 14 Apr 2023 03:08:28 -0700 Subject: Move mipmap generation into LLRenderTarget. DRTVWR-583 --- indra/newview/pipeline.cpp | 96 ++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 58 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f7882b98ba..fb39e0a8ea 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -190,6 +190,7 @@ F32 LLPipeline::CameraMaxCoF; F32 LLPipeline::CameraDoFResScale; F32 LLPipeline::RenderAutoHideSurfaceAreaLimit; bool LLPipeline::RenderScreenSpaceReflections; +S32 LLPipeline::RenderBufferVisualization; LLTrace::EventStatHandle LLPipeline::sStatBatchSize("renderbatchsize"); const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f; @@ -542,6 +543,7 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("CameraDoFResScale"); connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit"); connectRefreshCachedSettingsSafe("RenderScreenSpaceReflections"); + connectRefreshCachedSettingsSafe("RenderBufferVisualization"); gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); } @@ -1025,6 +1027,7 @@ void LLPipeline::refreshCachedSettings() CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale"); RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit"); RenderScreenSpaceReflections = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + RenderBufferVisualization = gSavedSettings.getS32("RenderBufferVisualization"); sReflectionProbesEnabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionsEnabled") && gSavedSettings.getBOOL("RenderReflectionsEnabled"); RenderSpotLight = nullptr; @@ -1267,7 +1270,7 @@ void LLPipeline::createLUTBuffers() mExposureMap.clear(); mExposureMap.flush(); - mLuminanceMap.allocate(256, 256, GL_R16F); + mLuminanceMap.allocate(256, 256, GL_R16F, false, LLTexUnit::TT_TEXTURE, LLTexUnit::TMG_AUTO); mLastExposure.allocate(1, 1, GL_R16F); } @@ -6888,58 +6891,21 @@ void LLPipeline::bindScreenToTexture() static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Bloom"); -void LLPipeline::renderPostProcess() -{ - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - - assertInitialized(); - - LLVector2 tc1(0, 0); - LLVector2 tc2((F32)mRT->screen.getWidth() * 2, (F32)mRT->screen.getHeight() * 2); - - LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); - LL_PROFILE_GPU_ZONE("renderPostProcess"); - - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable cull(GL_CULL_FACE); - - enableLightsFullbright(); - - LLGLDisable test(GL_ALPHA_TEST); - - gGL.setColorMask(true, true); - glClearColor(0, 0, 0, 0); - - gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - - tc2.setVec((F32)mRT->screen.getWidth(), (F32)mRT->screen.getHeight()); - - gGL.flush(); - - LLVertexBuffer::unbind(); - - -} - -LLRenderTarget* LLPipeline::screenTarget() { - - bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && - (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField && - !gCubeSnapshot; +void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 bufferIndex) { + dst->bindTarget(); + gDeferredBufferVisualProgram.bind(); + gDeferredBufferVisualProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_BILINEAR, bufferIndex); - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete() && !gCubeSnapshot; + static LLStaticHashedString mipLevel("mipLevel"); + if (RenderBufferVisualization != 4) + gDeferredBufferVisualProgram.uniform1f(mipLevel, 0); + else + gDeferredBufferVisualProgram.uniform1f(mipLevel, 8); - if (multisample || dof_enabled) - return &mRT->deferredLight; - - return &mRT->screen; + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + gDeferredBufferVisualProgram.unbind(); + dst->flush(); } void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst) { @@ -6970,9 +6936,6 @@ void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst) { mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); dst->flush(); - dst->bindTexture(0, 0, LLTexUnit::TFO_TRILINEAR); - glGenerateMipmap(GL_TEXTURE_2D); - // note -- unbind AFTER the glGenerateMipMap so time in generatemipmap can be profiled under "Luminance" // also note -- keep an eye on the performance of glGenerateMipmap, might need to replace it with a mip generation shader gLuminanceProgram.unbind(); @@ -7028,7 +6991,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst) { mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); + gGL.getTexUnit(channel)->unbind(mLastExposure.getUsage()); gExposureProgram.unbind(); dst->flush(); } @@ -7199,8 +7162,8 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); LLGLSLShader* shader = &gGlowCombineProgram; - S32 width = screenTarget()->getWidth(); - S32 height = screenTarget()->getHeight(); + S32 width = dst->getWidth(); + S32 height = dst->getHeight(); // Present everything. if (multisample) @@ -7562,13 +7525,30 @@ void LLPipeline::renderFinalize() renderDoF(&mRT->screen, &mPostMap); applyFXAA(&mPostMap, &mRT->screen); + LLRenderTarget* finalBuffer = &mRT->screen; + if (RenderBufferVisualization > -1) { + finalBuffer = &mPostMap; + switch (RenderBufferVisualization) + { + case 0: + case 1: + case 2: + case 3: + visualizeBuffers(&mRT->deferredScreen, finalBuffer, RenderBufferVisualization); + break; + case 4: + visualizeBuffers(&mLuminanceMap, finalBuffer, 0); + default: + break; + } + } // Present the screen target. gDeferredPostNoDoFProgram.bind(); // Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems. - gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mRT->screen); + gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, finalBuffer); gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); { -- cgit v1.2.3 From 03bd681564f0b0a630f6330ab9c61daa4856e5fe Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 14 Apr 2023 19:24:21 -0500 Subject: DRTVWR-559 Balance night scenes against release, nudge glow down a smidge, remove exposure correction from legacy fullbright balance PBR materials against legacy. --- indra/newview/pipeline.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f7882b98ba..ab5c5127f7 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7696,6 +7696,12 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); } + channel = shader.enableTexture(LLShaderMgr::EXPOSURE_MAP); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(&mExposureMap); + } + if (shader.getUniformLocation(LLShaderMgr::VIEWPORT) != -1) { shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0], -- cgit v1.2.3 From d048fa142c2babe25bb79f9423cc84bb2f813f7e Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 14 Apr 2023 15:03:36 -0700 Subject: SL-19561: Fix missing shadows on PBR alpha mask animeshes. TODO: Why did this work for the equivalent non-rigged prim? --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ab5c5127f7..c42bb45926 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8758,6 +8758,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera U32 saved_occlusion = sUseOcclusion; sUseOcclusion = 0; + // List of render pass types that use the prim volume as the shadow, + // ignoring textures. static const U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, -- cgit v1.2.3 From 95d07ccd8799808036528f8cd09288d83fc0c7e0 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 19 Apr 2023 15:56:01 -0700 Subject: SL-19598: Fix shadows not having textures for PBR/non-rigged/alpha blended prims --- indra/newview/pipeline.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c42bb45926..dc500465e2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6751,7 +6751,8 @@ void LLPipeline::renderShadowSimple(U32 type) gGLLastMatrix = NULL; } -void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigged) +// Currently only used for shadows -Cosmic,2023-04-19 +void LLPipeline::renderAlphaObjects(bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; assertInitialized(); @@ -6768,9 +6769,20 @@ void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigge LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); + if (rigged != (pparams->mAvatar != nullptr)) + { + // Pool contains both rigged and non-rigged DrawInfos. Only draw + // the objects we're interested in in this pass. + continue; + } + if (rigged) { - if (pparams->mAvatar != nullptr) + if (pparams->mGLTFMaterial) + { + mSimplePool->pushRiggedGLTFBatch(*pparams, lastAvatar, lastMeshId); + } + else { if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { @@ -6779,12 +6791,19 @@ void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigge lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, texture, batch_texture); + mSimplePool->pushBatch(*pparams, true, true); } } - else if (pparams->mAvatar == nullptr) + else { - mSimplePool->pushBatch(*pparams, texture, batch_texture); + if (pparams->mGLTFMaterial) + { + mSimplePool->pushGLTFBatch(*pparams); + } + else + { + mSimplePool->pushBatch(*pparams, true, true); + } } } @@ -6792,6 +6811,7 @@ void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigge gGLLastMatrix = NULL; } +// Currently only used for shadows -Cosmic,2023-04-19 void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); @@ -6809,6 +6829,7 @@ void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, gGLLastMatrix = NULL; } +// Currently only used for shadows -Cosmic,2023-04-19 void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); @@ -8885,7 +8906,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); LL_PROFILE_GPU_ZONE("shadow alpha blend"); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); - renderAlphaObjects(true, true, rigged); + renderAlphaObjects(rigged); } { -- cgit v1.2.3 From 005a5fa207d158995217cb9ecf5c214c8b2354cc Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 21 Apr 2023 13:26:24 -0700 Subject: SL-19606: Fix missing GLTF texture transforms in PBR alpha mask/alpha blend shadows --- indra/newview/pipeline.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 60d19bf1d6..ee011bf37c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6794,7 +6794,7 @@ void LLPipeline::renderAlphaObjects(bool rigged) lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, true, true); + mSimplePool->pushBatch(*pparams, true, true, true); } } else @@ -6805,7 +6805,7 @@ void LLPipeline::renderAlphaObjects(bool rigged) } else { - mSimplePool->pushBatch(*pparams, true, true); + mSimplePool->pushBatch(*pparams, true, true, true); } } } @@ -6822,11 +6822,11 @@ void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, gGLLastMatrix = NULL; if (rigged) { - mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); + mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture, true); } else { - mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); + mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture, true); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -6840,11 +6840,11 @@ void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batc gGLLastMatrix = NULL; if (rigged) { - mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); + mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture, true); } else { - mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); + mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture, true); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; -- cgit v1.2.3 From 78bb75989e36b9598852e7dcce05dce37ab0ebe1 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 21 Apr 2023 17:19:39 -0500 Subject: DRTVWR-559 Nudge legacy sky ambient to be more like release. Incidental decruft --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 60d19bf1d6..9fe9f4e487 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7039,7 +7039,7 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); - F32 e = llclamp(exposure(), 0.5f, 4.f); + F32 e = llclamp(exposure(), 0.5f, 4.f); static LLStaticHashedString s_exposure("exposure"); -- cgit v1.2.3 From 5d862c994c18b155bc761fa16dd4070281a1345e Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 25 Apr 2023 14:48:16 -0500 Subject: DRTVWR-559 Optimization pass on probe allocation and search. Incidental decruft. --- indra/newview/pipeline.cpp | 52 +++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 126924220c..4bb93d675e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6912,7 +6912,8 @@ void LLPipeline::bindScreenToTexture() static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Bloom"); -void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 bufferIndex) { +void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 bufferIndex) +{ dst->bindTarget(); gDeferredBufferVisualProgram.bind(); gDeferredBufferVisualProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_BILINEAR, bufferIndex); @@ -6929,7 +6930,8 @@ void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 dst->flush(); } -void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst) +{ // luminance sample and mipmap generation { LL_PROFILE_GPU_ZONE("luminance sample"); @@ -7054,7 +7056,8 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { dst->flush(); } -void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst) +{ if (RenderScreenSpaceReflections && !gCubeSnapshot) { @@ -7080,7 +7083,8 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* } } -void LLPipeline::generateGlow(LLRenderTarget* src) { +void LLPipeline::generateGlow(LLRenderTarget* src) +{ if (sRenderGlow) { LL_PROFILE_GPU_ZONE("glow"); @@ -7177,7 +7181,8 @@ void LLPipeline::generateGlow(LLRenderTarget* src) { } } -void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) +{ { llassert(!gCubeSnapshot); bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); @@ -7257,7 +7262,8 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { } } -void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) +{ LL_PROFILE_GPU_ZONE("copyRenderTarget"); dst->bindTarget(); @@ -7277,7 +7283,8 @@ void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst) { dst->flush(); } -void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst) +{ // Go ahead and do our glow combine here in our destination. We blit this later into the front buffer. dst->bindTarget(); @@ -7296,7 +7303,8 @@ void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst) { dst->flush(); } -void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) +{ { bool dof_enabled = (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && @@ -7462,10 +7470,12 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { // combine result based on alpha dst->bindTarget(); - if (RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete()) { + if (RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete()) + { glViewport(0, 0, dst->getWidth(), dst->getHeight()); } - else { + else + { gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); @@ -7500,6 +7510,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { void LLPipeline::renderFinalize() { + llassert(!gCubeSnapshot); LLVertexBuffer::unbind(); LLGLState::checkStates(); @@ -7520,22 +7531,20 @@ void LLPipeline::renderFinalize() gGL.setColorMask(true, true); glClearColor(0, 0, 0, 0); - if (!gCubeSnapshot) - { - copyScreenSpaceReflections(&mRT->screen, &mSceneMap); + + copyScreenSpaceReflections(&mRT->screen, &mSceneMap); - generateLuminance(&mRT->screen, &mLuminanceMap); + generateLuminance(&mRT->screen, &mLuminanceMap); - generateExposure(&mLuminanceMap, &mExposureMap); + generateExposure(&mLuminanceMap, &mExposureMap); - gammaCorrect(&mRT->screen, &mPostMap); + gammaCorrect(&mRT->screen, &mPostMap); - LLVertexBuffer::unbind(); - } + LLVertexBuffer::unbind(); - generateGlow(&mPostMap); + generateGlow(&mPostMap); - combineGlow(&mPostMap, &mRT->screen); + combineGlow(&mPostMap, &mRT->screen); gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; @@ -7547,7 +7556,8 @@ void LLPipeline::renderFinalize() applyFXAA(&mPostMap, &mRT->screen); LLRenderTarget* finalBuffer = &mRT->screen; - if (RenderBufferVisualization > -1) { + if (RenderBufferVisualization > -1) + { finalBuffer = &mPostMap; switch (RenderBufferVisualization) { -- cgit v1.2.3 From 88adfdcee4941dbc57725c8251c3435fbca1792e Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 26 Apr 2023 20:47:04 -0500 Subject: DRTVWR-559 Add "No Post" mode and refactor "Scene Gamma" into "Brightness" for adjusting legacy gamma when probe ambiance is 0 and dynamic exposure when probe ambiance is not zero. --- indra/newview/pipeline.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4bb93d675e..2cb11fc077 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7007,9 +7007,19 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst) { static LLCachedControl dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); static LLCachedControl dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); + F32 exposure_max = dynamic_exposure_max; + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); + + if (sky->getReflectionProbeAmbiance() > 0.f) + { //not a legacy sky, use gamma as a boost to max exposure + exposure_max = llmax(exposure_max - 1.f, 0.f); + exposure_max *= sky->getGamma(); + exposure_max += 1.f; + } + gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); - gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max); + gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, exposure_max); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7026,18 +7036,25 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { { LL_PROFILE_GPU_ZONE("gamma correct"); + static LLCachedControl no_post(gSavedSettings, "RenderDisablePostProcessing", false); + LLGLDepthTest depth(GL_FALSE, GL_FALSE); // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); + + LLGLSLShader& shader = no_post && gFloaterTools->isAvailable() ? gNoPostGammaCorrectProgram : // no post (no gamma, no exposure, no tonemapping) + LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance() == 0.f ? gLegacyPostGammaCorrectProgram : + gDeferredPostGammaCorrectProgram; + + shader.bind(); S32 channel = 0; - gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT); + shader.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT); - gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); + shader.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, src->getWidth(), src->getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, src->getWidth(), src->getHeight()); static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7045,13 +7062,13 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { static LLStaticHashedString s_exposure("exposure"); - gDeferredPostGammaCorrectProgram.uniform1f(s_exposure, e); + shader.uniform1f(s_exposure, e); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); gGL.getTexUnit(channel)->unbind(src->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); + shader.unbind(); } dst->flush(); } -- cgit v1.2.3 From 23addd8fb526d93c8223d5f38ba74a140894d8e5 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 27 Apr 2023 17:25:17 -0500 Subject: DRTVWR-559 Fix for crash on GL 3. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2cb11fc077..c890585b9f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -961,7 +961,7 @@ void LLPipeline::refreshCachedSettings() WindLightUseAtmosShaders = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("WindLightUseAtmosShaders"); RenderDeferred = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderDeferred"); RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash"); - RenderFSAASamples = gSavedSettings.getU32("RenderFSAASamples"); + RenderFSAASamples = LLFeatureManager::getInstance()->isFeatureAvailable("RenderFSAASamples") ? gSavedSettings.getU32("RenderFSAASamples") : 0; RenderResolutionDivisor = gSavedSettings.getU32("RenderResolutionDivisor"); RenderUIBuffer = gSavedSettings.getBOOL("RenderUIBuffer"); RenderShadowDetail = gSavedSettings.getS32("RenderShadowDetail"); -- cgit v1.2.3 From 6b83fabf729fd9d866fb150166cbd0af50f7f99d Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 24 Apr 2023 12:34:05 -0700 Subject: SL-19644: Move GLTF transform reset out of pushBatch --- indra/newview/pipeline.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c482256309..1768c6ee5f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6797,7 +6797,8 @@ void LLPipeline::renderAlphaObjects(bool rigged) lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, true, true, true); + LLRenderPass::resetGLTFTextureTransform(); + mSimplePool->pushBatch(*pparams, true, true); } } else @@ -6808,7 +6809,8 @@ void LLPipeline::renderAlphaObjects(bool rigged) } else { - mSimplePool->pushBatch(*pparams, true, true, true); + LLRenderPass::resetGLTFTextureTransform(); + mSimplePool->pushBatch(*pparams, true, true); } } } @@ -6825,11 +6827,11 @@ void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, gGLLastMatrix = NULL; if (rigged) { - mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture, true); + mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); } else { - mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture, true); + mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -6843,11 +6845,11 @@ void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batc gGLLastMatrix = NULL; if (rigged) { - mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture, true); + mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); } else { - mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture, true); + mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -8909,6 +8911,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); LL_PROFILE_GPU_ZONE("shadow alpha masked"); + LLRenderPass::resetGLTFTextureTransform(); renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, true, true, rigged); } @@ -8925,6 +8928,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + LLRenderPass::resetGLTFTextureTransform(); renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, true, true, rigged); } @@ -8941,6 +8945,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha material"); LL_PROFILE_GPU_ZONE("shadow alpha material"); + LLRenderPass::resetGLTFTextureTransform(); renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, true, false, rigged); -- cgit v1.2.3 From 51318d1808cb8e1212b24c5971ce9187b2e5e8ba Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 27 Apr 2023 17:55:31 -0700 Subject: SL-19644: Bind the shader on every shadow alpha blend call --- indra/newview/pipeline.cpp | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1768c6ee5f..2912d0da82 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -197,6 +197,7 @@ LLTrace::EventStatHandle LLPipeline::sStatBatchSize("renderbatchsize"); const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f; const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f; +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; @@ -6764,6 +6765,8 @@ void LLPipeline::renderAlphaObjects(bool rigged) assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; + S32 sun_up = LLEnvironment::instance().getIsSunUp() ? 1 : 0; + U32 target_width = LLRenderTarget::sCurResX; U32 type = LLRenderPass::PASS_ALPHA; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; @@ -6786,10 +6789,18 @@ void LLPipeline::renderAlphaObjects(bool rigged) { if (pparams->mGLTFMaterial) { + gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); mSimplePool->pushRiggedGLTFBatch(*pparams, lastAvatar, lastMeshId); } else { + gDeferredShadowAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { mSimplePool->uploadMatrixPalette(*pparams); @@ -6797,7 +6808,6 @@ void LLPipeline::renderAlphaObjects(bool rigged) lastMeshId = pparams->mSkinInfo->mHash; } - LLRenderPass::resetGLTFTextureTransform(); mSimplePool->pushBatch(*pparams, true, true); } } @@ -6805,11 +6815,18 @@ void LLPipeline::renderAlphaObjects(bool rigged) { if (pparams->mGLTFMaterial) { + gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); mSimplePool->pushGLTFBatch(*pparams); } else { - LLRenderPass::resetGLTFTextureTransform(); + gDeferredShadowAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); mSimplePool->pushBatch(*pparams, true, true); } } @@ -8836,8 +8853,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera stop_glerror(); - LLEnvironment& environment = LLEnvironment::instance(); - struct CompareVertexBuffer { bool operator()(const LLDrawInfo* const& lhs, const LLDrawInfo* const& rhs) @@ -8852,7 +8867,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { bool rigged = j == 1; gDeferredShadowProgram.bind(rigged); - LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); gGL.diffuseColor4f(1, 1, 1, 1); @@ -8897,28 +8911,25 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); - + const S32 sun_up = LLEnvironment::instance().getIsSunUp() ? 1 : 0; U32 target_width = LLRenderTarget::sCurResX; for (int i = 0; i < 2; ++i) { bool rigged = i == 1; - gDeferredShadowAlphaMaskProgram.bind(rigged); - LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); - LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); LL_PROFILE_GPU_ZONE("shadow alpha masked"); - LLRenderPass::resetGLTFTextureTransform(); + gDeferredShadowAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); LL_PROFILE_GPU_ZONE("shadow alpha blend"); - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); renderAlphaObjects(rigged); } @@ -8926,9 +8937,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); LL_PROFILE_GPU_ZONE("shadow alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); - LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - LLRenderPass::resetGLTFTextureTransform(); renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, true, true, rigged); } @@ -8936,16 +8946,16 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); LL_PROFILE_GPU_ZONE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); + if (i == 0) { - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); renderObjects(LLRenderPass::PASS_GRASS, true); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha material"); LL_PROFILE_GPU_ZONE("shadow alpha material"); - LLRenderPass::resetGLTFTextureTransform(); renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, true, false, rigged); @@ -8958,8 +8968,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { bool rigged = i == 1; gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); - LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; -- cgit v1.2.3 From 334d71e9107ae3c4d35b181f2ed6e5c9ff1de519 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 1 May 2023 17:05:09 -0500 Subject: SL-19656 Rewrite avatar and attachment render metrics to not interfere with render pipe and be representative of actual render cost instead of driver synchronization time. * SL-19656 Rewrite avatar and attachment render metrics to not interfere with render pipe and be representative of actual render cost instead of driver synchronization time. * SL-19656 Remove now dead code (trackAttachments et al). * SL-19656 Fix for crash on GL <= 3.2 --- indra/newview/pipeline.cpp | 125 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 111 insertions(+), 14 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2912d0da82..df8b8a552a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10070,7 +10070,88 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) static LLTrace::BlockTimerStatHandle FTM_GENERATE_IMPOSTOR("Generate Impostor"); -void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) +void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) +{ + if (gGLManager.mGLVersion < 3.25f) + { // profiling requires GL 3.3 or later + return; + } + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; + + mRT->deferredScreen.bindTarget(); + mRT->deferredScreen.clear(); + + bool profile_enabled = LLGLSLShader::sProfileEnabled; + LLGLSLShader::sProfileEnabled = true; + + if (!profile_attachments) + { + // profile entire avatar all at once + + // use gDebugProgram as a proxy for getting profile results + gDebugProgram.clearStats(); + gDebugProgram.placeProfileQuery(); + LLGLSLShader::sProfileEnabled = false; + + LLTimer cpu_timer; + + generateImpostor(avatar, false, true); + + avatar->mCPURenderTime = (F32)cpu_timer.getElapsedTimeF32() * 1000.f; + + LLGLSLShader::sProfileEnabled = true; + gDebugProgram.readProfileQuery(); + + avatar->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; + + avatar->mGPUSamplesPassed = gDebugProgram.mSamplesDrawn; + avatar->mGPUTrianglesRendered = gDebugProgram.mTrianglesDrawn; + } + else + { + // profile attachments one at a time + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + for (iter = begin; + iter != end; + ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object) + { + gDebugProgram.clearStats(); + gDebugProgram.placeProfileQuery(); + LLGLSLShader::sProfileEnabled = false; + + generateImpostor(avatar, false, true, attached_object); + LLGLSLShader::sProfileEnabled = true; + gDebugProgram.readProfileQuery(); + + attached_object->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; + + // TODO: maybe also record triangles and samples + } + } + } + } + + LLGLSLShader::sProfileEnabled = profile_enabled; + mRT->deferredScreen.flush(); + + if (cur_shader) + { + cur_shader->bind(); + } +} + +void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool for_profile, LLViewerObject* specific_attachment) { LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); LL_PROFILE_GPU_ZONE("generateImpostor"); @@ -10090,11 +10171,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) assertInitialized(); // previews can't be muted or impostered - bool visually_muted = !preview_avatar && avatar->isVisuallyMuted(); + bool visually_muted = !for_profile && !preview_avatar && avatar->isVisuallyMuted(); LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID() << " is " << ( visually_muted ? "" : "not ") << "visually muted" << LL_ENDL; - bool too_complex = !preview_avatar && avatar->isTooComplex(); + bool too_complex = !for_profile && !preview_avatar && avatar->isTooComplex(); LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID() << " is " << ( too_complex ? "" : "not ") << "too complex" << LL_ENDL; @@ -10129,6 +10210,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) ); } + if (specific_attachment && specific_attachment->isHUDAttachment()) + { //enable HUD rendering + setRenderTypeMask(RENDER_TYPE_HUD, END_RENDER_TYPES); + } + S32 occlusion = sUseOcclusion; sUseOcclusion = 0; @@ -10185,20 +10271,30 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) } else { - LLVOAvatar::attachment_map_t::iterator iter; - for (iter = avatar->mAttachmentPoints.begin(); - iter != avatar->mAttachmentPoints.end(); - ++iter) + if (specific_attachment) { - LLViewerJointAttachment *attachment = iter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) + markVisible(specific_attachment->mDrawable->getSpatialBridge(), *viewer_camera); + } + else + { + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + for (iter = begin; + iter != end; + ++iter) { - LLViewerObject* attached_object = attachment_iter->get(); - if (attached_object) + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) { - markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object) + { + markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); + } } } } @@ -10327,6 +10423,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LLDrawPoolAvatar::sMinimumAlpha = old_alpha; + if (!for_profile) { //create alpha mask based on depth buffer (grey out if muted) if (LLPipeline::sRenderDeferred) { -- cgit v1.2.3 From e09475713b7abe6fcb916f4a770081a1696b57ab Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 2 May 2023 18:47:21 -0500 Subject: DRTVWR-559 Optimization pass, make it so profileAvatar can read back GPU timer without a frame stall. --- indra/newview/pipeline.cpp | 71 +++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 45 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index df8b8a552a..4d9a8a594a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3016,18 +3016,6 @@ void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags f { if (drawablep && !drawablep->isDead() && assertInitialized()) { - if (debugLoggingEnabled("AnimatedObjectsLinkset")) - { - LLVOVolume *vol_obj = drawablep->getVOVolume(); - if (vol_obj && vol_obj->isAnimatedObject() && vol_obj->isRiggedMesh()) - { - std::string vobj_name = llformat("Vol%p", vol_obj); - F32 est_tris = vol_obj->getEstTrianglesMax(); - LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " markRebuild, tris " << est_tris - << " priority " << (S32) priority << " flag " << std::hex << flag << LL_ENDL; - } - } - if (!drawablep->isState(LLDrawable::BUILT)) { priority = true; @@ -7697,10 +7685,18 @@ void LLPipeline::bindShadowMaps(LLGLSLShader& shader) void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) { - shader.bind(); - bindLightFunc(shader); - bindShadowMaps(shader); - bindReflectionProbes(shader); + if (shader.mCanBindFast) + { // was previously fully bound, use fast path + shader.bind(); + bindLightFunc(shader); + bindShadowMaps(shader); + bindReflectionProbes(shader); + } + else + { //wasn't previously bound, use slow path + bindDeferredShader(shader); + shader.mCanBindFast = true; + } } void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) @@ -10068,30 +10064,24 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) } } -static LLTrace::BlockTimerStatHandle FTM_GENERATE_IMPOSTOR("Generate Impostor"); - void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) { if (gGLManager.mGLVersion < 3.25f) { // profiling requires GL 3.3 or later return; } + + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; mRT->deferredScreen.bindTarget(); mRT->deferredScreen.clear(); - bool profile_enabled = LLGLSLShader::sProfileEnabled; - LLGLSLShader::sProfileEnabled = true; - if (!profile_attachments) { - // profile entire avatar all at once - - // use gDebugProgram as a proxy for getting profile results - gDebugProgram.clearStats(); - gDebugProgram.placeProfileQuery(); - LLGLSLShader::sProfileEnabled = false; + // profile entire avatar all at once and readback asynchronously + avatar->placeProfileQuery(); LLTimer cpu_timer; @@ -10099,13 +10089,7 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) avatar->mCPURenderTime = (F32)cpu_timer.getElapsedTimeF32() * 1000.f; - LLGLSLShader::sProfileEnabled = true; - gDebugProgram.readProfileQuery(); - - avatar->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; - - avatar->mGPUSamplesPassed = gDebugProgram.mSamplesDrawn; - avatar->mGPUTrianglesRendered = gDebugProgram.mTrianglesDrawn; + avatar->readProfileQuery(5); // allow up to 5 frames of latency } else { @@ -10126,23 +10110,19 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) LLViewerObject* attached_object = attachment_iter->get(); if (attached_object) { + // use gDebugProgram to do the GPU queries gDebugProgram.clearStats(); - gDebugProgram.placeProfileQuery(); - LLGLSLShader::sProfileEnabled = false; + gDebugProgram.placeProfileQuery(true); generateImpostor(avatar, false, true, attached_object); - LLGLSLShader::sProfileEnabled = true; - gDebugProgram.readProfileQuery(); + gDebugProgram.readProfileQuery(true, true); attached_object->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; - - // TODO: maybe also record triangles and samples } } } } - LLGLSLShader::sProfileEnabled = profile_enabled; mRT->deferredScreen.flush(); if (cur_shader) @@ -10153,7 +10133,7 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool for_profile, LLViewerObject* specific_attachment) { - LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("generateImpostor"); LLGLState::checkStates(); @@ -10201,6 +10181,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool RENDER_TYPE_TREE, RENDER_TYPE_VOIDWATER, RENDER_TYPE_WATER, + RENDER_TYPE_ALPHA_POST_WATER, RENDER_TYPE_PASS_GRASS, RENDER_TYPE_HUD, RENDER_TYPE_PARTICLES, @@ -10392,9 +10373,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool LLDrawPoolAvatar::sMinimumAlpha = 0.f; } - if (preview_avatar) + if (preview_avatar || for_profile) { - // previews don't care about imposters + // previews and profiles don't care about imposters renderGeomDeferred(camera); renderGeomPostDeferred(camera); } @@ -10502,7 +10483,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - if (!preview_avatar) + if (!preview_avatar && !for_profile) { avatar->mNeedsImpostorUpdate = FALSE; avatar->cacheImpostorValues(); -- cgit v1.2.3 From 8077d33ba05a46ea61914be686816be5b54bae6d Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 11 May 2023 13:20:34 -0500 Subject: SL-19656 Remove LLPerfStats thread and fold into General thread. Hook avatar GPU time into LLPerfStats. Incidental decruft. --- indra/newview/pipeline.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4d9a8a594a..6ea86c4cbb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10073,6 +10073,9 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + // don't continue to profile an avatar that is known to be too slow + llassert(!avatar->isTooSlow()); + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; mRT->deferredScreen.bindTarget(); @@ -10345,25 +10348,28 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512); resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512); - if (!avatar->mImpostor.isComplete()) - { - avatar->mImpostor.allocate(resX, resY, GL_RGBA, true); + if (!for_profile) + { + if (!avatar->mImpostor.isComplete()) + { + avatar->mImpostor.allocate(resX, resY, GL_RGBA, true); - if (LLPipeline::sRenderDeferred) - { - addDeferredAttachments(avatar->mImpostor, true); - } - - gGL.getTexUnit(0)->bind(&avatar->mImpostor); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - else if(resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) - { - avatar->mImpostor.resize(resX,resY); - } + if (LLPipeline::sRenderDeferred) + { + addDeferredAttachments(avatar->mImpostor, true); + } + + gGL.getTexUnit(0)->bind(&avatar->mImpostor); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + else if (resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) + { + avatar->mImpostor.resize(resX, resY); + } - avatar->mImpostor.bindTarget(); + avatar->mImpostor.bindTarget(); + } } F32 old_alpha = LLDrawPoolAvatar::sMinimumAlpha; @@ -10466,7 +10472,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool gGL.popMatrix(); } - if (!preview_avatar) + if (!preview_avatar && !for_profile) { avatar->mImpostor.flush(); avatar->setImpostorDim(tdim); -- cgit v1.2.3 From 7d0903533c20a395e12c2d4c290fcde3ec6b2a53 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 11 May 2023 11:31:09 -0700 Subject: SL-19236: Fix HUDs not rendering when transparent water graphics setting is off --- indra/newview/pipeline.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4d9a8a594a..73e568f1ae 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2239,12 +2239,18 @@ bool LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); +// static +bool LLPipeline::isWaterClip() +{ + return (!sRenderTransparentWater || gCubeSnapshot) && !sRenderingHUDs; +} + void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); LL_PROFILE_GPU_ZONE("updateCull"); // should always be zero GPU time, but drop a timer to flush stuff out - bool water_clip = !sRenderTransparentWater && !sRenderingHUDs; + bool water_clip = isWaterClip(); if (water_clip) { -- cgit v1.2.3 From 339e02ef3311ad5c1197dfca2955a0c202b7c408 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 11 May 2023 21:19:58 -0700 Subject: Finally get glossy SSR up. DRTVWR-583 --- indra/newview/pipeline.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 126924220c..283be64af4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -190,6 +190,11 @@ F32 LLPipeline::CameraMaxCoF; F32 LLPipeline::CameraDoFResScale; F32 LLPipeline::RenderAutoHideSurfaceAreaLimit; bool LLPipeline::RenderScreenSpaceReflections; +S32 LLPipeline::RenderScreenSpaceReflectionIterations; +F32 LLPipeline::RenderScreenSpaceReflectionRayStep; +F32 LLPipeline::RenderScreenSpaceReflectionDistanceBias; +F32 LLPipeline::RenderScreenSpaceReflectionDepthRejectBias; +S32 LLPipeline::RenderScreenSpaceReflectionGlossySamples; S32 LLPipeline::RenderBufferVisualization; LLTrace::EventStatHandle LLPipeline::sStatBatchSize("renderbatchsize"); @@ -543,6 +548,11 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("CameraDoFResScale"); connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit"); connectRefreshCachedSettingsSafe("RenderScreenSpaceReflections"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionIterations"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionRayStep"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionDistanceBias"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionDepthRejectBias"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionsGlossySamples"); connectRefreshCachedSettingsSafe("RenderBufferVisualization"); gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); } @@ -1027,6 +1037,11 @@ void LLPipeline::refreshCachedSettings() CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale"); RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit"); RenderScreenSpaceReflections = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + RenderScreenSpaceReflectionIterations = gSavedSettings.getS32("RenderScreenSpaceReflectionIterations"); + RenderScreenSpaceReflectionRayStep = gSavedSettings.getF32("RenderScreenSpaceReflectionRayStep"); + RenderScreenSpaceReflectionDistanceBias = gSavedSettings.getF32("RenderScreenSpaceReflectionDistanceBias"); + RenderScreenSpaceReflectionDepthRejectBias = gSavedSettings.getF32("RenderScreenSpaceReflectionDepthRejectBias"); + RenderScreenSpaceReflectionGlossySamples = gSavedSettings.getS32("RenderScreenSpaceReflectionGlossySamples"); RenderBufferVisualization = gSavedSettings.getS32("RenderBufferVisualization"); sReflectionProbesEnabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionsEnabled") && gSavedSettings.getBOOL("RenderReflectionsEnabled"); RenderSpotLight = nullptr; @@ -8641,6 +8656,13 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) gGL.getTexUnit(channel)->bind(&mSceneMap); } + + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_ITR_COUNT, RenderScreenSpaceReflectionIterations); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_DIST_BIAS, RenderScreenSpaceReflectionDistanceBias); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_RAY_STEP, RenderScreenSpaceReflectionRayStep); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_GLOSSY_SAMPLES, RenderScreenSpaceReflectionGlossySamples); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_REJECT_BIAS, RenderScreenSpaceReflectionDepthRejectBias); + channel = shader.enableTexture(LLShaderMgr::SCENE_DEPTH); if (channel > -1) { -- cgit v1.2.3 From ee0b330b2d6a3433e3bac6ab21cf6cc3e580c605 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 16 May 2023 20:31:29 -0500 Subject: DRTVWR-559 Decruft deprecated OpenGL flags. --- indra/newview/pipeline.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 99deae309d..7f1db9b61e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -63,7 +63,6 @@ #include "llfeaturemanager.h" #include "llfloatertelehub.h" #include "llfloaterreg.h" -#include "llgldbg.h" #include "llhudmanager.h" #include "llhudnametag.h" #include "llhudtext.h" @@ -2428,7 +2427,6 @@ void LLPipeline::doOcclusion(LLCamera& camera) gGL.setColorMask(false, false); LLGLDisable blend(GL_BLEND); - LLGLDisable test(GL_ALPHA_TEST); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest depth(GL_TRUE, GL_FALSE); @@ -3742,7 +3740,6 @@ void render_hud_elements() if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { - LLGLEnable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() // Draw the tracking overlays @@ -3777,7 +3774,6 @@ void LLPipeline::renderHighlights() // Render highlighted faces. LLGLSPipelineAlpha gls_pipeline_alpha; LLColor4 color(1.f, 1.f, 1.f, 0.5f); - LLGLEnable color_mat(GL_COLOR_MATERIAL); disableLights(); if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) @@ -3947,8 +3943,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) } } - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - LLVertexBuffer::unbind(); LLGLState::checkStates(); @@ -4055,8 +4049,6 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LLGLEnable cull(GL_CULL_FACE); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - calcNearbyLights(camera); setupHWLights(); @@ -7140,7 +7132,6 @@ void LLPipeline::generateGlow(LLRenderTarget* src) { LLGLEnable blend_on(GL_BLEND); - LLGLEnable test(GL_ALPHA_TEST); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); @@ -7559,8 +7550,6 @@ void LLPipeline::renderFinalize() enableLightsFullbright(); - LLGLDisable test(GL_ALPHA_TEST); - gGL.setColorMask(true, true); glClearColor(0, 0, 0, 0); @@ -7971,8 +7960,6 @@ void LLPipeline::renderDeferredLighting() LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); LLViewerCamera *camera = LLViewerCamera::getInstance(); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); @@ -8133,7 +8120,6 @@ void LLPipeline::renderDeferredLighting() { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); - LLGLDisable test(GL_ALPHA_TEST); // full screen blit mScreenTriangleVB->setBuffer(); -- cgit v1.2.3 From 6f5f16e0319bde183534a779839299dca7fe50ab Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 17 May 2023 13:40:33 -0500 Subject: SL-19655 Remove concept of "low priority" updates (RenderDebugGLSession assertion stomping pass). Remove a couple unused debug settings and related code. --- indra/newview/pipeline.cpp | 77 +++++++++++----------------------------------- 1 file changed, 18 insertions(+), 59 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7f1db9b61e..9960ce7bd0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -283,7 +283,6 @@ bool LLPipeline::sRenderHighlight = true; LLRender::eTexIndex LLPipeline::sRenderHighlightTextureChannel = LLRender::DIFFUSE_MAP; bool LLPipeline::sForceOldBakedUpload = false; S32 LLPipeline::sUseOcclusion = 0; -bool LLPipeline::sDelayVBUpdate = true; bool LLPipeline::sAutoMaskAlphaDeferred = true; bool LLPipeline::sAutoMaskAlphaNonDeferred = false; bool LLPipeline::sRenderTransparentWater = true; @@ -474,7 +473,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderAutoMaskAlphaNonDeferred"); connectRefreshCachedSettingsSafe("RenderUseFarClip"); connectRefreshCachedSettingsSafe("RenderAvatarMaxNonImpostors"); - connectRefreshCachedSettingsSafe("RenderDelayVBUpdate"); connectRefreshCachedSettingsSafe("UseOcclusion"); // DEPRECATED -- connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders"); // DEPRECATED -- connectRefreshCachedSettingsSafe("RenderDeferred"); @@ -953,7 +951,6 @@ void LLPipeline::refreshCachedSettings() LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip"); LLVOAvatar::sMaxNonImpostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors"); LLVOAvatar::updateImpostorRendering(LLVOAvatar::sMaxNonImpostors); - LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate"); LLPipeline::sUseOcclusion = (!gUseWireframe @@ -1759,7 +1756,7 @@ void LLPipeline::createObject(LLViewerObject* vobj) vobj->setDrawableParent(NULL); // LLPipeline::addObject 2 } - markRebuild(drawablep, LLDrawable::REBUILD_ALL, TRUE); + markRebuild(drawablep, LLDrawable::REBUILD_ALL); if (drawablep->getVOVolume() && RenderAnimateRes) { @@ -1875,10 +1872,10 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list) { //will likely not receive any future world matrix updates // -- this keeps attachments from getting stuck in space and falling off your avatar drawablep->clearState(LLDrawable::ANIMATED_CHILD); - markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, TRUE); + markRebuild(drawablep, LLDrawable::REBUILD_VOLUME); if (drawablep->getVObj()) { - drawablep->getVObj()->dirtySpatialGroup(TRUE); + drawablep->getVObj()->dirtySpatialGroup(); } } iter = moved_list.erase(curiter); @@ -2977,67 +2974,31 @@ void LLPipeline::markMeshDirty(LLSpatialGroup* group) mMeshDirtyGroup.push_back(group); } -void LLPipeline::markRebuild(LLSpatialGroup* group, bool priority) +void LLPipeline::markRebuild(LLSpatialGroup* group) { if (group && !group->isDead() && group->getSpatialPartition()) { - if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_HUD) + if (!group->hasState(LLSpatialGroup::IN_BUILD_Q1)) { - priority = true; - } - - if (priority) - { - if (!group->hasState(LLSpatialGroup::IN_BUILD_Q1)) - { - llassert_always(!mGroupQ1Locked); - - mGroupQ1.push_back(group); - group->setState(LLSpatialGroup::IN_BUILD_Q1); - - if (group->hasState(LLSpatialGroup::IN_BUILD_Q2)) - { - LLSpatialGroup::sg_vector_t::iterator iter = std::find(mGroupQ2.begin(), mGroupQ2.end(), group); - if (iter != mGroupQ2.end()) - { - mGroupQ2.erase(iter); - } - group->clearState(LLSpatialGroup::IN_BUILD_Q2); - } - } - } - else if (!group->hasState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1)) - { - llassert_always(!mGroupQ2Locked); - mGroupQ2.push_back(group); - group->setState(LLSpatialGroup::IN_BUILD_Q2); + llassert_always(!mGroupQ1Locked); + mGroupQ1.push_back(group); + group->setState(LLSpatialGroup::IN_BUILD_Q1); } } } -void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, bool priority) +void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag) { if (drawablep && !drawablep->isDead() && assertInitialized()) { - if (!drawablep->isState(LLDrawable::BUILT)) - { - priority = true; - } - if (priority) + if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1)) { - if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1)) - { - mBuildQ1.push_back(drawablep); - drawablep->setState(LLDrawable::IN_REBUILD_Q1); // mark drawable as being in priority queue - } + mBuildQ1.push_back(drawablep); + drawablep->setState(LLDrawable::IN_REBUILD_Q1); // mark drawable as being in priority queue } - else if (!drawablep->isState(LLDrawable::IN_REBUILD_Q2)) - { - mBuildQ2.push_back(drawablep); - drawablep->setState(LLDrawable::IN_REBUILD_Q2); // need flag here because it is just a list - } - if (flag & (LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION)) + + if (flag & (LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION)) { drawablep->getVObj()->setChanged(LLXform::SILHOUETTE); } @@ -3083,7 +3044,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) markVisible(drawablep, camera); } - if (!sDelayVBUpdate) { //rebuild mesh as soon as we know it's visible group->rebuildMesh(); } @@ -3139,7 +3099,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) group->setVisible(); stateSort(group, camera); - if (!sDelayVBUpdate) { //rebuild mesh as soon as we know it's visible group->rebuildMesh(); } @@ -10759,7 +10718,7 @@ void LLPipeline::hideObject( const LLUUID& id ) void LLPipeline::hideDrawable( LLDrawable *pDrawable ) { pDrawable->setState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( pDrawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( pDrawable, LLDrawable::REBUILD_ALL); //hide the children LLViewerObject::const_child_list_t& child_list = pDrawable->getVObj()->getChildren(); for ( LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); @@ -10770,14 +10729,14 @@ void LLPipeline::hideDrawable( LLDrawable *pDrawable ) if ( drawable ) { drawable->setState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( drawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( drawable, LLDrawable::REBUILD_ALL); } } } void LLPipeline::unhideDrawable( LLDrawable *pDrawable ) { pDrawable->clearState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( pDrawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( pDrawable, LLDrawable::REBUILD_ALL); //restore children LLViewerObject::const_child_list_t& child_list = pDrawable->getVObj()->getChildren(); for ( LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); @@ -10788,7 +10747,7 @@ void LLPipeline::unhideDrawable( LLDrawable *pDrawable ) if ( drawable ) { drawable->clearState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( drawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( drawable, LLDrawable::REBUILD_ALL); } } } -- cgit v1.2.3 From c827d32ebedeaa46ed75a91ae779f6547fc0d090 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 17 May 2023 18:09:36 -0500 Subject: SL-19655 Decruft legacy GLSL shaders and now unused build queues. --- indra/newview/pipeline.cpp | 217 ++------------------------------------------- 1 file changed, 5 insertions(+), 212 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9960ce7bd0..2687ccfae2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -338,7 +338,6 @@ LLPipeline::LLPipeline() : mOldRenderDebugMask(0), mMeshDirtyQueryObject(0), mGroupQ1Locked(false), - mGroupQ2Locked(false), mResetVertexBuffers(false), mLastRebuildPool(NULL), mLightMask(0), @@ -557,7 +556,6 @@ void LLPipeline::cleanup() assertInitialized(); mGroupQ1.clear() ; - mGroupQ2.clear() ; for(pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ) @@ -2513,33 +2511,6 @@ void LLPipeline::clearRebuildGroups() // Copy the saved HUD groups back in mGroupQ1.assign(hudGroups.begin(), hudGroups.end()); mGroupQ1Locked = false; - - // Clear the HUD groups - hudGroups.clear(); - - mGroupQ2Locked = true; - for (LLSpatialGroup::sg_vector_t::iterator iter = mGroupQ2.begin(); - iter != mGroupQ2.end(); ++iter) - { - LLSpatialGroup* group = *iter; - - // If the group contains HUD objects, save the group - if (group->isHUDGroup()) - { - hudGroups.push_back(group); - } - // Else, no HUD objects so clear the build state - else - { - group->clearState(LLSpatialGroup::IN_BUILD_Q2); - } - } - // Clear the group - mGroupQ2.clear(); - - // Copy the saved HUD groups back in - mGroupQ2.assign(hudGroups.begin(), hudGroups.end()); - mGroupQ2Locked = false; } void LLPipeline::clearRebuildDrawables() @@ -2551,24 +2522,11 @@ void LLPipeline::clearRebuildDrawables() LLDrawable* drawablep = *iter; if (drawablep && !drawablep->isDead()) { - drawablep->clearState(LLDrawable::IN_REBUILD_Q2); - drawablep->clearState(LLDrawable::IN_REBUILD_Q1); + drawablep->clearState(LLDrawable::IN_REBUILD_Q); } } mBuildQ1.clear(); - // clear drawables on the non-priority build queue - for (LLDrawable::drawable_list_t::iterator iter = mBuildQ2.begin(); - iter != mBuildQ2.end(); ++iter) - { - LLDrawable* drawablep = *iter; - if (!drawablep->isDead()) - { - drawablep->clearState(LLDrawable::IN_REBUILD_Q2); - } - } - mBuildQ2.clear(); - //clear all moving bridges for (LLDrawable::drawable_vector_t::iterator iter = mMovedBridge.begin(); iter != mMovedBridge.end(); ++iter) @@ -2622,52 +2580,6 @@ void LLPipeline::rebuildPriorityGroups() } -void LLPipeline::rebuildGroups() -{ - if (mGroupQ2.empty() || gCubeSnapshot) - { - return; - } - - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - mGroupQ2Locked = true; - // Iterate through some drawables on the non-priority build queue - S32 size = (S32) mGroupQ2.size(); - S32 min_count = llclamp((S32) ((F32) (size * size)/4096*0.25f), 1, size); - - S32 count = 0; - - std::sort(mGroupQ2.begin(), mGroupQ2.end(), LLSpatialGroup::CompareUpdateUrgency()); - - LLSpatialGroup::sg_vector_t::iterator iter; - LLSpatialGroup::sg_vector_t::iterator last_iter = mGroupQ2.begin(); - - for (iter = mGroupQ2.begin(); - iter != mGroupQ2.end() && count <= min_count; ++iter) - { - LLSpatialGroup* group = *iter; - last_iter = iter; - - if (!group->isDead()) - { - group->rebuildGeom(); - - if (group->getSpatialPartition()->mRenderByGroup) - { - count++; - } - } - - group->clearState(LLSpatialGroup::IN_BUILD_Q2); - } - - mGroupQ2.erase(mGroupQ2.begin(), ++last_iter); - - mGroupQ2Locked = false; - - updateMovedList(mMovedBridge); -} - void LLPipeline::updateGeom(F32 max_dtime) { LLTimer update_timer; @@ -2693,16 +2605,6 @@ void LLPipeline::updateGeom(F32 max_dtime) LLDrawable* drawablep = *curiter; if (drawablep && !drawablep->isDead()) { - if (drawablep->isState(LLDrawable::IN_REBUILD_Q2)) - { - drawablep->clearState(LLDrawable::IN_REBUILD_Q2); - LLDrawable::drawable_list_t::iterator find = std::find(mBuildQ2.begin(), mBuildQ2.end(), drawablep); - if (find != mBuildQ2.end()) - { - mBuildQ2.erase(find); - } - } - if (drawablep->isUnload()) { drawablep->unload(); @@ -2711,7 +2613,7 @@ void LLPipeline::updateGeom(F32 max_dtime) if (updateDrawableGeom(drawablep, TRUE)) { - drawablep->clearState(LLDrawable::IN_REBUILD_Q1); + drawablep->clearState(LLDrawable::IN_REBUILD_Q); mBuildQ1.erase(curiter); } } @@ -2720,54 +2622,6 @@ void LLPipeline::updateGeom(F32 max_dtime) mBuildQ1.erase(curiter); } } - - // Iterate through some drawables on the non-priority build queue - S32 min_count = 16; - S32 size = (S32) mBuildQ2.size(); - if (size > 1024) - { - min_count = llclamp((S32) (size * (F32) size/4096), 16, size); - } - - S32 count = 0; - - max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, F32SecondsImplicit(max_dtime)); - LLSpatialGroup* last_group = NULL; - LLSpatialBridge* last_bridge = NULL; - - for (LLDrawable::drawable_list_t::iterator iter = mBuildQ2.begin(); - iter != mBuildQ2.end(); ) - { - LLDrawable::drawable_list_t::iterator curiter = iter++; - LLDrawable* drawablep = *curiter; - - LLSpatialBridge* bridge = drawablep->isRoot() ? drawablep->getSpatialBridge() : - drawablep->getParent()->getSpatialBridge(); - - if (drawablep->getSpatialGroup() != last_group && - (!last_bridge || bridge != last_bridge) && - (update_timer.getElapsedTimeF32() >= max_dtime) && count > min_count) - { - break; - } - - //make sure updates don't stop in the middle of a spatial group - //to avoid thrashing (objects are enqueued by group) - last_group = drawablep->getSpatialGroup(); - last_bridge = bridge; - - bool update_complete = true; - if (!drawablep->isDead()) - { - update_complete = updateDrawableGeom(drawablep, FALSE); - count++; - } - if (update_complete) - { - drawablep->clearState(LLDrawable::IN_REBUILD_Q2); - mBuildQ2.erase(curiter); - } - } updateMovedList(mMovedBridge); } @@ -2992,10 +2846,10 @@ void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags f { if (drawablep && !drawablep->isDead() && assertInitialized()) { - if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1)) + if (!drawablep->isState(LLDrawable::IN_REBUILD_Q)) { mBuildQ1.push_back(drawablep); - drawablep->setState(LLDrawable::IN_REBUILD_Q1); // mark drawable as being in priority queue + drawablep->setState(LLDrawable::IN_REBUILD_Q); // mark drawable as being in priority queue } if (flag & (LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION)) @@ -4837,63 +4691,6 @@ void LLPipeline::renderDebug() } } - if (mRenderDebugMask & LLPipeline::RENDER_DEBUG_BUILD_QUEUE) - { - U32 count = 0; - U32 size = mGroupQ2.size(); - LLColor4 col; - - LLVertexBuffer::unbind(); - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); - - gGL.pushMatrix(); - gGL.loadMatrix(gGLModelView); - gGLLastMatrix = NULL; - - for (LLSpatialGroup::sg_vector_t::iterator iter = mGroupQ2.begin(); iter != mGroupQ2.end(); ++iter) - { - LLSpatialGroup* group = *iter; - if (group->isDead()) - { - continue; - } - - LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge(); - - if (bridge && (!bridge->mDrawable || bridge->mDrawable->isDead())) - { - continue; - } - - if (bridge) - { - gGL.pushMatrix(); - gGL.multMatrix((F32*)bridge->mDrawable->getRenderMatrix().mMatrix); - } - - F32 alpha = llclamp((F32) (size-count)/size, 0.f, 1.f); - - - LLVector2 c(1.f-alpha, alpha); - c.normVec(); - - - ++count; - col.set(c.mV[0], c.mV[1], 0, alpha*0.5f+0.5f); - group->drawObjectBox(col); - - if (bridge) - { - gGL.popMatrix(); - } - } - - gGL.popMatrix(); - } - gGL.flush(); gUIProgram.unbind(); } @@ -5992,11 +5789,7 @@ void LLPipeline::findReferences(LLDrawable *drawablep) { LL_INFOS() << "In mBuildQ1" << LL_ENDL; } - if (std::find(mBuildQ2.begin(), mBuildQ2.end(), drawablep) != mBuildQ2.end()) - { - LL_INFOS() << "In mBuildQ2" << LL_ENDL; - } - + S32 count; count = gObjectList.findReferences(drawablep); -- cgit v1.2.3 From cae8aa6ecf231302653091162aa0e13e06c25696 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 18 May 2023 18:03:17 -0500 Subject: SL-19726 Fix for llTargetOmega on child prim breaking shadow rendering. Incidental decruft. --- indra/newview/pipeline.cpp | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2687ccfae2..40112421cd 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6452,6 +6452,7 @@ void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; + if (rigged) { mSimplePool->pushRiggedBatches(type + 1, texture, batch_texture); @@ -6460,40 +6461,9 @@ void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool { mSimplePool->pushBatches(type, texture, batch_texture); } - gGL.loadMatrix(gGLModelView); - gGLLastMatrix = NULL; -} - -void LLPipeline::renderShadowSimple(U32 type) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - assertInitialized(); - gGL.loadMatrix(gGLModelView); - gGLLastMatrix = NULL; - - LLVertexBuffer* last_vb = nullptr; - - LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); - LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); - - for (LLCullResult::drawinfo_iterator i = begin; i != end; ) - { - LLDrawInfo& params = **i; - - LLCullResult::increment_iterator(i, end); - LLVertexBuffer* vb = params.mVertexBuffer; - if (vb != last_vb) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("push shadow simple"); - mSimplePool->applyModelMatrix(params); - vb->setBuffer(); - vb->drawRange(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); - last_vb = vb; - } - } gGL.loadMatrix(gGLModelView); - gGLLastMatrix = NULL; + gGLLastMatrix = NULL; } // Currently only used for shadows -Cosmic,2023-04-19 @@ -8624,14 +8594,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera for (U32 type : types) { - if (rigged) - { - renderObjects(type, false, false, rigged); - } - else - { - renderShadowSimple(type); - } + renderObjects(type, false, false, rigged); } gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); -- cgit v1.2.3 From 39820e4750d5b9f661ef74ee9868df9e471c5f36 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 18 May 2023 18:41:53 -0500 Subject: DRTVWR-559 Fix for shower curtain not opening smoothly. Incidental decruft. --- indra/newview/pipeline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 40112421cd..715e2a2326 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2457,9 +2457,9 @@ void LLPipeline::doOcclusion(LLCamera& camera) } } -bool LLPipeline::updateDrawableGeom(LLDrawable* drawablep, bool priority) +bool LLPipeline::updateDrawableGeom(LLDrawable* drawablep) { - bool update_complete = drawablep->updateGeometry(priority); + bool update_complete = drawablep->updateGeometry(); if (update_complete && assertInitialized()) { drawablep->setState(LLDrawable::BUILT); @@ -2611,7 +2611,7 @@ void LLPipeline::updateGeom(F32 max_dtime) drawablep->clearState(LLDrawable::FOR_UNLOAD); } - if (updateDrawableGeom(drawablep, TRUE)) + if (updateDrawableGeom(drawablep)) { drawablep->clearState(LLDrawable::IN_REBUILD_Q); mBuildQ1.erase(curiter); -- cgit v1.2.3 From c6fc951f34c665d0f1cd6dcff1bea114fb0ff1a0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 22 May 2023 10:57:35 -0500 Subject: SL-19737 Fix for alpha objects falling off of impostors. --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 715e2a2326..779372b6e5 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9891,7 +9891,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool RENDER_TYPE_TREE, RENDER_TYPE_VOIDWATER, RENDER_TYPE_WATER, - RENDER_TYPE_ALPHA_POST_WATER, + RENDER_TYPE_ALPHA_PRE_WATER, RENDER_TYPE_PASS_GRASS, RENDER_TYPE_HUD, RENDER_TYPE_PARTICLES, -- cgit v1.2.3 From 96eb5f08b1ae5bbf001fac0af1358c703a7f22e5 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 24 May 2023 10:58:39 -0500 Subject: SL-19755 Small tweak to make exposure not start at black. --- indra/newview/pipeline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a49c57ba1e..9a8597e519 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1280,7 +1280,9 @@ void LLPipeline::createLUTBuffers() mExposureMap.allocate(1, 1, GL_R16F); mExposureMap.bindTarget(); + glClearColor(1, 1, 1, 0); mExposureMap.clear(); + glClearColor(0, 0, 0, 0); mExposureMap.flush(); mLuminanceMap.allocate(256, 256, GL_R16F, false, LLTexUnit::TT_TEXTURE, LLTexUnit::TMG_AUTO); -- cgit v1.2.3 From 47e311d6e8b9996de3e0a1ac75c13724ce7735aa Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 26 May 2023 16:56:33 -0700 Subject: Addressing some performance related feedback with SSR getting drastically slower. DRTVWR-559 DRTVWR-583 --- indra/newview/pipeline.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a49c57ba1e..2112993859 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -195,6 +195,7 @@ S32 LLPipeline::RenderScreenSpaceReflectionIterations; F32 LLPipeline::RenderScreenSpaceReflectionRayStep; F32 LLPipeline::RenderScreenSpaceReflectionDistanceBias; F32 LLPipeline::RenderScreenSpaceReflectionDepthRejectBias; +F32 LLPipeline::RenderScreenSpaceReflectionAdaptiveStepMultiplier; S32 LLPipeline::RenderScreenSpaceReflectionGlossySamples; S32 LLPipeline::RenderBufferVisualization; LLTrace::EventStatHandle LLPipeline::sStatBatchSize("renderbatchsize"); @@ -552,7 +553,8 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionRayStep"); connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionDistanceBias"); connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionDepthRejectBias"); - connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionsGlossySamples"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionAdaptiveStepMultiplier"); + connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionGlossySamples"); connectRefreshCachedSettingsSafe("RenderBufferVisualization"); gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); } @@ -1039,6 +1041,7 @@ void LLPipeline::refreshCachedSettings() RenderScreenSpaceReflectionRayStep = gSavedSettings.getF32("RenderScreenSpaceReflectionRayStep"); RenderScreenSpaceReflectionDistanceBias = gSavedSettings.getF32("RenderScreenSpaceReflectionDistanceBias"); RenderScreenSpaceReflectionDepthRejectBias = gSavedSettings.getF32("RenderScreenSpaceReflectionDepthRejectBias"); + RenderScreenSpaceReflectionAdaptiveStepMultiplier = gSavedSettings.getF32("RenderScreenSpaceReflectionAdaptiveStepMultiplier"); RenderScreenSpaceReflectionGlossySamples = gSavedSettings.getS32("RenderScreenSpaceReflectionGlossySamples"); RenderBufferVisualization = gSavedSettings.getS32("RenderBufferVisualization"); sReflectionProbesEnabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionsEnabled") && gSavedSettings.getBOOL("RenderReflectionsEnabled"); @@ -8421,6 +8424,13 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) shader.uniform1f(LLShaderMgr::DEFERRED_SSR_RAY_STEP, RenderScreenSpaceReflectionRayStep); shader.uniform1f(LLShaderMgr::DEFERRED_SSR_GLOSSY_SAMPLES, RenderScreenSpaceReflectionGlossySamples); shader.uniform1f(LLShaderMgr::DEFERRED_SSR_REJECT_BIAS, RenderScreenSpaceReflectionDepthRejectBias); + mPoissonOffset++; + + if (mPoissonOffset > 128 - RenderScreenSpaceReflectionGlossySamples) + mPoissonOffset = 0; + + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_NOISE_SINE, mPoissonOffset); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_ADAPTIVE_STEP_MULT, RenderScreenSpaceReflectionAdaptiveStepMultiplier); channel = shader.enableTexture(LLShaderMgr::SCENE_DEPTH); if (channel > -1) -- cgit v1.2.3 From 50ec54831de88926ca13c9a72d89006ceda6c355 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 1 Jun 2023 19:49:23 -0500 Subject: DRTVWR-559 Revert skies to be very close to release and disable tone mapping when probe ambiance is zero. Hack for desaturating legacy materials has been removed for performance and quality reasons. Adds a new setting for auto adjusting legacy skies. This is the PBR "opt out" button. If disabled, legacy skies will disable tonemapping, automatic probe ambiance, and HDR/exposure. If enabled, legacy skies will behave as if probe ambiance and HDR scale are 1.0, and ambient will be cut in half. HDR scale will act as a sky brightener, but will automatically adjust dynamic exposure so the sky will be properly exposed. If you want relatively even exposure all the time, set HDR Scale to 1.0. If you want a high range of exposures between indoor/dark areas and outdoor/bright areas, increase HDR Scale. Also tuned up SSAO (thanks Rye!). Reviewed with Brad. --- indra/newview/pipeline.cpp | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9a8597e519..852845edf4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6751,22 +6751,25 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst) { static LLStaticHashedString noiseVec("noiseVec"); static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); static LLCachedControl dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); - static LLCachedControl dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); - static LLCachedControl dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); - - F32 exposure_max = dynamic_exposure_max; LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - if (sky->getReflectionProbeAmbiance() > 0.f) - { //not a legacy sky, use gamma as a boost to max exposure - exposure_max = llmax(exposure_max - 1.f, 0.f); - exposure_max *= sky->getGamma(); - exposure_max += 1.f; - } + F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(); + F32 exp_min = 1.f; + F32 exp_max = 1.f; + + if (probe_ambiance > 0.f) + { + F32 hdr_scale = sqrtf(LLEnvironment::instance().getCurrentSky()->getGamma())*2.f; + if (hdr_scale > 1.f) + { + exp_min = 1.f / hdr_scale; + exp_max = hdr_scale; + } + } gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); - gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, exposure_max); + gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -6789,8 +6792,12 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { // Apply gamma correction to the frame here. + static LLCachedControl should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLGLSLShader& shader = no_post && gFloaterTools->isAvailable() ? gNoPostGammaCorrectProgram : // no post (no gamma, no exposure, no tonemapping) - LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance() == 0.f ? gLegacyPostGammaCorrectProgram : + psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f ? gLegacyPostGammaCorrectProgram : gDeferredPostGammaCorrectProgram; shader.bind(); @@ -7846,14 +7853,18 @@ void LLPipeline::renderDeferredLighting() LL_PROFILE_GPU_ZONE("atmospherics"); bindDeferredShader(soften_shader); - static LLCachedControl sky_scale(gSavedSettings, "RenderSkyHDRScale", 1.f); - static LLStaticHashedString sky_hdr_scale("sky_hdr_scale"); + static LLCachedControl ssao_scale(gSavedSettings, "RenderSSAOIrradianceScale", 0.5f); + static LLCachedControl ssao_max(gSavedSettings, "RenderSSAOIrradianceMax", 0.25f); + static LLStaticHashedString ssao_scale_str("ssao_irradiance_scale"); + static LLStaticHashedString ssao_max_str("ssao_irradiance_max"); + + soften_shader.uniform1f(ssao_scale_str, ssao_scale); + soften_shader.uniform1f(ssao_max_str, ssao_max); LLEnvironment &environment = LLEnvironment::instance(); soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); - soften_shader.uniform1f(sky_hdr_scale, sky_scale); - + soften_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); { -- cgit v1.2.3 From 8359c618fca10f4920c4f2572863b2426dbceabc Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 2 Jun 2023 11:54:47 -0500 Subject: DRTVWR-559 Add missed "should override" check (thanks, Rye!) --- indra/newview/pipeline.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 852845edf4..a41bed9186 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6751,9 +6751,11 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst) { static LLStaticHashedString noiseVec("noiseVec"); static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); static LLCachedControl dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); + static LLCachedControl should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true); + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(); + F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust); F32 exp_min = 1.f; F32 exp_max = 1.f; -- cgit v1.2.3 From 3305fbe1cf5fe3faa6dc5479aa29e6c891ee943f Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 14 Jun 2023 17:26:30 -0500 Subject: SL-19838 Fix for transparent PBR materials always casting shadows. --- indra/newview/pipeline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a41bed9186..c88b8b42ff 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6514,7 +6514,7 @@ void LLPipeline::renderAlphaObjects(bool rigged) { if (pparams->mGLTFMaterial) { - gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + gDeferredShadowGLTFAlphaBlendProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); @@ -6540,7 +6540,7 @@ void LLPipeline::renderAlphaObjects(bool rigged) { if (pparams->mGLTFMaterial) { - gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + gDeferredShadowGLTFAlphaBlendProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF); -- cgit v1.2.3 From 22f83b3436129e3198fcdd24ccb30baf253955c7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 15 Jun 2023 09:01:39 -0700 Subject: Add missing variable initialization, and make water support glossy SSR again. SL-19784 --- indra/newview/pipeline.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 147d87e0a4..6847a679f1 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -335,6 +335,7 @@ LLPipeline::LLPipeline() : mTextureMatrixOps(0), mNumVisibleNodes(0), mNumVisibleFaces(0), + mPoissonOffset(0), mInitialized(false), mShadersLoaded(false), -- cgit v1.2.3 From 22eecf1018d8adbf214b9f1072b3cd6d3ab3d5ae Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 23 Jun 2023 11:46:09 -0500 Subject: SL-19897 Fix for 100% transparent objects not showing up in highlight transparent until LoD switch. --- indra/newview/pipeline.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 38f27d4dfa..e64ef6d555 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10593,8 +10593,36 @@ void LLPipeline::handleShadowDetailChanged() } } -void LLPipeline::overrideEnvironmentMap() +class LLOctreeDirty : public OctreeTraveler { - //mReflectionMapManager.mProbes.clear(); - //mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); +public: + virtual void visit(const OctreeNode* state) + { + LLSpatialGroup* group = (LLSpatialGroup*)state->getListener(0); + + group->setState(LLSpatialGroup::GEOM_DIRTY); + gPipeline.markRebuild(group); + + for (LLSpatialGroup::bridge_list_t::iterator i = group->mBridgeList.begin(); i != group->mBridgeList.end(); ++i) + { + LLSpatialBridge* bridge = *i; + traverse(bridge->mOctree); + } + } +}; + + +void LLPipeline::rebuildDrawInfo() +{ + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); + iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + { + LLViewerRegion* region = *iter; + + LLOctreeDirty dirty; + + LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME); + dirty.traverse(part->mOctree); + } } + -- cgit v1.2.3 From 298109864503d9c1e00d41dd1556f9dfea988e14 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 27 Jun 2023 14:01:42 -0500 Subject: SL-19897 Followup -- handle 100% transparent objects that are "active" --- indra/newview/pipeline.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e64ef6d555..0c767e7767 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10600,8 +10600,11 @@ public: { LLSpatialGroup* group = (LLSpatialGroup*)state->getListener(0); - group->setState(LLSpatialGroup::GEOM_DIRTY); - gPipeline.markRebuild(group); + if (group->getSpatialPartition()->mRenderByGroup) + { + group->setState(LLSpatialGroup::GEOM_DIRTY); + gPipeline.markRebuild(group); + } for (LLSpatialGroup::bridge_list_t::iterator i = group->mBridgeList.begin(); i != group->mBridgeList.end(); ++i) { @@ -10623,6 +10626,9 @@ void LLPipeline::rebuildDrawInfo() LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME); dirty.traverse(part->mOctree); + + part = region->getSpatialPartition(LLViewerRegion::PARTITION_BRIDGE); + dirty.traverse(part->mOctree); } } -- cgit v1.2.3 From afcb421bdc666d9b45fb5adb7098b7e433042823 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 6 Jul 2023 12:53:42 -0700 Subject: SL-19567: (WIP) Add options to use higher precision for glow and post-process buffers. Disabled by default. --- indra/newview/pipeline.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0c767e7767..4183990261 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -840,7 +840,9 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mSceneMap.allocate(resX, resY, GL_RGB, true); } - mPostMap.allocate(resX, resY, GL_RGBA); + const bool post_hdr = gSavedSettings.getBOOL("RenderPostProcessingHDR"); + const U32 post_color_fmt = post_hdr ? GL_RGBA16F : GL_RGBA; + mPostMap.allocate(resX, resY, post_color_fmt); //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) @@ -1163,9 +1165,11 @@ void LLPipeline::createGLBuffers() // allocate screen space glow buffers const U32 glow_res = llmax(1, llmin(512, 1 << gSavedSettings.getS32("RenderGlowResolutionPow"))); + const bool glow_hdr = gSavedSettings.getBOOL("RenderGlowHDR"); + const U32 glow_color_fmt = glow_hdr ? GL_RGBA16F : GL_RGBA; for (U32 i = 0; i < 3; i++) { - mGlow[i].allocate(512, glow_res, GL_RGBA); + mGlow[i].allocate(512, glow_res, glow_color_fmt); } allocateScreenBuffer(resX, resY); -- cgit v1.2.3 From 66283201301b0e55336f4b20407fed811acdc739 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 11 Jul 2023 09:51:14 -0700 Subject: SL-19567: Add option RenderGlowNoise for low precision glow dithering, enabled by default --- indra/newview/pipeline.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4183990261..d50e671e05 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -157,6 +157,7 @@ S32 LLPipeline::RenderGlowResolutionPow; S32 LLPipeline::RenderGlowIterations; F32 LLPipeline::RenderGlowWidth; F32 LLPipeline::RenderGlowStrength; +bool LLPipeline::RenderGlowNoise; bool LLPipeline::RenderDepthOfField; bool LLPipeline::RenderDepthOfFieldInEditMode; F32 LLPipeline::CameraFocusTransitionTime; @@ -517,6 +518,7 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderGlowIterations"); connectRefreshCachedSettingsSafe("RenderGlowWidth"); connectRefreshCachedSettingsSafe("RenderGlowStrength"); + connectRefreshCachedSettingsSafe("RenderGlowNoise"); connectRefreshCachedSettingsSafe("RenderDepthOfField"); connectRefreshCachedSettingsSafe("RenderDepthOfFieldInEditMode"); connectRefreshCachedSettingsSafe("CameraFocusTransitionTime"); @@ -1007,6 +1009,7 @@ void LLPipeline::refreshCachedSettings() RenderGlowIterations = gSavedSettings.getS32("RenderGlowIterations"); RenderGlowWidth = gSavedSettings.getF32("RenderGlowWidth"); RenderGlowStrength = gSavedSettings.getF32("RenderGlowStrength"); + RenderGlowNoise = gSavedSettings.getBOOL("RenderGlowNoise"); RenderDepthOfField = gSavedSettings.getBOOL("RenderDepthOfField"); RenderDepthOfFieldInEditMode = gSavedSettings.getBOOL("RenderDepthOfFieldInEditMode"); CameraFocusTransitionTime = gSavedSettings.getF32("CameraFocusTransitionTime"); @@ -6886,6 +6889,19 @@ void LLPipeline::generateGlow(LLRenderTarget* src) warmthWeights.mV[2]); gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); + if (RenderGlowNoise) + { + S32 channel = gGlowExtractProgram.enableTexture(LLShaderMgr::GLOW_NOISE_MAP); + if (channel > -1) + { + gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + gGlowExtractProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, + mGlow[2].getWidth(), + mGlow[2].getHeight()); + } + { LLGLEnable blend_on(GL_BLEND); -- cgit v1.2.3 From c85bb7846d270ba23c447c1b0073cd238d5fd1bc Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 19 Jul 2023 12:52:36 -0500 Subject: DRTVWR-559 Fix for shadows not respecting double sided on opaque PBR surfaces --- indra/newview/pipeline.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d50e671e05..1402591015 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6494,6 +6494,25 @@ void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool gGLLastMatrix = NULL; } +void LLPipeline::renderGLTFObjects(U32 type, bool texture, bool rigged) +{ + assertInitialized(); + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + + if (rigged) + { + mSimplePool->pushRiggedGLTFBatches(type + 1, texture); + } + else + { + mSimplePool->pushGLTFBatches(type, texture); + } + + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; +} + // Currently only used for shadows -Cosmic,2023-04-19 void LLPipeline::renderAlphaObjects(bool rigged) { @@ -8601,8 +8620,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderPass::PASS_NORMMAP, LLRenderPass::PASS_NORMMAP_EMISSIVE, LLRenderPass::PASS_NORMSPEC, - LLRenderPass::PASS_NORMSPEC_EMISSIVE, - LLRenderPass::PASS_GLTF_PBR + LLRenderPass::PASS_NORMSPEC_EMISSIVE }; LLGLEnable cull(GL_CULL_FACE); @@ -8665,6 +8683,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderObjects(type, false, false, rigged); } + renderGLTFObjects(LLRenderPass::PASS_GLTF_PBR, false, rigged); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); } -- cgit v1.2.3 From b67172aa12be4a37c83042437844747ff0e02e34 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 21 Jul 2023 15:46:12 -0500 Subject: SL-20010 Make reflection probes ignore touch actions. --- indra/newview/pipeline.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1402591015..1b4c8f65a6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6223,7 +6223,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, face_hit, &position, NULL, NULL, NULL); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, FALSE, face_hit, &position, NULL, NULL, NULL); if (hit) { drawable = hit; @@ -6252,6 +6252,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, bool pick_transparent, bool pick_rigged, bool pick_unselectable, + bool pick_reflection_probe, S32* face_hit, LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -6285,7 +6286,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(j); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, &position, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -6342,7 +6343,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, &position, tex_coord, normal, tangent); if (hit) { LLVector4a delta; @@ -6430,7 +6431,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, FALSE, face_hit, intersection, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7165,7 +7166,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) LLVector4a result; result.clear(); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, TRUE, NULL, &result); focus_point.set(result.getF32ptr()); } -- cgit v1.2.3 From d8872d5273b5cc952f692d970f19db90588a1508 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 26 Jul 2023 21:30:24 +0300 Subject: SL-18720 getDataBegin() and stateSort() crashes No repro, but likely cause is in mOctreeNode being NULL. Marked octree group as dead when destroyed and added isDead verification --- indra/newview/pipeline.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1b4c8f65a6..1620b1ff4c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2466,8 +2466,11 @@ void LLPipeline::doOcclusion(LLCamera& camera) for (LLCullResult::sg_iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter) { LLSpatialGroup* group = *iter; - group->doOcclusion(&camera); - group->clearOcclusionState(LLSpatialGroup::ACTIVE_OCCLUSION); + if (!group->isDead()) + { + group->doOcclusion(&camera); + group->clearOcclusionState(LLSpatialGroup::ACTIVE_OCCLUSION); + } } //apply occlusion culling to object cache tree @@ -2912,6 +2915,10 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter) { LLSpatialGroup* group = *iter; + if (group->isDead()) + { + continue; + } group->checkOcclusion(); if (sUseOcclusion > 1 && group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { @@ -2971,6 +2978,10 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) { LLSpatialGroup* group = *iter; + if (group->isDead()) + { + continue; + } group->checkOcclusion(); if (sUseOcclusion > 1 && group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { @@ -3130,7 +3141,12 @@ void forAllDrawables(LLCullResult::sg_iterator begin, { for (LLCullResult::sg_iterator i = begin; i != end; ++i) { - for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j) + LLSpatialGroup* group = *i; + if (group->isDead()) + { + continue; + } + for (LLSpatialGroup::element_iter j = group->getDataBegin(); j != group->getDataEnd(); ++j) { if((*j)->hasDrawable()) { @@ -3339,6 +3355,10 @@ void LLPipeline::postSort(LLCamera &camera) for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) { LLSpatialGroup *group = *i; + if (group->isDead()) + { + continue; + } if (!sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { group->rebuildGeom(); @@ -3357,6 +3377,12 @@ void LLPipeline::postSort(LLCamera &camera) for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) { LLSpatialGroup *group = *i; + + if (group->isDead()) + { + continue; + } + if ((sUseOcclusion && group->isOcclusionState(LLSpatialGroup::OCCLUDED)) || (RenderAutoHideSurfaceAreaLimit > 0.f && group->mSurfaceArea > RenderAutoHideSurfaceAreaLimit * llmax(group->mObjectBoxSize, 10.f))) -- cgit v1.2.3 From 894c9e0417e7b29aaf31c673ca040dff93eb36ef Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 22 Aug 2023 13:17:58 -0500 Subject: SL-19842 WIP -- Move sky auto adjustment magic numbers to debug settings. --- indra/newview/pipeline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1620b1ff4c..0b5908a440 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7730,8 +7730,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } - shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + //shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); + //shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); shader.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mReflectionMapManager.mMaxProbeLOD); } -- cgit v1.2.3 From 2ce27627a18787113c1b9a1fd99b5a516d693a8c Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 30 Aug 2023 11:20:11 -0500 Subject: SL-19842 Followup -- fix sunlight going black and make automatic object probes more wishy-washy (removes dark splotches where probes get stuck in walls) --- indra/newview/pipeline.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0b5908a440..78d4e65d42 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7730,8 +7730,18 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } - //shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - //shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + // auto adjust legacy sun color if needed + static LLCachedControl should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true); + static LLCachedControl auto_adjust_sun_color_scale(gSavedSettings, "RenderSkyAutoAdjustSunColorScale", 1.f); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLColor3 sun_diffuse(mSunDiffuse.mV); + if (should_auto_adjust && psky->canAutoAdjust()) + { + sun_diffuse *= auto_adjust_sun_color_scale; + } + + shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sun_diffuse.mV); + shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); shader.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mReflectionMapManager.mMaxProbeLOD); } -- cgit v1.2.3 From a1a32edf52365415f35cea26b26c011fc4d35984 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 4 Oct 2023 15:41:44 -0500 Subject: SL-20141 Remove "Local Lights" checkbox and instead make the number of lights rendered scale with the "Quality & speed" slider --- indra/newview/pipeline.cpp | 107 ++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 79 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 78d4e65d42..9266c84540 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -130,7 +130,6 @@ S32 LLPipeline::RenderShadowDetail; S32 LLPipeline::RenderShadowSplits; bool LLPipeline::RenderDeferredSSAO; F32 LLPipeline::RenderShadowResolutionScale; -bool LLPipeline::RenderLocalLights; bool LLPipeline::RenderDelayCreation; bool LLPipeline::RenderAnimateRes; bool LLPipeline::FreezeTime; @@ -349,8 +348,7 @@ LLPipeline::LLPipeline() : mResetVertexBuffers(false), mLastRebuildPool(NULL), mLightMask(0), - mLightMovingMask(0), - mLightingDetail(0) + mLightMovingMask(0) { mNoiseMap = 0; mTrueNoiseMap = 0; @@ -471,8 +469,6 @@ void LLPipeline::init() mScreenTriangleVB->unmapBuffer(); } - setLightingDetail(-1); - // // Update all settings to trigger a cached settings refresh // @@ -491,7 +487,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderShadowSplits"); connectRefreshCachedSettingsSafe("RenderDeferredSSAO"); connectRefreshCachedSettingsSafe("RenderShadowResolutionScale"); - connectRefreshCachedSettingsSafe("RenderLocalLights"); connectRefreshCachedSettingsSafe("RenderDelayCreation"); connectRefreshCachedSettingsSafe("RenderAnimateRes"); connectRefreshCachedSettingsSafe("FreezeTime"); @@ -982,7 +977,6 @@ void LLPipeline::refreshCachedSettings() RenderShadowSplits = gSavedSettings.getS32("RenderShadowSplits"); RenderDeferredSSAO = gSavedSettings.getBOOL("RenderDeferredSSAO"); RenderShadowResolutionScale = gSavedSettings.getF32("RenderShadowResolutionScale"); - RenderLocalLights = gSavedSettings.getBOOL("RenderLocalLights"); RenderDelayCreation = gSavedSettings.getBOOL("RenderDelayCreation"); RenderAnimateRes = gSavedSettings.getBOOL("RenderAnimateRes"); FreezeTime = gSavedSettings.getBOOL("FreezeTime"); @@ -1356,39 +1350,6 @@ void LLPipeline::enableShadows(const bool enable_shadows) //should probably do something here to wrangle shadows.... } -S32 LLPipeline::getMaxLightingDetail() const -{ - /*if (mShaderLevel[SHADER_OBJECT] >= LLDrawPoolSimple::SHADER_LEVEL_LOCAL_LIGHTS) - { - return 3; - } - else*/ - { - return 1; - } -} - -S32 LLPipeline::setLightingDetail(S32 level) -{ - refreshCachedSettings(); - - if (level < 0) - { - if (RenderLocalLights) - { - level = 1; - } - else - { - level = 0; - } - } - level = llclamp(level, 0, getMaxLightingDetail()); - mLightingDetail = level; - - return mLightingDetail; -} - class LLOctreeDirtyTexture : public OctreeTraveler { public: @@ -5251,7 +5212,9 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) return; } - if (mLightingDetail >= 1) + static LLCachedControl local_light_count(gSavedSettings, "RenderLocalLightCount", 256); + + if (local_light_count >= 1) { // mNearbyLight (and all light_set_t's) are sorted such that // begin() == the closest light and rbegin() == the farthest light @@ -5518,7 +5481,9 @@ void LLPipeline::setupHWLights() mLightMovingMask = 0; - if (mLightingDetail >= 1) + static LLCachedControl local_light_count(gSavedSettings, "RenderLocalLightCount", 256); + + if (local_light_count >= 1) { for (light_set_t::iterator iter = mNearbyLights.begin(); iter != mNearbyLights.end(); ++iter) @@ -5661,10 +5626,6 @@ void LLPipeline::enableLights(U32 mask) { assertInitialized(); - if (mLightingDetail == 0) - { - mask &= 0xf003; // sun and backlight only (and fullbright bit) - } if (mLightMask != mask) { stop_glerror(); @@ -5692,28 +5653,13 @@ void LLPipeline::enableLights(U32 mask) } } -void LLPipeline::enableLightsStatic() -{ - assertInitialized(); - U32 mask = 0x01; // Sun - if (mLightingDetail >= 2) - { - mask |= mLightMovingMask; // Hardware moving lights - } - else - { - mask |= 0xff & (~2); // Hardware local lights - } - enableLights(mask); -} - void LLPipeline::enableLightsDynamic() { assertInitialized(); U32 mask = 0xff & (~2); // Local lights enableLights(mask); - if (isAgentAvatarValid() && getLightingDetail() <= 0) + if (isAgentAvatarValid()) { if (gAgentAvatarp->mSpecialRenderMode == 0) // normal { @@ -7961,9 +7907,9 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); } - bool render_local = RenderLocalLights; // && !gCubeSnapshot; + static LLCachedControl local_light_count(gSavedSettings, "RenderLocalLightCount", 256); - if (render_local) + if (local_light_count > 0) { gGL.setSceneBlendType(LLRender::BT_ADD); std::list fullscreen_lights; @@ -7998,8 +7944,15 @@ void LLPipeline::renderDeferredLighting() // mNearbyLights already includes distance calculation and excludes muted avatars. // It is calculated from mLights // mNearbyLights also provides fade value to gracefully fade-out out of range lights + S32 count = 0; for (light_set_t::iterator iter = mNearbyLights.begin(); iter != mNearbyLights.end(); ++iter) { + count++; + if (count > local_light_count) + { //stop collecting lights once we hit the limit + break; + } + LLDrawable * drawablep = iter->drawable; LLVOVolume * volume = drawablep->getVOVolume(); if (!volume) @@ -8046,24 +7999,20 @@ void LLPipeline::renderDeferredLighting() camera->getOrigin().mV[1] > c[1] + s + 0.2f || camera->getOrigin().mV[1] < c[1] - s - 0.2f || camera->getOrigin().mV[2] > c[2] + s + 0.2f || camera->getOrigin().mV[2] < c[2] - s - 0.2f) { // draw box if camera is outside box - if (render_local) + if (volume->isLightSpotlight()) { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - spot_lights.push_back(drawablep); - continue; - } + drawablep->getVOVolume()->updateSpotLightPriority(); + spot_lights.push_back(drawablep); + continue; + } - gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); - gGL.syncMatrices(); + gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); + gGL.syncMatrices(); - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - stop_glerror(); - } + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); } else { -- cgit v1.2.3 From bdb53fd56d56c659941e7e63f83cefc366acef6d Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 16 Nov 2023 16:46:12 -0600 Subject: SL-20611 Make haze effect local lights -- move sky and water haze to their own passes and unify sky and water haze in forward rendering shaders. --- indra/newview/pipeline.cpp | 66 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 11 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9266c84540..52afe16799 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7875,7 +7875,7 @@ void LLPipeline::renderDeferredLighting() if (RenderDeferredAtmospheric) { // apply sunlight contribution - LLGLSLShader &soften_shader = LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram; + LLGLSLShader &soften_shader = gDeferredSoftenProgram; LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - atmospherics"); LL_PROFILE_GPU_ZONE("atmospherics"); @@ -7904,7 +7904,7 @@ void LLPipeline::renderDeferredLighting() mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } - unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); + unbindDeferredShader(gDeferredSoftenProgram); } static LLCachedControl local_light_count(gSavedSettings, "RenderLocalLightCount", 256); @@ -8056,7 +8056,7 @@ void LLPipeline::renderDeferredLighting() LLVector4a center; center.load3(drawablep->getPositionAgent().mV); - const F32 *c = center.getF32ptr(); + const F32* c = center.getF32ptr(); F32 s = volume->getLightRadius() * 1.5f; sVisibleLightCount++; @@ -8105,8 +8105,8 @@ void LLPipeline::renderDeferredLighting() U32 idx = count - 1; bindDeferredShader(gDeferredMultiLightProgram[idx]); gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat *) light); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat *) col); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*)light); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*)col); gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; @@ -8124,11 +8124,11 @@ void LLPipeline::renderDeferredLighting() for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) { - LLDrawable *drawablep = *iter; - LLVOVolume *volume = drawablep->getVOVolume(); - LLVector3 center = drawablep->getPositionAgent(); - F32 * c = center.mV; - F32 light_size_final = volume->getLightRadius() * 1.5f; + LLDrawable* drawablep = *iter; + LLVOVolume* volume = drawablep->getVOVolume(); + LLVector3 center = drawablep->getPositionAgent(); + F32* c = center.mV; + F32 light_size_final = volume->getLightRadius() * 1.5f; F32 light_falloff_final = volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF); sVisibleLightCount++; @@ -8154,12 +8154,56 @@ void LLPipeline::renderDeferredLighting() } + + if (RenderDeferredAtmospheric) + { + LLGLEnable blend(GL_BLEND); + gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA); + gGL.setColorMask(true, false); + + for (U32 i = 0; i < 2; ++i) + { + // apply haze + LLGLSLShader &haze_shader = i == 0 ? gHazeProgram : gHazeWaterProgram; + + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - haze"); + LL_PROFILE_GPU_ZONE("haze"); + bindDeferredShader(haze_shader); + + static LLCachedControl ssao_scale(gSavedSettings, "RenderSSAOIrradianceScale", 0.5f); + static LLCachedControl ssao_max(gSavedSettings, "RenderSSAOIrradianceMax", 0.25f); + static LLStaticHashedString ssao_scale_str("ssao_irradiance_scale"); + static LLStaticHashedString ssao_max_str("ssao_irradiance_max"); + + haze_shader.uniform1f(ssao_scale_str, ssao_scale); + haze_shader.uniform1f(ssao_max_str, ssao_max); + + LLEnvironment &environment = LLEnvironment::instance(); + haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + haze_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + + haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); + + { + LLGLDepthTest depth(GL_FALSE); + + // full screen blit + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + unbindDeferredShader(haze_shader); + } + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + } + + gGL.setColorMask(true, true); } { // render non-deferred geometry (alpha, fullbright, glow) LLGLDisable blend(GL_BLEND); - //LLGLDisable stencil(GL_STENCIL_TEST); pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, -- cgit v1.2.3 From 70eda83fb08c5c4e8b0ea95868243d744c6e88e9 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 20 Nov 2023 21:25:06 +0100 Subject: SL-20563 Add 'No Post' option to Snapshot floater --- indra/newview/pipeline.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9266c84540..64d247a202 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -211,6 +211,7 @@ extern S32 gBoxFrame; extern BOOL gDisplaySwapBuffers; extern BOOL gDebugGL; extern BOOL gCubeSnapshot; +extern BOOL gSnapshotNoPost; bool gAvatarBacklight = false; @@ -6791,7 +6792,7 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { { LL_PROFILE_GPU_ZONE("gamma correct"); - static LLCachedControl no_post(gSavedSettings, "RenderDisablePostProcessing", false); + static LLCachedControl buildNoPost(gSavedSettings, "RenderDisablePostProcessing", false); LLGLDepthTest depth(GL_FALSE, GL_FALSE); @@ -6801,7 +6802,8 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLGLSLShader& shader = no_post && gFloaterTools->isAvailable() ? gNoPostGammaCorrectProgram : // no post (no gamma, no exposure, no tonemapping) + bool no_post = gSnapshotNoPost || (buildNoPost && gFloaterTools->isAvailable()); + LLGLSLShader& shader = no_post ? gNoPostGammaCorrectProgram : // no post (no gamma, no exposure, no tonemapping) psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f ? gLegacyPostGammaCorrectProgram : gDeferredPostGammaCorrectProgram; -- cgit v1.2.3 From 68875523e09f9fe06fc4b3cd5225995bb13966c3 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 30 Nov 2023 12:01:45 -0600 Subject: SL-20611 Incorporate water haze into new post effect atmospherics goodness --- indra/newview/pipeline.cpp | 156 ++++++++++++++++++++++++++++++++------------- 1 file changed, 110 insertions(+), 46 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 52afe16799..7b1e5a55d1 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3877,6 +3877,20 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LLGLEnable cull(GL_CULL_FACE); + bool done_atmospherics = LLPipeline::sRenderingHUDs; //skip atmospherics on huds + bool done_water_haze = done_atmospherics; + + // do atmospheric haze just before post water alpha + U32 atmospherics_pass = LLDrawPool::POOL_ALPHA_POST_WATER; + + if (LLPipeline::sUnderWaterRender) + { // if under water, do atmospherics just before the water pass + atmospherics_pass = LLDrawPool::POOL_WATER; + } + + // do water haze just before pre water alpha + U32 water_haze_pass = LLDrawPool::POOL_ALPHA_PRE_WATER; + calcNearbyLights(camera); setupHWLights(); @@ -3896,6 +3910,18 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) cur_type = poolp->getType(); + if (cur_type >= atmospherics_pass && !done_atmospherics) + { // do atmospherics against depth buffer before rendering alpha + doAtmospherics(); + done_atmospherics = true; + } + + if (cur_type >= water_haze_pass && !done_water_haze) + { // do water haze against depth buffer before rendering alpha + doWaterHaze(); + done_water_haze = true; + } + pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0) { @@ -8153,52 +8179,6 @@ void LLPipeline::renderDeferredLighting() } } - - - if (RenderDeferredAtmospheric) - { - LLGLEnable blend(GL_BLEND); - gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA); - gGL.setColorMask(true, false); - - for (U32 i = 0; i < 2; ++i) - { - // apply haze - LLGLSLShader &haze_shader = i == 0 ? gHazeProgram : gHazeWaterProgram; - - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - haze"); - LL_PROFILE_GPU_ZONE("haze"); - bindDeferredShader(haze_shader); - - static LLCachedControl ssao_scale(gSavedSettings, "RenderSSAOIrradianceScale", 0.5f); - static LLCachedControl ssao_max(gSavedSettings, "RenderSSAOIrradianceMax", 0.25f); - static LLStaticHashedString ssao_scale_str("ssao_irradiance_scale"); - static LLStaticHashedString ssao_max_str("ssao_irradiance_max"); - - haze_shader.uniform1f(ssao_scale_str, ssao_scale); - haze_shader.uniform1f(ssao_max_str, ssao_max); - - LLEnvironment &environment = LLEnvironment::instance(); - haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - haze_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); - - haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); - - { - LLGLDepthTest depth(GL_FALSE); - - // full screen blit - mScreenTriangleVB->setBuffer(); - mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - unbindDeferredShader(haze_shader); - } - - gGL.setSceneBlendType(LLRender::BT_ALPHA); - } - - gGL.setColorMask(true, true); } @@ -8254,6 +8234,90 @@ void LLPipeline::renderDeferredLighting() gGL.setColorMask(true, true); } +void LLPipeline::doAtmospherics() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + + if (RenderDeferredAtmospheric) + { + LLGLEnable blend(GL_BLEND); + gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); + + gGL.setColorMask(true, true); + + // apply haze + LLGLSLShader& haze_shader = gHazeProgram; + + LL_PROFILE_GPU_ZONE("haze"); + bindDeferredShader(haze_shader); + + LLEnvironment& environment = LLEnvironment::instance(); + haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + haze_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + + haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); + + LLGLDepthTest depth(GL_FALSE); + + // full screen blit + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(haze_shader); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + } +} + +void LLPipeline::doWaterHaze() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + + if (RenderDeferredAtmospheric) + { + LLGLEnable blend(GL_BLEND); + gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); + + gGL.setColorMask(true, true); + + // apply haze + LLGLSLShader& haze_shader = gHazeWaterProgram; + + LL_PROFILE_GPU_ZONE("haze"); + bindDeferredShader(haze_shader); + + haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); + + static LLStaticHashedString above_water_str("above_water"); + haze_shader.uniform1i(above_water_str, sUnderWaterRender ? -1 : 1); + + if (LLPipeline::sUnderWaterRender) + { + LLGLDepthTest depth(GL_FALSE); + + // full screen blit + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + else + { + //render water patches like LLDrawPoolWater does + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); + LLGLDisable cull(GL_CULL_FACE); + + gGLLastMatrix = NULL; + gGL.loadMatrix(gGLModelView); + + mWaterPool->pushFaceGeometry(); + } + + unbindDeferredShader(haze_shader); + + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + } +} + void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) { //construct frustum -- cgit v1.2.3 From c573d27e5baf23adbc14153c4d65a581f55febb4 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 1 Dec 2023 14:49:22 -0600 Subject: SL-20611 Followup -- fix for water rendering twice. Add comments around LLEventPoll hack. --- indra/newview/pipeline.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 76414b5e4e..50cd4adb73 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2311,13 +2311,6 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result) gSky.mVOWLSkyp->mDrawable->setVisible(camera); sCull->pushDrawable(gSky.mVOWLSkyp->mDrawable); } - - bool render_water = !sReflectionRender && (hasRenderType(LLPipeline::RENDER_TYPE_WATER) || hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER)); - - if (render_water) - { - LLWorld::getInstance()->precullWaterObjects(camera, sCull, render_water); - } } void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) -- cgit v1.2.3 From c28eb36a2c09f31f491676c8548dfa1c19277ce2 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 5 Dec 2023 19:50:25 -0600 Subject: SL-20654 Fix for box probes sometimes glitching out at the corners. Incidental fix for crash when mWaterPool is null. --- indra/newview/pipeline.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 50cd4adb73..bf4f0083ff 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8303,7 +8303,10 @@ void LLPipeline::doWaterHaze() gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - mWaterPool->pushFaceGeometry(); + if (mWaterPool) + { + mWaterPool->pushFaceGeometry(); + } } unbindDeferredShader(haze_shader); -- cgit v1.2.3 From a27740bbb2da04b14016de1398178df4fb970bcd Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 27 Nov 2023 17:59:16 +0100 Subject: SL-19655 BugSplat Crash: LLGLState::checkStates (2427) --- indra/newview/pipeline.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bf4f0083ff..f8812d9750 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3821,10 +3821,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) poolp->endDeferredPass(i); LLVertexBuffer::unbind(); - if (gDebugGL || gDebugPipeline) - { - LLGLState::checkStates(); - } + LLGLState::checkStates(); } } else -- cgit v1.2.3 From d05b80817b4c7ada2b3934f0d8c814fc67c50c8e Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 6 Dec 2023 10:33:32 -0600 Subject: SL-20611 Followup -- fix banding in water fog (thanks, Rye!) --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bf4f0083ff..8c3cf09098 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -789,7 +789,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (LLPipeline::sRenderTransparentWater) { //water reflection texture - mWaterDis.allocate(resX, resY, GL_RGBA, true); + mWaterDis.allocate(resX, resY, GL_RGBA16F, true); } if (RenderUIBuffer) -- cgit v1.2.3 From f3b87145775d3803306036d1e31fa39177f2600e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 11 Dec 2023 15:28:25 -0600 Subject: SL-20611 Followup -- fix for artifacts on water surface from GPUs that don't like to read from a depth buffer that is bound for writing --- indra/newview/pipeline.cpp | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2e55b65c82..b24a8106cc 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7476,7 +7476,7 @@ void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) } } -void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) +void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target, LLRenderTarget* depth_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LLRenderTarget* deferred_target = &mRT->deferredScreen; @@ -7515,7 +7515,14 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_target->getUsage()); if (channel > -1) { - gGL.getTexUnit(channel)->bind(deferred_target, TRUE); + if (depth_target) + { + gGL.getTexUnit(channel)->bind(depth_target, TRUE); + } + else + { + gGL.getTexUnit(channel)->bind(deferred_target, TRUE); + } stop_glerror(); } @@ -8232,16 +8239,42 @@ void LLPipeline::doAtmospherics() if (RenderDeferredAtmospheric) { + if (!sUnderWaterRender) + { + // copy depth buffer for use in haze shader (use water displacement map as temp storage) + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + + LLRenderTarget& src = gPipeline.mRT->screen; + LLRenderTarget& depth_src = gPipeline.mRT->deferredScreen; + LLRenderTarget& dst = gPipeline.mWaterDis; + + mRT->screen.flush(); + dst.bindTarget(); + gCopyDepthProgram.bind(); + + S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP); + S32 depth_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); + + gGL.getTexUnit(diff_map)->bind(&src); + gGL.getTexUnit(depth_map)->bind(&depth_src, true); + + gGL.setColorMask(false, false); + gPipeline.mScreenTriangleVB->setBuffer(); + gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + dst.flush(); + mRT->screen.bindTarget(); + } + LLGLEnable blend(GL_BLEND); gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); - gGL.setColorMask(true, true); // apply haze LLGLSLShader& haze_shader = gHazeProgram; LL_PROFILE_GPU_ZONE("haze"); - bindDeferredShader(haze_shader); + bindDeferredShader(haze_shader, nullptr, sUnderWaterRender ? nullptr : &mWaterDis); LLEnvironment& environment = LLEnvironment::instance(); haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); @@ -8294,7 +8327,7 @@ void LLPipeline::doWaterHaze() else { //render water patches like LLDrawPoolWater does - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); + /*LLGLDepthTest depth(GL_FALSE); LLGLDisable cull(GL_CULL_FACE); gGLLastMatrix = NULL; @@ -8303,7 +8336,7 @@ void LLPipeline::doWaterHaze() if (mWaterPool) { mWaterPool->pushFaceGeometry(); - } + }*/ } unbindDeferredShader(haze_shader); -- cgit v1.2.3 From 4ca23735d906c69742f4bf362eb97b87831c2ece Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 11 Dec 2023 15:40:33 -0600 Subject: SL-20611 Followup -- reenable water haze --- indra/newview/pipeline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b24a8106cc..f448983ac2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8327,7 +8327,7 @@ void LLPipeline::doWaterHaze() else { //render water patches like LLDrawPoolWater does - /*LLGLDepthTest depth(GL_FALSE); + LLGLDepthTest depth(GL_FALSE); LLGLDisable cull(GL_CULL_FACE); gGLLastMatrix = NULL; @@ -8336,7 +8336,7 @@ void LLPipeline::doWaterHaze() if (mWaterPool) { mWaterPool->pushFaceGeometry(); - }*/ + } } unbindDeferredShader(haze_shader); -- cgit v1.2.3 From 1f7f30aea4bb67bc9de9a6354085b7f0b0849617 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 11 Dec 2023 15:49:51 -0600 Subject: SL-20611 Brute force fix for water haze -- paid for by cycles saved by not drawing water twice, but needs a better long term solution. --- indra/newview/pipeline.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f448983ac2..adad22d0a8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -787,10 +787,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) resY /= res_mod; } - if (LLPipeline::sRenderTransparentWater) - { //water reflection texture - mWaterDis.allocate(resX, resY, GL_RGBA16F, true); - } + //water reflection texture (always needed as scratch space whether or not transparent water is enabled) + mWaterDis.allocate(resX, resY, GL_RGBA16F, true); if (RenderUIBuffer) { @@ -8239,7 +8237,6 @@ void LLPipeline::doAtmospherics() if (RenderDeferredAtmospheric) { - if (!sUnderWaterRender) { // copy depth buffer for use in haze shader (use water displacement map as temp storage) LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); @@ -8274,7 +8271,7 @@ void LLPipeline::doAtmospherics() LLGLSLShader& haze_shader = gHazeProgram; LL_PROFILE_GPU_ZONE("haze"); - bindDeferredShader(haze_shader, nullptr, sUnderWaterRender ? nullptr : &mWaterDis); + bindDeferredShader(haze_shader, nullptr, &mWaterDis); LLEnvironment& environment = LLEnvironment::instance(); haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); @@ -8300,6 +8297,32 @@ void LLPipeline::doWaterHaze() if (RenderDeferredAtmospheric) { + // copy depth buffer for use in haze shader (use water displacement map as temp storage) + { + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + + LLRenderTarget& src = gPipeline.mRT->screen; + LLRenderTarget& depth_src = gPipeline.mRT->deferredScreen; + LLRenderTarget& dst = gPipeline.mWaterDis; + + mRT->screen.flush(); + dst.bindTarget(); + gCopyDepthProgram.bind(); + + S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP); + S32 depth_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); + + gGL.getTexUnit(diff_map)->bind(&src); + gGL.getTexUnit(depth_map)->bind(&depth_src, true); + + gGL.setColorMask(false, false); + gPipeline.mScreenTriangleVB->setBuffer(); + gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + dst.flush(); + mRT->screen.bindTarget(); + } + LLGLEnable blend(GL_BLEND); gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); @@ -8309,7 +8332,7 @@ void LLPipeline::doWaterHaze() LLGLSLShader& haze_shader = gHazeWaterProgram; LL_PROFILE_GPU_ZONE("haze"); - bindDeferredShader(haze_shader); + bindDeferredShader(haze_shader, nullptr, &mWaterDis); haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); -- cgit v1.2.3 From 60196f6ab3697c5b6cff6b2c856449d94d56ddee Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 13 Dec 2023 12:47:04 -0600 Subject: SL-20611 Followup -- fix for impostors being invisible. --- indra/newview/pipeline.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/pipeline.cpp') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index adad22d0a8..3a1edb0d00 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8235,6 +8235,11 @@ void LLPipeline::doAtmospherics() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + if (sImpostorRender) + { // do not attempt atmospherics on impostors + return; + } + if (RenderDeferredAtmospheric) { { @@ -8294,6 +8299,10 @@ void LLPipeline::doAtmospherics() void LLPipeline::doWaterHaze() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + if (sImpostorRender) + { // do not attempt water haze on impostors + return; + } if (RenderDeferredAtmospheric) { -- cgit v1.2.3