summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormobserveur <mobserveur@gmail.com>2025-09-16 16:46:51 +0200
committermobserveur <mobserveur@gmail.com>2025-09-16 16:46:51 +0200
commit7aa203297435674b7b598eb2764a6db7edbb4bc3 (patch)
tree26a1cd40dc4205ab5640f9066d5c768583c8226a
parent56c5cfa9fd9685180e0ba90625dfdc5475d0dc9a (diff)
Fixes the slow down related to the attached huds rendering
This commit fixes the long time issue with attached huds rendering, which was causing important slow down with certain combinations of post processing settings.
-rw-r--r--indra/llrender/llglslshader.cpp12
-rw-r--r--indra/llrender/llrendertarget.cpp5
-rw-r--r--indra/llwindow/llopenglview-objc.h3
-rw-r--r--indra/llwindow/llopenglview-objc.mm129
-rw-r--r--indra/newview/llviewerdisplay.cpp9
-rw-r--r--indra/newview/pipeline.cpp218
-rw-r--r--indra/newview/pipeline.h4
7 files changed, 227 insertions, 153 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index aac5e3abc8..a1392e6288 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -1190,22 +1190,22 @@ S32 LLGLSLShader::bindTexture(S32 uniform, LLRenderTarget* texture, bool depth,
return -1;
}
- uniform = getTextureChannel(uniform);
+ S32 channel = getTextureChannel(uniform);
- if (uniform > -1)
+ if (channel > -1)
{
if (depth) {
- gGL.getTexUnit(uniform)->bind(texture, true);
+ gGL.getTexUnit(channel)->bind(texture, true);
}
else {
bool has_mips = mode == LLTexUnit::TFO_TRILINEAR || mode == LLTexUnit::TFO_ANISOTROPIC;
- gGL.getTexUnit(uniform)->bindManual(texture->getUsage(), texture->getTexture(index), has_mips);
+ gGL.getTexUnit(channel)->bindManual(texture->getUsage(), texture->getTexture(index), has_mips);
}
- gGL.getTexUnit(uniform)->setTextureFilteringOption(mode);
+ gGL.getTexUnit(channel)->setTextureFilteringOption(mode);
}
- return uniform;
+ return channel;
}
S32 LLGLSLShader::bindTexture(const std::string& uniform, LLRenderTarget* texture, bool depth, LLTexUnit::eTextureFilterOptions mode)
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 173b2b1745..ebdc609f94 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -524,13 +524,12 @@ void LLRenderTarget::bindTarget(std::string name_, U32 mode_)
else if(mMode == 1)
{
glDrawBuffers(static_cast<GLsizei>(mTex.size()), drawbuffers);
- glReadBuffer(GL_NONE);
+ //glReadBuffer(GL_NONE);
LOG_GLERROR(mName+" draw buffer");
}
else if(mMode == 2)
{
- GLenum buffers[] = {GL_NONE};
- glDrawBuffers(0, buffers);
+ //glDrawBuffer(GL_NONE);
glReadBuffer(GL_COLOR_ATTACHMENT0);
LOG_GLERROR(mName+" read buffer");
}
diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h
index fabce18b6a..249c997340 100644
--- a/indra/llwindow/llopenglview-objc.h
+++ b/indra/llwindow/llopenglview-objc.h
@@ -44,6 +44,9 @@
bool mSimulatedRightClick;
bool mOldResize;
+ NSOpenGLPixelFormat *pixelFormat;
+ NSOpenGLContext *glContext;
+
bool mHDRDisplay;
}
- (id) initWithSamples:(NSUInteger)samples;
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 3058a6f289..bbdb176560 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -65,16 +65,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
segment_standouts seg_standouts;
NSRange effectiveRange;
NSRange limitRange = NSMakeRange(0, [str length]);
-
+
while (limitRange.length > 0) {
NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];
limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
-
+
if (effectiveRange.length <= 0)
{
effectiveRange.length = 1;
}
-
+
if ([attr integerValue] == 2)
{
seg_lengths.push_back(effectiveRange.length);
@@ -97,12 +97,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
+ (NSScreen *)currentScreenForMouseLocation
{
NSPoint mouseLocation = [NSEvent mouseLocation];
-
+
NSEnumerator *screenEnumerator = [[NSScreen screens] objectEnumerator];
NSScreen *screen;
while ((screen = [screenEnumerator nextObject]) && !NSMouseInRect(mouseLocation, screen.frame, NO))
;
-
+
return screen;
}
@@ -111,7 +111,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
float normalizedX = fabs(fabs(self.frame.origin.x) - fabs(aPoint.x));
float normalizedY = aPoint.y - self.frame.origin.y;
-
+
return NSMakePoint(normalizedX, normalizedY);
}
@@ -124,6 +124,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
@implementation LLOpenGLView
+- (NSOpenGLContext*) glContext
+{
+ return glContext;
+}
+
+- (NSOpenGLPixelFormat*) pixelFormat
+{
+ return pixelFormat;
+}
+
// Force a high quality update after live resizing
- (void) viewDidEndLiveResize
{
@@ -154,7 +164,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
vram_megabytes = 256;
}
-
+
return (unsigned long)vram_megabytes; // return value is in megabytes.
}
@@ -179,15 +189,15 @@ attributedStringInfo getSegments(NSAttributedString *str)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowResized:) name:NSWindowDidResizeNotification
object:[self window]];
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification
object:[self window]];
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification
object:[self window]];
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification
object:[self window]];
@@ -263,7 +273,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
[self registerForDraggedTypes:[NSArray arrayWithObject:NSURLPboardType]];
[self initWithFrame:frame];
-
+
// Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6.
// Any specialized pixel formats, i.e. a core profile pixel format, should be initialized through rebuildContextWithFormat.
// 10.7 and 10.8 don't really care if we're defining a profile or not. If we don't explicitly request a core or legacy profile, it'll always assume a legacy profile (for compatibility reasons).
@@ -273,11 +283,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, 0,
- NSOpenGLPFASamples, 0,
- NSOpenGLPFADepthSize, 24,
- NSOpenGLPFAAlphaSize, 8,
- NSOpenGLPFAColorSize, 32,
+ //NSOpenGLPFASampleBuffers, samples,
+ //NSOpenGLPFASamples, 0,
+ NSOpenGLPFADepthSize, 24,
+ //NSOpenGLPFAAlphaSize, 8,
+ NSOpenGLPFAColorSize, 24,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
0
};
@@ -288,8 +298,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, 0,
- NSOpenGLPFASamples, 0,
+ //NSOpenGLPFASampleBuffers, samples,
+ //NSOpenGLPFASamples, 0,
NSOpenGLPFAColorFloat,
NSOpenGLPFAColorSize, 64,
NSOpenGLPFADepthSize, 24,
@@ -297,7 +307,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
0
};
- NSOpenGLPixelFormat *pixelFormat = nil;
+ //NSOpenGLPixelFormat *pixelFormat = nil;
mHDRDisplay = NO;
@@ -325,15 +335,15 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSLog(@"Failed to create pixel format!", nil);
return nil;
}
-
- NSOpenGLContext *glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
-
+
+ glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
+
if (glContext == nil)
{
NSLog(@"Failed to create OpenGL context!", nil);
return nil;
}
-
+
[self setPixelFormat:pixelFormat];
if(mHDRDisplay)
@@ -353,25 +363,32 @@ attributedStringInfo getSegments(NSAttributedString *str)
[self setWantsBestResolutionOpenGLSurface:gHiDPISupport];
[self setOpenGLContext:glContext];
-
+
[glContext setView:self];
-
+
[glContext makeCurrentContext];
-
+
+/*
if (vsync)
{
GLint value = 1;
[glContext setValues:&value forParameter:NSOpenGLCPSwapInterval];
- } else {
+ }
+ else
+ {
+ */
// supress this error after move to Xcode 7:
// error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]
// Tried using ObjC 'nonnull' keyword as per SO article but didn't build
- GLint swapInterval=0;
+ GLint swapInterval = 0;
[glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
- }
-
+ //}
+
+ GLint opacity = 1;
+ [glContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity];
+
mOldResize = false;
-
+
return self;
}
@@ -383,16 +400,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (BOOL) rebuildContextWithFormat:(NSOpenGLPixelFormat *)format
{
NSOpenGLContext *ctx = [self openGLContext];
-
+
[ctx clearDrawable];
[ctx initWithFormat:format shareContext:nil];
-
+
if (ctx == nil)
{
NSLog(@"Failed to create OpenGL context!", nil);
return false;
}
-
+
[self setOpenGLContext:ctx];
[ctx setView:self];
[ctx makeCurrentContext];
@@ -479,9 +496,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
float(dev_delta.x),
float(dev_delta.y)
};
-
+
callDeltaUpdate(mouseDeltas, 0);
-
+
NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
@@ -503,9 +520,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
float(dev_delta.x),
float(dev_delta.y)
};
-
+
callDeltaUpdate(mouseDeltas, 0);
-
+
NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
@@ -535,7 +552,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) otherMouseDragged:(NSEvent *)theEvent
{
- [self mouseDragged:theEvent];
+ [self mouseDragged:theEvent];
}
- (void) scrollWheel:(NSEvent *)theEvent
@@ -559,7 +576,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
-
+
uint keycode = [theEvent keyCode];
// We must not depend on flagsChange event to detect modifier flags changed,
// must depend on the modifire flags in the event parameter.
@@ -593,13 +610,13 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)flagsChanged:(NSEvent *)theEvent
{
NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent);
-
+
mModifiers = [theEvent modifierFlags];
callModifier([theEvent modifierFlags]);
-
+
NSInteger mask = 0;
switch([theEvent keyCode])
- {
+ {
case 56:
mask = NSShiftKeyMask;
break;
@@ -610,9 +627,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
mask = NSControlKeyMask;
break;
default:
- return;
+ return;
}
-
+
if (mModifiers & mask)
{
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
@@ -631,7 +648,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
eventData.mKeyEvent = NativeKeyEventData::KEYUP;
callKeyUp(&eventData, [theEvent keyCode], 0);
- }
+ }
}
- (BOOL) acceptsFirstResponder
@@ -643,11 +660,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
-
+
sourceDragMask = [sender draggingSourceOperationMask];
-
+
pboard = [sender draggingPasteboard];
-
+
if ([[pboard types] containsObject:NSURLPboardType])
{
if (sourceDragMask & NSDragOperationLink) {
@@ -662,7 +679,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
callHandleDragUpdated(mLastDraggedUrl);
-
+
return NSDragOperationLink;
}
@@ -716,12 +733,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
unsigned(selectedRange.location),
unsigned(selectedRange.length)
};
-
+
unsigned int replacement[2] = {
unsigned(replacementRange.location),
unsigned(replacementRange.length)
};
-
+
int string_length = [aString length];
unichar *text = new unichar[string_length];
attributedStringInfo segments;
@@ -822,7 +839,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
return;
}
}
-
+
@try
{
if (!mHasMarkedText)
@@ -835,7 +852,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
resetPreedit();
// We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text.
// But just in case...
-
+
for (NSInteger i = 0; i < [aString length]; i++)
{
handleUnicodeCharacter([aString characterAtIndex:i]);
@@ -981,10 +998,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSPoint screenPoint = [[view window] convertBaseToScreen:windowPoint];
NSPoint flippedScreenPoint = [currentScreen flipPoint:screenPoint];
flippedScreenPoint.y += [currentScreen frame].origin.y;
-
+
return flippedScreenPoint;
}
-
+
return NSZeroPoint;
}
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index ac0147002e..8f5585b6b1 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1388,7 +1388,7 @@ void render_hud_attachments()
gPipeline.stateSort(hud_cam, result);
- gPipeline.renderGeomPostDeferred(hud_cam);
+ gPipeline.renderGeomPostDeferredOnlyHud(hud_cam);
LLSpatialGroup::sNoDelete = false;
//gPipeline.clearReferences();
@@ -1533,6 +1533,7 @@ void render_ui(F32 zoom_factor, int subfield)
{
LLGLState::checkStates();
+ gPipeline.disableLights();
LL_PROFILE_ZONE_NAMED_CATEGORY_UI("HUD");
render_hud_elements();
@@ -1552,7 +1553,8 @@ void render_ui(F32 zoom_factor, int subfield)
{
if (!gDisconnected)
{
- LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 3D"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_3D);
+ LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 3D");
+ LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_3D);
LLGLState::checkStates();
render_ui_3d();
LLGLState::checkStates();
@@ -1565,7 +1567,8 @@ void render_ui(F32 zoom_factor, int subfield)
if (render_ui)
{
- LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 2D"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D);
+ LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 2D");
+ LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D);
LLHUDObject::renderAll();
render_ui_2d();
}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e993ca25b7..ce77d05a26 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -229,7 +229,7 @@ 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;
+const U32 SHADOWS_RESY = 512;
extern S32 gBoxFrame;
extern bool gDisplaySwapBuffers;
@@ -914,7 +914,7 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_)
if (RenderFSAAType > 0)
{
GLuint AAFormat = GL_RGBA8;
- if(mHDRDisplay && MPColorPrecision == 2)
+ if(mHDRDisplay && MPColorPrecision != 1)
{
AAFormat = GL_RGBA16F;
}
@@ -931,7 +931,7 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_)
mSMAABlendBuffer.release();
}
- mDummyRT.allocate(8, 8, GL_RGBA8, false);
+ //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, screenFormat, true);
@@ -1230,7 +1230,7 @@ void LLPipeline::releaseGLBuffers()
mSMAASearchMap = 0;
}
- mDummyRT.release();
+ //mDummyRT.release();
releaseLUTBuffers();
@@ -3881,7 +3881,6 @@ void LLPipeline::postSort(LLCamera &camera)
LL_PUSH_CALLSTACKS();
}
-
void render_hud_elements()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI);
@@ -4176,6 +4175,84 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion)
}
}
+// Render the geometry for the attached huds
+// This fixes the slow down due to attached huds
+void LLPipeline::renderGeomPostDeferredOnlyHud(LLCamera& camera)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
+ LL_PROFILE_GPU_ZONE("renderGeomPostDeferred");
+ LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED);
+
+ U32 cur_type = 0;
+
+ LLGLEnable cull(GL_CULL_FACE);
+
+ gGL.setSceneBlendType(LLRender::BT_ALPHA);
+ gGL.setColorMask(true, false);
+
+ pool_set_t::iterator iter1 = mPools.begin();
+
+ while ( iter1 != mPools.end() )
+ {
+ LLDrawPool *poolp = *iter1;
+
+ cur_type = poolp->getType();
+
+ pool_set_t::iterator iter2 = iter1;
+ if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0)
+ {
+ LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred poolrender");
+
+ gGLLastMatrix = NULL;
+ gGL.loadMatrix(gGLModelView);
+
+ for( S32 i = 0; i < poolp->getNumPostDeferredPasses(); i++ )
+ {
+ LLVertexBuffer::unbind();
+ poolp->beginPostDeferredPass(i);
+ for (iter2 = iter1; iter2 != mPools.end(); iter2++)
+ {
+ LLDrawPool *p = *iter2;
+ if (p->getType() != cur_type)
+ {
+ break;
+ }
+
+ p->renderPostDeferred(i);
+ }
+ poolp->endPostDeferredPass(i);
+ LLVertexBuffer::unbind();
+
+ if (gDebugGL || gDebugPipeline)
+ {
+ LLGLState::checkStates(GL_FALSE);
+ }
+ }
+ }
+ else
+ {
+ // Skip all pools of this type
+ for (iter2 = iter1; iter2 != mPools.end(); iter2++)
+ {
+ LLDrawPool *p = *iter2;
+ if (p->getType() != cur_type)
+ {
+ break;
+ }
+ }
+ }
+ iter1 = iter2;
+ LOG_GLERROR("after pools");
+ }
+
+ gGLLastMatrix = NULL;
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ gGL.loadMatrix(gGLModelView);
+
+ LOG_GLERROR("LLPipeline::renderGeomPostDeferredOnlyHud()");
+}
+
+
// 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)
@@ -4211,8 +4288,11 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
// do water haze just before pre water alpha
U32 water_haze_pass = LLDrawPool::POOL_ALPHA_PRE_WATER;
- calcNearbyLights(camera);
- setupHWLights();
+ if(!done_atmospherics)
+ {
+ calcNearbyLights(camera);
+ setupHWLights();
+ }
gGL.setSceneBlendType(LLRender::BT_ALPHA);
gGL.setColorMask(true, false);
@@ -5830,19 +5910,19 @@ void LLPipeline::setupHWLights()
if(!mHDRDisplay)
{
- F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]);
- if (max_color > 1.f)
- {
- mSunDiffuse *= 1.f/max_color;
- }
- mSunDiffuse.clamp();
+ F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]);
+ if (max_color > 1.f)
+ {
+ mSunDiffuse *= 1.f/max_color;
+ }
+ mSunDiffuse.clamp();
- max_color = llmax(mMoonDiffuse.mV[0], mMoonDiffuse.mV[1], mMoonDiffuse.mV[2]);
- if (max_color > 1.f)
- {
- mMoonDiffuse *= 1.f/max_color;
- }
- mMoonDiffuse.clamp();
+ max_color = llmax(mMoonDiffuse.mV[0], mMoonDiffuse.mV[1], mMoonDiffuse.mV[2]);
+ if (max_color > 1.f)
+ {
+ mMoonDiffuse *= 1.f/max_color;
+ }
+ mMoonDiffuse.clamp();
}
// prevent underlighting from having neither lightsource facing us
@@ -7160,9 +7240,6 @@ void LLPipeline::generateLuminance(LLRenderTarget* src, LLRenderTarget* dst)
renderTriangle();
- gLuminanceProgram.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
- gLuminanceProgram.unbindTexture(LLShaderMgr::DEFERRED_EMISSIVE);
- gLuminanceProgram.unbindTexture(LLShaderMgr::NORMAL_MAP);
gLuminanceProgram.unbind();
dst->flush();
@@ -7278,11 +7355,11 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
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->unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ //shader->unbindTexture(LLShaderMgr::EXPOSURE_MAP);
shader->unbind();
dst->flush();
}
@@ -7338,8 +7415,8 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)
renderTriangle();
- shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
- shader.unbindTexture(LLShaderMgr::EXPOSURE_MAP);
+ //shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ //shader.unbindTexture(LLShaderMgr::EXPOSURE_MAP);
shader.unbind();
}
dst->flush();
@@ -7381,7 +7458,7 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst)
renderTriangle();
- shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
+ //shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE);
shader.unbind();
dst->flush();
@@ -7465,7 +7542,7 @@ void LLPipeline::generateGlow(LLRenderTarget* src)
gPipeline.enableLightsFullbright();
renderTriangle();
- gGlowExtractProgram.unbindTexture(LLShaderMgr::DIFFUSE_MAP);
+ //gGlowExtractProgram.unbindTexture(LLShaderMgr::DIFFUSE_MAP);
gGlowExtractProgram.unbindTexture(LLShaderMgr::GLOW_NOISE_MAP);
gGlowExtractProgram.unbind();
mGlow[2].flush();
@@ -7564,7 +7641,7 @@ bool LLPipeline::applyCAS(LLRenderTarget* src, LLRenderTarget* dst)
S32 channel = sharpen_shader->bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT);
renderTriangle();
- sharpen_shader->unbindTexture(channel);
+ //sharpen_shader->unbindTexture(channel);
sharpen_shader->unbind();
dst->flush();
@@ -7599,16 +7676,11 @@ bool LLPipeline::generateFXAABuffer(LLRenderTarget* src)
renderTriangle();
}
- shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage());
+ //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;
}
@@ -8233,31 +8305,13 @@ 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);
- 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);
@@ -8266,13 +8320,10 @@ void LLPipeline::renderFinalize()
U16 activeRT = 0;
- LLRenderTarget* postHDRBuffer = &mRT->screen;
+ LLRenderTarget* postHDRTarget = &mRT->screen;
if (hdr)
{
- if(generateFXAABuffer(postHDRBuffer));
- else generateSMAABuffers(postHDRBuffer);
-
copyScreenSpaceReflections(&mRT->screen, &mSceneMap);
if(!mHDRDisplay)
@@ -8282,37 +8333,15 @@ void LLPipeline::renderFinalize()
generateExposure(&mLuminanceMap, &mExposureMap);
tonemap(&mRT->screen, &mRT->deferredLight);
- postHDRBuffer = &mRT->deferredLight;
+ postHDRTarget = &mRT->deferredLight;
}
}
- gammaCorrect(postHDRBuffer, &mPostMaps[1 - activeRT]);
+ gammaCorrect(postHDRTarget, &mPostMaps[1 - activeRT]);
activeRT = 1 - activeRT;
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]))
@@ -8333,11 +8362,25 @@ void LLPipeline::renderFinalize()
}
}
+ {
+ generateFXAABuffer(&mPostMaps[activeRT]);
+ generateSMAABuffers(&mPostMaps[activeRT]);
+ }
+
if(renderDoF(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
{
activeRT = 1 - activeRT;
}
+ if(applyFXAA(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+ else if(applySMAA(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]))
+ {
+ activeRT = 1 - activeRT;
+ }
+
LLRenderTarget* finalBuffer = &mPostMaps[activeRT];
if (RenderBufferVisualization > -1)
@@ -8406,6 +8449,12 @@ void LLPipeline::renderFinalize()
// Present the screen target.
+ 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]);
+
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.
@@ -8423,7 +8472,7 @@ void LLPipeline::renderFinalize()
gDeferredPostNoDoFNoiseProgram.unbindTexture(LLShaderMgr::DEFERRED_DEPTH);
gDeferredPostNoDoFNoiseProgram.unbind();
- gGL.flush();
+ //gGL.flush();
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -9830,11 +9879,12 @@ void LLPipeline::renderShadow(const glm::mat4& view, const glm::mat4& proj, LLCa
LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_LESS);
+ //static LLCachedControl<bool> sShadowAlternative(gSavedSettings, "MPShadowAlternative", false);
+
updateCull(shadow_cam, result);
stateSort(shadow_cam, result);
- //generate shadow map
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
gGL.loadMatrix(glm::value_ptr(proj));
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index f33495fd69..97d6a1fe8a 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -314,6 +314,7 @@ public:
void renderGeomDeferred(LLCamera& camera, bool do_occlusion = false);
void renderGeomPostDeferred(LLCamera& camera);
+ void renderGeomPostDeferredOnlyHud(LLCamera& camera);
void renderGeomShadow(LLCamera& camera);
void bindLightFunc(LLGLSLShader& shader);
@@ -746,7 +747,7 @@ public:
LLRenderTarget mFXAAMap;
LLRenderTarget mSMAABlendBuffer;
- LLRenderTarget mDummyRT;
+ //LLRenderTarget mDummyRT;
// render ui to buffer target
LLRenderTarget mUIScreen;
@@ -1104,6 +1105,7 @@ public:
};
void render_bbox(const LLVector3 &min, const LLVector3 &max);
+
void render_hud_elements();
extern LLPipeline gPipeline;