diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-09-09 07:27:14 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-09-09 12:28:41 +0800 |
commit | 12743eca6958b897d7eb3f0cf791ad8ada3fc790 (patch) | |
tree | b785e705d8dac3cf3b2de36b04b6d0ab1f604d56 | |
parent | 4568096b3078d2d8980646f5b0b2f93762eb1caa (diff) | |
parent | ccf0114f36968d6cf6dfb11e1c5a035406314924 (diff) |
Merge remote-tracking branch 'mobserveur/experimental2'
27 files changed, 831 insertions, 327 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 42af68c276..9ff483b92b 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -357,7 +357,9 @@ S32 LLImageGL::dataFormatBits(S32 dataformat) case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac #endif case GL_DEPTH_COMPONENT: return 24; + case GL_DEPTH_COMPONENT16: return 16; case GL_DEPTH_COMPONENT24: return 24; + case GL_DEPTH_COMPONENT32: return 32; case GL_RGBA16: return 64; case GL_R16F: return 16; case GL_RG16F: return 32; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 70993393ff..332d15f76c 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -530,7 +530,9 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio { if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC) { - glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy); + //glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy); + //We plan to add a setting. For now we stick to a low value. + glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, 4.0); } else { @@ -1592,7 +1594,6 @@ void LLRender::end(std::string comment_) void LLRender::flush(std::string comment_) { - LOG_GLERROR("LLRender::flush() begin " + comment_); if (mCount > 0) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -1661,9 +1662,9 @@ void LLRender::flush(std::string comment_) } resetStriders(count); - } - LOG_GLERROR("LLRender::flush() end " + comment_); + LOG_GLERROR("LLRender::flush() end " + comment_); + } } void LLRender::flush() @@ -1765,9 +1766,11 @@ LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count) vb->setColorData(mColorsp.get()); } -#if LL_DARWIN + if(gGLManager.mIsApple && LLVertexBuffer::getVertexBufferMode() == 0) + { vb->unmapBuffer(); -#endif + } + vb->unbind(); return vb; diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index ddb2bf5df7..e898e03feb 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -326,7 +326,6 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) { gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR); LOG_GLERROR(mName + " setting address mode to TAM_MIRROR"); - } else #endif @@ -367,8 +366,7 @@ bool LLRenderTarget::allocateDepth() gGL.getTexUnit(0)->bindManual(mUsage, mDepth); U32 internal_type = LLTexUnit::getInternalType(mUsage); - - LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_FLOAT, NULL, false); + LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); sBytesAllocated += mResX*mResY*4; @@ -521,9 +519,7 @@ void LLRenderTarget::bindTarget(std::string name_, U32 mode_) { glDrawBuffers(static_cast<GLsizei>(mTex.size()), drawbuffers); glReadBuffer(GL_COLOR_ATTACHMENT0); - LOG_GLERROR(mName+" read and write buffers"); - } else if(mMode == 1) { @@ -557,8 +553,11 @@ void LLRenderTarget::clear(U32 mask_in) U32 mask = 0; if(!mTex.empty()) mask |= GL_COLOR_BUFFER_BIT; - if (mUseDepth) mask |= GL_DEPTH_BUFFER_BIT; + if (mUseDepth) + { + mask |= GL_DEPTH_BUFFER_BIT; + } if (mFBO) { check_framebuffer_status(); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6a3f88f9d3..81d45bc431 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1512,6 +1512,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bloomExtractORM"); mReservedUniforms.push_back("bloomExtractMetal"); mReservedUniforms.push_back("bloomExtractNonMetal"); + mReservedUniforms.push_back("bloomClampValue"); + mReservedUniforms.push_back("mpHDRBoost"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 8b0bfc6bbe..19416066a5 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -352,6 +352,8 @@ public: BLOOM_EXTRACT_ORM, // "bloomExtractORM" BLOOM_EXTRACT_METAL, // "bloomExtractMetal" BLOOM_EXTRACT_NONMETAL, // "bloomExtractNonMetal" + BLOOM_CLAMP, // "bloomClampValue" + MP_HDR_BOOST, // "mpHDRBoost" END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 43d780a383..1bd7a57cd9 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -29,7 +29,6 @@ #include "llfasttimer.h" #include "llsys.h" #include "llvertexbuffer.h" -// #include "llrender.h" #include "llglheaders.h" #include "llrender.h" #include "llvector4a.h" @@ -272,13 +271,13 @@ static GLuint gen_buffer() { LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("gen buffer"); sIndex = pool_size; -#if !LL_DARWIN +//#if !LL_DARWIN if (!gGLManager.mIsAMD) { glGenBuffers(pool_size, sNamePool); } else -#endif +//#endif { // work around for AMD driver bug for (U32 i = 0; i < pool_size; ++i) { @@ -355,7 +354,6 @@ public: { //allocate a new buffer LL_PROFILE_GPU_ZONE("vbo alloc"); - data = (U8*) ll_aligned_malloc_16(size); if (type == GL_ARRAY_BUFFER) @@ -383,7 +381,6 @@ public: } mAllocated -= size; - if (name) { delete_buffers(1, &name); @@ -615,6 +612,8 @@ public: static LLVBOPool* sVBOPool = nullptr; +static U32 sMPVertexBufferMode = 0; + void LLVertexBufferData::drawWithMatrix() { if (!mVB) @@ -946,11 +945,13 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const } //static -void LLVertexBuffer::initClass(LLWindow* window) +void LLVertexBuffer::initClass(LLWindow* window, U32 mode_) { llassert(sVBOPool == nullptr); - if (gGLManager.mIsApple) + sMPVertexBufferMode = mode_; + + if (mode_ == 0 && gGLManager.mIsApple) { LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL; sVBOPool = new LLAppleVBOPool(); @@ -973,6 +974,12 @@ void LLVertexBuffer::initClass(LLWindow* window) } //static +U32 LLVertexBuffer::getVertexBufferMode() +{ + return sMPVertexBufferMode; +} + +//static void LLVertexBuffer::unbind() { glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -1291,7 +1298,7 @@ U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 inde count = mNumVerts - index; } - if (!gGLManager.mIsApple) + if (!gGLManager.mIsApple || sMPVertexBufferMode == 1) { U32 start = mOffsets[type] + sTypeSize[type] * index; U32 end = start + sTypeSize[type] * count-1; @@ -1328,7 +1335,7 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count) count = mNumIndices-index; } - if (!gGLManager.mIsApple) + if (!gGLManager.mIsApple || sMPVertexBufferMode == 1) { U32 start = sizeof(U16) * index; U32 end = start + sizeof(U16) * count-1; @@ -1365,13 +1372,35 @@ void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8 { if (gGLManager.mIsApple) { + if(sMPVertexBufferMode == 1) + { + //LL_WARNS() << "flush_vbo mode 1" << LL_ENDL; + + U32 MapBits = GL_MAP_WRITE_BIT; + //U32 MapBits = GL_MAP_READ_BIT; + U32 buffer_size = end-start+1; + + U8 * mptr = NULL; + mptr = (U8*) glMapBufferRange( target, start, end-start+1, MapBits); + + if (mptr) + { + std::memcpy(mptr, (U8*) data, buffer_size); + if(!glUnmapBuffer(target)) LL_WARNS() << "glUnmapBuffer() failed" << LL_ENDL; + } + else LL_WARNS() << "glMapBufferRange() returned NULL" << LL_ENDL; + + } + else + { + //LL_WARNS() << "flush_vbo mode 0" << LL_ENDL; // on OS X, flush_vbo doesn't actually write to the GL buffer, so be sure to call // _mapBuffer to tag the buffer for flushing to GL _mapBuffer(); LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb memcpy"); - //LOG_GLERROR("LLVertexBuffer::flush_vbo()"); // copy into mapped buffer memcpy(dst+start, data, end-start+1); + } } else { @@ -1428,7 +1457,7 @@ void LLVertexBuffer::_unmapBuffer() } }; - if (gGLManager.mIsApple) + if (gGLManager.mIsApple && sMPVertexBufferMode == 0) { LOG_GLERROR("LLVertexBuffer::_unmapBuffer() - apple 1"); if (mMappedData) @@ -1713,80 +1742,70 @@ void LLVertexBuffer::setupVertexBuffer() LOG_GLERROR("LLVertexBuffer::setupVertexBuffer()"); U8* base = nullptr; - AttributeType loc; - void* ptr = nullptr; - U32 data_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; - if (data_mask & MAP_VERTEX) - { - loc = TYPE_VERTEX; - ptr = (void*)(base + mOffsets[TYPE_VERTEX]); - glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); - - LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_VERTEX"); - } - if (data_mask & MAP_NORMAL) { - loc = TYPE_NORMAL; - ptr = (void*)(base + mOffsets[TYPE_NORMAL]); + AttributeType loc = TYPE_NORMAL; + void* ptr = (void*)(base + mOffsets[TYPE_NORMAL]); glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_NORMAL], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_NORMAL"); } - - if (data_mask & MAP_TEXCOORD0) + if (data_mask & MAP_TEXCOORD3) { - loc = TYPE_TEXCOORD0; - //glEnableVertexAttribArray(loc); - ptr = (void*)(base + mOffsets[TYPE_TEXCOORD0]); - glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], ptr); + AttributeType loc = TYPE_TEXCOORD3; + void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD3]); + glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], ptr); - LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD0"); + LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD3"); } + if (data_mask & MAP_TEXCOORD2) + { + AttributeType loc = TYPE_TEXCOORD2; + void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD2]); + glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], ptr); + LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD2"); + } if (data_mask & MAP_TEXCOORD1) { - loc = TYPE_TEXCOORD1; - ptr = (void*)(base + mOffsets[TYPE_TEXCOORD1]); + AttributeType loc = TYPE_TEXCOORD1; + void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD1]); glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD1"); } - - if (data_mask & MAP_TEXCOORD2) + if (data_mask & MAP_TANGENT) { - loc = TYPE_TEXCOORD2; - ptr = (void*)(base + mOffsets[TYPE_TEXCOORD2]); - glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], ptr); + AttributeType loc = TYPE_TANGENT; + void* ptr = (void*)(base + mOffsets[TYPE_TANGENT]); + glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TANGENT], ptr); - LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD2"); + LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TANGENT"); } - - if (data_mask & MAP_TEXCOORD3) + if (data_mask & MAP_TEXCOORD0) { - loc = TYPE_TEXCOORD3; - ptr = (void*)(base + mOffsets[TYPE_TEXCOORD3]); - glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], ptr); + AttributeType loc = TYPE_TEXCOORD0; + //glEnableVertexAttribArray(loc); + void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD0]); + glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], ptr); - LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD3"); + LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXCOORD0"); } - if (data_mask & MAP_COLOR) { - loc = TYPE_COLOR; + AttributeType loc = TYPE_COLOR; //bind emissive instead of color pointer if emissive is present - ptr = (data_mask & MAP_EMISSIVE) ? (void*)(base + mOffsets[TYPE_EMISSIVE]) : (void*)(base + mOffsets[TYPE_COLOR]); + void* ptr = (data_mask & MAP_EMISSIVE) ? (void*)(base + mOffsets[TYPE_EMISSIVE]) : (void*)(base + mOffsets[TYPE_COLOR]); glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_COLOR], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_COLOR"); } - if (data_mask & MAP_EMISSIVE) { - loc = TYPE_EMISSIVE; - ptr = (void*)(base + mOffsets[TYPE_EMISSIVE]); + AttributeType loc = TYPE_EMISSIVE; + void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE]); glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_EMISSIVE"); @@ -1799,60 +1818,55 @@ void LLVertexBuffer::setupVertexBuffer() LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_COLOR"); } } - - if (data_mask & MAP_TANGENT) - { - loc = TYPE_TANGENT; - ptr = (void*)(base + mOffsets[TYPE_TANGENT]); - glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TANGENT], ptr); - - LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TANGENT"); - } - if (data_mask & MAP_WEIGHT) { - loc = TYPE_WEIGHT; - ptr = (void*)(base + mOffsets[TYPE_WEIGHT]); + AttributeType loc = TYPE_WEIGHT; + void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT]); glVertexAttribPointer(loc, 1, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_WEIGHT"); } - if (data_mask & MAP_WEIGHT4) { - loc = TYPE_WEIGHT4; - ptr = (void*)(base + mOffsets[TYPE_WEIGHT4]); + AttributeType loc = TYPE_WEIGHT4; + void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT4]); glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_WEIGHT4"); } + if (data_mask & MAP_JOINT) + { + AttributeType loc = TYPE_JOINT; + void* ptr = (void*)(base + mOffsets[TYPE_JOINT]); + glVertexAttribIPointer(loc, 4, GL_UNSIGNED_SHORT, LLVertexBuffer::sTypeSize[TYPE_JOINT], ptr); + LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_JOINT"); + } if (data_mask & MAP_CLOTHWEIGHT) { - loc = TYPE_CLOTHWEIGHT; - ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]); + AttributeType loc = TYPE_CLOTHWEIGHT; + void* ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]); glVertexAttribPointer(loc, 4, GL_FLOAT, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_CLOTHWEIGHT"); } - if (data_mask & MAP_JOINT) - { - loc = TYPE_JOINT; - ptr = (void*)(base + mOffsets[TYPE_JOINT]); - glVertexAttribIPointer(loc, 4, GL_UNSIGNED_SHORT, LLVertexBuffer::sTypeSize[TYPE_JOINT], ptr); - - LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_JOINT"); - } - if (data_mask & MAP_TEXTURE_INDEX) { - loc = TYPE_TEXTURE_INDEX; - ptr = (void*)(base + mOffsets[TYPE_VERTEX] + 12); + AttributeType loc = TYPE_TEXTURE_INDEX; + void* ptr = (void*)(base + mOffsets[TYPE_VERTEX] + 12); glVertexAttribIPointer(loc, 1, GL_UNSIGNED_INT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_TEXTURE_INDEX"); } + if (data_mask & MAP_VERTEX) + { + AttributeType loc = TYPE_VERTEX; + void* ptr = (void*)(base + mOffsets[TYPE_VERTEX]); + glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); + + LOG_GLERROR("LLVertexBuffer::setupVertexBuffer TYPE_VERTEX"); + } } void LLVertexBuffer::setPositionData(const LLVector4a* data) @@ -1966,3 +1980,7 @@ void LLVertexBuffer::setIndexData(const U32* data, U32 offset, U32 count) } flush_vbo(GL_ELEMENT_ARRAY_BUFFER, offset * sizeof(U32), (offset + count) * sizeof(U32) - 1, (U8*)data, mMappedIndexData); } + + + + diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 375ad76fb8..bf5f2b5ab6 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -109,7 +109,7 @@ public: return *this; } - static void initClass(LLWindow* window); + static void initClass(LLWindow* window, U32 mode_ = 0); static void cleanupClass(); static void setupClientArrays(U32 data_mask); static void drawArrays(U32 mode, const std::vector<LLVector3>& pos); @@ -128,6 +128,8 @@ public: // flush any pending mapped buffers static void flushBuffers(); + static U32 getVertexBufferMode(); + //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize // 2 - update LLVertexBuffer::vb_type_name diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 97f4125484..fabce18b6a 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -43,6 +43,8 @@ bool mMarkedTextAllowed; bool mSimulatedRightClick; bool mOldResize; + + bool mHDRDisplay; } - (id) initWithSamples:(NSUInteger)samples; - (id) initWithSamples:(NSUInteger)samples andVsync:(BOOL)vsync; diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 3cb6686c02..e8276e523f 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -29,6 +29,7 @@ #import "llappdelegate-objc.h" extern BOOL gHiDPISupport; +extern BOOL gHDRDisplaySupport; #pragma mark local functions @@ -64,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); @@ -96,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; } @@ -110,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); } @@ -153,24 +154,30 @@ attributedStringInfo getSegments(NSAttributedString *str) { vram_megabytes = 256; } - + return (unsigned long)vram_megabytes; // return value is in megabytes. } +- (void)viewWillMoveToWindow:(nullable NSWindow *)newWindow +{ + if(mHDRDisplay) self.wantsExtendedDynamicRangeOpenGLSurface = YES; + //else self.wantsExtendedDynamicRangeOpenGLSurface = NO; +} + - (void)viewDidMoveToWindow { [[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]]; @@ -246,52 +253,90 @@ 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). - NSOpenGLPixelFormatAttribute attrs[] = { - NSOpenGLPFANoRecovery, + NSOpenGLPixelFormatAttribute SDRAttrs[] = { NSOpenGLPFADoubleBuffer, - NSOpenGLPFAClosestPolicy, - NSOpenGLPFAAccelerated, NSOpenGLPFASampleBuffers, 0, NSOpenGLPFASamples, 0, NSOpenGLPFAStencilSize, 8, NSOpenGLPFADepthSize, 24, - NSOpenGLPFAAlphaSize, 8, - NSOpenGLPFAColorSize, 24, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core, 0 }; - - NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease]; + + + NSOpenGLPixelFormatAttribute HDRAttrs[] = { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFASampleBuffers, 0, + NSOpenGLPFASamples, 0, + NSOpenGLPFAStencilSize, 8, + NSOpenGLPFAColorFloat, + NSOpenGLPFAColorSize, 64, + NSOpenGLPFADepthSize, 24, + NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core, + 0}; + + NSOpenGLPixelFormat *pixelFormat = nil; + + mHDRDisplay = NO; + + if(gHDRDisplaySupport) + { + pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:HDRAttrs] autorelease]; + if (pixelFormat == nil) + { + NSLog(@"Failed to create pixel format for HDR Display!", nil); + pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:SDRAttrs] autorelease]; + } + else + { + mHDRDisplay = YES; + } + } + else + { + pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:SDRAttrs] autorelease]; + } if (pixelFormat == nil) { NSLog(@"Failed to create pixel format!", nil); return nil; } - + NSOpenGLContext *glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; - + if (glContext == nil) { NSLog(@"Failed to create OpenGL context!", nil); return nil; } - + [self setPixelFormat:pixelFormat]; + if(mHDRDisplay) + { + CGColorSpaceRef color_space = [self.window.colorSpace CGColorSpace]; + CGColorSpaceRef color_space_extended = CGColorSpaceCreateExtended(color_space); + NSColorSpace* extended_ns_color_space + = [[NSColorSpace alloc] initWithCGColorSpace:color_space_extended]; + + self.window.colorSpace = extended_ns_color_space; + CGColorSpaceRelease(color_space_extended); + } + //for retina support [self setWantsBestResolutionOpenGLSurface:gHiDPISupport]; [self setOpenGLContext:glContext]; - + [glContext setView:self]; - + [glContext makeCurrentContext]; - + if (vsync) { GLint value = 1; @@ -303,9 +348,9 @@ attributedStringInfo getSegments(NSAttributedString *str) GLint swapInterval=0; [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; } - + mOldResize = false; - + return self; } @@ -317,16 +362,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]; @@ -413,9 +458,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; @@ -437,9 +482,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; @@ -469,7 +514,7 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) otherMouseDragged:(NSEvent *)theEvent { - [self mouseDragged:theEvent]; + [self mouseDragged:theEvent]; } - (void) scrollWheel:(NSEvent *)theEvent @@ -493,7 +538,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. @@ -527,13 +572,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; @@ -544,9 +589,9 @@ attributedStringInfo getSegments(NSAttributedString *str) mask = NSControlKeyMask; break; default: - return; + return; } - + if (mModifiers & mask) { eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; @@ -565,7 +610,7 @@ attributedStringInfo getSegments(NSAttributedString *str) { eventData.mKeyEvent = NativeKeyEventData::KEYUP; callKeyUp(&eventData, [theEvent keyCode], 0); - } + } } - (BOOL) acceptsFirstResponder @@ -577,11 +622,11 @@ attributedStringInfo getSegments(NSAttributedString *str) { NSPasteboard *pboard; NSDragOperation sourceDragMask; - + sourceDragMask = [sender draggingSourceOperationMask]; - + pboard = [sender draggingPasteboard]; - + if ([[pboard types] containsObject:NSURLPboardType]) { if (sourceDragMask & NSDragOperationLink) { @@ -596,7 +641,7 @@ attributedStringInfo getSegments(NSAttributedString *str) - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender { callHandleDragUpdated(mLastDraggedUrl); - + return NSDragOperationLink; } @@ -650,12 +695,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; @@ -756,7 +801,7 @@ attributedStringInfo getSegments(NSAttributedString *str) return; } } - + @try { if (!mHasMarkedText) @@ -769,7 +814,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]); @@ -915,10 +960,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/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index c97e014e46..3aca4660f3 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -38,7 +38,6 @@ #include "lldir.h" #include "indra_constants.h" - #include <OpenGL/OpenGL.h> #include <Carbon/Carbon.h> #include <CoreServices/CoreServices.h> @@ -53,6 +52,7 @@ extern bool gDebugWindowProc; bool gHiDPISupport = true; +bool gHDRDisplaySupport = false; const S32 BITS_PER_PIXEL = 32; const S32 MAX_NUM_RESOLUTIONS = 32; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c93da4c576..dbd2ddcc3b 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14363,16 +14363,72 @@ <!-- megapahit settings --> - <key>MPLowColorPrecision</key> + + <key>MPVertexBufferMode</key> + <map> + <key>Comment</key> + <string>Vertex Buffer Mode for Mac (0=LL, 1=MP)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>MPHDRDisplay</key> <map> <key>Comment</key> - <string>Enable / Disable lower precision buffers encoding</string> + <string>Enable / Disable HDR Display Support (Mac)</string> <key>Persist</key> <integer>1</integer> <key>Type</key> <string>Boolean</string> <key>Value</key> + <integer>0</integer> + </map> + <key>MPHDRBoost</key> + <map> + <key>Comment</key> + <string>HDR Boost</string> + <key>Persist</key> <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <integer>1.5</integer> + </map> + <key>MPHDRGamma</key> + <map> + <key>Comment</key> + <string>HDR Gamma</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <integer>2.4</integer> + </map> + <key>MPHDRUIBoost</key> + <map> + <key>Comment</key> + <string>HDR UI Boost</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <integer>1.5</integer> + </map> + <key>MPColorPrecision</key> + <map> + <key>Comment</key> + <string>Color buffers precision</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>0</integer> </map> <key>MPNoGLDebug</key> <map> @@ -14449,28 +14505,6 @@ <key>Value</key> <integer>0</integer> </map> - <key>MPDumbCopy</key> - <map> - <key>Comment</key> - <string>Add a useless copy in pipeline::renderFinalize()</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <real>0</real> - </map> - <key>MPRenderShadowOpti</key> - <map> - <key>Comment</key> - <string>Shadows Optimisations</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>U32</string> - <key>Value</key> - <integer>0</integer> - </map> <key>MPRenderShadowMaxDist</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/MPHDRDisplayGammaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/MPHDRDisplayGammaF.glsl new file mode 100644 index 0000000000..7107cfcbce --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/MPHDRDisplayGammaF.glsl @@ -0,0 +1,55 @@ +/** + * @file postDeferredGammaCorrect.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +out vec4 frag_color; + +uniform sampler2D diffuseRect; + +uniform float gamma = 2.2; +uniform float mpHDRBoost; + +in vec2 vary_fragcoord; + +vec3 clampHDRRange(vec3 color); + +vec3 HDRDisplayGamma(vec3 linearRGB) +{ + bvec3 cutoff = lessThan(linearRGB, vec3(0.0031308)); + vec3 higher = vec3(1.055)*pow(linearRGB, vec3(1.0/gamma)) - vec3(0.055); + vec3 lower = linearRGB * vec3(12.92); + + return mix(higher, lower, cutoff); +} + +void main() +{ + vec4 diff = texture(diffuseRect, vary_fragcoord); + diff.rgb = mpHDRBoost * HDRDisplayGamma(diff.rgb); + diff.rgb = clampHDRRange(diff.rgb); + frag_color = diff; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl b/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl index 60a8300352..fdb77cce6e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl @@ -1351,10 +1351,6 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord, //----------------------------------------------------------------------------- // Neighborhood Blending Pixel Shader (Third Pass) -vec3 srgb_to_linear(vec3 cs); -vec4 srgb_to_linear4(vec4 cs); -vec3 linear_to_srgb(vec3 cl); - float4 SMAANeighborhoodBlendingPS(float2 texcoord, float4 offset, SMAATexture2D(colorTex), @@ -1373,7 +1369,6 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, SMAA_BRANCH if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) { float4 color = SMAASampleLevelZero(colorTex, texcoord); - color.rgb = srgb_to_linear(color.rgb); #if SMAA_REPROJECTION float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord)); @@ -1382,8 +1377,6 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, color.a = sqrt(5.0 * length(velocity)); #endif - color.rgb = linear_to_srgb(color.rgb); - return color; } else { bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical) @@ -1400,15 +1393,8 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, // We exploit bilinear filtering to mix current pixel with the chosen // neighbor: - //float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); - //color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); - float4 color = SMAASampleLevelZero(colorTex, blendingCoord.xy); - color.rgb = srgb_to_linear(color.rgb); - color = blendingWeight.x * color; - - float4 color2 = SMAASampleLevelZero(colorTex, blendingCoord.zw); - color2.rgb = srgb_to_linear(color2.rgb); - color += blendingWeight.y * color2; + float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); + color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); #if SMAA_REPROJECTION // Antialias velocity for proper reprojection in a later stage: @@ -1419,7 +1405,6 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, color.a = sqrt(5.0 * length(velocity)); #endif - color.rgb = linear_to_srgb(color.rgb); return color; } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 4ccc6f54a8..197ce48a45 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -30,7 +30,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform float gamma; -uniform vec2 screen_res; +//uniform vec2 screen_res; in vec2 vary_fragcoord; vec3 linear_to_srgb(vec3 cl); diff --git a/indra/newview/app_settings/shaders/class1/effects/bloomCombineF.glsl b/indra/newview/app_settings/shaders/class1/effects/bloomCombineF.glsl index 31a6e10fa4..40cfdd6bff 100644 --- a/indra/newview/app_settings/shaders/class1/effects/bloomCombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/bloomCombineF.glsl @@ -6,18 +6,16 @@ uniform sampler2D diffuseMap; uniform sampler2D bloomBlurredMap; uniform float bloomStrength; +uniform float bloomClampValue; void main() { vec4 hdrColor = texture(diffuseMap, vary_texcoord0); - vec3 bloomColor = texture(bloomBlurredMap, vary_texcoord0).rgb; - vec4 result = vec4(0.0); + vec4 bloomColor = texture(bloomBlurredMap, vary_texcoord0); + vec4 result = hdrColor; - result.r = min(hdrColor.r + bloomStrength * bloomColor.r, 1.0); - result.g = min(hdrColor.g + bloomStrength * bloomColor.g, 1.0); - result.b = min(hdrColor.b + bloomStrength * bloomColor.b, 1.0); - result.a = hdrColor.a; + result.rgb += bloomStrength * bloomColor.rgb; + result.rgb = clamp(result.rgb, vec3(0.0), vec3(bloomClampValue)); - //bloomColor += hdrColor.rgb; frag_color = result; }
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/effects/bloomExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/bloomExtractF.glsl index 8fb10d8698..d878ab053e 100644 --- a/indra/newview/app_settings/shaders/class1/effects/bloomExtractF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/bloomExtractF.glsl @@ -56,7 +56,7 @@ void main() if(orm.b < 0.15) { // non metal - if(orm.g > bloomExtractNonMetal) + if(orm.g >= bloomExtractNonMetal) { discard; return; @@ -65,7 +65,7 @@ void main() else if(orm.b > 0.8) { // metal - if(orm.g > bloomExtractMetal) + if(orm.g >= bloomExtractMetal) { discard; return; diff --git a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl index 83fe1c505f..42cc333829 100644 --- a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl @@ -27,10 +27,12 @@ out vec4 frag_color; uniform sampler2D diffuseMap; +uniform float mpHDRBoost = 1.0; + in vec2 vary_texcoord0; in vec4 vertex_color; void main() { - frag_color = vertex_color*texture(diffuseMap, vary_texcoord0.xy); + frag_color = mpHDRBoost * vertex_color*texture(diffuseMap, vary_texcoord0.xy); } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 5d107e69db..48e2631d8b 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -305,6 +305,7 @@ extern bool gDebugGL; #if LL_DARWIN extern bool gHiDPISupport; +extern bool gHDRDisplaySupport; #endif //////////////////////////////////////////////////////////// @@ -581,6 +582,7 @@ static void settings_to_globals() LLWindowMacOSX::sUseMultGL = gSavedSettings.getBOOL("RenderAppleUseMultGL"); #endif // LL_SDL gHiDPISupport = gSavedSettings.getBOOL("RenderHiDPI"); + gHDRDisplaySupport = gSavedSettings.getBOOL("MPHDRDisplay"); #endif } @@ -1297,11 +1299,15 @@ void LLAppViewer::initMaxHeapSize() //------------------------------------------------------------------------------------------ //currently SL is built under 32-bit setting, we set its max heap size no more than 1.6 GB. - #ifndef LL_X86_64 +/* +#ifndef LL_X86_64 F32Gigabytes max_heap_size_gb = (F32Gigabytes)gSavedSettings.getF32("MaxHeapSize") ; #else +*/ F32Gigabytes max_heap_size_gb = (F32Gigabytes)gSavedSettings.getF32("MaxHeapSize64"); +/* #endif +*/ LLMemory::initMaxHeapSizeGB(max_heap_size_gb); } diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 334f9cb692..5b94051e33 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2647,6 +2647,8 @@ void LLPanelPreferenceGraphics3::onMPRecommanded() gSavedSettings.setU32("RenderFSAAType", 2); gSavedSettings.setU32("RenderFSAASamples", 2); + gSavedSettings.setBOOL("RenderAnisotropic", false); + // Shadows gSavedSettings.setS32("RenderShadowDetail", 0); @@ -2658,8 +2660,8 @@ void LLPanelPreferenceGraphics3::onMPRecommanded() // Bloom gSavedSettings.setU32("MPRenderBloom", 0); - gSavedSettings.setF32("MPBloomBlurRadius", 1.0); - gSavedSettings.setF32("MPBloomBlurRadiusAdd", 0.6); + gSavedSettings.setF32("MPBloomBlurRadius", 1.2); + gSavedSettings.setF32("MPBloomBlurRadiusAdd", 1.2); gSavedSettings.setF32("MPBloomExtractBrightness", 0.1); gSavedSettings.setF32("MPBloomStrength", 1.0); @@ -2681,11 +2683,18 @@ void LLPanelPreferenceGraphics3::onMPRecommanded() gSavedSettings.setBOOL("RenderDisableVintageMode", true); gSavedSettings.setBOOL("RenderTransparentWater", true); - gSavedSettings.setBOOL("MPLowColorPrecision", true); + gSavedSettings.setU32("MPColorPrecision", 0); + + gSavedSettings.setU32("RenderResolutionDivisor", 1.0); gSavedSettings.setBOOL("RenderGLMultiThreadedTextures", false); gSavedSettings.setBOOL("RenderAppleUseMultGL", false); gSavedSettings.setBOOL("MPNoGLDebug", true); + + gSavedSettings.setBOOL("MPHDRDisplay", false); + gSavedSettings.setF32("MPHDRBoost", 1.0); + gSavedSettings.setF32("MPHDRUIBoost", 1.0); + gSavedSettings.setF32("MPHDRGamma", 2.4); } //------------------------LLPanelPreferenceControls-------------------------------- diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index d247d3260e..2ddb749141 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -297,8 +297,8 @@ void LLReflectionMapManager::update() U32 color_fmt = render_hdr ? GL_R11F_G11F_B10F : GL_RGB8; - static LLCachedControl<bool> MPLowColorPrecision(gSavedSettings, "MPLowColorPrecision", 0); - if(MPLowColorPrecision) + static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0); + if(MPColorPrecision == 1) { color_fmt = GL_RGB8; } @@ -563,12 +563,10 @@ void LLReflectionMapManager::update() if(probe->mCompletedCount < 2) { - LL_WARNS() << "we program a short delay for this probe" << LL_ENDL; probe->mNextUpdateTime = gFrameTimeSeconds + fmax( ((F32)sMPUpdatePeriod / 2.0), 0.25); } else { - LL_WARNS() << "we program a long delay for this probe" << LL_ENDL; probe->mNextUpdateTime = gFrameTimeSeconds + fmax( (F32)sMPUpdatePeriod, 0.25); } @@ -820,7 +818,6 @@ void LLReflectionMapManager::doProbeUpdate() mUpdatingProbe->mCompletedCount++; mUpdatingProbe = nullptr; mRadiancePass = false; - LL_WARNS() << "probe updated !" << LL_ENDL; } else { @@ -1027,7 +1024,6 @@ void LLReflectionMapManager::updateProbeIrradiance(LLReflectionMap* probe) static LLStaticHashedString sSourceIdx("sourceIdx"); - LL_WARNS() << "IRRADIANCE 1" << LL_ENDL; mMipChain[0].bindTarget("irradiance", 0); mMipChain[0].clear(0); @@ -1107,7 +1103,6 @@ void LLReflectionMapManager::updateProbeRadiance(LLReflectionMap* probe) static LLStaticHashedString sSourceIdx("sourceIdx"); - LL_WARNS() << "RADIANCE" << LL_ENDL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_RADIANCE); mMipChain[0].bindTarget("radiance", 0); @@ -1802,8 +1797,6 @@ void LLReflectionMapManager::initReflectionMaps() mDefaultProbe->mNextUpdateTime = 0.f; touch_default_probe(mDefaultProbe); - - LL_WARNS() << "====== END initReflectionMaps() =======" << LL_ENDL; } if (mVertexBuffer.isNull()) diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index ac0147002e..5183370076 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1687,6 +1687,10 @@ void render_ui_3d() gUIProgram.bind(); gGL.color4f(1.f, 1.f, 1.f, 1.f); + static LLCachedControl<bool> hdrDisplay(gSavedSettings, "MPHDRDisplay"); + static LLCachedControl<F32> hdrUIBoost(gSavedSettings, "MPHDRUIBoost"); + if(hdrDisplay) gUIProgram.uniform1f(LLShaderMgr::MP_HDR_BOOST, (GLfloat)hdrUIBoost); + // Coordinate axes static LLCachedControl<bool> show_axes(gSavedSettings, "ShowAxes"); if (show_axes()) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 753652f168..43cb7d8a14 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -202,6 +202,7 @@ LLGLSLShader gDeferredPostTonemapProgram; LLGLSLShader gNoPostTonemapProgram; LLGLSLShader gDeferredPostGammaCorrectProgram; LLGLSLShader gLegacyPostGammaCorrectProgram; +LLGLSLShader gHDRGammaCorrectProgram; LLGLSLShader gExposureProgram; LLGLSLShader gExposureProgramNoFade; LLGLSLShader gLuminanceProgram; @@ -449,6 +450,7 @@ void LLViewerShaderMgr::finalizeShaderList() mShaderList.push_back(&gNoPostTonemapProgram); mShaderList.push_back(&gDeferredPostGammaCorrectProgram); // for gamma mShaderList.push_back(&gLegacyPostGammaCorrectProgram); + mShaderList.push_back(&gHDRGammaCorrectProgram); mShaderList.push_back(&gDeferredDiffuseProgram); mShaderList.push_back(&gDeferredBumpProgram); mShaderList.push_back(&gDeferredPBROpaqueProgram); @@ -806,9 +808,12 @@ std::string LLViewerShaderMgr::loadBasicShaders() if (shadow_detail >= 1) { - attribs["SUN_SHADOW"] = "1"; + if(shadow_detail < 3) + { + attribs["SUN_SHADOW"] = "1"; + } - if (shadow_detail >= 2) + if (shadow_detail > 1) { attribs["SPOT_SHADOW"] = "1"; } @@ -906,8 +911,9 @@ bool LLViewerShaderMgr::loadShadersWater() bool success = true; bool terrainWaterSuccess = true; + S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail"); bool use_sun_shadow = mShaderLevel[SHADER_DEFERRED] > 1 && - gSavedSettings.getS32("RenderShadowDetail") > 0; + shadow_detail > 0 && shadow_detail < 3; if (mShaderLevel[SHADER_WATER] == 0) { @@ -1157,6 +1163,7 @@ bool LLViewerShaderMgr::loadShadersDeferred() gLuminanceProgram.unload(); gDeferredPostGammaCorrectProgram.unload(); gLegacyPostGammaCorrectProgram.unload(); + gHDRGammaCorrectProgram.unload(); gDeferredPostTonemapProgram.unload(); gNoPostTonemapProgram.unload(); for (auto i = 0; i < 4; ++i) @@ -2500,6 +2507,21 @@ bool LLViewerShaderMgr::loadShadersDeferred() if (success) { + gHDRGammaCorrectProgram.mName = "HDR Gamma Correction Post Process"; + gHDRGammaCorrectProgram.mFeatures.hasSrgb = true; + gHDRGammaCorrectProgram.mFeatures.isDeferred = true; + gHDRGammaCorrectProgram.mShaderFiles.clear(); + gHDRGammaCorrectProgram.clearPermutations(); + //gHDRGammaCorrectProgram.addPermutation("HDR_GAMMA", "1"); + gHDRGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gHDRGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/MPHDRDisplayGammaF.glsl", GL_FRAGMENT_SHADER)); + gHDRGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gHDRGammaCorrectProgram.createShader(); + llassert(success); + } + + if (success) + { gDeferredPostTonemapProgram.mName = "Deferred Tonemap Post Process"; gDeferredPostTonemapProgram.mFeatures.hasSrgb = true; gDeferredPostTonemapProgram.mFeatures.isDeferred = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 4d16c12630..7f989f281e 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -254,6 +254,7 @@ extern LLGLSLShader gDeferredPostNoDoFProgram; extern LLGLSLShader gDeferredPostNoDoFNoiseProgram; extern LLGLSLShader gDeferredPostGammaCorrectProgram; extern LLGLSLShader gLegacyPostGammaCorrectProgram; +extern LLGLSLShader gHDRGammaCorrectProgram; extern LLGLSLShader gDeferredPostTonemapProgram; extern LLGLSLShader gNoPostTonemapProgram; extern LLGLSLShader gExposureProgram; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9e52ed9a12..2c070dcbb9 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1967,7 +1967,8 @@ LLViewerWindow::LLViewerWindow(const Params& p) LL_DEBUGS("Window") << "Loading feature tables." << LL_ENDL; // Initialize OpenGL Renderer - LLVertexBuffer::initClass(mWindow); + LLVertexBuffer::initClass(mWindow, gSavedSettings.getU32("MPVertexBufferMode")); + LL_INFOS("RenderInit") << "LLVertexBuffer initialization done." << LL_ENDL ; if (!gGL.init(true)) { @@ -5177,7 +5178,7 @@ bool LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei glReadPixels( subimage_x_offset, out_y + subimage_y_offset, read_width, 1, - GL_DEPTH_COMPONENT, GL_FLOAT, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, depth_line_buffer->getData()// current output pixel is beginning of buffer... ); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b373532aa0..800ed79d8a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -144,7 +144,6 @@ U32 LLPipeline::RenderFSAAType; F32 LLPipeline::RenderResolutionDivisor; bool LLPipeline::RenderUIBuffer; S32 LLPipeline::RenderShadowDetail; -S32 LLPipeline::MPRenderShadowOpti; S32 LLPipeline::RenderShadowSplits; bool LLPipeline::RenderDeferredSSAO; F32 LLPipeline::RenderShadowResolutionScale; @@ -354,13 +353,13 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) U32 norm = GL_RGBA16F; U32 emissive = GL_RGB16F; - static LLCachedControl<bool> MPLowColorPrecision(gSavedSettings, "MPLowColorPrecision", 0); - static LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false); static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true); + static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0); + bool hdr = has_hdr() && gGLManager.mGLVersion > 4.05f; - if (!hdr || MPLowColorPrecision) + if (!hdr || MPColorPrecision < 2) { norm = GL_RGB10_A2; emissive = GL_RGB8; @@ -485,6 +484,10 @@ void LLPipeline::init() gSavedSettings.setBOOL("RenderPerformanceTest", true); } +#if LL_DARWIN + mHDRDisplay = gSavedSettings.getBOOL("MPHDRDisplay"); +#endif + mOldRenderDebugMask = mRenderDebugMask; mBackfaceCull = true; @@ -533,7 +536,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderResolutionDivisor"); connectRefreshCachedSettingsSafe("RenderUIBuffer"); connectRefreshCachedSettingsSafe("RenderShadowDetail"); - connectRefreshCachedSettingsSafe("MPRenderShadowOpti"); connectRefreshCachedSettingsSafe("RenderShadowSplits"); connectRefreshCachedSettingsSafe("RenderDeferredSSAO"); connectRefreshCachedSettingsSafe("RenderShadowResolutionScale"); @@ -819,13 +821,15 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) return ret; } -bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) +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 @@ -838,14 +842,14 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) mRT = &mAuxillaryRT; U32 res = mReflectionMapManager.mProbeResolution * 4; //multiply by 4 because probes will be 16x super sampled - allocateScreenBufferInternal(res, res); + 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; - allocateScreenBufferInternal(res, res); + allocateScreenBufferInternal(res, res, 2); } mRT = &mMainRT; @@ -858,25 +862,27 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) F32 res_mod = fmin(RenderResolutionDivisor, 4.0); - LL_WARNS() << "res_mod=" << res_mod << " resX=" << resX << " resY=" << resY << LL_ENDL; - if (res_mod >= 0.5 && res_mod <= 4.0) { resX = (U32)(floor((F32)resX / res_mod)); resY = (U32)(floor((F32)resY / res_mod)); - LL_WARNS() << "res_mod=" << res_mod << " resX=" << resX << " resY=" << resY << LL_ENDL; } S32 shadow_detail = RenderShadowDetail; bool ssao = RenderDeferredSSAO; //allocate deferred rendering color buffers - if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA8, true)) return false; + + GLuint deferredScreenFormat = GL_RGBA8; + if((hdr || mHDRDisplay) && MPColorPrecision == 2) deferredScreenFormat = GL_RGBA16F; + + if (!mRT->deferredScreen.allocate(resX, resY, deferredScreenFormat, true)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; - GLuint screenFormat = hdr ? GL_RGBA16F : GL_RGBA8; + GLuint screenFormat = GL_RGBA8; + if(hdr || mHDRDisplay) screenFormat = GL_RGBA16F; - if (!mRT->screen.allocate(resX, resY, screenFormat)) return false; + if (!mRT->screen.allocate(resX, resY, GL_RGBA16F)) return false; mRT->deferredScreen.shareDepthBuffer(mRT->screen); @@ -890,13 +896,16 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) } //allocateShadowBuffer(resX, resY); - allocateShadowBuffer(SHADOWS_RESX, SHADOWS_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_RGBA8)) + if (!mUIScreen.allocate(resX, resY, UIFormat)) { return false; } @@ -904,10 +913,13 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) if (RenderFSAAType > 0) { - if (!mFXAAMap.allocate(resX, resY, GL_RGBA8)) 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, GL_RGBA8, false)) return false; + if (!mSMAABlendBuffer.allocate(resX, resY, AAFormat, false)) return false; } } else @@ -921,17 +933,25 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) if(RenderScreenSpaceReflections) { - mSceneMap.allocate(resX, resY, screenFormat, 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(); } - //mPostMaps[0].allocate(resX, resY, screenFormat); - //mPostMaps[1].allocate(resX, resY, screenFormat); - mPostMaps[0].allocate(resX, resY, GL_RGBA); - mPostMaps[1].allocate(resX, resY, GL_RGBA); + 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. @@ -975,7 +995,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) 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++) { @@ -1311,17 +1331,21 @@ void LLPipeline::createGLBuffers() // 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_RGBA8; + 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(resX/2.0, resY/2.0, glow_color_fmt); + mBloomMap.allocate(512, 256, glow_color_fmt); for (U32 i = 0; i < 2; i++) { - mBloomBlur[i].allocate(resX/2.0, resY/2.0, glow_color_fmt); + mBloomBlur[i].allocate(512, 256, glow_color_fmt); } allocateScreenBuffer(resX, resY); @@ -3867,6 +3891,10 @@ void render_hud_elements() gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_TRUE, GL_FALSE); + static LLCachedControl<bool> HDRDisplay(gSavedSettings, "MPHDRDisplay"); + static LLCachedControl<F32> hdrUIBoost(gSavedSettings, "MPHDRUIBoost"); + if(HDRDisplay) gUIProgram.uniform1f(LLShaderMgr::MP_HDR_BOOST, (GLfloat)hdrUIBoost); + if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { gViewerWindow->renderSelections(false, false, false); // For HUD version in render_ui_3d() @@ -5797,19 +5825,22 @@ void LLPipeline::setupHWLights() mSunDiffuse.setVec(psky->getSunlightColor()); mMoonDiffuse.setVec(psky->getMoonlightColor()); - F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); - if (max_color > 1.f) + if(!mHDRDisplay) { - 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; + max_color = llmax(mMoonDiffuse.mV[0], mMoonDiffuse.mV[1], mMoonDiffuse.mV[2]); + if (max_color > 1.f) + { + mMoonDiffuse *= 1.f/max_color; + } + mMoonDiffuse.clamp(); } - mMoonDiffuse.clamp(); // prevent underlighting from having neither lightsource facing us if (!sun_up && !moon_up) @@ -7072,9 +7103,8 @@ static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Post processing"); void LLPipeline::visualizeBuffers(LLRenderTarget* src, LLRenderTarget* dst, U32 bufferIndex) { dst->bindTarget("visualizeBuffers", 1); - dst->clear(); 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) @@ -7152,7 +7182,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool } dst->bindTarget("generateExposure", 1); - //dst->clear(); + dst->clear(); LLGLDepthTest depth(GL_FALSE, GL_FALSE); @@ -7320,9 +7350,20 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) 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); - shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); + //screensize isn't a uniform int he 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, (GLfloat)mp_hdr_boost); + } renderTriangle(); @@ -8046,6 +8087,9 @@ bool LLPipeline::renderBloom(LLRenderTarget* src, LLRenderTarget* dst) 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); @@ -8055,7 +8099,7 @@ bool LLPipeline::renderBloom(LLRenderTarget* src, LLRenderTarget* dst) mBloomMap.clear(); gBloomExtractProgram.bind(); - gBloomExtractProgram.bindTexture(LLShaderMgr::DIFFUSE_MAP, src); + 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); @@ -8138,6 +8182,7 @@ bool LLPipeline::renderBloom(LLRenderTarget* src, LLRenderTarget* dst) 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(); @@ -8183,36 +8228,41 @@ void LLPipeline::renderFinalize() { copyScreenSpaceReflections(&mRT->screen, &mSceneMap); - generateLuminance(&mRT->screen, &mLuminanceMap); + if(!mHDRDisplay) + { + generateLuminance(&mRT->screen, &mLuminanceMap); + generateExposure(&mLuminanceMap, &mExposureMap); - generateExposure(&mLuminanceMap, &mExposureMap); + tonemap(&mRT->screen, &mRT->deferredLight); + postHDRBuffer = &mRT->deferredLight; + } + } - tonemap(&mRT->screen, &mRT->deferredLight); + gammaCorrect(postHDRBuffer, &mPostMaps[activeRT]); - postHDRBuffer = &mRT->deferredLight; + if(hdr) + { + generateGlow(&mPostMaps[activeRT]); } - gammaCorrect(postHDRBuffer, &mPostMaps[0]); - - generateGlow(&mPostMaps[0]); - LLVertexBuffer::unbind(); - if(renderBloom(&mPostMaps[activeRT], &mPostMaps[1 - activeRT])) + if(hdr) { - activeRT = 1 - activeRT; + if(renderBloom(&mPostMaps[activeRT], &mPostMaps[1 - activeRT])) + { + activeRT = 1 - activeRT; + } } - combineGlow(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]); - activeRT = 1 - activeRT; - - if(applyFXAA(&mPostMaps[activeRT], &mPostMaps[1 - activeRT])) + if(hdr) { + combineGlow(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]); activeRT = 1 - activeRT; } - if(applyCAS(&mPostMaps[activeRT], &mPostMaps[1 - activeRT])) + if(applyFXAA(&mPostMaps[activeRT], &mPostMaps[1 - activeRT])) { activeRT = 1 - activeRT; } @@ -8222,6 +8272,14 @@ void LLPipeline::renderFinalize() 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])) { @@ -8280,6 +8338,15 @@ void LLPipeline::renderFinalize() 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; } @@ -8699,7 +8766,7 @@ void LLPipeline::renderDeferredLighting() tc_moon = mat * tc_moon; mTransformedMoonDir.set(tc_moon); - if ((RenderDeferredSSAO && !gCubeSnapshot) || RenderShadowDetail > 0) + if ((RenderDeferredSSAO && !gCubeSnapshot) || (RenderShadowDetail > 0 && RenderShadowDetail < 4)) { LL_PROFILE_GPU_ZONE("sun program"); deferred_light_target->bindTarget("sun_shader", 1); @@ -10357,7 +10424,7 @@ 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(); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index fd94f1428c..4bba462f78 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -131,7 +131,8 @@ public: //attempt to allocate screen buffers at resX, resY //returns true if allocation successful, false otherwise - bool allocateScreenBufferInternal(U32 resX, U32 resY); + //type 0 = screen, 1 = probe, 2 = mirror + bool allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_ = 0); bool allocateShadowBuffer(U32 resX, U32 resY); // rebuild all LLVOVolume render batches @@ -820,6 +821,9 @@ public: bool mShadersLoaded; U32 mTransformFeedbackPrimitives; //number of primitives expected to be generated by transform feedback + + bool mHDRDisplay; + protected: bool mRenderTypeEnabled[NUM_RENDER_TYPES]; std::stack<std::string> mRenderTypeEnableStack; @@ -1019,7 +1023,6 @@ public: static F32 RenderResolutionDivisor; static bool RenderUIBuffer; static S32 RenderShadowDetail; - static S32 MPRenderShadowOpti; static S32 RenderShadowSplits; static bool RenderDeferredSSAO; static F32 RenderShadowResolutionScale; diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics3.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics3.xml index 8b76ece106..ddc00915a5 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics3.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics3.xml @@ -299,6 +299,71 @@ font="SansSerifSmall" Beware: SMAA + Sharpness currently causes a slow down on Mac. </text> +<text +follows="left|top" +layout="topleft" +width="400" +height="18" +left="55" +top_pad="12" +font="SansSerifSmall" +> +Disabling HUDS (Option + Shift + H) fixes the issue. +</text> + +<text +name="aniso_lbl" +follows="left|top" +layout="topleft" +width="140" +height="18" +left="20" +top_pad="40" +font="SansSerifSmall" +text_color="White" +> +Texture Filtering +</text> + +<check_box +name="mp_aniso_ctrl" +control_name="RenderAnisotropic" +label="Anisotropic Filtering" +layout="topleft" +width="200" +height="16" +left="20" +top_delta="32" +initial_value="true" +> +<check_box.commit_callback +function="Pref.RenderOptionUpdate" /> +</check_box> + +<icon +name="mp_aniso_bullet" +tool_tip="Low performance impact on PC/Linux, Medium performance impact on Mac (We are investigating)" +image_name="mp_yellow_bullet" +follows="left|top" +width="16" +height="16" +layout="topleft" +left_pad="5" +top_delta="-2" +/> + +<icon +name="mp_aniso_info_bullet" +tool_tip="Improves textures clarity at certain angles (i.e. ground). This should be on, but on Mac there is an abnormal performance penalty, currently." +image_name="mp_info_bullet" +follows="left|top" +width="16" +height="16" +layout="topleft" +left_pad="5" +top_delta="0" +/> + </panel> <panel @@ -886,7 +951,7 @@ top_delta="-1" increment="0.1" initial_value="1.0" min_val="0.5" -max_val="2.0" +max_val="4.0" label_width="2" > </slider> @@ -1542,12 +1607,26 @@ name="preferences_visuals_others" layout="topleft" follows="top|left"> +<text +name="mp_aa_lbl" +follows="left|top" +layout="topleft" +top_pad="20" +width="400" +height="18" +left="20" +font="SansSerifSmall" +text_color="White" +> +Visual Quality Settings: +</text> + <check_box name="VintageCtrl" control_name="RenderDisableVintageMode" label="HDR and Emissive" layout="topleft" -width="250" +width="300" height="16" left="20" top_delta="32" @@ -1565,7 +1644,7 @@ follows="left|top" width="16" height="16" layout="topleft" -left_pad="5" +left_pad="8" top_delta="-2" /> @@ -1586,7 +1665,7 @@ name="mp_transparent_water" control_name="RenderTransparentWater" label="Transparent Water" layout="topleft" -width="250" +width="300" height="16" left="20" top_delta="32" @@ -1604,7 +1683,7 @@ follows="left|top" width="16" height="16" layout="topleft" -left_pad="5" +left_pad="8" top_delta="-2" /> @@ -1620,45 +1699,6 @@ left_pad="5" top_delta="0" /> -<check_box -name="colorPrecisionCtrl" -control_name="MPLowColorPrecision" -label="Lower color precision (needs restart)" -layout="topleft" -width="250" -height="16" -left="20" -top_delta="32" -initial_value="false" -> -<check_box.commit_callback -function="Pref.RenderOptionUpdate" /> -</check_box> - -<icon -name="mp_lowcolor_bullet" -tool_tip="Can help performance specially in high resolution" -image_name="mp_green_bullet" -follows="left|top" -width="16" -height="16" -layout="topleft" -left_pad="5" -top_delta="-2" -/> - -<icon -name="mp_lowcolor_info_bullet" -tool_tip="Lowers the internal color precision which can help with performance." -image_name="mp_info_bullet" -follows="left|top" -width="16" -height="16" -layout="topleft" -left_pad="5" -top_delta="0" -/> - <text name="mp_resdiv_lbl" follows="left|top" @@ -1681,9 +1721,9 @@ height="16" left_delta="150" top_delta="-1" initial_value="1.0" -increment="0.25" -min_val="1.0" -max_val="4.0" +increment="0.1" +min_val="0.8" +max_val="2.0" decimal_digits="2" label_width="2"> </slider> @@ -1696,12 +1736,25 @@ name="preferences_visuals_others" layout="topleft" follows="top|left"> +<text +follows="left|top" +layout="topleft" +top_pad="20" +width="400" +height="18" +left="20" +font="SansSerifSmall" +text_color="White" +> +Advanced settings: +</text> + <check_box name="MultiTexCtrl" control_name="RenderGLMultiThreadedTextures" label="Multithreaded Textures" layout="topleft" -width="250" +width="400" height="16" left="20" top_delta="32" @@ -1738,7 +1791,7 @@ name="AppleMultGLCtrl" control_name="RenderAppleUseMultGL" label="Apple Multithreaded OpenGL" layout="topleft" -width="250" +width="400" height="16" left="20" top_delta="32" @@ -1770,12 +1823,194 @@ left_pad="5" top_delta="0" /> +<text +name="color_precision_lbl" +follows="left|top" +layout="topleft" +width="200" +height="18" +left="32" +top_pad="20" +font="SansSerifSmall" +> +Color precision (needs restart): +</text> + +<combo_box +name="colorPrecisionCtrl" +control_name="MPColorPrecision" +layout="topleft" +width="80" +height="18" +left_pad="8" +top_delta="0" +> +<combo_box.item +label="Low" +name="low" +value="1"/> +<combo_box.item +label="Default" +name="default" +value="0"/> +<combo_box.item +label="High" +name="high" +value="2"/> +</combo_box> + +<icon +name="mp_lowcolor_bullet" +tool_tip="Low setting can help performance specially in high resolution" +image_name="mp_green_bullet" +follows="left|top" +width="16" +height="16" +layout="topleft" +left_pad="104" +top_delta="-2" +/> + +<icon +name="mp_lowcolor_info_bullet" +tool_tip="Sets the internal color resolution. Improves the speed or quality." +image_name="mp_info_bullet" +follows="left|top" +width="16" +height="16" +layout="topleft" +left_pad="5" +top_delta="0" +/> + +<text +follows="left|top" +layout="topleft" +top_pad="30" +width="400" +height="18" +left="20" +font="SansSerifSmall" +text_color="White" +> +HDR Display (Experimental - Mac only): +</text> + +<icon +name="mp_hdrd_bullet" +tool_tip="You need an Apple hdr/xdr display" +image_name="mp_info_bullet" +follows="left|top" +width="16" +height="16" +layout="topleft" +left_pad="5" +top_delta="-2" +/> + +<text +follows="left|top" +layout="topleft" +width="400" +height="18" +left="20" +top_pad="12" +font="SansSerifSmall" +text_color="White" +> +Warning: HDR shows extreme luminosity contrast. Use carefully! +</text> + +<check_box +name="HDRDisplayCtrl" +control_name="MPHDRDisplay" +label="HDR Display (Mac)" +layout="topleft" +width="250" +height="16" +left="20" +top_delta="32" +initial_value="true" +> +</check_box> + +<text +name="mp_hdrd_gamma_lbl" +follows="left|top" +layout="topleft" +width="140" +height="18" +left="32" +top_pad="16" +font="SansSerifSmall" +> +Gamma +</text> + +<slider +control_name="MPHDRGamma" +follows="left|top" +layout="topleft" +width="200" +height="16" +left_delta="150" +top_delta="-1" +initial_value="2.2" +increment="0.05" +min_val="1.8" +max_val="2.6" +decimal_digits="2" +label_width="2"> +</slider> + +<text +name="mp_hdrd_uiboost_lbl" +follows="left|top" +layout="topleft" +width="140" +height="18" +left="32" +top_pad="16" +font="SansSerifSmall" +> +UI Luminosity Boost +</text> + +<slider +control_name="MPHDRUIBoost" +follows="left|top" +layout="topleft" +width="200" +height="16" +left_delta="150" +top_delta="-1" +initial_value="1.0" +increment="0.1" +min_val="1.0" +max_val="1.4" +decimal_digits="2" +label_width="2"> +</slider> + +<text +follows="left|top" +layout="topleft" +top_pad="30" +width="400" +height="18" +left="20" +font="SansSerifSmall" +text_color="White" +> +Developer settings: +</text> + <check_box name="NoGLDebugCtrl" control_name="MPNoGLDebug" label="No GL Debug" layout="topleft" -width="250" +width="400" height="16" left="20" top_delta="32" @@ -1807,8 +2042,22 @@ left_pad="5" top_delta="0" /> +<check_box +name="MPAppleVBModeCtrl" +control_name="MPVertexBufferMode" +label="Megapahit Vertex Buffer Mode (needs restart)" +layout="topleft" +width="400" +height="16" +left="20" +top_delta="32" +initial_value="false" +> +</check_box> + </panel> + </tab_container> </panel>
\ No newline at end of file |