diff options
author | Rye <rye@lindenlab.com> | 2024-11-03 02:28:39 -0500 |
---|---|---|
committer | Rye <rye@lindenlab.com> | 2024-11-04 01:30:20 -0800 |
commit | 687930d5094e85c13d5ae7967b09eb08a879b333 (patch) | |
tree | a4ce0040ecde0c8aef71f1ba6f107c5703dc1d6d /indra | |
parent | a57d82b3a9337eb4ac00340e80749ac97392e03e (diff) |
Integrate glow combine pass with other post process render passes to reduce another full screen copy
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/SMAANeighborhoodBlendF.glsl | 10 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/cofF.glsl | 6 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl | 7 | ||||
-rw-r--r-- | indra/newview/llgltfmaterialpreviewmgr.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.h | 2 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 147 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 4 | ||||
-rw-r--r-- | indra/newview/rlvdefines.h | 26 | ||||
-rw-r--r-- | indra/newview/rlvhelper.h | 14 |
12 files changed, 171 insertions, 113 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/SMAANeighborhoodBlendF.glsl b/indra/newview/app_settings/shaders/class1/deferred/SMAANeighborhoodBlendF.glsl index 3276405447..08052a9ddf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/SMAANeighborhoodBlendF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/SMAANeighborhoodBlendF.glsl @@ -31,10 +31,12 @@ in vec2 vary_texcoord0; in vec4 vary_offset; uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; uniform sampler2D blendTex; #if SMAA_REPROJECTION uniform sampler2D velocityTex; #endif +uniform sampler2D depthMap; #define float4 vec4 #define float2 vec2 @@ -51,7 +53,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, void main() { - frag_color = SMAANeighborhoodBlendingPS(vary_texcoord0, + vec4 diff = SMAANeighborhoodBlendingPS(vary_texcoord0, vary_offset, diffuseRect, blendTex @@ -59,5 +61,11 @@ void main() , velocityTex #endif ); +#ifndef NO_GLOW + diff.rgb += texture2D(emissiveRect, vary_texcoord0).rgb; +#endif + frag_color = diff; + + gl_FragDepth = texture(depthMap, vary_texcoord0.xy).r; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl index 4a26b8924a..36611db2fb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl @@ -29,6 +29,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D depthMap; +uniform sampler2D emissiveRect; uniform float focal_distance; uniform float blur_constant; @@ -66,12 +67,13 @@ void main() vec4 p = inv_proj*ndc; float depth = p.z/p.w; - vec4 diff = texture(diffuseRect, vary_fragcoord.xy); + vec4 diff = texture(diffuseRect, tc); float sc = calc_cof(depth); sc = min(sc, max_cof); sc = max(sc, -max_cof); - frag_color.rgb = diff.rgb; + vec4 bloom = texture2D(emissiveRect, tc); + frag_color.rgb = diff.rgb + bloom.rgb; frag_color.a = sc/max_cof*0.5+0.5; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl index 07384ebe9b..cb0a6edea9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl @@ -30,7 +30,6 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D depthMap; -uniform vec2 screen_res; in vec2 vary_fragcoord; void main() diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index ca000dcb23..0e7858743c 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -29,10 +29,12 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D emissiveRect; +uniform sampler2D depthMap; in vec2 tc; void main() { frag_color = texture(diffuseRect, tc) + texture(emissiveRect, tc); + gl_FragDepth = texture(depthMap, tc.xy).r; } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl index 6d34c8aefa..8a8de88182 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl @@ -28,6 +28,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; uniform vec2 screen_res; @@ -36,6 +37,8 @@ in vec2 vary_tc; void main() { vec3 col = texture(diffuseRect, vary_tc).rgb; - - frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144))); +#ifndef NO_GLOW + col += texture2D(emissiveRect, vary_tc).rgb; +#endif + frag_color = vec4(col, dot(col, vec3(0.299, 0.587, 0.144))); } diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index f473afb74c..5ca841f9f1 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.cpp +++ b/indra/newview/llgltfmaterialpreviewmgr.cpp @@ -529,32 +529,14 @@ bool LLGLTFPreviewTexture::render() gPipeline.tonemap(&screen, dst); std::swap(src, dst); + // Final render LLVertexBuffer::unbind(); gPipeline.generateGlow(src); - gPipeline.combineGlow(src, dst); - std::swap(src, dst); + gPipeline.combineGlow(src, nullptr); // *HACK: Restore mExposureMap (it will be consumed by generateExposure next frame) gPipeline.mExposureMap.swapFBORefs(gPipeline.mLastExposure); - // Final render - - gDeferredPostNoDoFProgram.bind(); - - // From LLPipeline::renderFinalize: "Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems." - gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); - gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, mBoundTarget, true); - - gDeferredPostNoDoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); - - { - LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); - gPipeline.mScreenTriangleVB->setBuffer(); - gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - gDeferredPostNoDoFProgram.unbind(); - // Clean up gPipeline.setupHWLights(); gPipeline.mReflectionMapManager.forceDefaultProbeAndUpdateUniforms(false); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 52fd75f672..4d248af5d5 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -87,6 +87,7 @@ LLGLSLShader gRadianceGenProgram; LLGLSLShader gHeroRadianceGenProgram; LLGLSLShader gIrradianceGenProgram; LLGLSLShader gGlowCombineFXAAProgram; +LLGLSLShader gFXAALumaGenProgram; LLGLSLShader gTwoTextureCompareProgram; LLGLSLShader gOneTextureFilterProgram; LLGLSLShader gDebugProgram; @@ -206,6 +207,7 @@ LLGLSLShader gFXAAProgram[4]; LLGLSLShader gSMAAEdgeDetectProgram[4]; LLGLSLShader gSMAABlendWeightsProgram[4]; LLGLSLShader gSMAANeighborhoodBlendProgram[4]; +LLGLSLShader gSMAANeighborhoodBlendGlowCombineProgram[4]; LLGLSLShader gCASProgram; LLGLSLShader gCASLegacyGammaProgram; LLGLSLShader gDeferredPostNoDoFProgram; @@ -2496,6 +2498,7 @@ bool LLViewerShaderMgr::loadShadersDeferred() gSMAANeighborhoodBlendProgram[i].clearPermutations(); gSMAANeighborhoodBlendProgram[i].addPermutations(defines); + gSMAANeighborhoodBlendProgram[i].addPermutation("NO_GLOW", "1"); gSMAANeighborhoodBlendProgram[i].mShaderFiles.clear(); gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -2503,8 +2506,27 @@ bool LLViewerShaderMgr::loadShadersDeferred() gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB)); gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB)); gSMAANeighborhoodBlendProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gSMAANeighborhoodBlendProgram[i].createShader(); } + + if (success) + { + gSMAANeighborhoodBlendGlowCombineProgram[i].mName = llformat("SMAA Neighborhood Blending Glow Combine (%s)", smaa_pair.second.c_str()); + gSMAANeighborhoodBlendGlowCombineProgram[i].mFeatures.isDeferred = true; + + gSMAANeighborhoodBlendGlowCombineProgram[i].clearPermutations(); + gSMAANeighborhoodBlendGlowCombineProgram[i].addPermutations(defines); + + gSMAANeighborhoodBlendGlowCombineProgram[i].mShaderFiles.clear(); + gSMAANeighborhoodBlendGlowCombineProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAANeighborhoodBlendGlowCombineProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendV.glsl", GL_VERTEX_SHADER_ARB)); + gSMAANeighborhoodBlendGlowCombineProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAANeighborhoodBlendGlowCombineProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB)); + gSMAANeighborhoodBlendGlowCombineProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = gSMAANeighborhoodBlendGlowCombineProgram[i].createShader(); + } ++i; } } @@ -2970,7 +2992,7 @@ bool LLViewerShaderMgr::loadShadersInterface() if (success) { - gGlowCombineFXAAProgram.mName = "Glow CombineFXAA Shader"; + gGlowCombineFXAAProgram.mName = "Glow Combine FXAA Luma Gen Shader"; gGlowCombineFXAAProgram.mShaderFiles.clear(); gGlowCombineFXAAProgram.mShaderFiles.push_back(make_pair("interface/glowcombineFXAAV.glsl", GL_VERTEX_SHADER)); gGlowCombineFXAAProgram.mShaderFiles.push_back(make_pair("interface/glowcombineFXAAF.glsl", GL_FRAGMENT_SHADER)); @@ -2985,6 +3007,25 @@ bool LLViewerShaderMgr::loadShadersInterface() } } + if (success) + { + gFXAALumaGenProgram.mName = "FXAA Luma Gen Shader"; + gFXAALumaGenProgram.mShaderFiles.clear(); + gFXAALumaGenProgram.mShaderFiles.push_back(make_pair("interface/glowcombineFXAAV.glsl", GL_VERTEX_SHADER)); + gFXAALumaGenProgram.mShaderFiles.push_back(make_pair("interface/glowcombineFXAAF.glsl", GL_FRAGMENT_SHADER)); + gFXAALumaGenProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; + gFXAALumaGenProgram.clearPermutations(); + gFXAALumaGenProgram.addPermutation("NO_GLOW", "1"); + success = gFXAALumaGenProgram.createShader(); + if (success) + { + gFXAALumaGenProgram.bind(); + gFXAALumaGenProgram.uniform1i(sGlowMap, 0); + gFXAALumaGenProgram.uniform1i(sScreenMap, 1); + gFXAALumaGenProgram.unbind(); + } + } + #ifdef LL_WINDOWS if (success) { diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index afc29e6fd2..60b880c161 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -160,6 +160,7 @@ extern LLGLSLShader gRadianceGenProgram; extern LLGLSLShader gHeroRadianceGenProgram; extern LLGLSLShader gIrradianceGenProgram; extern LLGLSLShader gGlowCombineFXAAProgram; +extern LLGLSLShader gFXAALumaGenProgram; extern LLGLSLShader gDebugProgram; enum NormalDebugShaderVariant : S32 { @@ -250,6 +251,7 @@ extern LLGLSLShader gFXAAProgram[4]; extern LLGLSLShader gSMAAEdgeDetectProgram[4]; extern LLGLSLShader gSMAABlendWeightsProgram[4]; extern LLGLSLShader gSMAANeighborhoodBlendProgram[4]; +extern LLGLSLShader gSMAANeighborhoodBlendGlowCombineProgram[4]; extern LLGLSLShader gCASProgram; extern LLGLSLShader gCASLegacyGammaProgram; extern LLGLSLShader gDeferredPostNoDoFProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 541208b133..a88756452e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6903,7 +6903,10 @@ static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Bloom"); void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 bufferIndex) { - dst->bindTarget(); + if (dst) + { + dst->bindTarget(); + } gDeferredBufferVisualProgram.bind(); gDeferredBufferVisualProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_BILINEAR, bufferIndex); @@ -6916,7 +6919,10 @@ void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); gDeferredBufferVisualProgram.unbind(); - dst->flush(); + if (dst) + { + dst->flush(); + } } void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst) @@ -7297,20 +7303,20 @@ void LLPipeline::applyCAS(LLRenderTarget* src, LLRenderTarget* dst) dst->flush(); } -void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) +void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst, bool combine_glow) { llassert(!gCubeSnapshot); LLGLSLShader* shader = &gGlowCombineProgram; LL_PROFILE_GPU_ZONE("aa"); - S32 width = dst->getWidth(); - S32 height = dst->getHeight(); + S32 width = src->getWidth(); + S32 height = src->getHeight(); // bake out texture2D with RGBL for FXAA shader mFXAAMap.bindTarget(); mFXAAMap.invalidate(GL_COLOR_BUFFER_BIT); - shader = &gGlowCombineFXAAProgram; + shader = combine_glow ? &gGlowCombineFXAAProgram : &gFXAALumaGenProgram; shader->bind(); S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); @@ -7318,6 +7324,7 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } + shader->bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); { LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); @@ -7330,7 +7337,10 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) mFXAAMap.flush(); - dst->bindTarget(); + if (dst) + { + dst->bindTarget(); + } static LLCachedControl<U32> aa_quality(gSavedSettings, "RenderFSAASamples", 0U); U32 fsaa_quality = std::clamp(aa_quality(), 0U, 3U); @@ -7362,15 +7372,17 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { 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); + shader->bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } shader->unbind(); - dst->flush(); + if (dst) + { + dst->flush(); + } } void LLPipeline::generateSMAABuffers(LLRenderTarget* src) @@ -7492,7 +7504,7 @@ void LLPipeline::generateSMAABuffers(LLRenderTarget* src) } } -void LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst) +void LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst, bool combine_glow) { llassert(!gCubeSnapshot); @@ -7514,11 +7526,14 @@ void LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst) //LLGLDisable stencil(GL_STENCIL_TEST); // Bind setup: - LLRenderTarget* bound_target = dst; - LLGLSLShader& blend_shader = gSMAANeighborhoodBlendProgram[fsaa_quality]; + LLGLSLShader& blend_shader = combine_glow ? gSMAANeighborhoodBlendGlowCombineProgram[fsaa_quality] + : gSMAANeighborhoodBlendProgram[fsaa_quality]; - bound_target->bindTarget(); - bound_target->invalidate(GL_COLOR_BUFFER_BIT); + if(dst) + { + dst->bindTarget(); + dst->invalidate(GL_COLOR_BUFFER_BIT); + } blend_shader.bind(); blend_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics); @@ -7536,13 +7551,21 @@ void LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst) mSMAABlendBuffer.bindTexture(0, blend_channel, LLTexUnit::TFO_BILINEAR); } + blend_shader.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); + + blend_shader.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - bound_target->flush(); blend_shader.unbind(); gGL.getTexUnit(diffuse_channel)->unbindFast(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(blend_channel)->unbindFast(LLTexUnit::TT_TEXTURE); + + if (dst) + { + dst->flush(); + } } } @@ -7571,20 +7594,25 @@ 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(); - + if (dst) { + dst->bindTarget(); + } + { gGlowCombineProgram.bind(); gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); + gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } - - dst->flush(); + if (dst) + { + dst->flush(); + } } void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) @@ -7702,13 +7730,14 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); - gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)dst->getWidth(), (GLfloat)dst->getHeight()); + gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)mFXAAMap.getWidth(), (GLfloat)mFXAAMap.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); + gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7728,7 +7757,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) gDeferredPostProgram.bind(); gDeferredPostProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mFXAAMap, LLTexUnit::TFO_POINT); - gDeferredPostProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)dst->getWidth(), (GLfloat)dst->getHeight()); + gDeferredPostProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); @@ -7743,14 +7772,18 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { // combine result based on alpha - dst->bindTarget(); - glViewport(0, 0, dst->getWidth(), dst->getHeight()); + if(dst) + { + dst->bindTarget(); + } + glViewport(0, 0, mFXAAMap.getWidth(), mFXAAMap.getHeight()); gDeferredDoFCombineProgram.bind(); gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_LIGHT, &mFXAAMap, LLTexUnit::TFO_POINT); + gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); - gDeferredDoFCombineProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)dst->getWidth(), (GLfloat)dst->getHeight()); + gDeferredDoFCombineProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->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()); @@ -7761,7 +7794,10 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) gDeferredDoFCombineProgram.unbind(); - dst->flush(); + if (dst) + { + dst->flush(); + } } } @@ -7815,36 +7851,36 @@ void LLPipeline::renderFinalize() generateGlow(src); - combineGlow(src, dest); - std::swap(src, dest); - 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 dof_enabled = - (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField && - !gCubeSnapshot; - if(dof_enabled) + bool smaa_enabled = RenderFSAAType == 2 && mFXAAMap.isComplete() && mSMAABlendBuffer.isComplete(); + bool fxaa_enabled = RenderFSAAType == 1 && mFXAAMap.isComplete(); + bool dof_enabled = RenderDepthOfField && + (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()); + if(dof_enabled) // DoF Combines Glow { - renderDoF(src, dest); - std::swap(src, dest); + LLRenderTarget* dof_dest = (smaa_enabled || fxaa_enabled) ? dest : nullptr; // render to screen if no AA enabled + renderDoF(src, dof_dest); + std::swap(src, dof_dest); } - if (RenderFSAAType == 2 && mFXAAMap.isComplete() && mSMAABlendBuffer.isComplete()) + // Render to screen + if (smaa_enabled) { generateSMAABuffers(src); - applySMAA(src, dest); - std::swap(src, dest); + applySMAA(src, nullptr, !dof_enabled); } - - if (RenderFSAAType == 1 && mFXAAMap.isComplete()) + else if (fxaa_enabled) { - applyFXAA(src, dest); - std::swap(src, dest); + applyFXAA(src, nullptr, !dof_enabled); + } + else if (!dof_enabled) + { + combineGlow(src, nullptr); } if (RenderBufferVisualization > -1) @@ -7855,16 +7891,16 @@ void LLPipeline::renderFinalize() case 1: case 2: case 3: - visualizeBuffers(&mRT->deferredScreen, src, RenderBufferVisualization); + visualizeBuffers(&mRT->deferredScreen, nullptr, RenderBufferVisualization); break; case 4: - visualizeBuffers(&mLuminanceMap, src, 0); + visualizeBuffers(&mLuminanceMap, nullptr, 0); break; case 5: { if (RenderFSAAType > 0) { - visualizeBuffers(&mFXAAMap, src, 0); + visualizeBuffers(&mFXAAMap, nullptr, 0); } break; } @@ -7872,7 +7908,7 @@ void LLPipeline::renderFinalize() { if (RenderFSAAType == 2) { - visualizeBuffers(&mSMAABlendBuffer, src, 0); + visualizeBuffers(&mSMAABlendBuffer, nullptr, 0); } break; } @@ -7881,23 +7917,6 @@ void LLPipeline::renderFinalize() } } - // Present the screen target. - gDeferredPostNoDoFProgram.bind(); // Add noise as part of final render to screen pass to avoid damaging other post effects - - // Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems. - gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src); - gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); - - gDeferredPostNoDoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); - - { - 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)) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index b76d07704c..309665f80a 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -158,9 +158,9 @@ public: void tonemap(LLRenderTarget* src, LLRenderTarget* dst, bool gamma_correct = true); void generateGlow(LLRenderTarget* src); void applyCAS(LLRenderTarget* src, LLRenderTarget* dst); - void applyFXAA(LLRenderTarget* src, LLRenderTarget* dst); + void applyFXAA(LLRenderTarget* src, LLRenderTarget* dst, bool combine_glow); void generateSMAABuffers(LLRenderTarget* src); - void applySMAA(LLRenderTarget* src, LLRenderTarget* dst); + void applySMAA(LLRenderTarget* src, LLRenderTarget* dst, bool combine_glow); void renderDoF(LLRenderTarget* src, LLRenderTarget* dst); void copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst); void combineGlow(LLRenderTarget* src, LLRenderTarget* dst); diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index e39328fdd6..0deb59cad0 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -32,24 +32,24 @@ // // Defining these makes it easier if we ever need to change our tag -#define RLV_WARNS LL_WARNS("RLV") -#define RLV_INFOS LL_INFOS("RLV") -#define RLV_DEBUGS LL_DEBUGS("RLV") -#define RLV_ENDL LL_ENDL -#define RLV_VERIFY(f) (f) +#define RLV_WARNS LL_WARNS("RLV") +#define RLV_INFOS LL_INFOS("RLV") +#define RLV_DEBUGS LL_DEBUGS("RLV") +#define RLV_ENDL LL_ENDL +#define RLV_VERIFY(f) (f) #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG // Make sure we halt execution on errors - #define RLV_ERRS LL_ERRS("RLV") + #define RLV_ERRS LL_ERRS("RLV") // Keep our asserts separate from LL's - #define RLV_ASSERT(f) if (!(f)) { RLV_ERRS << "ASSERT (" << #f << ")" << RLV_ENDL; } - #define RLV_ASSERT_DBG(f) RLV_ASSERT(f) + #define RLV_ASSERT(f) if (!(f)) { RLV_ERRS << "ASSERT (" << #f << ")" << RLV_ENDL; } + #define RLV_ASSERT_DBG(f) RLV_ASSERT(f) #else // Don't halt execution on errors in release - #define RLV_ERRS LL_WARNS("RLV") + #define RLV_ERRS LL_WARNS("RLV") // We don't want to check assertions in release builds #ifdef RLV_DEBUG - #define RLV_ASSERT(f) RLV_VERIFY(f) + #define RLV_ASSERT(f) RLV_VERIFY(f) #define RLV_ASSERT_DBG(f) #else #define RLV_ASSERT(f) @@ -142,9 +142,9 @@ namespace Rlv enum class EExceptionCheck { - Permissive, // Exception can be set by any object - Strict, // Exception must be set by all objects holding the restriction - Default, // Permissive or strict will be determined by currently enforced restrictions + Permissive, // Exception can be set by any object + Strict, // Exception must be set by all objects holding the restriction + Default, // Permissive or strict will be determined by currently enforced restrictions }; // Replace&remove in c++23 diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index f241332594..f0ce35b816 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -49,12 +49,12 @@ namespace Rlv enum EBehaviourFlags : uint32_t { // General behaviour flags - Strict = 0x0001, // Behaviour has a "_sec" version - Synonym = 0x0002, // Behaviour is a synonym of another - Extended = 0x0004, // Behaviour is part of the RLVa extended command set - Experimental = 0x0008, // Behaviour is part of the RLVa experimental command set - Blocked = 0x0010, // Behaviour is blocked - Deprecated = 0x0020, // Behaviour is deprecated + Strict = 0x0001, // Behaviour has a "_sec" version + Synonym = 0x0002, // Behaviour is a synonym of another + Extended = 0x0004, // Behaviour is part of the RLVa extended command set + Experimental = 0x0008, // Behaviour is part of the RLVa experimental command set + Blocked = 0x0010, // Behaviour is blocked + Deprecated = 0x0020, // Behaviour is deprecated MaskGeneral = 0x0FFF, // Force-wear specific flags @@ -175,7 +175,7 @@ namespace Rlv template<EBehaviour templBhvr> using ReplyHandler = CommandHandler<EParamType::Reply, templBhvr>; // List of shared handlers - using VersionReplyHandler = ReplyHandler<EBehaviour::Version>; // Shared between @version and @versionnew + using VersionReplyHandler = ReplyHandler<EBehaviour::Version>; // Shared between @version and @versionnew // // CommandProcessor - Templated glue class that brings BehaviourInfo, CommandHandlerBaseImpl and CommandHandler together |