summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r--indra/newview/pipeline.cpp90
1 files changed, 56 insertions, 34 deletions
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);