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.cpp2000
1 files changed, 1438 insertions, 562 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index fae55055c5..fb04722864 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -29,11 +29,13 @@
#include "pipeline.h"
// library includes
+#include "llimagepng.h"
#include "llaudioengine.h" // For debugging.
#include "llerror.h"
#include "llviewercontrol.h"
#include "llfasttimer.h"
#include "llfontgl.h"
+#include "llfontvertexbuffer.h"
#include "llnamevalue.h"
#include "llpointer.h"
#include "llprimitive.h"
@@ -117,6 +119,20 @@
#include "llenvironment.h"
#include "llsettingsvo.h"
+#include "SMAAAreaTex.h"
+#include "SMAASearchTex.h"
+#include "llerror.h"
+#ifndef LL_WINDOWS
+#define A_GCC 1
+#pragma GCC diagnostic ignored "-Wunused-function"
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#if LL_LINUX
+#pragma GCC diagnostic ignored "-Wrestrict"
+#endif
+#endif
+#define A_CPU 1
+#include "app_settings/shaders/class1/deferred/CASF.glsl" // This is also C++
+
extern bool gSnapshot;
bool gShiftFrame = false;
@@ -124,8 +140,8 @@ bool gShiftFrame = false;
bool LLPipeline::WindLightUseAtmosShaders;
bool LLPipeline::RenderDeferred;
F32 LLPipeline::RenderDeferredSunWash;
-U32 LLPipeline::RenderFSAASamples;
-U32 LLPipeline::RenderResolutionDivisor;
+U32 LLPipeline::RenderFSAAType;
+F32 LLPipeline::RenderResolutionDivisor;
bool LLPipeline::RenderUIBuffer;
S32 LLPipeline::RenderShadowDetail;
S32 LLPipeline::RenderShadowSplits;
@@ -204,7 +220,7 @@ S32 LLPipeline::RenderHeroProbeUpdateRate;
S32 LLPipeline::RenderHeroProbeConservativeUpdateMultiplier;
LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
-const U32 LLPipeline::MAX_BAKE_WIDTH = 512;
+const U32 LLPipeline::MAX_PREVIEW_WIDTH = 512;
const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f;
@@ -212,8 +228,10 @@ const F32 ALPHA_BLEND_CUTOFF = 0.598f;
const F32 DEFERRED_LIGHT_FALLOFF = 0.5f;
const U32 DEFERRED_VB_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1;
+const U32 SHADOWS_RESX = 1024;
+const U32 SHADOWS_RESY = 768;
+
extern S32 gBoxFrame;
-//extern bool gHideSelectedObjects;
extern bool gDisplaySwapBuffers;
extern bool gDebugGL;
extern bool gCubeSnapshot;
@@ -252,6 +270,7 @@ LLTrace::BlockTimerStatHandle FTM_STATESORT("Sort Draw State");
LLTrace::BlockTimerStatHandle FTM_PIPELINE("Pipeline");
LLTrace::BlockTimerStatHandle FTM_CLIENT_COPY("Client Copy");
LLTrace::BlockTimerStatHandle FTM_RENDER_DEFERRED("Deferred Shading");
+LLTrace::BlockTimerStatHandle FTM_RENDER_SHADOWS("Shadows");
LLTrace::BlockTimerStatHandle FTM_RENDER_UI_HUD("HUD");
LLTrace::BlockTimerStatHandle FTM_RENDER_UI_3D("3D");
@@ -269,6 +288,7 @@ static LLStaticHashedString sDelta("delta");
static LLStaticHashedString sDistFactor("dist_factor");
static LLStaticHashedString sKern("kern");
static LLStaticHashedString sKernScale("kern_scale");
+static LLStaticHashedString sSmaaRTMetrics("SMAA_RT_METRICS");
//----------------------------------------
@@ -329,10 +349,28 @@ void validate_framebuffer_object();
// target -- RenderTarget to add attachments to
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+fogmask, See: class1\deferred\materialF.glsl & softenlight
- && target.addColorAttachment(GL_RGB16F); // frag_data[3] PBR emissive OR material env intensity
+ U32 orm = GL_RGBA8;
+ U32 norm = GL_RGBA16F;
+ U32 emissive = GL_RGB16F;
+
+ static LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
+ static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
+ static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0);
+ static LLCachedControl<bool> MPHDRDisplay(gSavedSettings, "MPHDRDisplay", false);
+
+ bool hdr = has_hdr() && gGLManager.mGLVersion > 4.05f;
+
+ if (!hdr || MPColorPrecision != 2) norm = GL_RGB10_A2;
+ if (!hdr || (!MPHDRDisplay && MPColorPrecision == 1)) emissive = GL_RGB8;
+
+ bool valid = true;
+ valid = valid && target.addColorAttachment(orm); // frag-data[1] specular OR PBR ORM
+ valid = valid && target.addColorAttachment(norm);
+ if (has_emissive)
+ {
+ valid = valid && target.addColorAttachment(emissive); // frag_data[3] PBR emissive OR material env intensity
+ }
+
return valid;
}
@@ -394,9 +432,10 @@ void LLPipeline::init()
mInitialized = true;
- stop_glerror();
+ LOG_GLERROR("LLPipeline::init()");
//create render pass pools
+ getPool(LLDrawPool::POOL_WATEREXCLUSION);
getPool(LLDrawPool::POOL_ALPHA_PRE_WATER);
getPool(LLDrawPool::POOL_ALPHA_POST_WATER);
getPool(LLDrawPool::POOL_SIMPLE);
@@ -443,6 +482,10 @@ void LLPipeline::init()
gSavedSettings.setBOOL("RenderPerformanceTest", true);
}
+#if LL_DARWIN
+ mHDRDisplay = gSavedSettings.getBOOL("MPHDRDisplay");
+#endif
+
mOldRenderDebugMask = mRenderDebugMask;
mBackfaceCull = true;
@@ -487,7 +530,7 @@ void LLPipeline::init()
// DEPRECATED -- connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders");
// DEPRECATED -- connectRefreshCachedSettingsSafe("RenderDeferred");
connectRefreshCachedSettingsSafe("RenderDeferredSunWash");
- connectRefreshCachedSettingsSafe("RenderFSAASamples");
+ connectRefreshCachedSettingsSafe("RenderFSAAType");
connectRefreshCachedSettingsSafe("RenderResolutionDivisor");
connectRefreshCachedSettingsSafe("RenderUIBuffer");
connectRefreshCachedSettingsSafe("RenderShadowDetail");
@@ -564,7 +607,15 @@ void LLPipeline::init()
connectRefreshCachedSettingsSafe("RenderMirrors");
connectRefreshCachedSettingsSafe("RenderHeroProbeUpdateRate");
connectRefreshCachedSettingsSafe("RenderHeroProbeConservativeUpdateMultiplier");
- gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings));
+
+ LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl("CollectFontVertexBuffers");
+ if (cntrl_ptr.notNull())
+ {
+ cntrl_ptr->getCommitSignal()->connect([](LLControlVariable* control, const LLSD& value, const LLSD& previous)
+ {
+ LLFontVertexBuffer::enableBufferCollection(control->getValue().asBoolean());
+ });
+ }
}
LLPipeline::~LLPipeline()
@@ -630,6 +681,8 @@ void LLPipeline::cleanup()
// don't delete wl sky pool it was handled above in the for loop
//delete mWLSkyPool;
mWLSkyPool = NULL;
+ delete mWaterExclusionPool;
+ mWaterExclusionPool = nullptr;
releaseGLBuffers();
@@ -654,7 +707,8 @@ void LLPipeline::cleanup()
void LLPipeline::destroyGL()
{
- stop_glerror();
+ LOG_GLERROR("LLPipeline::destroyGL()");
+
unloadShaders();
mHighlightFaces.clear();
@@ -683,7 +737,9 @@ void LLPipeline::resizeShadowTexture()
{
releaseSunShadowTargets();
releaseSpotShadowTargets();
- allocateShadowBuffer(mRT->width, mRT->height);
+ //GLuint resX = gViewerWindow->getWorldViewWidthRaw();
+ //GLuint resY = gViewerWindow->getWorldViewHeightRaw();
+ allocateShadowBuffer(SHADOWS_RESX, SHADOWS_RESY);
gResizeShadowTexture = false;
}
@@ -713,6 +769,12 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
return ret == FBO_SUCCESS_FULLRES;
}
+void LLPipeline::renderTriangle()
+{
+ gPipeline.mScreenTriangleVB->setBuffer();
+ gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+}
+
LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)
{
@@ -725,40 +787,26 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)
// refresh cached settings here to protect against inconsistent event handling order
refreshCachedSettings();
- U32 samples = RenderFSAASamples;
-
eFBOStatus ret = FBO_SUCCESS_FULLRES;
- if (!allocateScreenBuffer(resX, resY, samples))
+ if (!allocateScreenBufferInternal(resX, resY))
{
//failed to allocate at requested specification, return false
ret = FBO_FAILURE;
releaseScreenBuffers();
- //reduce number of samples
- while (samples > 0)
- {
- samples /= 2;
- if (allocateScreenBuffer(resX, resY, samples))
- { //success
- return FBO_SUCCESS_LOWRES;
- }
- releaseScreenBuffers();
- }
-
- samples = 0;
//reduce resolution
while (resY > 0 && resX > 0)
{
resY /= 2;
- if (allocateScreenBuffer(resX, resY, samples))
+ if (allocateScreenBufferInternal(resX, resY))
{
return FBO_SUCCESS_LOWRES;
}
releaseScreenBuffers();
resX /= 2;
- if (allocateScreenBuffer(resX, resY, samples))
+ if (allocateScreenBufferInternal(resX, resY))
{
return FBO_SUCCESS_LOWRES;
}
@@ -771,9 +819,15 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)
return ret;
}
-bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
+bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
+
+ static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
+ bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();
+
+ static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0);
+
if (mRT == &mMainRT)
{ // hacky -- allocate auxillary buffer
@@ -786,14 +840,14 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
mRT = &mAuxillaryRT;
U32 res = mReflectionMapManager.mProbeResolution * 4; //multiply by 4 because probes will be 16x super sampled
- allocateScreenBuffer(res, res, samples);
+ allocateScreenBufferInternal(res, res, 1);
if (RenderMirrors)
{
mHeroProbeManager.initReflectionMaps();
res = mHeroProbeManager.mProbeResolution; // We also scale the hero probe RT to the probe res since we don't super sample it.
mRT = &mHeroProbeRT;
- allocateScreenBuffer(res, res, samples);
+ allocateScreenBufferInternal(res, res, 2);
}
mRT = &mMainRT;
@@ -804,76 +858,118 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
mRT->width = resX;
mRT->height = resY;
- U32 res_mod = RenderResolutionDivisor;
+ F32 res_mod = fmin(RenderResolutionDivisor, 4.0);
- if (res_mod > 1 && res_mod < resX && res_mod < resY)
+ if (res_mod >= 0.5 && res_mod <= 4.0)
{
- resX /= res_mod;
- resY /= res_mod;
+ resX = (U32)(floor((F32)resX / res_mod));
+ resY = (U32)(floor((F32)resY / res_mod));
}
S32 shadow_detail = RenderShadowDetail;
bool ssao = RenderDeferredSSAO;
//allocate deferred rendering color buffers
- if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true)) return false;
+
+ GLuint deferredScreenFormat = GL_RGBA8;
+ if((hdr && MPColorPrecision == 2)) deferredScreenFormat = GL_RGBA16F;
+
+ if (!mRT->deferredScreen.allocate(resX, resY, deferredScreenFormat, true)) return false;
if (!addDeferredAttachments(mRT->deferredScreen)) return false;
GLuint screenFormat = GL_RGBA16F;
+ if(!hdr && !mHDRDisplay && MPColorPrecision == 1) screenFormat = GL_RGB8;
if (!mRT->screen.allocate(resX, resY, screenFormat)) return false;
mRT->deferredScreen.shareDepthBuffer(mRT->screen);
- 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_RGBA16F)) return false;
+ if (hdr || shadow_detail > 0 || ssao || RenderDepthOfField)
+ { //only need mRT->deferredLight for shadows OR ssao OR dof
+ if (!mRT->deferredLight.allocate(resX, resY, screenFormat)) return false;
}
else
{
mRT->deferredLight.release();
}
- allocateShadowBuffer(resX, resY);
+ //allocateShadowBuffer(resX, resY);
+ if(type_ == 0) allocateShadowBuffer(SHADOWS_RESX, SHADOWS_RESY);
if (!gCubeSnapshot) // hack to not re-allocate various targets for cube snapshots
{
+ GLuint UIFormat = GL_RGBA8;
+ //if(mHDRDisplay && MPColorPrecision == 2) UIFormat = GL_RGBA16F;
+
if (RenderUIBuffer)
{
- if (!mUIScreen.allocate(resX, resY, GL_RGBA))
+ if (!mUIScreen.allocate(resX, resY, UIFormat))
{
return false;
}
}
- if (samples > 0)
+ if (RenderFSAAType > 0)
{
- if (!mFXAAMap.allocate(resX, resY, GL_RGBA)) return false;
+ GLuint AAFormat = GL_RGBA8;
+ if(mHDRDisplay && MPColorPrecision == 2)
+ {
+ AAFormat = GL_RGBA16F;
+ }
+
+ if (!mFXAAMap.allocate(resX, resY, AAFormat)) return false;
+ if (RenderFSAAType == 2)
+ {
+ if (!mSMAABlendBuffer.allocate(resX, resY, AAFormat, false)) return false;
+ }
}
else
{
mFXAAMap.release();
+ mSMAABlendBuffer.release();
}
+ mDummyRT.allocate(8, 8, GL_RGBA8, false);
+
//water reflection texture (always needed as scratch space whether or not transparent water is enabled)
- mWaterDis.allocate(resX, resY, GL_RGBA16F, true);
+ mWaterDis.allocate(resX, resY, screenFormat, true);
if(RenderScreenSpaceReflections)
{
- mSceneMap.allocate(resX, resY, GL_RGB, true);
+ //mSceneMap.allocate(resX, resY, screenFormat, true);
+ //We plan a setting. For now e go with a reasonable value
+ mSceneMap.allocate(512, 512, screenFormat, true);
}
else
{
mSceneMap.release();
}
- 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);
+ if((hdr && MPColorPrecision == 2) || mHDRDisplay)
+ {
+ mPostMaps[0].allocate(resX, resY, screenFormat);
+ mPostMaps[1].allocate(resX, resY, screenFormat);
+ }
+ else
+ {
+ mPostMaps[0].allocate(resX, resY, GL_RGBA);
+ mPostMaps[1].allocate(resX, resY, GL_RGBA);
+ }
+
+ // The water exclusion mask needs its own depth buffer so we can take care of the problem of multiple water planes.
+ // Should we ever make water not just a plane, it also aids with that as well as the water planes will be rendered into the mask.
+ // Why do we do this? Because it saves us some janky logic in the exclusion shader when we generate the mask.
+ // Regardless, this should always only be an R8 texture unless we choose to start having multiple kinds of exclusion that 8 bits can't handle.
+ // - Geenz 2025-02-06
+ bool success = mWaterExclusionMask.allocate(resX, resY, GL_R8, true);
+
+ assert(success);
// used to scale down textures
// See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown
- mDownResMap.allocate(4, 4, GL_RGBA);
+ mDownResMap.allocate(1024, 1024, GL_RGBA8);
+
+ mBakeMap.allocate(LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH, LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT, GL_RGBA8);
}
//HACK make screenbuffer allocations start failing after 30 seconds
if (gSavedSettings.getBOOL("SimulateFBOFailure"))
@@ -883,7 +979,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
gGL.getTexUnit(0)->disable();
- stop_glerror();
+ LOG_GLERROR("LLPipeline::allocateScreenBufferInternal end");
return true;
}
@@ -896,16 +992,19 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY)
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
S32 shadow_detail = RenderShadowDetail;
- F32 scale = gCubeSnapshot ? 1.0f : llmax(0.f, RenderShadowResolutionScale); // Don't scale probe shadow maps
- U32 sun_shadow_map_width = BlurHappySize(resX, scale);
- U32 sun_shadow_map_height = BlurHappySize(resY, scale);
+ F32 scale = gCubeSnapshot ? 1.0f : llmax(0.5f, RenderShadowResolutionScale); // Don't scale probe shadow maps
+ //U32 sun_shadow_map_width = BlurHappySize(resX, scale);
+ //U32 sun_shadow_map_height = BlurHappySize(resY, scale);
+ U32 sun_shadow_map_width = resX * scale;
+ U32 sun_shadow_map_height = resY * scale;
- if (shadow_detail > 0)
+ if (shadow_detail > 0 && shadow_detail < 3)
{ //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))
+ if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, true, LLTexUnit::TT_TEXTURE, LLTexUnit::TMG_NONE))
{
+ LL_WARNS() << "failed allocating shadow buffer " << i << " w:" << sun_shadow_map_width << " h:" << sun_shadow_map_height << LL_ENDL;
return false;
}
}
@@ -1004,8 +1103,8 @@ void LLPipeline::refreshCachedSettings()
WindLightUseAtmosShaders = true; // DEPRECATED -- gSavedSettings.getBOOL("WindLightUseAtmosShaders");
RenderDeferred = true; // DEPRECATED -- gSavedSettings.getBOOL("RenderDeferred");
RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash");
- RenderFSAASamples = LLFeatureManager::getInstance()->isFeatureAvailable("RenderFSAASamples") ? gSavedSettings.getU32("RenderFSAASamples") : 0;
- RenderResolutionDivisor = gSavedSettings.getU32("RenderResolutionDivisor");
+ RenderFSAAType = gSavedSettings.getU32("RenderFSAAType");
+ RenderResolutionDivisor = gSavedSettings.getF32("RenderResolutionDivisor");
RenderUIBuffer = gSavedSettings.getBOOL("RenderUIBuffer");
RenderShadowDetail = gSavedSettings.getS32("RenderShadowDetail");
RenderShadowSplits = gSavedSettings.getS32("RenderShadowSplits");
@@ -1090,12 +1189,21 @@ void LLPipeline::refreshCachedSettings()
LLVOAvatar::sMaxNonImpostors = 1;
LLVOAvatar::updateImpostorRendering(LLVOAvatar::sMaxNonImpostors);
}
+
+ LLFontVertexBuffer::enableBufferCollection(gSavedSettings.getBOOL("CollectFontVertexBuffers"));
}
void LLPipeline::releaseGLBuffers()
{
assertInitialized();
+ mBloomMap.release();
+
+ for (U32 i = 0; i < 2; i++)
+ {
+ mBloomBlur[i].release();
+ }
+
if (mNoiseMap)
{
LLImageGL::deleteTextures(1, &mNoiseMap);
@@ -1108,13 +1216,30 @@ void LLPipeline::releaseGLBuffers()
mTrueNoiseMap = 0;
}
+ if (mSMAAAreaMap)
+ {
+ LLImageGL::deleteTextures(1, &mSMAAAreaMap);
+ mSMAAAreaMap = 0;
+ }
+
+ if (mSMAASearchMap)
+ {
+ LLImageGL::deleteTextures(1, &mSMAASearchMap);
+ mSMAASearchMap = 0;
+ }
+
+ mDummyRT.release();
+
releaseLUTBuffers();
mWaterDis.release();
mSceneMap.release();
- mPostMap.release();
+ mWaterExclusionMask.release();
+
+ mPostMaps[0].release();
+ mPostMaps[1].release();
mFXAAMap.release();
@@ -1122,6 +1247,8 @@ void LLPipeline::releaseGLBuffers()
mDownResMap.release();
+ mBakeMap.release();
+
for (U32 i = 0; i < 3; i++)
{
mGlow[i].release();
@@ -1200,26 +1327,38 @@ void LLPipeline::releaseSpotShadowTargets()
void LLPipeline::createGLBuffers()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
- stop_glerror();
+ LOG_GLERROR("LLPipeline::createGLBuffers()");
assertInitialized();
- stop_glerror();
-
GLuint resX = gViewerWindow->getWorldViewWidthRaw();
GLuint resY = gViewerWindow->getWorldViewHeightRaw();
// 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;
+ static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0);
+
+ U32 glow_color_fmt = glow_hdr ? GL_RGBA16F : GL_RGBA8;
+ if(MPColorPrecision == 2) glow_color_fmt = GL_RGBA16F;
+
for (U32 i = 0; i < 3; i++)
{
mGlow[i].allocate(512, glow_res, glow_color_fmt);
}
+ mBloomMap.allocate(512, 256, glow_color_fmt);
+
+ for (U32 i = 0; i < 2; i++)
+ {
+ mBloomBlur[i].allocate(512, 256, glow_color_fmt);
+ }
+
allocateScreenBuffer(resX, resY);
- mRT->width = 0;
- mRT->height = 0;
+ // Do not zero out mRT dimensions here. allocateScreenBuffer() above
+ // already sets the correct dimensions. Zeroing them caused resizeShadowTexture()
+ // to fail if called immediately after createGLBuffers (e.g., post graphics change).
+ // mRT->width = 0;
+ // mRT->height = 0;
if (!mNoiseMap)
@@ -1238,7 +1377,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, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false);
+ LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB8, noiseRes, noiseRes, GL_RGB, GL_UNSIGNED_INT, noise, false);
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
@@ -1253,10 +1392,81 @@ 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, 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);
}
+ if (!mSMAAAreaMap)
+ {
+ std::vector<U8> tempBuffer(AREATEX_SIZE);
+ for (U32 y = 0; y < AREATEX_HEIGHT; y++)
+ {
+ U32 srcY = AREATEX_HEIGHT - 1 - y;
+ // unsigned int srcY = y;
+ memcpy(&tempBuffer[y * AREATEX_PITCH], areaTexBytes + srcY * AREATEX_PITCH, AREATEX_PITCH);
+ }
+
+ LLImageGL::generateTextures(1, &mSMAAAreaMap);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mSMAAAreaMap);
+ LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RG8, AREATEX_WIDTH, AREATEX_HEIGHT, GL_RG,
+ GL_UNSIGNED_BYTE, tempBuffer.data(), false);
+ gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+
+ if (!mSMAASearchMap)
+ {
+ std::vector<U8> tempBuffer(SEARCHTEX_SIZE);
+ for (U32 y = 0; y < SEARCHTEX_HEIGHT; y++)
+ {
+ U32 srcY = SEARCHTEX_HEIGHT - 1 - y;
+ // unsigned int srcY = y;
+ memcpy(&tempBuffer[y * SEARCHTEX_PITCH], searchTexBytes + srcY * SEARCHTEX_PITCH, SEARCHTEX_PITCH);
+ }
+
+ LLImageGL::generateTextures(1, &mSMAASearchMap);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mSMAASearchMap);
+ LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R8, SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT,
+ GL_RED, GL_UNSIGNED_BYTE, tempBuffer.data(), false);
+ gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+
+ if (!mSMAASampleMap)
+ {
+ LLPointer<LLImageRaw> raw_image = new LLImageRaw;
+ LLPointer<LLImagePNG> png_image = new LLImagePNG;
+ static LLCachedControl<std::string> sample_path(gSavedSettings, "SamplePath", "");
+ if (gDirUtilp->fileExists(sample_path()) && png_image->load(sample_path()) && png_image->decode(raw_image, 0.0f))
+ {
+ U32 format = 0;
+ switch (raw_image->getComponents())
+ {
+ case 1:
+ format = GL_RED;
+ break;
+ case 2:
+ format = GL_RG;
+ break;
+ case 3:
+ format = GL_RGB;
+ break;
+ case 4:
+ format = GL_RGBA;
+ break;
+ default:
+ return;
+ };
+ LLImageGL::generateTextures(1, &mSMAASampleMap);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mSMAASampleMap);
+ LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB, raw_image->getWidth(),
+ raw_image->getHeight(), format, GL_UNSIGNED_BYTE, raw_image->getData(), false);
+ LOG_GLERROR("LLPipeline::createGLBuffers after setManualImage");
+ gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+ }
+
createLUTBuffers();
gBumpImageList.restoreGL();
@@ -1273,7 +1483,18 @@ void LLPipeline::createLUTBuffers()
{
U32 lightResX = gSavedSettings.getU32("RenderSpecularResX");
U32 lightResY = gSavedSettings.getU32("RenderSpecularResY");
- F32* ls = new F32[lightResX*lightResY];
+ F32* ls = nullptr;
+ try
+ {
+ ls = new F32[lightResX*lightResY];
+ }
+ catch (std::bad_alloc&)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ // might be better to set the error into mFatalMessage and rethrow
+ LL_ERRS() << "Bad memory allocation in createLUTBuffers! lightResX: "
+ << lightResX << " lightResY: " << lightResY << LL_ENDL;
+ }
F32 specExp = gSavedSettings.getF32("RenderSpecularExponent");
// Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks)
for (U32 y = 0; y < lightResY; ++y)
@@ -1300,11 +1521,7 @@ void LLPipeline::createLUTBuffers()
}
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;
-#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);
@@ -1317,22 +1534,31 @@ void LLPipeline::createLUTBuffers()
}
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();
+ mPbrBrdfLut.bindTarget("mPbrBrdfLut", 1);
+
+ if (gDeferredGenBrdfLutProgram.isComplete())
+ {
+ gDeferredGenBrdfLutProgram.bind();
+ llassert_always(LLGLSLShader::sCurBoundShaderPtr != nullptr);
+
+ 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();
+ }
+ else
+ {
+ LL_WARNS("Brad") << gDeferredGenBrdfLutProgram.mName << " failed to load, cannot be used!" << LL_ENDL;
+ }
gDeferredGenBrdfLutProgram.unbind();
mPbrBrdfLut.flush();
mExposureMap.allocate(1, 1, GL_R16F);
- mExposureMap.bindTarget();
+ mExposureMap.bindTarget("mExposureMap", 1);
glClearColor(1, 1, 1, 0);
mExposureMap.clear();
glClearColor(0, 0, 0, 0);
@@ -1542,6 +1768,10 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0)
poolp = mPBRAlphaMaskPool;
break;
+ case LLDrawPool::POOL_WATEREXCLUSION:
+ poolp = mWaterExclusionPool;
+ break;
+
default:
llassert(0);
LL_ERRS() << "Invalid Pool Type in LLPipeline::findPool() type=" << type << LL_ENDL;
@@ -2022,9 +2252,9 @@ F32 LLPipeline::calcPixelArea(const LLVector4a& center, const LLVector4a& size,
}
//get area of circle around node
- F32 app_angle = atanf(size.getLength3().getF32()/dist);
- F32 radius = app_angle*LLDrawable::sCurPixelAngle;
- return radius*radius * F_PI;
+ F32 app_angle = atanf(size.getLength3().getF32() / dist);
+ F32 radius = app_angle * LLDrawable::sCurPixelAngle;
+ return radius * radius * F_PI;
}
void LLPipeline::grabReferences(LLCullResult& result)
@@ -2359,7 +2589,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result)
gSky.mVOSkyp->mDrawable->setVisible(camera);
sCull->pushDrawable(gSky.mVOSkyp->mDrawable);
gSky.updateCull();
- stop_glerror();
+ LOG_GLERROR("LLPipeline::updateCull sky");
}
if (hasRenderType(LLPipeline::RENDER_TYPE_WL_SKY) &&
@@ -2369,6 +2599,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result)
{
gSky.mVOWLSkyp->mDrawable->setVisible(camera);
sCull->pushDrawable(gSky.mVOWLSkyp->mDrawable);
+ LOG_GLERROR("LLPipeline::updateCull pushDrawable");
}
}
@@ -2521,6 +2752,8 @@ void LLPipeline::doOcclusion(LLCamera& camera)
gGL.setColorMask(true, true);
}
+
+ LOG_GLERROR("LLPipeline::doOcclusion()");
}
bool LLPipeline::updateDrawableGeom(LLDrawable* drawablep)
@@ -2690,6 +2923,7 @@ void LLPipeline::updateGeom(F32 max_dtime)
}
updateMovedList(mMovedBridge);
+ LOG_GLERROR("LLPipeline::updateGeom()");
}
void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
@@ -3640,6 +3874,7 @@ void LLPipeline::postSort(LLCamera &camera)
}
}
+ LLVertexBuffer::flushBuffers();
// LLSpatialGroup::sNoDelete = false;
LL_PUSH_CALLSTACKS();
}
@@ -3687,6 +3922,8 @@ void render_hud_elements()
}
gUIProgram.unbind();
+
+ LOG_GLERROR("LLPipeline::render_hud_elements()");
}
static inline void bindHighlightProgram(LLGLSLShader& program)
@@ -3720,7 +3957,12 @@ void LLPipeline::renderSelectedFaces(const LLColor4& color)
for (auto facep : mSelectedFaces)
{
- if (!facep || facep->getDrawable()->isDead())
+ if (!facep || !facep->getViewerObject())
+ {
+ LLSelectMgr::getInstance()->clearSelections();
+ return;
+ }
+ if (!facep->getDrawable() || facep->getDrawable()->isDead())
{
LL_ERRS() << "Bad face on selection" << LL_ENDL;
return;
@@ -3786,6 +4028,8 @@ void LLPipeline::renderHighlights()
unbindHighlightProgram(gHighlightSpecularProgram);
}
}
+
+ LOG_GLERROR("LLPipeline::renderHighlights()");
}
//debug use
@@ -3795,39 +4039,36 @@ 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_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY);
LL_PROFILE_GPU_ZONE("renderGeomDeferred");
llassert(!sRenderingHUDs);
-#if GL_VERSION_1_1
if (gUseWireframe)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
-#endif
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);
+ glm::mat4 last_modelview = get_last_modelview();
+ glm::mat4 cur_modelview = get_current_modelview();
// 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
+ glm::mat4 m = glm::inverse(last_modelview); // last camera space to world space
+ m = cur_modelview * m; // world space to camera space
- glh::matrix4f n = m.inverse();
+ glm::mat4 n = glm::inverse(m);
- for (U32 i = 0; i < 16; ++i)
- {
- gGLDeltaModelView[i] = m.m[i];
- gGLInverseDeltaModelView[i] = n.m[i];
- }
+ gGLDeltaModelView = m;
+ gGLInverseDeltaModelView = n;
}
bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion && !LLGLSLShader::sProfileEnabled;
setupHWLights();
+ LOG_GLERROR("LLPipeline::renderGeomDeferred() setupHWLights");
{
LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools");
@@ -3916,7 +4157,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion)
}
}
iter1 = iter2;
- stop_glerror();
+ LOG_GLERROR("");
}
gGLLastMatrix = NULL;
@@ -3927,25 +4168,24 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion)
} // Tracy ZoneScoped
-#if GL_VERSION_1_1
if (gUseWireframe)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
-#endif
}
+// Render all of our geometry that's required after our deferred pass.
+// This is gonna be stuff like alpha, water, etc.
void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
LL_PROFILE_GPU_ZONE("renderGeomPostDeferred");
+ LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED);
-#if GL_VERSION_1_1
if (gUseWireframe)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
-#endif
U32 cur_type = 0;
@@ -3953,6 +4193,10 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
bool done_atmospherics = LLPipeline::sRenderingHUDs; //skip atmospherics on huds
bool done_water_haze = done_atmospherics;
+ bool done_water_exclusion = false;
+
+ // do water exclusion just before water pass.
+ U32 water_exclusion_pass = LLDrawPool::POOL_WATEREXCLUSION;
// do atmospheric haze just before post water alpha
U32 atmospherics_pass = LLDrawPool::POOL_ALPHA_POST_WATER;
@@ -3978,12 +4222,25 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
LLGLState::checkStates(GL_FALSE);
}
+ // turn off atmospherics and water haze for low detail reflection probe
+ static LLCachedControl<S32> probe_level(gSavedSettings, "RenderReflectionProbeLevel", 0);
+ bool low_detail_probe = probe_level == 0 && gCubeSnapshot;
+ done_atmospherics = done_atmospherics || low_detail_probe;
+ done_water_haze = done_water_haze || low_detail_probe;
+
+
while ( iter1 != mPools.end() )
{
LLDrawPool *poolp = *iter1;
cur_type = poolp->getType();
+ if (cur_type >= water_exclusion_pass && !done_water_exclusion)
+ { // do water exclusion against depth buffer before rendering alpha
+ doWaterExclusionMask();
+ done_water_exclusion = true;
+ }
+
if (cur_type >= atmospherics_pass && !done_atmospherics)
{ // do atmospherics against depth buffer before rendering alpha
doAtmospherics();
@@ -4040,7 +4297,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
}
}
iter1 = iter2;
- stop_glerror();
+ LOG_GLERROR("after pools");
}
gGLLastMatrix = NULL;
@@ -4056,12 +4313,12 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
renderDebug();
}
-#if GL_VERSION_1_1
if (gUseWireframe)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
-#endif
+
+ LOG_GLERROR("LLPipeline::renderGeomPostDeferred()");
}
void LLPipeline::renderGeomShadow(LLCamera& camera)
@@ -4121,11 +4378,12 @@ void LLPipeline::renderGeomShadow(LLCamera& camera)
}
}
iter1 = iter2;
- stop_glerror();
+ LOG_GLERROR("");
}
gGLLastMatrix = NULL;
gGL.loadMatrix(gGLModelView);
+ LOG_GLERROR("LLPipeline::renderGeomShadow()");
}
@@ -4154,11 +4412,9 @@ void LLPipeline::renderPhysicsDisplay()
gGL.flush();
gDebugProgram.bind();
-#if GL_VERSION_1_1
LLGLEnable(GL_POLYGON_OFFSET_LINE);
-#endif
glPolygonOffset(3.f, 3.f);
- glLineWidth(3.f);
+ //glLineWidth(3.f);
LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -4172,12 +4428,10 @@ void LLPipeline::renderPhysicsDisplay()
bool wireframe = (pass == 2);
-#if GL_VERSION_1_1
if (wireframe)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
-#endif
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
@@ -4197,14 +4451,12 @@ void LLPipeline::renderPhysicsDisplay()
}
gGL.flush();
-#if GL_VERSION_1_1
if (wireframe)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
-#endif
}
- glLineWidth(1.f);
+ //glLineWidth(1.f);
gDebugProgram.unbind();
}
@@ -4282,16 +4534,14 @@ void LLPipeline::renderDebug()
glClearColor(clearColor.mV[0],clearColor.mV[1],clearColor.mV[2],0);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // no stencil -- deprecated | GL_STENCIL_BUFFER_BIT);
gGL.setColorMask(true, false);
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-#endif
}
//NavMesh
if ( pathfindingConsole->isRenderNavMesh() )
{
gGL.flush();
- glLineWidth(2.0f);
+ //glLineWidth(2.0f);
LLGLEnable cull(GL_CULL_FACE);
LLGLDisable blend(GL_BLEND);
@@ -4314,10 +4564,8 @@ void LLPipeline::renderDebug()
gPathfindingProgram.bind();
gGL.flush();
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-#endif
- glLineWidth(1.0f);
+ //glLineWidth(1.0f);
gGL.flush();
}
//User designated path
@@ -4373,9 +4621,7 @@ void LLPipeline::renderDebug()
LLGLDisable cull(i >= 2 ? GL_CULL_FACE : 0);
gGL.flush();
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-#endif
//get rid of some z-fighting
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
@@ -4400,10 +4646,8 @@ void LLPipeline::renderDebug()
gGL.flush();
}
-#if GL_VERSION_1_1
LLGLEnable lineOffset(GL_POLYGON_OFFSET_LINE);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
-#endif
F32 offset = gSavedSettings.getF32("PathfindingLineOffset");
@@ -4423,14 +4667,10 @@ void LLPipeline::renderDebug()
}
else
{
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-#endif
gPathfindingProgram.uniform1f(sAmbiance, ambiance);
llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] );
-#if GL_VERSION_1_1
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-#endif
}
}
@@ -4440,16 +4680,14 @@ void LLPipeline::renderDebug()
gPathfindingProgram.uniform1f(sTint, 1.f);
gPathfindingProgram.uniform1f(sAlphaScale, 1.f);
- glLineWidth(gSavedSettings.getF32("PathfindingLineWidth"));
+ //glLineWidth(gSavedSettings.getF32("PathfindingLineWidth"));
LLGLDisable blendOut(GL_BLEND);
llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] );
gGL.flush();
- glLineWidth(1.f);
+ //glLineWidth(1.f);
}
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-#endif
}
}
}
@@ -4460,9 +4698,7 @@ void LLPipeline::renderDebug()
{ //render navmesh xray
F32 ambiance = gSavedSettings.getF32("PathfindingAmbiance");
-#if GL_VERSION_1_1
LLGLEnable lineOffset(GL_POLYGON_OFFSET_LINE);
-#endif
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
F32 offset = gSavedSettings.getF32("PathfindingLineOffset");
@@ -4471,7 +4707,7 @@ void LLPipeline::renderDebug()
LLGLEnable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER);
gGL.flush();
- glLineWidth(2.0f);
+ //glLineWidth(2.0f);
LLGLEnable cull(GL_CULL_FACE);
gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint"));
@@ -4479,14 +4715,10 @@ void LLPipeline::renderDebug()
if (gSavedSettings.getBOOL("PathfindingXRayWireframe"))
{ //draw hidden wireframe as darker and less opaque
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
-#endif
gPathfindingProgram.uniform1f(sAmbiance, 1.f);
llPathingLibInstance->renderNavMesh();
-#if GL_VERSION_1_1
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-#endif
}
else
{
@@ -4502,7 +4734,7 @@ void LLPipeline::renderDebug()
gPathfindingProgram.bind();
gGL.flush();
- glLineWidth(1.0f);
+ //glLineWidth(1.0f);
}
glPolygonOffset(0.f, 0.f);
@@ -4526,9 +4758,7 @@ void LLPipeline::renderDebug()
gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep, true);
-#if GL_VERSION_1_1
glPointSize(8.f);
-#endif
LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS);
gGL.begin(LLRender::POINTS);
@@ -4553,39 +4783,55 @@ void LLPipeline::renderDebug()
}
gGL.end();
gGL.flush();
-#if GL_VERSION_1_1
glPointSize(1.f);
-#endif
}
// Debug stuff.
- 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++)
+ if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE |
+ LLPipeline::RENDER_DEBUG_OCCLUSION |
+ LLPipeline::RENDER_DEBUG_LIGHTS |
+ LLPipeline::RENDER_DEBUG_BATCH_SIZE |
+ LLPipeline::RENDER_DEBUG_UPDATE_TYPE |
+ LLPipeline::RENDER_DEBUG_BBOXES |
+ LLPipeline::RENDER_DEBUG_NORMALS |
+ LLPipeline::RENDER_DEBUG_POINTS |
+ LLPipeline::RENDER_DEBUG_TEXTURE_AREA |
+ LLPipeline::RENDER_DEBUG_TEXTURE_ANIM |
+ LLPipeline::RENDER_DEBUG_RAYCAST |
+ LLPipeline::RENDER_DEBUG_AVATAR_VOLUME |
+ LLPipeline::RENDER_DEBUG_AVATAR_JOINTS |
+ LLPipeline::RENDER_DEBUG_AGENT_TARGET |
+ LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA |
+ LLPipeline::RENDER_DEBUG_TEXEL_DENSITY))
+ {
+ LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("render debug bridges");
+
+ for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
{
- LLSpatialPartition* part = region->getSpatialPartition(i);
- if (part)
+ for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
{
- if ( (hud_only && (part->mDrawableType == RENDER_TYPE_HUD || part->mDrawableType == RENDER_TYPE_HUD_PARTICLES)) ||
- (!hud_only && hasRenderType(part->mDrawableType)) )
+ LLSpatialPartition* part = region->getSpatialPartition(i);
+ if (part)
{
- part->renderDebug();
+ if ((hud_only && (part->mDrawableType == RENDER_TYPE_HUD || part->mDrawableType == RENDER_TYPE_HUD_PARTICLES)) ||
+ (!hud_only && hasRenderType(part->mDrawableType)))
+ {
+ part->renderDebug();
+ }
}
}
}
- }
- for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
- {
- LLSpatialBridge* bridge = *i;
- if (!bridge->isDead() && hasRenderType(bridge->mDrawableType))
+ for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
{
- gGL.pushMatrix();
- gGL.multMatrix((F32*)bridge->mDrawable->getRenderMatrix().mMatrix);
- bridge->renderDebug();
- gGL.popMatrix();
+ LLSpatialBridge* bridge = *i;
+ if (!bridge->isDead() && hasRenderType(bridge->mDrawableType))
+ {
+ gGL.pushMatrix();
+ gGL.multMatrix((F32*)bridge->mDrawable->getRenderMatrix().mMatrix);
+ bridge->renderDebug();
+ gGL.popMatrix();
+ }
}
}
@@ -4625,12 +4871,11 @@ void LLPipeline::renderDebug()
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display");
bindDeferredShader(gReflectionProbeDisplayProgram, NULL);
- mScreenTriangleVB->setBuffer();
LLGLEnable blend(GL_BLEND);
LLGLDepthTest depth(GL_FALSE);
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
unbindDeferredShader(gReflectionProbeDisplayProgram);
}
@@ -4741,9 +4986,7 @@ void LLPipeline::renderDebug()
{
//render visible point cloud
gGL.flush();
-#if GL_VERSION_1_1
glPointSize(8.f);
-#endif
gGL.begin(LLRender::POINTS);
F32* c = col+i*4;
@@ -4757,9 +5000,7 @@ void LLPipeline::renderDebug()
gGL.end();
gGL.flush();
-#if GL_VERSION_1_1
glPointSize(1.f);
-#endif
LLVector3* ext = mShadowExtents[i];
LLVector3 pos = (ext[0]+ext[1])*0.5f;
@@ -5081,6 +5322,17 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
}
break;
+ case LLDrawPool::POOL_WATEREXCLUSION:
+ if (mWaterExclusionPool)
+ {
+ llassert(0);
+ LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Water Exclusion Pool" << LL_ENDL;
+ }
+ else
+ {
+ mWaterExclusionPool = new_poolp;
+ }
+ break;
default:
llassert(0);
@@ -5203,6 +5455,11 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp )
mPBRAlphaMaskPool = NULL;
break;
+ case LLDrawPool::POOL_WATEREXCLUSION:
+ llassert(poolp == mWaterExclusionPool);
+ mWaterExclusionPool = nullptr;
+ break;
+
default:
llassert(0);
LL_WARNS() << "Invalid Pool Type in LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL;
@@ -5569,6 +5826,8 @@ void LLPipeline::setupHWLights()
mSunDiffuse.setVec(psky->getSunlightColor());
mMoonDiffuse.setVec(psky->getMoonlightColor());
+ if(!mHDRDisplay)
+ {
F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]);
if (max_color > 1.f)
{
@@ -5582,6 +5841,7 @@ void LLPipeline::setupHWLights()
mMoonDiffuse *= 1.f/max_color;
}
mMoonDiffuse.clamp();
+ }
// prevent underlighting from having neither lightsource facing us
if (!sun_up && !moon_up)
@@ -6607,6 +6867,8 @@ void LLPipeline::resetVertexBuffers(LLDrawable* drawable)
facep->clearVertexBuffer();
}
}
+
+ LOG_GLERROR("LLPipeline::resetVertexBuffers()");
}
void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool rigged)
@@ -6626,6 +6888,7 @@ void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool
gGL.loadMatrix(gGLModelView);
gGLLastMatrix = NULL;
+ LOG_GLERROR("LLPipeline::renderObjects()");
}
void LLPipeline::renderGLTFObjects(U32 type, bool texture, bool rigged)
@@ -6654,6 +6917,7 @@ void LLPipeline::renderGLTFObjects(U32 type, bool texture, bool rigged)
{
LL::GLTFSceneManager::instance().render(true, true);
}
+ LOG_GLERROR("LLPipeline::renderGLTFObjects()");
}
// Currently only used for shadows -Cosmic,2023-04-19
@@ -6666,8 +6930,14 @@ void LLPipeline::renderAlphaObjects(bool rigged)
S32 sun_up = LLEnvironment::instance().getIsSunUp() ? 1 : 0;
U32 target_width = LLRenderTarget::sCurResX;
U32 type = LLRenderPass::PASS_ALPHA;
- LLVOAvatar* lastAvatar = nullptr;
+ // for gDeferredShadowAlphaMaskProgram
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin;
+ // for gDeferredShadowGLTFAlphaBlendProgram
+ const LLVOAvatar* lastAvatarGLTF = nullptr;
+ U64 lastMeshIdGLTF = 0;
+ bool skipLastSkinGLTF;
auto* begin = gPipeline.beginRenderMap(type);
auto* end = gPipeline.endRenderMap(type);
@@ -6691,7 +6961,7 @@ void LLPipeline::renderAlphaObjects(bool 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);
- LLRenderPass::pushRiggedGLTFBatch(*pparams, lastAvatar, lastMeshId);
+ LLRenderPass::pushRiggedGLTFBatch(*pparams, lastAvatarGLTF, lastMeshIdGLTF, skipLastSkinGLTF);
}
else
{
@@ -6699,14 +6969,10 @@ void LLPipeline::renderAlphaObjects(bool 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)
+ if (mSimplePool->uploadMatrixPalette(pparams->mAvatar, pparams->mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- mSimplePool->uploadMatrixPalette(*pparams);
- lastAvatar = pparams->mAvatar;
- lastMeshId = pparams->mSkinInfo->mHash;
+ mSimplePool->pushBatch(*pparams, true, true);
}
-
- mSimplePool->pushBatch(*pparams, true, true);
}
}
else
@@ -6732,6 +6998,7 @@ void LLPipeline::renderAlphaObjects(bool rigged)
gGL.loadMatrix(gGLModelView);
gGLLastMatrix = NULL;
+ LOG_GLERROR("LLPipeline::renderAlphaObjects()");
}
// Currently only used for shadows -Cosmic,2023-04-19
@@ -6750,6 +7017,7 @@ void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture,
}
gGL.loadMatrix(gGLModelView);
gGLLastMatrix = NULL;
+ LOG_GLERROR("LLPipeline::renderMaskedObjects()");
}
// Currently only used for shadows -Cosmic,2023-04-19
@@ -6768,6 +7036,7 @@ void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batc
}
gGL.loadMatrix(gGLModelView);
gGLLastMatrix = NULL;
+ LOG_GLERROR("LLPipeline::renderFullbrightMaskedObjects()");
}
void apply_cube_face_rotation(U32 face)
@@ -6830,13 +7099,13 @@ void LLPipeline::bindScreenToTexture()
}
-static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Bloom");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Post processing");
void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 bufferIndex)
{
- dst->bindTarget();
+ dst->bindTarget("visualizeBuffers", 1);
gDeferredBufferVisualProgram.bind();
- gDeferredBufferVisualProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_BILINEAR, bufferIndex);
+ gDeferredBufferVisualProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT, bufferIndex);
static LLStaticHashedString mipLevel("mipLevel");
if (RenderBufferVisualization != 4)
@@ -6844,8 +7113,7 @@ void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32
else
gDeferredBufferVisualProgram.uniform1f(mipLevel, 8);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
gDeferredBufferVisualProgram.unbind();
dst->flush();
}
@@ -6856,7 +7124,8 @@ void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst)
{
LL_PROFILE_GPU_ZONE("luminance sample");
- dst->bindTarget();
+ dst->bindTarget("generateLuminance", 0);
+ dst->clear();
LLGLDepthTest depth(GL_FALSE, GL_FALSE);
@@ -6887,14 +7156,21 @@ void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst)
static LLStaticHashedString diffuse_luminance_scale_s("diffuse_luminance_scale");
gLuminanceProgram.uniform1f(diffuse_luminance_scale_s, diffuse_luminance_scale);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
+
+ gLuminanceProgram.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ gLuminanceProgram.unbindTexture(LLShaderMgr::DEFERRED_EMISSIVE);
+ gLuminanceProgram.unbindTexture(LLShaderMgr::NORMAL_MAP);
+ gLuminanceProgram.unbind();
+
dst->flush();
// 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();
+ //gLuminanceProgram.unbind();
}
+
+ LOG_GLERROR("LLPipeline::generateLuminance()");
}
void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool use_history) {
@@ -6905,17 +7181,15 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
if (use_history)
{
// copy last frame's exposure into mLastExposure
- mLastExposure.bindTarget();
+ mLastExposure.bindTarget("mLastExposure", 1);
gCopyProgram.bind();
gGL.getTexUnit(0)->bind(dst);
-
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
-
+ renderTriangle();
mLastExposure.flush();
}
- dst->bindTarget();
+ dst->bindTarget("generateExposure", 1);
+ dst->clear();
LLGLDepthTest depth(GL_FALSE, GL_FALSE);
@@ -6949,48 +7223,79 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
static LLStaticHashedString dt("dt");
static LLStaticHashedString noiseVec("noiseVec");
static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params");
+ static LLStaticHashedString dynamic_exposure_params2("dynamic_exposure_params2");
+ static LLStaticHashedString dynamic_exposure_e("dynamic_exposure_enabled");
+ static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false);
+ static LLCachedControl<bool> dynamic_exposure_enabled(gSavedSettings, "RenderDynamicExposureEnabled", true);
static LLCachedControl<F32> dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f);
- static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true);
+ static LLCachedControl<F32> dynamic_exposure_speed_error(gSavedSettings, "RenderDynamicExposureSpeedError", 0.1f);
+ static LLCachedControl<F32> dynamic_exposure_speed_target(gSavedSettings, "RenderDynamicExposureSpeedTarget", 2.f);
LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky();
- F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust);
+ F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust());
+
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;
+ static LLCachedControl<bool> use_exposure_sky_settings(gSavedSettings, "RenderUseExposureSkySettings", false);
- if (hdr_scale > 1.f)
+ if (use_exposure_sky_settings)
+ {
+ if (dynamic_exposure_enabled)
{
- exp_min = 1.f / hdr_scale;
- exp_max = hdr_scale;
+ exp_min = sky->getHDROffset(should_auto_adjust()) - sky->getHDRMin(should_auto_adjust());
+ exp_max = sky->getHDROffset(should_auto_adjust()) + sky->getHDRMax(should_auto_adjust());
+ }
+ else
+ {
+ exp_min = sky->getHDROffset(should_auto_adjust());
+ exp_max = sky->getHDROffset(should_auto_adjust());
+ }
+ }
+ else if (dynamic_exposure_enabled)
+ {
+ 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;
+ }
}
}
+
shader->uniform1f(dt, gFrameIntervalSeconds);
shader->uniform2f(noiseVec, ll_frand() * 2.0f - 1.0f, ll_frand() * 2.0f - 1.0f);
- shader->uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max);
+ shader->uniform4f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max, dynamic_exposure_speed_error);
+ shader->uniform4f(dynamic_exposure_params2, sky->getHDROffset(should_auto_adjust()), exp_min, exp_max, dynamic_exposure_speed_target);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
if (use_history)
{
- gGL.getTexUnit(channel)->unbind(mLastExposure.getUsage());
+ //gGL.getTexUnit(channel)->unbind(mLastExposure.getUsage());
}
+
+ shader->unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ shader->unbindTexture(LLShaderMgr::EXPOSURE_MAP);
shader->unbind();
dst->flush();
}
+
+ LOG_GLERROR("LLPipeline::generateExposure()");
}
extern LLPointer<LLImageGL> gEXRImage;
-void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) {
- dst->bindTarget();
+void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)
+{
+ dst->bindTarget("tonemap", 1);
// gamma correct lighting
{
- LL_PROFILE_GPU_ZONE("gamma correct");
+ LL_PROFILE_GPU_ZONE("tonemap");
static LLCachedControl<bool> buildNoPost(gSavedSettings, "RenderDisablePostProcessing", false);
@@ -6998,18 +7303,16 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) {
// Apply gamma correction to the frame here.
- static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true);
+ static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false);
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
- 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;
+ bool no_post = gSnapshotNoPost || psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f || (buildNoPost && gFloaterTools && gFloaterTools->isAvailable());
+ LLGLSLShader& shader = no_post ? gNoPostTonemapProgram : gDeferredPostTonemapProgram;
shader.bind();
- S32 channel = 0;
+ //S32 channel = 0;
shader.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT);
@@ -7022,18 +7325,67 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) {
F32 e = llclamp(exposure(), 0.5f, 4.f);
static LLStaticHashedString s_exposure("exposure");
- static LLStaticHashedString aces_mix("aces_mix");
+ static LLStaticHashedString tonemap_mix("tonemap_mix");
+ static LLStaticHashedString tonemap_type("tonemap_type");
shader.uniform1f(s_exposure, e);
- shader.uniform1f(aces_mix, gEXRImage.notNull() ? 0.f : 0.3f);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ static LLCachedControl<U32> tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U);
+ shader.uniform1i(tonemap_type, tonemap_type_setting);
+ shader.uniform1f(tonemap_mix, psky->getTonemapMix(should_auto_adjust()));
- gGL.getTexUnit(channel)->unbind(src->getUsage());
+ renderTriangle();
+
+ shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ shader.unbindTexture(LLShaderMgr::EXPOSURE_MAP);
shader.unbind();
}
dst->flush();
+ LOG_GLERROR("LLPipeline::tonemap()");
+}
+
+void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst)
+{
+ LLGLDepthTest depth(GL_FALSE, GL_FALSE);
+
+ // gamma correct lighting
+ {
+ LL_PROFILE_GPU_ZONE("gamma correct");
+
+ dst->bindTarget("gammaCorrect", 1);
+ dst->clear(GL_COLOR_BUFFER_BIT);
+
+ static LLCachedControl<bool> buildNoPost(gSavedSettings, "RenderDisablePostProcessing", false);
+ static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false);
+
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
+ LLGLSLShader& shader = psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f ? gLegacyPostGammaCorrectProgram :
+ gDeferredPostGammaCorrectProgram;
+
+ static LLCachedControl<F32> mp_hdr_boost(gSavedSettings, "MPHDRBoost", false);
+ static LLCachedControl<F32> mp_hdr_gamma(gSavedSettings, "MPHDRGamma", false);
+ if(mHDRDisplay) shader = gHDRGammaCorrectProgram;
+
+ shader.bind();
+ shader.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT);
+ //screensize isn't a uniform in the shader, we comment out for now
+ //shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight());
+
+ if(mHDRDisplay)
+ {
+ shader.uniform1f(LLShaderMgr::GAMMA, (GLfloat)mp_hdr_gamma);
+ shader.uniform1f(LLShaderMgr::MP_HDR_BOOST, 1.0);
+ }
+
+ renderTriangle();
+
+ shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ shader.unbind();
+
+ dst->flush();
+ }
+
+ LOG_GLERROR("LLPipeline::gammaCorrect()");
}
void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst)
@@ -7046,7 +7398,7 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget*
LLRenderTarget& depth_src = mRT->deferredScreen;
- dst->bindTarget();
+ dst->bindTarget("copyScreenSpaceReflections", 1);
dst->clear();
gCopyDepthProgram.bind();
@@ -7056,11 +7408,11 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget*
gGL.getTexUnit(diff_map)->bind(src);
gGL.getTexUnit(depth_map)->bind(&depth_src, true);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
dst->flush();
}
+ LOG_GLERROR("LLPipeline::copyScreenSpaceReflection()");
}
void LLPipeline::generateGlow(LLRenderTarget* src)
@@ -7068,7 +7420,9 @@ void LLPipeline::generateGlow(LLRenderTarget* src)
if (sRenderGlow)
{
LL_PROFILE_GPU_ZONE("glow");
- mGlow[2].bindTarget();
+ LL_RECORD_BLOCK_TIME(FTM_RENDER_GLOW);
+
+ mGlow[2].bindTarget("mGlow[2]", 1);
mGlow[2].clear();
gGlowExtractProgram.bind();
@@ -7108,14 +7462,13 @@ void LLPipeline::generateGlow(LLRenderTarget* src)
gGL.color4f(1, 1, 1, 1);
gPipeline.enableLightsFullbright();
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
-
+ renderTriangle();
+ gGlowExtractProgram.unbindTexture(LLShaderMgr::DIFFUSE_MAP);
+ gGlowExtractProgram.unbindTexture(LLShaderMgr::GLOW_NOISE_MAP);
+ gGlowExtractProgram.unbind();
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));
@@ -7135,7 +7488,7 @@ void LLPipeline::generateGlow(LLRenderTarget* src)
for (S32 i = 0; i < kernel; i++)
{
- mGlow[i % 2].bindTarget();
+ mGlow[i % 2].bindTarget("mGlow[i % 2]", 1);
mGlow[i % 2].clear();
if (i == 0)
@@ -7156,8 +7509,7 @@ void LLPipeline::generateGlow(LLRenderTarget* src)
gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta);
}
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
mGlow[i % 2].flush();
}
@@ -7167,30 +7519,115 @@ void LLPipeline::generateGlow(LLRenderTarget* src)
}
else // !sRenderGlow, skip the glow ping-pong and just clear the result target
{
- mGlow[1].bindTarget();
+ mGlow[1].bindTarget("mGlow[1]", 1);
mGlow[1].clear();
mGlow[1].flush();
}
+ LOG_GLERROR("LLPipeline::generateGlow()");
}
-void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
+bool LLPipeline::applyCAS(LLRenderTarget* src, LLRenderTarget* dst)
+{
+ static LLCachedControl<F32> cas_sharpness(gSavedSettings, "RenderCASSharpness", 0.4f);
+ if (cas_sharpness == 0.0f || !gCASProgram.isComplete())
+ {
+ return false;
+ }
+
+ LLGLSLShader* sharpen_shader = &gCASProgram;
+
+ // Bind setup:
+ dst->bindTarget("applyCAS", 1);
+ dst->clear();
+
+ sharpen_shader->bind();
+
+ {
+ static LLStaticHashedString cas_param_0("cas_param_0");
+ static LLStaticHashedString cas_param_1("cas_param_1");
+ static LLStaticHashedString out_screen_res("out_screen_res");
+
+ varAU4(const0);
+ varAU4(const1);
+ CasSetup(const0, const1,
+ cas_sharpness(), // Sharpness tuning knob (0.0 to 1.0).
+ (AF1)src->getWidth(), (AF1)src->getHeight(), // Input size.
+ (AF1)dst->getWidth(), (AF1)dst->getHeight()); // Output size.
+
+ sharpen_shader->uniform4uiv(cas_param_0, 1, const0);
+ sharpen_shader->uniform4uiv(cas_param_1, 1, const1);
+
+ sharpen_shader->uniform2f(out_screen_res, (AF1)dst->getWidth(), (AF1)dst->getHeight());
+ }
+
+ S32 channel = sharpen_shader->bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT);
+ renderTriangle();
+ sharpen_shader->unbindTexture(channel);
+ sharpen_shader->unbind();
+
+ dst->flush();
+
+ return true;
+}
+
+bool LLPipeline::generateFXAABuffer(LLRenderTarget* src)
+{
+ llassert(!gCubeSnapshot);
+ bool multisample = RenderFSAAType == 1 && gFXAAProgram[0].isComplete() && mFXAAMap.isComplete();
+
+ if(!multisample) return false;
+
+ LL_PROFILE_GPU_ZONE("aa");
+
+ // bake out texture2D with RGBL for FXAA shader
+ mFXAAMap.bindTarget("applyFXAA", 1);
+ mFXAAMap.clear(GL_COLOR_BUFFER_BIT);
+
+ LLGLSLShader* shader = &gGlowCombineFXAAProgram;
+ shader->bind();
+
+ S32 channel = shader->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);
+ renderTriangle();
+ }
+
+ shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage());
+ shader->unbind();
+
+ mFXAAMap.flush();
+
+ LLGLDepthTest depth(GL_FALSE, GL_FALSE);
+ mDummyRT.bindTarget("dummy",1);
+ mDummyRT.clear(GL_COLOR_BUFFER_BIT);
+ mDummyRT.flush();
+
+ return true;
+}
+
+bool LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
{
{
llassert(!gCubeSnapshot);
- bool multisample = RenderFSAASamples > 1 && mFXAAMap.isComplete();
- LLGLSLShader* shader = &gGlowCombineProgram;
+ bool multisample = RenderFSAAType == 1 && gFXAAProgram[0].isComplete() && mFXAAMap.isComplete();
- S32 width = dst->getWidth();
- S32 height = dst->getHeight();
+ if(!multisample) return false;
- // Present everything.
- if (multisample)
{
LL_PROFILE_GPU_ZONE("aa");
+ S32 width = dst->getWidth();
+ S32 height = dst->getHeight();
+
// bake out texture2D with RGBL for FXAA shader
- mFXAAMap.bindTarget();
+ mFXAAMap.bindTarget("applyFXAA", 1);
+ mFXAAMap.clear(GL_COLOR_BUFFER_BIT);
- shader = &gGlowCombineFXAAProgram;
+ LLGLSLShader* shader = &gGlowCombineFXAAProgram;
shader->bind();
S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage());
@@ -7201,8 +7638,7 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
{
LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage());
@@ -7210,8 +7646,13 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
mFXAAMap.flush();
- dst->bindTarget();
- shader = &gFXAAProgram;
+ dst->bindTarget("applyFXAA", 1);
+ dst->clear();
+
+ static LLCachedControl<U32> aa_quality(gSavedSettings, "RenderFSAASamples", 0U);
+ U32 fsaa_quality = std::clamp(aa_quality(), 0U, 3U);
+
+ shader = &gFXAAProgram[fsaa_quality];
shader->bind();
channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mFXAAMap.getUsage());
@@ -7220,12 +7661,14 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
mFXAAMap.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 / mFXAAMap.getWidth();
F32 scale_y = (F32)height / mFXAAMap.getHeight();
@@ -7241,34 +7684,206 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH);
gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
+ }
+
+ if (channel > -1)
+ {
+ shader->unbindTexture(channel);
}
shader->unbind();
dst->flush();
}
- else {
- copyRenderTarget(src, dst);
+ }
+
+ return true;
+}
+
+bool LLPipeline::generateSMAABuffers(LLRenderTarget* src)
+{
+ llassert(!gCubeSnapshot);
+ if(RenderFSAAType < 2) return false;
+ bool multisample = gSMAAEdgeDetectProgram[0].isComplete() && mFXAAMap.isComplete() && mSMAABlendBuffer.isComplete();
+
+ if(!multisample) return false;
+
+ // Present everything.
+ if (multisample)
+ {
+ LL_PROFILE_GPU_ZONE("aa");
+ static LLCachedControl<U32> aa_quality(gSavedSettings, "RenderFSAASamples", 0U);
+ U32 fsaa_quality = std::clamp(aa_quality(), 0U, 3U);
+
+ S32 width = src->getWidth();
+ S32 height = src->getHeight();
+
+ float rt_metrics[] = { 1.f / width, 1.f / height, (float)width, (float)height };
+
+ LLGLDepthTest depth(GL_FALSE, GL_FALSE);
+
+ static LLCachedControl<bool> use_sample(gSavedSettings, "RenderSMAAUseSample", false);
+ //static LLCachedControl<bool> use_stencil(gSavedSettings, "RenderSMAAUseStencil", true);
+ {
+ //LLGLState stencil(GL_STENCIL_TEST, use_stencil);
+
+ // Bind setup:
+ LLRenderTarget& dest = mFXAAMap;
+ LLGLSLShader& edge_shader = gSMAAEdgeDetectProgram[fsaa_quality];
+
+ dest.bindTarget("generateSMAABuffers", 1);
+ dest.clear(GL_COLOR_BUFFER_BIT);
+
+ edge_shader.bind();
+ edge_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics);
+
+ S32 channel = edge_shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+
+ if (channel > -1)
+ {
+ if (!use_sample)
+ {
+ src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+ else
+ {
+ gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mSMAASampleMap);
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ }
+ }
+
+ renderTriangle();
+
+ edge_shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ gGL.getTexUnit(channel)->unbindFast(LLTexUnit::TT_TEXTURE);
+ edge_shader.unbind();
+ dest.flush();
+ }
+
+ {
+ // Bind setup:
+ LLRenderTarget& dest = mSMAABlendBuffer;
+ LLGLSLShader& blend_weights_shader = gSMAABlendWeightsProgram[fsaa_quality];
+
+ dest.bindTarget("mSMAABlendBuffer", 1);
+ dest.clear(GL_COLOR_BUFFER_BIT);
+
+ blend_weights_shader.bind();
+ blend_weights_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics);
+
+ S32 edge_tex_channel = blend_weights_shader.enableTexture(LLShaderMgr::SMAA_EDGE_TEX, mFXAAMap.getUsage());
+ if (edge_tex_channel > -1)
+ {
+ mFXAAMap.bindTexture(0, edge_tex_channel, LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(edge_tex_channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+ S32 area_tex_channel = blend_weights_shader.enableTexture(LLShaderMgr::SMAA_AREA_TEX, LLTexUnit::TT_TEXTURE);
+ if (area_tex_channel > -1)
+ {
+ gGL.getTexUnit(area_tex_channel)->bindManual(LLTexUnit::TT_TEXTURE, mSMAAAreaMap);
+ gGL.getTexUnit(area_tex_channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(area_tex_channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+ S32 search_tex_channel = blend_weights_shader.enableTexture(LLShaderMgr::SMAA_SEARCH_TEX, LLTexUnit::TT_TEXTURE);
+ if (search_tex_channel > -1)
+ {
+ gGL.getTexUnit(search_tex_channel)->bindManual(LLTexUnit::TT_TEXTURE, mSMAASearchMap);
+ gGL.getTexUnit(search_tex_channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(search_tex_channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+
+ renderTriangle();
+
+ blend_weights_shader.unbind();
+ dest.flush();
+ gGL.getTexUnit(edge_tex_channel)->unbindFast(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(area_tex_channel)->unbindFast(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(search_tex_channel)->unbindFast(LLTexUnit::TT_TEXTURE);
+ }
+ }
+
+ LOG_GLERROR("LLPipeline::generateSMAABuffers()");
+
+ return true;
+}
+
+bool LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst)
+{
+ llassert(!gCubeSnapshot);
+
+ bool multisample = false;
+
+ if(RenderFSAAType > 1)
+ {
+ multisample = gSMAAEdgeDetectProgram[0].isComplete() && mFXAAMap.isComplete() && mSMAABlendBuffer.isComplete();
+ }
+
+ if(!multisample) return false;
+
+ {
+ LL_PROFILE_GPU_ZONE("aa");
+ static LLCachedControl<U32> aa_quality(gSavedSettings, "RenderFSAASamples", 0U);
+ U32 fsaa_quality = std::clamp(aa_quality(), 0U, 3U);
+
+ S32 width = src->getWidth();
+ S32 height = src->getHeight();
+
+ float rt_metrics[] = { 1.f / width, 1.f / height, (float)width, (float)height };
+
+ LLGLDepthTest depth(GL_FALSE, GL_FALSE);
+
+ static LLCachedControl<bool> use_sample(gSavedSettings, "RenderSMAAUseSample", false);
+
+ {
+ // Bind setup:
+ LLRenderTarget* bound_target = dst;
+ LLGLSLShader& blend_shader = gSMAANeighborhoodBlendProgram[fsaa_quality];
+
+ bound_target->bindTarget("applySMAA", 1);
+ bound_target->clear(GL_COLOR_BUFFER_BIT);
+
+ blend_shader.bind();
+ blend_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics);
+
+ S32 diffuse_channel = blend_shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ if(diffuse_channel > -1)
+ {
+ src->bindTexture(0, diffuse_channel, LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(diffuse_channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+
+ S32 blend_channel = blend_shader.enableTexture(LLShaderMgr::SMAA_BLEND_TEX);
+ if (blend_channel > -1)
+ {
+ mSMAABlendBuffer.bindTexture(0, blend_channel, LLTexUnit::TFO_BILINEAR);
+ }
+
+ renderTriangle();
+ gGL.getTexUnit(diffuse_channel)->unbindFast(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(blend_channel)->unbindFast(LLTexUnit::TT_TEXTURE);
+ blend_shader.unbind();
+ bound_target->flush();
}
}
+
+ LOG_GLERROR("LLPipeline::applySMAA()");
+ return true;
}
void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst)
{
LL_PROFILE_GPU_ZONE("copyRenderTarget");
- dst->bindTarget();
-
+ dst->bindTarget("copyRenderTarget", 1);
+ dst->clear(GL_COLOR_BUFFER_BIT);
gDeferredPostNoDoFProgram.bind();
gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src);
- gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true);
+ //gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true);
- {
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
- }
+ renderTriangle();
gDeferredPostNoDoFProgram.unbind();
@@ -7279,7 +7894,7 @@ 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();
+ dst->bindTarget("combineGlow", 1);
{
@@ -7288,14 +7903,14 @@ void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst)
gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src);
gGlowCombineProgram.bindTexture(LLShaderMgr::DEFERRED_EMISSIVE, &mGlow[1]);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
dst->flush();
+ LOG_GLERROR("LLPipeline::combineGlow()");
}
-void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
+bool LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
{
{
bool dof_enabled =
@@ -7303,6 +7918,8 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
RenderDepthOfField &&
!gCubeSnapshot;
+ if(!dof_enabled) return false;
+
gViewerWindow->setup3DViewport();
if (dof_enabled)
@@ -7411,7 +8028,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
F32 magnification = focal_length / (subject_distance - focal_length);
{ // build diffuse+bloom+CoF
- mRT->deferredLight.bindTarget();
+ mRT->deferredLight.bindTarget("renderDOF", 1);
gDeferredCoFProgram.bind();
@@ -7428,8 +8045,8 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
+
gDeferredCoFProgram.unbind();
mRT->deferredLight.flush();
}
@@ -7438,7 +8055,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale);
{ // perform DoF sampling at half-res (preserve alpha channel)
- src->bindTarget();
+ src->bindTarget("DoF sampling", 1);
glViewport(0, 0, dof_width, dof_height);
gGL.setColorMask(true, false);
@@ -7450,8 +8067,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
gDeferredPostProgram.unbind();
@@ -7461,19 +8077,8 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
{ // combine result based on alpha
- dst->bindTarget();
- if (RenderFSAASamples > 1 && mFXAAMap.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]);
- }
+ dst->bindTarget("DoF combine", 1);
+ glViewport(0, 0, dst->getWidth(), dst->getHeight());
gDeferredDoFCombineProgram.bind();
gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT);
@@ -7485,19 +8090,134 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)
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);
- gDeferredDoFCombineProgram.unbind();
+ renderTriangle();
+ gDeferredDoFCombineProgram.unbind();
dst->flush();
}
}
- else
- {
- copyRenderTarget(src, dst);
- }
}
+
+ return true;
+}
+
+bool LLPipeline::renderBloom(LLRenderTarget* src, LLRenderTarget* dst)
+{
+ static LLCachedControl<U32> mp_render_bloom(gSavedSettings, "MPRenderBloom", 0);
+
+ if(mp_render_bloom < 1) return false;
+
+ static LLCachedControl<F32> mp_bloom_extract_brightness(gSavedSettings, "MPBloomExtractBrightness", 0.10);
+ static LLCachedControl<F32> mp_bloom_radius(gSavedSettings, "MPBloomBlurRadius", 1.5);
+ static LLCachedControl<F32> mp_bloom_radius_add(gSavedSettings, "MPBloomBlurRadiusAdd", 0);
+ static LLCachedControl<F32> mp_bloom_strength(gSavedSettings, "MPBloomStrength", 1.0);
+ static LLCachedControl<F32> mp_bloom_metal(gSavedSettings, "MPBloomExtractMetal", 0.2);
+ static LLCachedControl<F32> mp_bloom_nonmetal(gSavedSettings, "MPBloomExtractNonMetal", 0.2);
+
+ F32 clampValue = 1.0;
+ if(mHDRDisplay) clampValue = 11.0;
+
+ LLGLDepthTest depth(GL_FALSE, GL_FALSE);
+ LLGLDisable blend(GL_BLEND);
+
+ mBloomMap.bindTarget("mBloomMap", 1);
+
+ glClearColor(0, 0, 0, 0);
+ mBloomMap.clear();
+
+ gBloomExtractProgram.bind();
+ gBloomExtractProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, &mRT->screen);
+ gBloomExtractProgram.bindTexture(LLShaderMgr::BLOOM_EXTRACT_ORM, &mRT->deferredScreen, false, LLTexUnit::TFO_POINT, 1);
+ //gBloomExtractProgram.bindTexture(LLShaderMgr::BLOOM_EXTRACT_EMISSIVE, &mGlow[1], false, LLTexUnit::TFO_POINT, 0);
+ gBloomExtractProgram.bindTexture(LLShaderMgr::BLOOM_EXTRACT_EMISSIVE2, &mRT->deferredScreen, false, LLTexUnit::TFO_POINT, 3);
+
+ gBloomExtractProgram.uniform1f(LLShaderMgr::BLOOM_EXTRACT_BRIGHTNESS, 1.0 - mp_bloom_extract_brightness);
+ gBloomExtractProgram.uniform1f(LLShaderMgr::BLOOM_EXTRACT_METAL, mp_bloom_metal);
+ gBloomExtractProgram.uniform1f(LLShaderMgr::BLOOM_EXTRACT_NONMETAL, mp_bloom_nonmetal);
+
+ renderTriangle();
+
+ gBloomExtractProgram.unbindTexture(LLShaderMgr::DIFFUSE_MAP);
+ gBloomExtractProgram.unbindTexture(LLShaderMgr::BLOOM_EXTRACT_ORM);
+ gBloomExtractProgram.unbindTexture(LLShaderMgr::BLOOM_EXTRACT_EMISSIVE);
+ gBloomExtractProgram.unbindTexture(LLShaderMgr::BLOOM_EXTRACT_EMISSIVE2);
+
+ gBloomExtractProgram.unbind();
+ mBloomMap.flush();
+
+
+ // ping pong blur
+
+ S16 horizontal = 1, first_iteration = true;
+ unsigned int amount = mp_render_bloom;
+ if(amount > 10) amount = 10;
+
+ F32 radius = mp_bloom_radius;
+
+ gBloomBlurProgram.bind();
+
+
+ // Iteration 0
+
+ gBloomBlurProgram.uniform1f(LLShaderMgr::BLOOM_BLUR_RADIUS, radius);
+
+ mBloomBlur[0].bindTarget("", 1);
+ //mBloomBlur[0].clear();
+ gBloomBlurProgram.uniform1i( LLShaderMgr::BLOOM_BLURH, 0);
+ gBloomBlurProgram.bindTexture( LLShaderMgr::BLOOM_EMAP, &mBloomMap);
+ renderTriangle();
+ mBloomBlur[0].flush();
+
+ mBloomBlur[1].bindTarget("", 1);
+ gBloomBlurProgram.uniform1i( LLShaderMgr::BLOOM_BLURH, 1);
+ gBloomBlurProgram.bindTexture( LLShaderMgr::BLOOM_EMAP, &mBloomBlur[0]);
+ renderTriangle();
+ mBloomBlur[1].flush();
+
+
+ // additional iterations
+
+ for (unsigned int i = 1; i < amount; i++)
+ {
+ radius += mp_bloom_radius_add;
+ gBloomBlurProgram.uniform1f(LLShaderMgr::BLOOM_BLUR_RADIUS, radius);
+
+ mBloomBlur[0].bindTarget("", 1);
+ gBloomBlurProgram.uniform1i( LLShaderMgr::BLOOM_BLURH, 0);
+ gBloomBlurProgram.bindTexture( LLShaderMgr::BLOOM_EMAP, &mBloomBlur[1]);
+ renderTriangle();
+ mBloomBlur[0].flush();
+
+ mBloomBlur[1].bindTarget("", 1);
+ gBloomBlurProgram.uniform1i( LLShaderMgr::BLOOM_BLURH, 1);
+ gBloomBlurProgram.bindTexture( LLShaderMgr::BLOOM_EMAP, &mBloomBlur[0]);
+ renderTriangle();
+ mBloomBlur[1].flush();
+ }
+
+ gBloomBlurProgram.unbindTexture(LLShaderMgr::BLOOM_EMAP);
+ gBloomBlurProgram.unbind();
+
+
+ // combine
+
+ dst->bindTarget("bloom combine", 1);
+ //dst->clear();
+
+ gBloomCombineProgram.bind();
+
+ gBloomCombineProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, src);
+ gBloomCombineProgram.bindTexture(LLShaderMgr::BLOOM_BMAP, &mBloomBlur[1]);
+ gBloomCombineProgram.uniform1f(LLShaderMgr::BLOOM_STRENGTH, mp_bloom_strength);
+ gBloomCombineProgram.uniform1f(LLShaderMgr::BLOOM_CLAMP, clampValue);
+
+ renderTriangle();
+
+ gBloomCombineProgram.unbind();
+ dst->flush();
+
+ return true;
}
void LLPipeline::renderFinalize()
@@ -7511,44 +8231,115 @@ void LLPipeline::renderFinalize()
LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM);
LL_PROFILE_GPU_ZONE("renderFinalize");
+#if LL_DARWIN
+ //gGL.debugTexUnits();
+
+ // Aims to fix the slowdowns in the post processing
+ for (S32 i = 0; i < 16; i++)
+ {
+ if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE)
+ {
+ gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType());
+ gGL.getTexUnit(i)->disable();
+ }
+ }
+#endif
+
gGL.color4f(1, 1, 1, 1);
LLGLDepthTest depth(GL_FALSE);
LLGLDisable blend(GL_BLEND);
LLGLDisable cull(GL_CULL_FACE);
- enableLightsFullbright();
+ 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.setColorMask(true, true);
glClearColor(0, 0, 0, 0);
+ static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
+ bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();
- copyScreenSpaceReflections(&mRT->screen, &mSceneMap);
+ U16 activeRT = 0;
- generateLuminance(&mRT->screen, &mLuminanceMap);
+ LLRenderTarget* postHDRBuffer = &mRT->screen;
- generateExposure(&mLuminanceMap, &mExposureMap);
+ if (hdr)
+ {
+ if(generateFXAABuffer(postHDRBuffer));
+ else generateSMAABuffers(postHDRBuffer);
- gammaCorrect(&mRT->screen, &mPostMap);
+ copyScreenSpaceReflections(&mRT->screen, &mSceneMap);
- LLVertexBuffer::unbind();
+ if(!mHDRDisplay)
+ {
+ generateLuminance(&mRT->screen, &mLuminanceMap);
- generateGlow(&mPostMap);
+ generateExposure(&mLuminanceMap, &mExposureMap);
- combineGlow(&mPostMap, &mRT->screen);
+ tonemap(&mRT->screen, &mRT->deferredLight);
+ postHDRBuffer = &mRT->deferredLight;
+ }
+ }
- 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]);
+ gammaCorrect(postHDRBuffer, &mPostMaps[1 - activeRT]);
+ activeRT = 1 - activeRT;
- renderDoF(&mRT->screen, &mPostMap);
+ generateGlow(&mPostMaps[activeRT]);
+
+ if(!hdr)
+ {
+ if(generateFXAABuffer(postHDRBuffer))
+ {
+ }
+ else if(generateSMAABuffers(postHDRBuffer))
+ {
+ }
+ else
+ {
+ }
+ }
+
+ if(applyFXAA(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+ else if(applySMAA(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+
+ if(hdr)
+ {
+ if(renderBloom(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+ }
+
+ combineGlow(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]);
+ activeRT = 1 - activeRT;
+
+ if(!mHDRDisplay)
+ {
+ //CAS breaks the hdr colors for now.
+ if(applyCAS(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+ }
+
+ if(renderDoF(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+
+ LLRenderTarget* finalBuffer = &mPostMaps[activeRT];
- applyFXAA(&mPostMap, &mRT->screen);
- LLRenderTarget* finalBuffer = &mRT->screen;
if (RenderBufferVisualization > -1)
{
- finalBuffer = &mPostMap;
switch (RenderBufferVisualization)
{
case 0:
@@ -7559,6 +8350,53 @@ void LLPipeline::renderFinalize()
break;
case 4:
visualizeBuffers(&mLuminanceMap, finalBuffer, 0);
+ break;
+ case 5:
+ {
+ if (RenderFSAAType > 0)
+ {
+ visualizeBuffers(&mFXAAMap, finalBuffer, 0);
+ }
+ break;
+ }
+ case 6:
+ {
+ if (RenderFSAAType == 2)
+ {
+ visualizeBuffers(&mSMAABlendBuffer, finalBuffer, 0);
+ }
+ break;
+ }
+ case 7:
+ visualizeBuffers(&mBloomMap, finalBuffer, 0);
+ break;
+ case 8:
+ visualizeBuffers(&mBloomBlur[1], finalBuffer, 0);
+ break;
+ case 9:
+ visualizeBuffers(&mPostMaps[activeRT], finalBuffer, 0);
+ break;
+ case 10:
+ visualizeBuffers(&mGlow[0], finalBuffer, 0);
+ break;
+ case 11:
+ visualizeBuffers(&mGlow[1], finalBuffer, 0);
+ break;
+ case 12:
+ visualizeBuffers(&mGlow[2], finalBuffer, 0);
+ break;
+ case 13:
+ visualizeBuffers(&mSceneMap, finalBuffer, 0);
+ break;
+ case 14:
+ visualizeBuffers(&mRT->screen, finalBuffer, 0);
+ break;
+ case 15:
+ visualizeBuffers(&mRT->deferredLight, finalBuffer, 0);
+ break;
+ case 16:
+ visualizeBuffers(&mPostMaps[1-activeRT], finalBuffer, 0);
+ break;
default:
break;
}
@@ -7566,19 +8404,24 @@ void LLPipeline::renderFinalize()
// Present the screen target.
- gDeferredPostNoDoFProgram.bind();
+ gDeferredPostNoDoFNoiseProgram.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, finalBuffer);
- gDeferredPostNoDoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true);
+ gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, finalBuffer);
+ gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true);
+
+ gDeferredPostNoDoFNoiseProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)finalBuffer->getWidth(), (GLfloat)finalBuffer->getHeight());
{
LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
- gDeferredPostNoDoFProgram.unbind();
+ gDeferredPostNoDoFNoiseProgram.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ gDeferredPostNoDoFNoiseProgram.unbindTexture(LLShaderMgr::DEFERRED_DEPTH);
+ gDeferredPostNoDoFNoiseProgram.unbind();
+
+ gGL.flush();
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -7600,6 +8443,7 @@ void LLPipeline::renderFinalize()
// flush calls made to "addTrianglesDrawn" so far to stats machinery
recordTrianglesDrawn();
+ LOG_GLERROR("LLPipeline::renderFinalize()");
}
void LLPipeline::bindLightFunc(LLGLSLShader& shader)
@@ -7619,6 +8463,8 @@ void LLPipeline::bindLightFunc(LLGLSLShader& shader)
void LLPipeline::bindShadowMaps(LLGLSLShader& shader)
{
+ LOG_GLERROR("bindShadowMaps() 1");
+
for (U32 i = 0; i < 4; i++)
{
LLRenderTarget* shadow_target = getSunShadowTarget(i);
@@ -7632,6 +8478,8 @@ void LLPipeline::bindShadowMaps(LLGLSLShader& shader)
}
}
+ LOG_GLERROR("bindShadowMaps() 2");
+
for (U32 i = 4; i < 6; i++)
{
S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i);
@@ -7728,7 +8576,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_
if (sReflectionRender && !shader.getUniformLocation(LLShaderMgr::MODELVIEW_MATRIX))
{
- shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_MATRIX, 1, false, mReflectionModelView.m);
+ shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_MATRIX, 1, false, glm::value_ptr(mReflectionModelView));
}
channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE);
@@ -7740,7 +8588,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_
bindLightFunc(shader);
- stop_glerror();
+ LOG_GLERROR("bindDeferredShader()");
light_target = light_target ? light_target : deferred_light_target;
channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, light_target->getUsage());
@@ -7756,26 +8604,26 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_
}
}
- stop_glerror();
+ LOG_GLERROR("bindDeferredShader() 2");
bindShadowMaps(shader);
- stop_glerror();
+ LOG_GLERROR("bindDeferredShader() 3");
F32 mat[16*6];
for (U32 i = 0; i < 16; i++)
{
- mat[i] = mSunShadowMatrix[0].m[i];
- mat[i+16] = mSunShadowMatrix[1].m[i];
- mat[i+32] = mSunShadowMatrix[2].m[i];
- mat[i+48] = mSunShadowMatrix[3].m[i];
- mat[i+64] = mSunShadowMatrix[4].m[i];
- mat[i+80] = mSunShadowMatrix[5].m[i];
+ mat[i] = glm::value_ptr(mSunShadowMatrix[0])[i];
+ mat[i+16] = glm::value_ptr(mSunShadowMatrix[1])[i];
+ mat[i+32] = glm::value_ptr(mSunShadowMatrix[2])[i];
+ mat[i+48] = glm::value_ptr(mSunShadowMatrix[3])[i];
+ mat[i+64] = glm::value_ptr(mSunShadowMatrix[4])[i];
+ mat[i+80] = glm::value_ptr(mSunShadowMatrix[5])[i];
}
shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_SHADOW_MATRIX, 6, false, mat);
- stop_glerror();
+ LOG_GLERROR("bindDeferredShader() 4");
if (!LLPipeline::sReflectionProbesEnabled)
{
@@ -7876,19 +8724,19 @@ 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.uniformMatrix4fv(LLShaderMgr::MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, glm::value_ptr(gGLDeltaModelView));
+ shader.uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, glm::value_ptr(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();
- shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, false, norm_mat.m);
+ glm::mat4 norm_mat = glm::transpose(glm::inverse(get_current_modelview()));
+ shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, false, glm::value_ptr(norm_mat));
}
// auto adjust legacy sun color if needed
- static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true);
+ static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false);
static LLCachedControl<F32> auto_adjust_sun_color_scale(gSavedSettings, "RenderSkyAutoAdjustSunColorScale", 1.f);
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
LLColor3 sun_diffuse(mSunDiffuse.mV);
@@ -7929,6 +8777,8 @@ void LLPipeline::renderDeferredLighting()
return;
}
+ LOG_GLERROR("renderDeferredLighting begin");
+
llassert(!sRenderingHUDs);
F32 light_scale = 1.f;
@@ -7958,51 +8808,33 @@ void LLPipeline::renderDeferredLighting()
LLGLEnable cull(GL_CULL_FACE);
LLGLEnable blend(GL_BLEND);
- glh::matrix4f mat = copy_matrix(gGLModelView);
+ glm::mat4 mat = get_current_modelview();
setupHWLights(); // to set mSun/MoonDir;
- glh::vec4f tc(mSunDir.mV);
- mat.mult_matrix_vec(tc);
- mTransformedSunDir.set(tc.v);
+ glm::vec4 tc(mSunDir);
+ tc = mat * tc;
+ mTransformedSunDir.set(tc);
- glh::vec4f tc_moon(mMoonDir.mV);
- mat.mult_matrix_vec(tc_moon);
- mTransformedMoonDir.set(tc_moon.v);
+ glm::vec4 tc_moon(mMoonDir);
+ tc_moon = mat * tc_moon;
+ mTransformedMoonDir.set(tc_moon);
- if (RenderDeferredSSAO || RenderShadowDetail > 0)
+ if ((RenderDeferredSSAO && !gCubeSnapshot) || (RenderShadowDetail > 0 && RenderShadowDetail < 4))
{
LL_PROFILE_GPU_ZONE("sun program");
- deferred_light_target->bindTarget();
+ deferred_light_target->bindTarget("sun_shader", 1);
{ // paint shadow/SSAO light map (direct lighting lightmap)
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - sun shadow");
- bindDeferredShader(gDeferredSunProgram, deferred_light_target);
+
+ LLGLSLShader& sun_shader = gCubeSnapshot ? gDeferredSunProbeProgram : gDeferredSunProgram;
+ bindDeferredShader(sun_shader, deferred_light_target);
mScreenTriangleVB->setBuffer();
glClearColor(1, 1, 1, 1);
deferred_light_target->clear(GL_COLOR_BUFFER_BIT);
glClearColor(0, 0, 0, 0);
- glh::matrix4f inv_trans = get_current_modelview().inverse().transpose();
-
- const U32 slice = 32;
- F32 offset[slice * 3];
- for (U32 i = 0; i < 4; i++)
- {
- for (U32 j = 0; j < 8; j++)
- {
- glh::vec3f v;
- v.set_value(sinf(6.284f / 8 * j), cosf(6.284f / 8 * j), -(F32) i);
- v.normalize();
- inv_trans.mult_matrix_vec(v);
- v.normalize();
- offset[(i * 8 + j) * 3 + 0] = v.v[0];
- offset[(i * 8 + j) * 3 + 1] = v.v[2];
- offset[(i * 8 + j) * 3 + 2] = v.v[1];
- }
- }
-
- gDeferredSunProgram.uniform3fv(sOffset, slice, offset);
- gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES,
+ sun_shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES,
(GLfloat)deferred_light_target->getWidth(),
(GLfloat)deferred_light_target->getHeight());
@@ -8012,18 +8844,18 @@ void LLPipeline::renderDeferredLighting()
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
}
- unbindDeferredShader(gDeferredSunProgram);
+ unbindDeferredShader(sun_shader);
}
deferred_light_target->flush();
}
- if (RenderDeferredSSAO)
+ if (RenderDeferredSSAO && !gCubeSnapshot)
{
// soften direct lighting lightmap
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow");
LL_PROFILE_GPU_ZONE("soften shadow");
// blur lightmap
- screen_target->bindTarget();
+ screen_target->bindTarget("SSAO", 1);
glClearColor(1, 1, 1, 1);
screen_target->clear(GL_COLOR_BUFFER_BIT);
glClearColor(0, 0, 0, 0);
@@ -8056,8 +8888,7 @@ void LLPipeline::renderDeferredLighting()
{
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
screen_target->flush();
@@ -8065,21 +8896,20 @@ void LLPipeline::renderDeferredLighting()
bindDeferredShader(gDeferredBlurLightProgram, screen_target);
- deferred_light_target->bindTarget();
+ deferred_light_target->bindTarget("blur light", 1);
gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f);
{
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
deferred_light_target->flush();
unbindDeferredShader(gDeferredBlurLightProgram);
}
- screen_target->bindTarget();
+ screen_target->bindTarget("renderDeferredLighting screen_target", 1);
// clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky
glClearColor(0, 0, 0, 0);
screen_target->clear(GL_COLOR_BUFFER_BIT);
@@ -8101,6 +8931,7 @@ void LLPipeline::renderDeferredLighting()
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);
@@ -8111,21 +8942,22 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
// full screen blit
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
unbindDeferredShader(gDeferredSoftenProgram);
}
static LLCachedControl<S32> local_light_count(gSavedSettings, "RenderLocalLightCount", 256);
+ static LLCachedControl<S32> probe_level(gSavedSettings, "RenderReflectionProbeLevel", 0);
- if (local_light_count > 0)
+ if (local_light_count > 0 && (!gCubeSnapshot || probe_level > 0))
{
gGL.setSceneBlendType(LLRender::BT_ADD);
std::list<LLVector4> fullscreen_lights;
LLDrawable::drawable_list_t spot_lights;
LLDrawable::drawable_list_t fullscreen_spot_lights;
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
if (!gCubeSnapshot)
{
@@ -8221,6 +9053,8 @@ void LLPipeline::renderDeferredLighting()
gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF));
+ gDeferredLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0);
+
gGL.syncMatrices();
mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center));
@@ -8234,10 +9068,10 @@ void LLPipeline::renderDeferredLighting()
continue;
}
- glh::vec3f tc(c);
- mat.mult_matrix_vec(tc);
+ glm::vec3 tc(center);
+ tc = mul_mat4_vec3(mat, tc);
- fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s));
+ fullscreen_lights.push_back(LLVector4(tc.x, tc.y, tc.z, s));
light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)));
}
}
@@ -8281,6 +9115,8 @@ void LLPipeline::renderDeferredLighting()
gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF));
+ gDeferredSpotLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0);
+
gGL.syncMatrices();
mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center));
@@ -8319,10 +9155,10 @@ void LLPipeline::renderDeferredLighting()
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);
+ gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0);
far_z = 0.f;
count = 0;
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
unbindDeferredShader(gDeferredMultiLightProgram[idx]);
}
}
@@ -8338,25 +9174,29 @@ void LLPipeline::renderDeferredLighting()
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++;
- glh::vec3f tc(c);
- mat.mult_matrix_vec(tc);
+ glm::vec3 tc(center);
+ tc = mul_mat4_vec3(mat, tc);
setupSpotLight(gDeferredMultiSpotLightProgram, drawablep);
// send light color to shader in linear space
LLColor3 col = volume->getLightLinearColor() * light_scale;
- gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v);
+ gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, glm::value_ptr(tc));
gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final);
gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, light_falloff_final);
+ gDeferredMultiSpotLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0);
+
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ /*
+ gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ */
}
gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION);
@@ -8399,6 +9239,7 @@ void LLPipeline::renderDeferredLighting()
LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK,
LLPipeline::RENDER_TYPE_TERRAIN,
LLPipeline::RENDER_TYPE_WATER,
+ LLPipeline::RENDER_TYPE_WATEREXCLUSION,
END_RENDER_TYPES);
renderGeomPostDeferred(*LLViewerCamera::getInstance());
@@ -8418,11 +9259,14 @@ void LLPipeline::renderDeferredLighting()
}
}
gGL.setColorMask(true, true);
+
+ LOG_GLERROR("renderDeferredLighting end");
}
void LLPipeline::doAtmospherics()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
+ LOG_GLERROR("doAtmospherics begin");
if (sImpostorRender)
{ // do not attempt atmospherics on impostors
@@ -8440,7 +9284,7 @@ void LLPipeline::doAtmospherics()
LLRenderTarget& dst = gPipeline.mWaterDis;
mRT->screen.flush();
- dst.bindTarget();
+ dst.bindTarget("doAtmospherics dst", 1);
gCopyDepthProgram.bind();
S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP);
@@ -8450,11 +9294,10 @@ void LLPipeline::doAtmospherics()
gGL.getTexUnit(depth_map)->bind(&depth_src, true);
gGL.setColorMask(false, false);
- gPipeline.mScreenTriangleVB->setBuffer();
- gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
dst.flush();
- mRT->screen.bindTarget();
+ mRT->screen.bindTarget("atmospherics", 1);
}
LLGLEnable blend(GL_BLEND);
@@ -8476,13 +9319,14 @@ void LLPipeline::doAtmospherics()
LLGLDepthTest depth(GL_FALSE);
// full screen blit
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
unbindDeferredShader(haze_shader);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
+
+ LOG_GLERROR("doAtmospherics end");
}
void LLPipeline::doWaterHaze()
@@ -8504,7 +9348,7 @@ void LLPipeline::doWaterHaze()
LLRenderTarget& dst = gPipeline.mWaterDis;
mRT->screen.flush();
- dst.bindTarget();
+ dst.bindTarget("water haze copy depth", 1);
gCopyDepthProgram.bind();
S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP);
@@ -8514,11 +9358,10 @@ void LLPipeline::doWaterHaze()
gGL.getTexUnit(depth_map)->bind(&depth_src, true);
gGL.setColorMask(false, false);
- gPipeline.mScreenTriangleVB->setBuffer();
- gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
dst.flush();
- mRT->screen.bindTarget();
+ mRT->screen.bindTarget("water haze", 1);
}
LLGLEnable blend(GL_BLEND);
@@ -8537,13 +9380,14 @@ void LLPipeline::doWaterHaze()
static LLStaticHashedString above_water_str("above_water");
haze_shader.uniform1i(above_water_str, sUnderWaterRender ? -1 : 1);
+ haze_shader.bindTexture(LLShaderMgr::WATER_EXCLUSIONTEX, &mWaterExclusionMask);
+
if (LLPipeline::sUnderWaterRender)
{
LLGLDepthTest depth(GL_FALSE);
// full screen blit
- mScreenTriangleVB->setBuffer();
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ renderTriangle();
}
else
{
@@ -8565,6 +9409,19 @@ void LLPipeline::doWaterHaze()
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
+
+ LOG_GLERROR("after doWaterHaze()");
+}
+
+void LLPipeline::doWaterExclusionMask()
+{
+ mWaterExclusionMask.bindTarget("", 1);
+ glClearColor(1, 1, 1, 1);
+ mWaterExclusionMask.clear();
+ mWaterExclusionPool->render();
+
+ mWaterExclusionMask.flush();
+ glClearColor(0, 0, 0, 0);
}
void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
@@ -8595,10 +9452,10 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
//matrix from volume space to agent space
LLMatrix4 light_mat(quat, LLVector4(origin,1.f));
- glh::matrix4f light_to_agent((F32*) light_mat.mMatrix);
- glh::matrix4f light_to_screen = get_current_modelview() * light_to_agent;
+ glm::mat4 light_to_agent(glm::make_mat4((F32*) light_mat.mMatrix));
+ glm::mat4 light_to_screen = get_current_modelview() * light_to_agent;
- glh::matrix4f screen_to_light = light_to_screen.inverse();
+ glm::mat4 screen_to_light = glm::inverse(light_to_screen);
F32 s = volume->getLightRadius()*1.5f;
F32 near_clip = dist;
@@ -8606,34 +9463,34 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
F32 height = scale.mV[VY];
F32 far_clip = s+dist-scale.mV[VZ];
- F32 fovy = fov * RAD_TO_DEG;
+ F32 fovy = fov; // radians
F32 aspect = width/height;
- 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);
+ glm::mat4 trans(0.5f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.5f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 1.0f);
- glh::vec3f p1(0, 0, -(near_clip+0.01f));
- glh::vec3f p2(0, 0, -(near_clip+1.f));
+ glm::vec3 p1(0, 0, -(near_clip+0.01f));
+ glm::vec3 p2(0, 0, -(near_clip+1.f));
- glh::vec3f screen_origin(0, 0, 0);
+ glm::vec3 screen_origin(0, 0, 0);
- light_to_screen.mult_matrix_vec(p1);
- light_to_screen.mult_matrix_vec(p2);
- light_to_screen.mult_matrix_vec(screen_origin);
+ p1 = mul_mat4_vec3(light_to_screen, p1);
+ p2 = mul_mat4_vec3(light_to_screen, p2);
+ screen_origin = mul_mat4_vec3(light_to_screen, screen_origin);
- glh::vec3f n = p2-p1;
- n.normalize();
+ glm::vec3 n = p2-p1;
+ n = glm::normalize(n);
F32 proj_range = far_clip - near_clip;
- glh::matrix4f light_proj = gl_perspective(fovy, aspect, near_clip, far_clip);
+ glm::mat4 light_proj = glm::perspective(fovy, aspect, near_clip, far_clip);
screen_to_light = trans * light_proj * screen_to_light;
- shader.uniformMatrix4fv(LLShaderMgr::PROJECTOR_MATRIX, 1, false, screen_to_light.m);
+ shader.uniformMatrix4fv(LLShaderMgr::PROJECTOR_MATRIX, 1, false, glm::value_ptr(screen_to_light));
shader.uniform1f(LLShaderMgr::PROJECTOR_NEAR, near_clip);
- shader.uniform3fv(LLShaderMgr::PROJECTOR_P, 1, p1.v);
- shader.uniform3fv(LLShaderMgr::PROJECTOR_N, 1, n.v);
- shader.uniform3fv(LLShaderMgr::PROJECTOR_ORIGIN, 1, screen_origin.v);
+ shader.uniform3fv(LLShaderMgr::PROJECTOR_P, 1, glm::value_ptr(p1));
+ shader.uniform3fv(LLShaderMgr::PROJECTOR_N, 1, glm::value_ptr(n));
+ shader.uniform3fv(LLShaderMgr::PROJECTOR_ORIGIN, 1, glm::value_ptr(screen_origin));
shader.uniform1f(LLShaderMgr::PROJECTOR_RANGE, proj_range);
shader.uniform1f(LLShaderMgr::PROJECTOR_AMBIANCE, params.mV[2]);
S32 s_idx = -1;
@@ -8711,6 +9568,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
}
}
+ LOG_GLERROR("setupSpotLight() end");
}
void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
@@ -8718,7 +9576,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
LLRenderTarget* deferred_target = &mRT->deferredScreen;
LLRenderTarget* deferred_light_target = &mRT->deferredLight;
- stop_glerror();
+ LOG_GLERROR("unbindDeferredShader() begin");
shader.disableTexture(LLShaderMgr::NORMAL_MAP, deferred_target->getUsage());
shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage());
shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage());
@@ -8767,6 +9625,8 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(0)->activate();
shader.unbind();
+
+ LOG_GLERROR("unbindDeferredShader() end");
}
void LLPipeline::setEnvMat(LLGLSLShader& shader)
@@ -8821,6 +9681,11 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader)
}
// reflection probe shaders generally sample the scene map as well for SSR
+
+ //if(RenderScreenSpaceReflections)
+ //{
+ //LL_WARNS() << "binding SSR to reflection maps" << LL_ENDL;
+
channel = shader.enableTexture(LLShaderMgr::SCENE_MAP);
if (channel > -1)
{
@@ -8846,8 +9711,10 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader)
{
gGL.getTexUnit(channel)->bind(&mSceneMap, true);
}
+ //}
+ LOG_GLERROR("bindReflectionProbes() end");
}
void LLPipeline::unbindReflectionProbes(LLGLSLShader& shader)
@@ -8861,6 +9728,8 @@ void LLPipeline::unbindReflectionProbes(LLGLSLShader& shader)
gGL.getTexUnit(channel)->enable(LLTexUnit::TT_TEXTURE);
}
}
+
+ LOG_GLERROR("unbindReflectionProbes() end");
}
@@ -8871,10 +9740,8 @@ inline float sgn(float a)
return (0.0F);
}
-glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up)
+glm::mat4 look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up)
{
- glh::matrix4f ret;
-
LLVector3 dirN;
LLVector3 upN;
LLVector3 lftN;
@@ -8888,53 +9755,28 @@ glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up)
dirN = dir;
dirN.normVec();
- ret.m[ 0] = lftN[0];
- ret.m[ 1] = upN[0];
- ret.m[ 2] = -dirN[0];
- ret.m[ 3] = 0.f;
+ F32 ret[16];
+ ret[ 0] = lftN[0];
+ ret[ 1] = upN[0];
+ ret[ 2] = -dirN[0];
+ ret[ 3] = 0.f;
- ret.m[ 4] = lftN[1];
- ret.m[ 5] = upN[1];
- ret.m[ 6] = -dirN[1];
- ret.m[ 7] = 0.f;
+ ret[ 4] = lftN[1];
+ ret[ 5] = upN[1];
+ ret[ 6] = -dirN[1];
+ ret[ 7] = 0.f;
- ret.m[ 8] = lftN[2];
- ret.m[ 9] = upN[2];
- ret.m[10] = -dirN[2];
- ret.m[11] = 0.f;
+ ret[ 8] = lftN[2];
+ ret[ 9] = upN[2];
+ ret[10] = -dirN[2];
+ ret[11] = 0.f;
- ret.m[12] = -(lftN*pos);
- ret.m[13] = -(upN*pos);
- ret.m[14] = dirN*pos;
- ret.m[15] = 1.f;
+ ret[12] = -(lftN*pos);
+ ret[13] = -(upN*pos);
+ ret[14] = dirN*pos;
+ ret[15] = 1.f;
- return ret;
-}
-
-glh::matrix4f scale_translate_to_fit(const LLVector3 min, const LLVector3 max)
-{
- glh::matrix4f ret;
- ret.m[ 0] = 2/(max[0]-min[0]);
- ret.m[ 4] = 0;
- ret.m[ 8] = 0;
- ret.m[12] = -(max[0]+min[0])/(max[0]-min[0]);
-
- ret.m[ 1] = 0;
- ret.m[ 5] = 2/(max[1]-min[1]);
- ret.m[ 9] = 0;
- ret.m[13] = -(max[1]+min[1])/(max[1]-min[1]);
-
- ret.m[ 2] = 0;
- ret.m[ 6] = 0;
- ret.m[10] = 2/(max[2]-min[2]);
- ret.m[14] = -(max[2]+min[2])/(max[2]-min[2]);
-
- ret.m[ 3] = 0;
- ret.m[ 7] = 0;
- ret.m[11] = 0;
- ret.m[15] = 1;
-
- return ret;
+ return glm::make_mat4(ret);
}
static LLTrace::BlockTimerStatHandle FTM_SHADOW_RENDER("Render Shadows");
@@ -8946,11 +9788,13 @@ static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_MASKED("Alpha Masked");
static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_BLEND("Alpha Blend");
static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_TREE("Alpha Tree");
static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_GRASS("Alpha Grass");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_MATERIAL("Alpha Material");
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 depth_clamp)
+void LLPipeline::renderShadow(const glm::mat4& view, const glm::mat4& proj, LLCamera& shadow_cam, LLCullResult& result, bool depth_clamp)
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_SHADOW_RENDER);
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_RENDER);
LL_PROFILE_GPU_ZONE("renderShadow");
LLPipeline::sShadowRender = true;
@@ -8991,10 +9835,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
//generate shadow map
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
- gGL.loadMatrix(proj.m);
+ gGL.loadMatrix(glm::value_ptr(proj));
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix();
- gGL.loadMatrix(view.m);
+ gGL.loadMatrix(glm::value_ptr(view));
stop_glerror();
gGLLastMatrix = NULL;
@@ -9028,8 +9872,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
gGL.setColorMask(false, false);
}
- LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow simple"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE);
+ LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow simple");
LL_PROFILE_GPU_ZONE("shadow simple");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE);
+
gGL.getTexUnit(0)->disable();
for (U32 type : types)
@@ -9050,12 +9896,15 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
{
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM);
renderGeomShadow(shadow_cam);
}
{
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha");
LL_PROFILE_GPU_ZONE("shadow alpha");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA);
+
const S32 sun_up = LLEnvironment::instance().getIsSunUp() ? 1 : 0;
U32 target_width = LLRenderTarget::sCurResX;
@@ -9066,6 +9915,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");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_MASKED);
gDeferredShadowAlphaMaskProgram.bind(rigged);
LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up);
LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width);
@@ -9075,12 +9925,15 @@ 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");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_BLEND);
renderAlphaObjects(rigged);
}
{
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked");
LL_PROFILE_GPU_ZONE("shadow alpha masked");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_FULLBRIGHT_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);
@@ -9090,6 +9943,8 @@ 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");
+ LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_GRASS);
+
gDeferredTreeShadowProgram.bind(rigged);
LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(ALPHA_BLEND_CUTOFF);
@@ -9101,6 +9956,8 @@ 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");
+ LL_RECORD_BLOCK_TIME(FTM_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);
@@ -9388,11 +10245,19 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
return;
}
+ if(gCubeSnapshot)
+ {
+ LL_WARNS() << "generateSunShadow() gCubeSnapshot" << LL_ENDL;
+ return;
+ }
+
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW);
LL_PROFILE_GPU_ZONE("generateSunShadow");
LLDisableOcclusionCulling no_occlusion;
+ U32 splits = 4;
+
bool skip_avatar_update = false;
if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
{
@@ -9404,13 +10269,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
}
- F64 last_modelview[16];
- F64 last_projection[16];
- for (U32 i = 0; i < 16; i++)
- { //store last_modelview of world camera
- last_modelview[i] = gGLLastModelView[i];
- last_projection[i] = gGLLastProjection[i];
- }
+ glm::mat4 last_modelview = get_last_modelview();
+ glm::mat4 last_projection = get_last_projection();
pushRenderTypeMask();
andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
@@ -9489,12 +10349,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
//get sun view matrix
//store current projection/modelview matrix
- glh::matrix4f saved_proj = get_current_projection();
- glh::matrix4f saved_view = get_current_modelview();
- glh::matrix4f inv_view = saved_view.inverse();
+ glm::mat4 saved_proj = get_current_projection();
+ glm::mat4 saved_view = get_current_modelview();
+ glm::mat4 inv_view = glm::inverse(saved_view);
- glh::matrix4f view[6];
- glh::matrix4f proj[6];
+ glm::mat4 view[6];
+ glm::mat4 proj[6];
LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir);
@@ -9502,17 +10362,14 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
LLPlane shadow_near_clip;
{
LLVector3 p = camera.getOrigin(); // gAgent.getPositionAgent();
- p += caster_dir * RenderFarClip*2.f;
+ p += caster_dir * RenderFarClip*1.1f;
shadow_near_clip.setVec(p, caster_dir);
}
LLVector3 lightDir = -caster_dir;
lightDir.normVec();
- glh::vec3f light_dir(lightDir.mV);
-
//create light space camera matrix
-
LLVector3 at = lightDir;
LLVector3 up = camera.getAtAxis();
@@ -9564,9 +10421,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
//get good split distances for frustum
for (U32 i = 0; i < fp.size(); ++i)
{
- glh::vec3f v(fp[i].mV);
- saved_view.mult_matrix_vec(v);
- fp[i].setVec(v.v);
+ glm::vec3 v(fp[i]);
+ v = mul_mat4_vec3(saved_view, v);
+ fp[i] = LLVector3(v);
}
min = fp[0];
@@ -9578,30 +10435,38 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
update_min_max(min, max, fp[i]);
}
- near_clip = llclamp(-max.mV[2], 0.01f, 4.0f);
- F32 far_clip = llclamp(-min.mV[2]*2.f, 16.0f, 512.0f);
+ static LLCachedControl<F32> maxDist(gSavedSettings, "MPRenderShadowMaxDist", 128);
- //far_clip = llmin(far_clip, 128.f);
+ near_clip = llclamp(-max.mV[2], 0.01f, 4.0f);
+ F32 far_clip = llclamp(-min.mV[2]*1.1, 16.0f, maxDist);
far_clip = llmin(far_clip, camera.getFar());
F32 range = far_clip-near_clip;
- LLVector3 split_exp = RenderShadowSplitExponent;
+ F32 closestDist = 2.0;
+ F32 closeDist = 10.0;
- F32 da = 1.f-llmax( fabsf(lightDir*up), fabsf(lightDir*camera.getLeftAxis()) );
+ mSunClipPlanes.mV[0] = near_clip + closestDist;
+ mSunClipPlanes.mV[1] = near_clip + closeDist;
+ mSunClipPlanes.mV[2] = mSunClipPlanes.mV[1] + (range-closeDist)*0.4;
+ mSunClipPlanes.mV[3] = far_clip;
+ /*
+ LLVector3 split_exp = RenderShadowSplitExponent;
+ F32 da = 1.f-llmax( fabsf(lightDir*up), fabsf(lightDir*camera.getLeftAxis()) );
da = powf(da, split_exp.mV[2]);
F32 sxp = split_exp.mV[1] + (split_exp.mV[0]-split_exp.mV[1])*da;
- for (U32 i = 0; i < 4; ++i)
+ for (U32 i = 0; i < splits; ++i)
{
- F32 x = (F32)(i+1)/4.f;
+ F32 x = (F32)(i+1)/(F32)splits;
x = powf(x, sxp);
mSunClipPlanes.mV[i] = near_clip+range*x;
}
+ */
- mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding
+ //mSunClipPlanes.mV[0] *= 1.1f; //bump back first split for transition padding
}
if (gCubeSnapshot)
@@ -9615,13 +10480,17 @@ 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)
+ if (mSunDiffuse == LLColor4::black || RenderShadowDetail == 3)
{ //sun diffuse is totally black shadows don't matter
skipRenderingShadows();
}
else
{
- for (S32 j = 0; j < (gCubeSnapshot ? 2 : 4); j++)
+ S32 begin = 0;
+ S32 end = splits-1;
+ if(gCubeSnapshot) end = 1;
+
+ for (S32 j = begin; j <= end; j++)
{
if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot)
{
@@ -9659,8 +10528,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f;
delta.normVec();
F32 dp = delta*pn;
- frust[i] = eye + (delta*dist[j]*0.75f)/dp;
- frust[i+4] = eye + (delta*dist[j+1]*1.25f)/dp;
+ frust[i] = eye + (delta*dist[j]*0.9f)/dp;
+ frust[i+4] = eye + (delta*dist[j+1]*1.1f)/dp;
}
shadow_cam.calcAgentFrustumPlanes(frust);
@@ -9673,8 +10542,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
std::vector<LLVector3> fp;
- if (!gPipeline.getVisiblePointCloud(shadow_cam, min, max, fp, lightDir)
- || j > RenderShadowSplits)
+ if (!gPipeline.getVisiblePointCloud(shadow_cam, min, max, fp, lightDir))
{
//no possible shadow receivers
if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot)
@@ -9684,7 +10552,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
mShadowCamera[j+4] = shadow_cam;
}
- mRT->shadow[j].bindTarget();
+ mRT->shadow[j].bindTarget("", 1);
{
LLGLDepthTest depth(GL_TRUE);
mRT->shadow[j].clear();
@@ -9715,9 +10583,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
for (U32 i = 0; i < fp.size(); i++)
{
- glh::vec3f p = glh::vec3f(fp[i].mV);
- view[j].mult_matrix_vec(p);
- wpf.push_back(LLVector3(p.v));
+ glm::vec3 p(fp[i]);
+ p = mul_mat4_vec3(view[j], p);
+ wpf.push_back(LLVector3(p));
}
min = wpf[0];
@@ -9817,7 +10685,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
{ //just use ortho projection
mShadowFOV.mV[j] = -1.f;
origin.clearVec();
- proj[j] = gl_ortho(min.mV[0], max.mV[0],
+ proj[j] = glm::ortho(min.mV[0], max.mV[0],
min.mV[1], max.mV[1],
-max.mV[2], -min.mV[2]);
}
@@ -9908,37 +10776,37 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
{ //just use ortho projection
origin.clearVec();
mShadowError.mV[j] = -1.f;
- proj[j] = gl_ortho(min.mV[0], max.mV[0],
+ proj[j] = glm::ortho(min.mV[0], max.mV[0],
min.mV[1], max.mV[1],
-max.mV[2], -min.mV[2]);
}
else
{
//get perspective projection
- view[j] = view[j].inverse();
+ view[j] = glm::inverse(view[j]);
//llassert(origin.isFinite());
- glh::vec3f origin_agent(origin.mV);
+ glm::vec3 origin_agent(origin);
//translate view to origin
- view[j].mult_matrix_vec(origin_agent);
+ origin_agent = mul_mat4_vec3(view[j], origin_agent);
- eye = LLVector3(origin_agent.v);
+ eye = LLVector3(origin_agent);
//llassert(eye.isFinite());
if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot)
{
mShadowFrustOrigin[j] = eye;
}
- view[j] = look(LLVector3(origin_agent.v), lightDir, -up);
+ view[j] = look(LLVector3(origin_agent), lightDir, -up);
F32 fx = 1.f/tanf(fovx);
F32 fz = 1.f/tanf(fovz);
- proj[j] = glh::matrix4f(-fx, 0, 0, 0,
- 0, (yfar+ynear)/(ynear-yfar), 0, (2.f*yfar*ynear)/(ynear-yfar),
- 0, 0, -fz, 0,
- 0, -1.f, 0, 0);
+ proj[j] = glm::mat4(-fx, 0, 0, 0,
+ 0, (yfar + ynear) / (ynear - yfar), 0, -1.0f,
+ 0, 0, -fz, 0,
+ 0, (2.f * yfar * ynear) / (ynear - yfar), 0, 0);
}
}
}
@@ -9957,19 +10825,16 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_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);
+ glm::mat4 trans(0.5f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.5f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 1.0f);
set_current_modelview(view[j]);
set_current_projection(proj[j]);
- for (U32 i = 0; i < 16; i++)
- {
- gGLLastModelView[i] = mShadowModelview[j].m[i];
- gGLLastProjection[i] = mShadowProjection[j].m[i];
- }
+ set_last_modelview(mShadowModelview[j]);
+ set_last_projection(mShadowProjection[j]);
mShadowModelview[j] = view[j];
mShadowProjection[j] = proj[j];
@@ -9977,8 +10842,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
stop_glerror();
- mRT->shadow[j].bindTarget();
- mRT->shadow[j].getViewport(gGLViewport);
+ mRT->shadow[j].bindTarget("mRT->shadow[j] (rendering)", 1);
+ //mRT->shadow[j].getViewport(gGLViewport);
+ //mRT->shadow[j].getViewport(0, 0, SHADOWS_RESX, SHADOWS_RESY);
mRT->shadow[j].clear();
{
@@ -10084,9 +10950,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
LLMatrix4 mat(quat, LLVector4(origin, 1.f));
- view[i + 4] = glh::matrix4f((F32*)mat.mMatrix);
+ view[i + 4] = glm::make_mat4((F32*)mat.mMatrix);
- view[i + 4] = view[i + 4].inverse();
+ view[i + 4] = glm::inverse(view[i + 4]);
//get perspective matrix
F32 near_clip = dist + 0.01f;
@@ -10094,27 +10960,24 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
F32 height = scale.mV[VY];
F32 far_clip = dist + volume->getLightRadius() * 1.5f;
- F32 fovy = fov * RAD_TO_DEG;
+ F32 fovy = fov; // radians
F32 aspect = width / height;
- proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip);
+ proj[i + 4] = glm::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);
+ glm::mat4 trans(0.5f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.5f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 1.0f);
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];
- }
+ set_last_modelview(mShadowModelview[i + 4]);
+ set_last_projection(mShadowProjection[i + 4]);
mShadowModelview[i + 4] = view[i + 4];
mShadowProjection[i + 4] = proj[i + 4];
@@ -10129,8 +10992,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
//
- mSpotShadow[i].bindTarget();
- mSpotShadow[i].getViewport(gGLViewport);
+ mSpotShadow[i].bindTarget("mSpotShadow[i]", 1);
+ //mSpotShadow[i].getViewport(gGLViewport);
mSpotShadow[i].clear();
static LLCullResult result[2];
@@ -10162,18 +11025,15 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
{
set_current_modelview(view[1]);
set_current_projection(proj[1]);
- gGL.loadMatrix(view[1].m);
+ gGL.loadMatrix(glm::value_ptr(view[1]));
gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.loadMatrix(proj[1].m);
+ gGL.loadMatrix(glm::value_ptr(proj[1]));
gGL.matrixMode(LLRender::MM_MODELVIEW);
}
gGL.setColorMask(true, true);
- for (U32 i = 0; i < 16; i++)
- {
- gGLLastModelView[i] = (F32)last_modelview[i];
- gGLLastProjection[i] = (F32)last_projection[i];
- }
+ set_last_modelview(last_modelview);
+ set_last_projection(last_projection);
popRenderTypeMask();
@@ -10181,6 +11041,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
{
gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
}
+
+ LOG_GLERROR("LLPipeline::generateSunShadow()");
}
void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, bool texture)
@@ -10196,6 +11058,8 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, bool texture)
pass->renderGroup(group,type,texture);
}
}
+
+ LOG_GLERROR("LLPipeline::renderGroups()");
}
void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture)
@@ -10211,6 +11075,8 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture)
pass->renderRiggedGroup(group, type, texture);
}
}
+
+ LOG_GLERROR("LLPipeline::renderRiggedGroups()");
}
void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments)
@@ -10227,7 +11093,7 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments)
LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr;
- mRT->deferredScreen.bindTarget();
+ mRT->deferredScreen.bindTarget("mRT->deferredScreen in profileAvatar", 1);
mRT->deferredScreen.clear();
if (!profile_attachments)
@@ -10281,6 +11147,8 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments)
{
cur_shader->bind();
}
+
+ LOG_GLERROR("LLPipeline::profileAvatar()");
}
void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool for_profile, LLViewerObject* specific_attachment)
@@ -10473,18 +11341,18 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool
F32 distance = (pos-camera.getOrigin()).length();
F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
F32 aspect = tdim.mV[0]/tdim.mV[1];
- glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
+ glm::mat4 persp = glm::perspective(glm::radians(fov), aspect, 1.f, 256.f);
set_current_projection(persp);
- gGL.loadMatrix(persp.m);
+ gGL.loadMatrix(glm::value_ptr(persp));
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix();
- glh::matrix4f mat;
- camera.getOpenGLTransform(mat.m);
- mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat;
+ F32 ogl_mat[16];
+ camera.getOpenGLTransform(ogl_mat);
+ glm::mat4 mat = glm::make_mat4((GLfloat*) OGL_TO_CFR_ROTATION) * glm::make_mat4(ogl_mat);
- gGL.loadMatrix(mat.m);
+ gGL.loadMatrix(glm::value_ptr(mat));
set_current_modelview(mat);
glClearColor(0.0f,0.0f,0.0f,0.0f);
@@ -10501,7 +11369,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool
{
if (!avatar->mImpostor.isComplete())
{
- avatar->mImpostor.allocate(resX, resY, GL_RGBA, true);
+ avatar->mImpostor.allocate(resX, resY, GL_RGBA8, true);
if (LLPipeline::sRenderDeferred)
{
@@ -10517,7 +11385,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool
avatar->mImpostor.resize(resX, resY);
}
- avatar->mImpostor.bindTarget();
+ avatar->mImpostor.bindTarget("avatar->mImpostor", 1);
}
}
@@ -10606,11 +11474,16 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool
gGL.diffuseColor4fv(LLColor4::pink.mV );
}
- gGL.begin(LLRender::QUADS);
- gGL.vertex3f(-1, -1, clip_plane);
- gGL.vertex3f(1, -1, clip_plane);
- gGL.vertex3f(1, 1, clip_plane);
- gGL.vertex3f(-1, 1, clip_plane);
+ gGL.begin(LLRender::TRIANGLES);
+ {
+ gGL.vertex3f(-1.f, -1.f, clip_plane);
+ gGL.vertex3f(1.f, -1.f, clip_plane);
+ gGL.vertex3f(1.f, 1.f, clip_plane);
+
+ gGL.vertex3f(-1.f, -1.f, clip_plane);
+ gGL.vertex3f(1.f, 1.f, clip_plane);
+ gGL.vertex3f(-1.f, 1.f, clip_plane);
+ }
gGL.end();
gGL.flush();
@@ -10649,6 +11522,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool
}
LLVertexBuffer::unbind();
+
+ LOG_GLERROR("LLPipeline::generateImpostor()");
+
LLGLState::checkStates();
}
@@ -10973,7 +11849,7 @@ void LLPipeline::skipRenderingShadows()
for (S32 j = 0; j < 4; j++)
{
- mRT->shadow[j].bindTarget();
+ mRT->shadow[j].bindTarget("skip rendering shadows", 1);
mRT->shadow[j].clear();
mRT->shadow[j].flush();
}