summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-02-01 17:09:34 -0600
committerDave Parks <davep@lindenlab.com>2023-02-01 17:09:34 -0600
commit6f136d403b6bbccae80661c6585f29e1caed3a7c (patch)
tree9ca9853598555139f980fc915ec8646abfd58f21
parentc136c5ece4a6baf3b0a34c32211e00a3d0fc4b69 (diff)
SL-19000 Fix various 3D UI components not respecting depth buffer. Incidental decruft. Do I get a prize for 1000th jira?
-rw-r--r--indra/llrender/llglstates.h39
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl12
-rw-r--r--indra/newview/lldrawpoolbump.cpp1
-rw-r--r--indra/newview/lldrawpoolsky.cpp2
-rw-r--r--indra/newview/llface.cpp8
-rw-r--r--indra/newview/llmodelpreview.cpp3
-rw-r--r--indra/newview/llselectmgr.cpp11
-rw-r--r--indra/newview/llviewerdisplay.cpp25
-rw-r--r--indra/newview/pipeline.cpp118
-rw-r--r--indra/newview/pipeline.h1
13 files changed, 76 insertions, 187 deletions
diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h
index 27ab142925..c46585eab4 100644
--- a/indra/llrender/llglstates.h
+++ b/indra/llrender/llglstates.h
@@ -57,7 +57,7 @@ class LLGLSDefault
{
protected:
LLGLEnable mColorMaterial;
- LLGLDisable mAlphaTest, mBlend, mCullFace, mDither, mFog,
+ LLGLDisable mAlphaTest, mBlend, mCullFace, mDither,
mLineSmooth, mLineStipple, mNormalize, mPolygonSmooth,
mGLMultisample;
public:
@@ -70,7 +70,6 @@ public:
mBlend(GL_BLEND),
mCullFace(GL_CULL_FACE),
mDither(GL_DITHER),
- mFog(GL_FOG),
mLineSmooth(GL_LINE_SMOOTH),
mLineStipple(GL_LINE_STIPPLE),
mNormalize(GL_NORMALIZE),
@@ -82,11 +81,11 @@ public:
class LLGLSObjectSelect
{
protected:
- LLGLDisable mBlend, mFog, mAlphaTest;
+ LLGLDisable mBlend, mAlphaTest;
LLGLEnable mCullFace;
public:
LLGLSObjectSelect()
- : mBlend(GL_BLEND), mFog(GL_FOG),
+ : mBlend(GL_BLEND),
mAlphaTest(GL_ALPHA_TEST),
mCullFace(GL_CULL_FACE)
{ }
@@ -130,28 +129,6 @@ public:
//----------------------------------------------------------------------------
-class LLGLSFog
-{
-protected:
- LLGLEnable mFog;
-public:
- LLGLSFog()
- : mFog(GL_FOG)
- {}
-};
-
-class LLGLSNoFog
-{
-protected:
- LLGLDisable mFog;
-public:
- LLGLSNoFog()
- : mFog(GL_FOG)
- {}
-};
-
-//----------------------------------------------------------------------------
-
class LLGLSPipeline
{
protected:
@@ -175,16 +152,6 @@ public:
{ }
};
-class LLGLSPipelineEmbossBump
-{
-protected:
- LLGLDisable mFog;
-public:
- LLGLSPipelineEmbossBump()
- : mFog(GL_FOG)
- { }
-};
-
class LLGLSPipelineSelection
{
protected:
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
index 226e63cdda..50d697ae12 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
@@ -28,11 +28,7 @@
/*[EXTRA_CODE_HERE]*/
-#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
#define FXAA_PC 1
//#define FXAA_GLSL_130 1
@@ -2092,6 +2088,7 @@ half4 FxaaPixelShader(
#endif
uniform sampler2D diffuseMap;
+uniform sampler2D depthMap;
uniform vec2 rcp_screen_res;
uniform vec4 rcp_frame_opt;
@@ -2120,8 +2117,7 @@ void main()
- //diff = texture2D(diffuseMap, vary_tc);
-
- frag_color = diff;
-
+ frag_color = diff;
+
+ gl_FragDepth = texture(depthMap, vary_fragcoord.xy).r;
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
index 0b4680767a..3ead2149f5 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
@@ -27,20 +27,18 @@
/*[EXTRA_CODE_HERE]*/
-#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-uniform sampler2D glowMap;
-uniform sampler2D screenMap;
+uniform sampler2D emissiveRect;
+uniform sampler2D diffuseRect;
+uniform sampler2D depthMap;
-VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
+in vec2 tc;
void main()
{
- frag_color = texture2D(glowMap, vary_texcoord0.xy) +
- texture2D(screenMap, vary_texcoord1.xy);
+ frag_color = texture2D(emissiveRect, tc) +
+ texture2D(diffuseRect, tc);
+
+ gl_FragDepth = texture(depthMap, tc).r;
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
index 6a4c2ca623..c50548d528 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
@@ -27,20 +27,17 @@
/*[EXTRA_CODE_HERE]*/
-#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
uniform sampler2D diffuseRect;
uniform vec2 screen_res;
-VARYING vec2 vary_tc;
+
+in vec2 vary_tc;
void main()
{
- vec3 col = texture2D(diffuseRect, vary_tc).rgb;
-
- frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
+ vec3 col = texture(diffuseRect, vary_tc).rgb;
+
+ frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
index 71fa095505..8fa08a18c3 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
@@ -25,17 +25,13 @@
uniform mat4 modelview_projection_matrix;
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec2 texcoord0;
-ATTRIBUTE vec2 texcoord1;
+in vec3 position;
-VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
+out vec2 tc;
void main()
{
- gl_Position = vec4(position.xyz, 1.0);
- vary_texcoord0 = position.xy * 0.5 + 0.5;
- vary_texcoord1 = vary_texcoord0;
+ gl_Position = vec4(position.xyz, 1.0);
+ tc = position.xy * 0.5 + 0.5;
}
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 254c74df79..f5d0412993 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -663,7 +663,6 @@ void LLDrawPoolBump::beginBump()
void LLDrawPoolBump::renderBump(U32 pass)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
- LLGLDisable fog(GL_FOG);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_LEQUAL);
LLGLEnable blend(GL_BLEND);
gGL.diffuseColor4f(1,1,1,1);
diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp
index a7b5ec5fc8..c39d728c95 100644
--- a/indra/newview/lldrawpoolsky.cpp
+++ b/indra/newview/lldrawpoolsky.cpp
@@ -84,8 +84,6 @@ void LLDrawPoolSky::render(S32 pass)
LLGLSPipelineDepthTestSkyBox gls_skybox(true, false);
- LLGLEnable fog_enable( (mShaderLevel < 1 && LLViewerCamera::getInstance()->cameraUnderWater()) ? GL_FOG : 0);
-
gGL.pushMatrix();
LLVector3 origin = LLViewerCamera::getInstance()->getOrigin();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 345fb81ada..811f475705 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -616,14 +616,6 @@ void LLFace::renderOneWireframe(const LLColor4 &color, F32 fogCfx, bool wirefram
}
else
{
- LLGLEnable fog(GL_FOG);
- glFogi(GL_FOG_MODE, GL_LINEAR);
- float d = (LLViewerCamera::getInstance()->getPointOfInterest() - LLViewerCamera::getInstance()->getOrigin()).magVec();
- LLColor4 fogCol = color * fogCfx;
- glFogf(GL_FOG_START, d);
- glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV())));
- glFogfv(GL_FOG_COLOR, fogCol.mV);
-
gGL.flush();
{
gGL.diffuseColor4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f);
diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp
index df1a29d039..66d14df1f4 100644
--- a/indra/newview/llmodelpreview.cpp
+++ b/indra/newview/llmodelpreview.cpp
@@ -3114,8 +3114,7 @@ BOOL LLModelPreview::render()
LLGLDisable no_blend(GL_BLEND);
LLGLEnable cull(GL_CULL_FACE);
LLGLDepthTest depth(GL_FALSE); // SL-12781 disable z-buffer to render background color
- LLGLDisable fog(GL_FOG);
-
+
{
gUIProgram.bind();
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 1f604f3cba..02e85d7470 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -7020,15 +7020,8 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
{
gGL.flush();
gGL.blendFunc(LLRender::BF_SOURCE_COLOR, LLRender::BF_ONE);
- LLGLEnable fog(GL_FOG);
- glFogi(GL_FOG_MODE, GL_LINEAR);
- float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec();
- LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0);
- glFogf(GL_FOG_START, d);
- glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV())));
- glFogfv(GL_FOG_COLOR, fogCol.mV);
-
- LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL);
+
+ LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL);
gGL.flush();
gGL.begin(LLRender::LINES);
{
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 28d6267029..2a2d390765 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1312,23 +1312,17 @@ void render_ui(F32 zoom_factor, int subfield)
gGL.popMatrix();
}
+ // Render our post process prior to the HUD, UI, etc.
+ gPipeline.renderPostProcess();
+
+ // apply gamma correction and post effects
+ gPipeline.renderFinalize();
+
{
LLGLState::checkStates();
- // Render our post process prior to the HUD, UI, etc.
- gPipeline.renderPostProcess();
- LLGLState::checkStates();
- // draw hud and 3D ui elements into screen render target so they'll be able to use
- // the depth buffer (avoids extra copy of depth buffer per frame)
- gPipeline.screenTarget()->bindTarget();
- // 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_UI("HUD"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_HUD);
+ LL_PROFILE_ZONE_NAMED_CATEGORY_UI("HUD");
render_hud_elements();
LLGLState::checkStates();
render_hud_attachments();
@@ -1357,11 +1351,6 @@ void render_ui(F32 zoom_factor, int subfield)
}
}
- gPipeline.screenTarget()->flush();
-
- // apply gamma correction and post effects before rendering 2D UI
- gPipeline.renderFinalize();
-
if (render_ui)
{
LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 2D"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D);
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<LLVertexBuffer> buff = new LLVertexBuffer(mask, 0);
- buff->allocateBuffer(3, 0);
-
- LLStrider<LLVector3> v;
- LLStrider<LLVector2> uv1;
- LLStrider<LLVector2> 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();
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 0c11c7ef89..5b80ae5696 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -665,7 +665,6 @@ public:
LLRenderTarget deferredScreen;
LLRenderTarget fxaaBuffer;
LLRenderTarget edgeMap;
- LLRenderTarget deferredDepth;
LLRenderTarget deferredLight;
//sun shadow map