From 65161e6b393a6df6fa0a932aeb940fb7ac7ea084 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Mon, 12 Dec 2016 18:24:46 +0200 Subject: MAINT-6125 - Mesh avatar deforms constantly MAINT-6910 - [MAINT-RC] Some mesh turns invisible when camera is moved on the Maint-RC viewer only - caused by fix for MAINT-6125. Commulative fix. Fixed for booth ticket's in indra/newview/llvovolume.cpp Remained fixed, it's a small code improvements which is not related to MAINT-6125, MAINT-6910 --- indra/llrender/llvertexbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 5048799854..7e47471db6 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -509,7 +509,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) } } - U32 map_tc[] = + static const U32 map_tc[] = { MAP_TEXCOORD1, MAP_TEXCOORD2, -- cgit v1.2.3 From 325c076d094140fddf11cb291ca45c8a1426f442 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Thu, 26 Oct 2017 18:33:08 +0300 Subject: MAINT-7213 Shared media (media as a texture) unusable with transparent mesh New outline selection around mesh objects. --- indra/llrender/CMakeLists.txt | 2 ++ indra/llrender/llgl.h | 17 +++++++++++++++++ indra/llrender/llglcommonfunc.cpp | 37 +++++++++++++++++++++++++++++++++++++ indra/llrender/llglcommonfunc.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 indra/llrender/llglcommonfunc.cpp create mode 100644 indra/llrender/llglcommonfunc.h (limited to 'indra/llrender') diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index 331f988382..07a0d8c402 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -51,6 +51,7 @@ set(llrender_SOURCE_FILES lltexture.cpp lluiimage.cpp llvertexbuffer.cpp + llglcommonfunc.cpp ) set(llrender_HEADER_FILES @@ -78,6 +79,7 @@ set(llrender_HEADER_FILES lltexture.h lluiimage.h llvertexbuffer.h + llglcommonfunc.h ) set_source_files_properties(${llrender_HEADER_FILES} diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index aa98b3f6bc..4c4302d05b 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -256,6 +256,9 @@ void clear_glerror(); if the existing GL state does not match the expected GL state. */ + +#include "boost/function.hpp" + class LLGLState { public: @@ -297,6 +300,20 @@ public: LLGLEnableAlphaReject(bool enable); }; +// Enable with functor +class LLGLEnableFunc : LLGLState +{ +public: + LLGLEnableFunc(LLGLenum state, bool enable, boost::function func) + : LLGLState(state, enable) + { + if (enable) + { + func(); + } + } +}; + /// TODO: Being deprecated. class LLGLEnable : public LLGLState { diff --git a/indra/llrender/llglcommonfunc.cpp b/indra/llrender/llglcommonfunc.cpp new file mode 100644 index 0000000000..e9ec28927f --- /dev/null +++ b/indra/llrender/llglcommonfunc.cpp @@ -0,0 +1,37 @@ +/** +* @file llglcommonfunc.cpp +* @brief Implementation of the LLGLCommonFunc. +* +* $LicenseInfo:firstyear=2001&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2010, 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$ +*/ + +#include "llglheaders.h" +#include "llglcommonfunc.h" + +namespace LLGLCommonFunc +{ + void selected_stencil_test() + { + glStencilFunc(GL_ALWAYS, 2, 0xffff); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + } +} diff --git a/indra/llrender/llglcommonfunc.h b/indra/llrender/llglcommonfunc.h new file mode 100644 index 0000000000..f1f8ff7bc4 --- /dev/null +++ b/indra/llrender/llglcommonfunc.h @@ -0,0 +1,30 @@ +/** +* @file llphoenixfunc.h +* @brief File include common opengl code snippets +* +* $LicenseInfo:firstyear=2003&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2010, 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$ +*/ + +namespace LLGLCommonFunc +{ + void selected_stencil_test(); +} -- cgit v1.2.3 From df376c029936da11b3e1dda54f9c327de50440a8 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 26 Dec 2017 18:20:06 +0200 Subject: MAINT-6437 - Tile-Based Texture Animation Scales Incorrectly for Rigged Mesh when worn (MacOS only) FIXED. --- indra/llrender/llglslshader.cpp | 54 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 970502f2d6..97557267cf 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -744,24 +744,25 @@ BOOL LLGLSLShader::mapUniforms(const vector * uniforms) , even if the "diffuseMap" will be appear and use first in shader code. As example where this situation appear see: "Deferred Material Shader 28/29/30/31" - And tickets: MAINT-4165, MAINT-4839, MAINT-3568 + And tickets: MAINT-4165, MAINT-4839, MAINT-3568, MAINT-6437 */ S32 diffuseMap = glGetUniformLocationARB(mProgramObject, "diffuseMap"); + S32 specularMap = glGetUniformLocationARB(mProgramObject, "specularMap"); S32 bumpMap = glGetUniformLocationARB(mProgramObject, "bumpMap"); S32 environmentMap = glGetUniformLocationARB(mProgramObject, "environmentMap"); std::set skip_index; - if (-1 != diffuseMap && (-1 != bumpMap || -1 != environmentMap)) + if (-1 != diffuseMap && (-1 != specularMap || -1 != bumpMap || -1 != environmentMap)) { GLenum type; GLsizei length; GLint size = -1; char name[1024]; - diffuseMap = bumpMap = environmentMap = -1; + diffuseMap = specularMap = bumpMap = environmentMap = -1; for (S32 i = 0; i < activeCount; i++) { @@ -775,6 +776,18 @@ BOOL LLGLSLShader::mapUniforms(const vector * uniforms) continue; } + if (-1 == specularMap && std::string(name) == "specularMap") + { + specularMap = i; + continue; + } + + if (-1 == specularMap && std::string(name) == "specularMap") + { + specularMap = i; + continue; + } + if (-1 == bumpMap && std::string(name) == "bumpMap") { bumpMap = i; @@ -788,34 +801,29 @@ BOOL LLGLSLShader::mapUniforms(const vector * uniforms) } } + bool specularDiff = specularMap < diffuseMap && -1 != specularMap; bool bumpLessDiff = bumpMap < diffuseMap && -1 != bumpMap; bool envLessDiff = environmentMap < diffuseMap && -1 != environmentMap; - if (bumpLessDiff && envLessDiff) + if (specularDiff || bumpLessDiff || envLessDiff) { mapUniform(diffuseMap, uniforms); - mapUniform(bumpMap, uniforms); - mapUniform(environmentMap, uniforms); - skip_index.insert(diffuseMap); - skip_index.insert(bumpMap); - skip_index.insert(environmentMap); - } - else if (bumpLessDiff) - { - mapUniform(diffuseMap, uniforms); - mapUniform(bumpMap, uniforms); - skip_index.insert(diffuseMap); - skip_index.insert(bumpMap); - } - else if (envLessDiff) - { - mapUniform(diffuseMap, uniforms); - mapUniform(environmentMap, uniforms); + if (-1 != specularMap) { + mapUniform(specularMap, uniforms); + skip_index.insert(specularMap); + } - skip_index.insert(diffuseMap); - skip_index.insert(environmentMap); + if (-1 != bumpMap) { + mapUniform(bumpMap, uniforms); + skip_index.insert(bumpMap); + } + + if (-1 != environmentMap) { + mapUniform(environmentMap, uniforms); + skip_index.insert(environmentMap); + } } } -- cgit v1.2.3 From fadb3792caa5279d3521dcaad44a6211bfa4bfad Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 9 Jan 2018 20:31:21 +0200 Subject: MAINT-8146 Fixed Installing viewer to non default path results in incorrect fonts loading --- indra/llrender/llfontfreetype.cpp | 64 +++++++++++++++++++++++++++++++++++++-- indra/llrender/llfontfreetype.h | 2 ++ indra/llrender/llfontregistry.cpp | 2 +- 3 files changed, 65 insertions(+), 3 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index de26d19efc..5c1f4ff8b3 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -106,6 +106,8 @@ LLFontFreetype::LLFontFreetype() mAscender(0.f), mDescender(0.f), mLineHeight(0.f), + pFontBuffer(NULL), + mBufferSize(0), mIsFallback(FALSE), mFTFace(NULL), mRenderGlyphCount(0), @@ -128,6 +130,8 @@ LLFontFreetype::~LLFontFreetype() mCharGlyphInfoMap.clear(); delete mFontBitmapCachep; + delete pFontBuffer; + disclaimMem(mBufferSize); // mFallbackFonts cleaned up by LLPointer destructor } @@ -143,13 +147,64 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v int error; +#ifdef LL_WINDOWS + + if (mBufferSize > 0) + { + delete pFontBuffer; + disclaimMem(mBufferSize); + pFontBuffer = NULL; + mBufferSize = 0; + } + + S32 file_size = 0; + LLFILE* file = LLFile::fopen(filename, "rb"); + if (!file) + { + return FALSE; + } + + if (!fseek(file, 0, SEEK_END)) + { + file_size = ftell(file); + fseek(file, 0, SEEK_SET); + } + + // Don't delete before FT_Done_Face + pFontBuffer = new(std::nothrow) U8[file_size]; + if (!pFontBuffer) + { + fclose(file); + return FALSE; + } + + mBufferSize = fread(pFontBuffer, 1, file_size, file); + fclose(file); + + if (mBufferSize != file_size) + { + delete pFontBuffer; + mBufferSize = 0; + return FALSE; + } + + error = FT_New_Memory_Face( gFTLibrary, + (FT_Byte*) pFontBuffer, + mBufferSize, + 0, + &mFTFace); +#else error = FT_New_Face( gFTLibrary, filename.c_str(), 0, - &mFTFace ); + &mFTFace); +#endif - if (error) + if (error) { + delete pFontBuffer; + pFontBuffer = NULL; + mBufferSize = 0; return FALSE; } @@ -166,10 +221,15 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v { // Clean up freetype libs. FT_Done_Face(mFTFace); + delete pFontBuffer; + pFontBuffer = NULL; + mBufferSize = 0; mFTFace = NULL; return FALSE; } + claimMem(mBufferSize); + F32 y_max, y_min, x_max, x_min; F32 ems_per_unit = 1.f/ mFTFace->units_per_EM; F32 pixels_per_unit = pixels_per_em * ems_per_unit; diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index a5ece42b88..26ba695418 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -158,6 +158,8 @@ private: F32 mLineHeight; LLFT_Face mFTFace; + U8* pFontBuffer; + S32 mBufferSize; BOOL mIsFallback; font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars) diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index d003687415..3c829596ce 100644 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp @@ -447,7 +447,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) if (!fontp->loadFace(font_path, extra_scale * point_size, LLFontGL::sVertDPI, LLFontGL::sHorizDPI, 2, is_fallback)) { - LL_INFOS_ONCE("LLFontRegistry") << "Couldn't load font " << *file_name_it << LL_ENDL; + LL_INFOS_ONCE("LLFontRegistry") << "Couldn't load font " << *file_name_it << " from path " << local_path << LL_ENDL; delete fontp; fontp = NULL; } -- cgit v1.2.3 From 56c878925af77324e2e85db2203cc82b86693664 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 12 Jan 2018 18:54:20 +0200 Subject: MAINT-7003 Crash in LLVBOPool Error to help figuring out if error happens due to gl or memory issue --- indra/llrender/llvertexbuffer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 35c771b61b..1ca42039a3 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -191,6 +191,10 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) if (mUsage != GL_DYNAMIC_COPY_ARB) { //data will be provided by application ret = (U8*) ll_aligned_malloc<64>(size); + if (!ret) + { + LL_ERRS() << "Failed to allocate for LLVBOPool buffer" << LL_ENDL; + } } } else -- cgit v1.2.3 From 6e445e82e2a1c1559be5193cd2c131c5f1207f55 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 30 Jan 2018 14:03:26 +0000 Subject: MAINT-8091 Removed deprecated and unused private memory pooling --- indra/llrender/llvertexbuffer.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index c06fdd9700..a55ca5ed9c 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -98,7 +98,6 @@ U32 LLVertexBuffer::sCurVAOName = 1; U32 LLVertexBuffer::sAllocatedIndexBytes = 0; U32 LLVertexBuffer::sIndexCount = 0; -LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL; U32 LLVertexBuffer::sBindCount = 0; U32 LLVertexBuffer::sSetCount = 0; S32 LLVertexBuffer::sCount = 0; @@ -863,11 +862,6 @@ void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping) { sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject; sDisableVBOMapping = sEnableVBOs && no_vbo_mapping; - - if (!sPrivatePoolp) - { - sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC); - } } //static @@ -910,12 +904,6 @@ void LLVertexBuffer::cleanupClass() sStreamVBOPool.cleanup(); sDynamicVBOPool.cleanup(); sDynamicCopyVBOPool.cleanup(); - - if(sPrivatePoolp) - { - LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp); - sPrivatePoolp = NULL; - } } //---------------------------------------------------------------------------- @@ -1206,7 +1194,7 @@ bool LLVertexBuffer::createGLBuffer(U32 size) { static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; - mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); + mMappedData = (U8*)ll_aligned_malloc_16(size); disclaimMem(mSize); mSize = size; claimMem(mSize); @@ -1248,7 +1236,7 @@ bool LLVertexBuffer::createGLIndices(U32 size) } else { - mMappedIndexData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); + mMappedIndexData = (U8*)ll_aligned_malloc_16(size); static int gl_buffer_idx = 0; mGLIndices = ++gl_buffer_idx; mIndicesSize = size; @@ -1271,7 +1259,7 @@ void LLVertexBuffer::destroyGLBuffer() } else { - FREE_MEM(sPrivatePoolp, (void*) mMappedData); + ll_aligned_free_16((void*)mMappedData); mMappedData = NULL; mEmpty = true; } @@ -1291,7 +1279,7 @@ void LLVertexBuffer::destroyGLIndices() } else { - FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData); + ll_aligned_free_16((void*)mMappedIndexData); mMappedIndexData = NULL; mEmpty = true; } -- cgit v1.2.3 From 55990724a37620f6a6835d14db4348166ea22848 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 30 Jan 2018 17:07:00 +0200 Subject: Keep attributes name (useful for debug) --- indra/llrender/llglslshader.cpp | 8 ++++++++ indra/llrender/llglslshader.h | 11 +++++++++++ 2 files changed, 19 insertions(+) (limited to 'indra/llrender') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 97557267cf..4702042ab9 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -537,7 +537,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector * attri mAttribute.clear(); U32 numAttributes = (attributes == NULL) ? 0 : attributes->size(); +#if LL_RELEASE_WITH_DEBUG_INFO + mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, { -1, NULL }); +#else mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1); +#endif if (res) { //read back channel locations @@ -551,7 +555,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector * attri S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name); if (index != -1) { +#if LL_RELEASE_WITH_DEBUG_INFO + mAttribute[i] = { index, name }; +#else mAttribute[i] = index; +#endif mAttributeMask |= 1 << i; LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL; } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 6f10d122cb..b56b914013 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -167,7 +167,18 @@ public: U32 mLightHash; GLhandleARB mProgramObject; +#if LL_RELEASE_WITH_DEBUG_INFO + struct attr_name + { + GLint loc; + const char *name; + void operator = (GLint _loc) { loc = _loc; } + operator GLint () { return loc; } + }; + std::vector mAttribute; //lookup table of attribute enum to attribute channel +#else std::vector mAttribute; //lookup table of attribute enum to attribute channel +#endif U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask()) std::vector mUniform; //lookup table of uniform enum to uniform location LLStaticStringTable mUniformMap; //lookup map of uniform name to uniform location -- cgit v1.2.3 From 0f690ab4dae4c2888ace57362497752592d6fc77 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 30 Jan 2018 17:07:27 +0200 Subject: Add const --- indra/llrender/llvertexbuffer.cpp | 14 +++++++------- indra/llrender/llvertexbuffer.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 7e47471db6..3a1ce0cbb7 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -324,7 +324,7 @@ void LLVBOPool::cleanup() //NOTE: each component must be AT LEAST 4 bytes in size to avoid a performance penalty on AMD hardware -S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = +const S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = { sizeof(LLVector4), // TYPE_VERTEX, sizeof(LLVector4), // TYPE_NORMAL, @@ -341,7 +341,7 @@ S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes }; -static std::string vb_type_name[] = +static const std::string vb_type_name[] = { "TYPE_VERTEX", "TYPE_NORMAL", @@ -360,7 +360,7 @@ static std::string vb_type_name[] = "TYPE_INDEX", }; -U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = +const U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = { GL_TRIANGLES, GL_TRIANGLE_STRIP, @@ -1388,7 +1388,7 @@ void LLVertexBuffer::setupVertexArray() #endif sGLRenderArray = mGLArray; - U32 attrib_size[] = + static const U32 attrib_size[] = { 3, //TYPE_VERTEX, 3, //TYPE_NORMAL, @@ -1405,7 +1405,7 @@ void LLVertexBuffer::setupVertexArray() 1, //TYPE_TEXTURE_INDEX }; - U32 attrib_type[] = + static const U32 attrib_type[] = { GL_FLOAT, //TYPE_VERTEX, GL_FLOAT, //TYPE_NORMAL, @@ -1422,7 +1422,7 @@ void LLVertexBuffer::setupVertexArray() GL_UNSIGNED_INT, //TYPE_TEXTURE_INDEX }; - bool attrib_integer[] = + static const bool attrib_integer[] = { false, //TYPE_VERTEX, false, //TYPE_NORMAL, @@ -1439,7 +1439,7 @@ void LLVertexBuffer::setupVertexArray() true, //TYPE_TEXTURE_INDEX }; - U32 attrib_normalized[] = + static const U32 attrib_normalized[] = { GL_FALSE, //TYPE_VERTEX, GL_FALSE, //TYPE_NORMAL, diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index bd27296eb6..c89d7e3958 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -341,8 +341,8 @@ public: static bool sDisableVBOMapping; //disable glMapBufferARB static bool sEnableVBOs; - static S32 sTypeSize[TYPE_MAX]; - static U32 sGLMode[LLRender::NUM_MODES]; + static const S32 sTypeSize[TYPE_MAX]; + static const U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; static U32 sGLRenderArray; static U32 sGLRenderIndices; -- cgit v1.2.3 From e394c0623d5b015ba5495b3c80559a7420186c5b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 12 Feb 2018 19:31:53 +0200 Subject: MAINT-8146 Remade fix with streams to save memory --- indra/llrender/llfontfreetype.cpp | 114 +++++++++++++++++++++----------------- indra/llrender/llfontfreetype.h | 9 ++- 2 files changed, 69 insertions(+), 54 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 5c1f4ff8b3..bd2eef7fd3 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -31,6 +31,9 @@ // Freetype stuff #include +#ifdef LL_WINDOWS +#include +#endif // For some reason, this won't work if it's not wrapped in the ifdef #ifdef FT_FREETYPE_H @@ -106,8 +109,10 @@ LLFontFreetype::LLFontFreetype() mAscender(0.f), mDescender(0.f), mLineHeight(0.f), - pFontBuffer(NULL), - mBufferSize(0), +#ifdef LL_WINDOWS + pFileStream(NULL), + pFtStream(NULL), +#endif mIsFallback(FALSE), mFTFace(NULL), mRenderGlyphCount(0), @@ -129,12 +134,29 @@ LLFontFreetype::~LLFontFreetype() std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); mCharGlyphInfoMap.clear(); +#ifdef LL_WINDOWS + delete pFileStream; // closed by FT_Done_Face + delete pFtStream; +#endif delete mFontBitmapCachep; - delete pFontBuffer; - disclaimMem(mBufferSize); // mFallbackFonts cleaned up by LLPointer destructor } +#ifdef LL_WINDOWS +unsigned long ft_read_cb(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { + if (count <= 0) return count; + llifstream *file_stream = static_cast(stream->descriptor.pointer); + file_stream->seekg(offset, std::ios::beg); + file_stream->read((char*)buffer, count); + return file_stream->gcount(); +} + +void ft_close_cb(FT_Stream stream) { + llifstream *file_stream = static_cast(stream->descriptor.pointer); + file_stream->close(); +} +#endif + BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, S32 components, BOOL is_fallback) { // Don't leak face objects. This is also needed to deal with @@ -148,51 +170,37 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v int error; #ifdef LL_WINDOWS - - if (mBufferSize > 0) + pFileStream = new llifstream(filename, std::ios::binary); + if (pFileStream->is_open()) { - delete pFontBuffer; - disclaimMem(mBufferSize); - pFontBuffer = NULL; - mBufferSize = 0; - } - - S32 file_size = 0; - LLFILE* file = LLFile::fopen(filename, "rb"); - if (!file) - { - return FALSE; + std::streampos beg = pFileStream->tellg(); + pFileStream->seekg(0, std::ios::end); + std::streampos end = pFileStream->tellg(); + std::size_t file_size = end - beg; + pFileStream->seekg(0, std::ios::beg); + + pFtStream = new LLFT_Stream(); + pFtStream->base = 0; + pFtStream->pos = 0; + pFtStream->size = file_size; + pFtStream->descriptor.pointer = pFileStream; + pFtStream->read = ft_read_cb; + pFtStream->close = ft_close_cb; + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = (FT_StreamRec*)pFtStream; + + error = FT_Open_Face(gFTLibrary, + &args, + 0, + &mFTFace); } - - if (!fseek(file, 0, SEEK_END)) - { - file_size = ftell(file); - fseek(file, 0, SEEK_SET); - } - - // Don't delete before FT_Done_Face - pFontBuffer = new(std::nothrow) U8[file_size]; - if (!pFontBuffer) - { - fclose(file); - return FALSE; - } - - mBufferSize = fread(pFontBuffer, 1, file_size, file); - fclose(file); - - if (mBufferSize != file_size) + else { - delete pFontBuffer; - mBufferSize = 0; + delete pFileStream; return FALSE; } - - error = FT_New_Memory_Face( gFTLibrary, - (FT_Byte*) pFontBuffer, - mBufferSize, - 0, - &mFTFace); #else error = FT_New_Face( gFTLibrary, filename.c_str(), @@ -202,9 +210,11 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v if (error) { - delete pFontBuffer; - pFontBuffer = NULL; - mBufferSize = 0; +#ifdef LL_WINDOWS + pFileStream->close(); + delete pFileStream; + delete pFtStream; +#endif return FALSE; } @@ -219,17 +229,17 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v if (error) { +#ifdef LL_WINDOWS + pFileStream->close(); + delete pFileStream; + delete pFtStream; +#endif // Clean up freetype libs. FT_Done_Face(mFTFace); - delete pFontBuffer; - pFontBuffer = NULL; - mBufferSize = 0; mFTFace = NULL; return FALSE; } - claimMem(mBufferSize); - F32 y_max, y_min, x_max, x_min; F32 ems_per_unit = 1.f/ mFTFace->units_per_EM; F32 pixels_per_unit = pixels_per_em * ems_per_unit; diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index 26ba695418..aadebf5e70 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -40,6 +40,8 @@ // We'll forward declare the struct here. JC struct FT_FaceRec_; typedef struct FT_FaceRec_* LLFT_Face; +struct FT_StreamRec_; +typedef struct FT_StreamRec_ LLFT_Stream; class LLFontManager { @@ -158,8 +160,11 @@ private: F32 mLineHeight; LLFT_Face mFTFace; - U8* pFontBuffer; - S32 mBufferSize; + +#ifdef LL_WINDOWS + llifstream *pFileStream; + LLFT_Stream *pFtStream; +#endif BOOL mIsFallback; font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars) -- cgit v1.2.3 From 8f65593786a4302a1ef7c95ce048bd658367a220 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 13 Feb 2018 14:45:09 +0200 Subject: MAINT-8146 Clearing pointers --- indra/llrender/llfontfreetype.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index bd2eef7fd3..ab668dc192 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -199,6 +199,7 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v else { delete pFileStream; + pFileStream = NULL; return FALSE; } #else @@ -214,6 +215,8 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v pFileStream->close(); delete pFileStream; delete pFtStream; + pFileStream = NULL; + pFtStream = NULL; #endif return FALSE; } @@ -229,13 +232,15 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v if (error) { + // Clean up freetype libs. + FT_Done_Face(mFTFace); #ifdef LL_WINDOWS pFileStream->close(); delete pFileStream; delete pFtStream; + pFileStream = NULL; + pFtStream = NULL; #endif - // Clean up freetype libs. - FT_Done_Face(mFTFace); mFTFace = NULL; return FALSE; } -- cgit v1.2.3 From 06bce2ddd0958cff3c2ee477a880e998dfc48be7 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 15 Feb 2018 21:55:24 +0000 Subject: Add debug setting and code to allow nVidia nSight graphics debugging to capture SL frames. These changes are only enabled if RenderNsightDebugSupport is true and eliminate use of some OpenGL legacy functionality which is incompatible with nSight capture (mostly glReadPixels and other fixed-function pipe rendering calls). --- indra/llrender/llgl.cpp | 11 +++++++++++ indra/llrender/llrender.cpp | 1 + indra/llrender/llrender.h | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 155c2402bd..35b6951779 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1348,8 +1348,19 @@ void LLGLManager::initExtensions() if (mHasVertexShader) { LL_INFOS() << "initExtensions() VertexShader-related procs..." << LL_ENDL; + + // nSight doesn't support use of ARB funcs that have been normalized in the API + if (!LLRender::sNsightDebugSupport) + { glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetAttribLocationARB"); glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GLH_EXT_GET_PROC_ADDRESS("glBindAttribLocationARB"); + } + else + { + glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetAttribLocation"); + glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBindAttribLocation"); + } + glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetActiveAttribARB"); glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dARB"); glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dvARB"); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 76f28bb43f..65d6181920 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -49,6 +49,7 @@ U32 LLRender::sUICalls = 0; U32 LLRender::sUIVerts = 0; U32 LLTexUnit::sWhiteTexture = 0; bool LLRender::sGLCoreProfile = false; +bool LLRender::sNsightDebugSupport = false; static const U32 LL_NUM_TEXTURE_LAYERS = 32; static const U32 LL_NUM_LIGHT_UNITS = 8; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index a67fb8da52..2573129fd3 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -438,7 +438,8 @@ public: static U32 sUICalls; static U32 sUIVerts; static bool sGLCoreProfile; - + static bool sNsightDebugSupport; + private: friend class LLLightState; -- cgit v1.2.3 From d9064d3a4e83a44c518851643993b0b79ac33e13 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 27 Feb 2018 15:49:15 +0200 Subject: MAINT-8317 Fixed Local Textures for Advanced Lighting Projectors do not keep the selected texture. --- indra/llrender/llrender.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/llrender') diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 2573129fd3..32bb728d8a 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -269,6 +269,13 @@ public: SPECULAR_MAP, NUM_TEXTURE_CHANNELS, }; + + enum eVolumeTexIndex + { + LIGHT_TEX = 0, + SCULPT_TEX, + NUM_VOLUME_TEXTURE_CHANNELS, + }; typedef enum { TRIANGLES = 0, -- cgit v1.2.3 From 4156fb832c02f8ca07620ad9e0b0960320d57806 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 6 Mar 2018 12:59:32 +0000 Subject: MAINT-6363 Normal and specular maps should not be downloaded if ALM is off --- indra/llrender/llgltexture.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender') diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 45592ee077..70610d9626 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -49,6 +49,7 @@ public: enum EBoostLevel { BOOST_NONE = 0, + BOOST_ALM , //acts like NONE when ALM is on, max discard when ALM is off BOOST_AVATAR_BAKED , BOOST_AVATAR , BOOST_CLOUDS , -- cgit v1.2.3