From 3a597af700e55e2017c85220b2b97cc9f3aef9aa Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 18 Jan 2012 16:30:53 -0800 Subject: EXP-1513 FIX Underscore ( _ ) fails to show in first chat entry in Local Chat fixed font metrics rounding error and made corrective adjustments in layout --- indra/llrender/llfontgl.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 82e8227ffe..12f86cf599 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -218,13 +218,13 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons switch (valign) { case TOP: - cur_y -= mFontFreetype->getAscenderHeight(); + cur_y -= getAscenderHeight(); break; case BOTTOM: - cur_y += mFontFreetype->getDescenderHeight(); + cur_y += getDescenderHeight(); break; case VCENTER: - cur_y -= (mFontFreetype->getAscenderHeight() - mFontFreetype->getDescenderHeight()) / 2.f; + cur_y -= (getAscenderHeight() - getDescenderHeight()) / 2.f; break; case BASELINE: // Baseline, do nothing. @@ -390,12 +390,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons //FIXME: add underline as glyph? if (style_to_add & UNDERLINE) { - F32 descender = mFontFreetype->getDescenderHeight(); + F32 descender = (F32)llfloor(mFontFreetype->getDescenderHeight()); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.begin(LLRender::LINES); - gGL.vertex2f(start_x, cur_y - (descender)); - gGL.vertex2f(cur_x, cur_y - (descender)); + gGL.vertex2f(start_x, cur_y - descender); + gGL.vertex2f(cur_x, cur_y - descender); gGL.end(); } @@ -446,17 +446,17 @@ S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y // font metrics - override for LLFontFreetype that returns units of virtual pixels F32 LLFontGL::getLineHeight() const { - return (F32)llround(mFontFreetype->getLineHeight() / sScaleY); + return (F32)llceil(mFontFreetype->getLineHeight() / sScaleY); } F32 LLFontGL::getAscenderHeight() const { - return (F32)llround(mFontFreetype->getAscenderHeight() / sScaleY); + return (F32)llceil(mFontFreetype->getAscenderHeight() / sScaleY); } F32 LLFontGL::getDescenderHeight() const { - return (F32)llround(mFontFreetype->getDescenderHeight() / sScaleY); + return (F32)llceil(mFontFreetype->getDescenderHeight() / sScaleY); } S32 LLFontGL::getWidth(const std::string& utf8text) const -- cgit v1.2.3 From 0bbe8d73cb687e34d1b10c58b67c465df076739c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 25 Jan 2012 15:37:36 -0600 Subject: SH-2565 Move resetVertexBuffer operation to a consistent location (also avoid redundant resetting of vertex buffers on detail switches). Change assertion to a warning with count info. Fix bytes pooled debug display. Remove unused static vertex buffer. --- indra/llrender/llvertexbuffer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index eb302392bb..518f3898a4 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -205,14 +205,13 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) rec.mGLName = name; rec.mClientData = buffer; - sBytesPooled += size; - if (!LLVertexBuffer::sDisableVBOMapping && mUsage == GL_DYNAMIC_DRAW_ARB) { glDeleteBuffersARB(1, &rec.mGLName); } else { + sBytesPooled += size; mFreeList[i].push_back(rec); } } -- cgit v1.2.3 From 71a660e0060b9aa2c5c01fd94e8070075b373d8d Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 26 Jan 2012 10:17:41 -0800 Subject: * Fixed up shader compilation errors to get lighting and shadows working again on Mac. * Cleaned up vertex buffer allocation to guarantee allocation and deallocation using the same allocation methods from the same pools. * Added new shader feature for atmospheric helpers in the absence of lighting. Reviewed by davep. --- indra/llrender/llglslshader.cpp | 21 +++- indra/llrender/llglslshader.h | 1 + indra/llrender/llshadermgr.cpp | 5 +- indra/llrender/llvertexbuffer.cpp | 222 ++++++++++++++++++-------------------- indra/llrender/llvertexbuffer.h | 31 ++++-- 5 files changed, 151 insertions(+), 129 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 6b2852670a..3773568ad8 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -64,10 +64,23 @@ BOOL shouldChange(const LLVector4& v1, const LLVector4& v2) } LLShaderFeatures::LLShaderFeatures() -: calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false), -hasTransport(false), hasSkinning(false), hasObjectSkinning(false), hasAtmospherics(false), isSpecular(false), -hasGamma(false), hasLighting(false), isAlphaLighting(false), calculatesAtmospherics(false), mIndexedTextureChannels(0), disableTextureIndex(false), -hasAlphaMask(false) + : atmosphericHelpers(false) + , calculatesLighting(false) + , calculatesAtmospherics(false) + , hasLighting(false) + , isAlphaLighting(false) + , isShiny(false) + , isFullbright(false) + , isSpecular(false) + , hasWaterFog(false) + , hasTransport(false) + , hasSkinning(false) + , hasObjectSkinning(false) + , hasAtmospherics(false) + , hasGamma(false) + , mIndexedTextureChannels(0) + , disableTextureIndex(false) + , hasAlphaMask(false) { } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 00b4b0dbd4..7873fe3c4e 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -33,6 +33,7 @@ class LLShaderFeatures { public: + bool atmosphericHelpers; bool calculatesLighting; bool calculatesAtmospherics; bool hasLighting; // implies no transport (it's possible to have neither though) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 1a03aeebb7..908443e8cf 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -94,13 +94,16 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->calculatesLighting) + if (features->calculatesLighting || features->atmosphericHelpers) { if (!shader->attachObject("windlight/atmosphericsHelpersV.glsl")) { return FALSE; } + } + if (features->calculatesLighting) + { if (features->isSpecular) { if (!shader->attachObject("lighting/lightFuncSpecularV.glsl")) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 518f3898a4..9069885341 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -53,19 +53,19 @@ U32 nhpo2(U32 v) //============================================================================ //static -LLVBOPool LLVertexBuffer::sStreamVBOPool; -LLVBOPool LLVertexBuffer::sDynamicVBOPool; -LLVBOPool LLVertexBuffer::sStreamIBOPool; -LLVBOPool LLVertexBuffer::sDynamicIBOPool; +LLVBOPool LLVertexBuffer::sStreamVBOPool(GL_STREAM_DRAW_ARB, GL_ARRAY_BUFFER_ARB); +LLVBOPool LLVertexBuffer::sDynamicVBOPool(GL_DYNAMIC_DRAW_ARB, GL_ARRAY_BUFFER_ARB); +LLVBOPool LLVertexBuffer::sStreamIBOPool(GL_STREAM_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB); +LLVBOPool LLVertexBuffer::sDynamicIBOPool(GL_DYNAMIC_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB); U32 LLVBOPool::sBytesPooled = 0; -LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL ; +LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL; U32 LLVertexBuffer::sBindCount = 0; U32 LLVertexBuffer::sSetCount = 0; S32 LLVertexBuffer::sCount = 0; S32 LLVertexBuffer::sGLCount = 0; S32 LLVertexBuffer::sMappedCount = 0; -BOOL LLVertexBuffer::sDisableVBOMapping = FALSE ; +BOOL LLVertexBuffer::sDisableVBOMapping = FALSE; BOOL LLVertexBuffer::sEnableVBOs = TRUE; U32 LLVertexBuffer::sGLRenderBuffer = 0; U32 LLVertexBuffer::sGLRenderArray = 0; @@ -204,8 +204,8 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) Record rec; rec.mGLName = name; rec.mClientData = buffer; - - if (!LLVertexBuffer::sDisableVBOMapping && mUsage == GL_DYNAMIC_DRAW_ARB) + + if (buffer == NULL) { glDeleteBuffersARB(1, &rec.mGLName); } @@ -282,7 +282,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) { if (sLastMask != data_mask) { - BOOL error = FALSE; + bool error = false; if (LLGLSLShader::sNoFixedFunction) { @@ -343,7 +343,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) { if (gDebugSession) { - error = TRUE; + error = true; gFailLog << "Bad client state! " << array[i] << " disabled." << std::endl; } else @@ -363,7 +363,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) { //needs to be disabled, make sure it was (DEBUG TEMPORARY) if (gDebugSession) { - error = TRUE; + error = true; gFailLog << "Bad client state! " << array[i] << " enabled." << std::endl; } else @@ -547,7 +547,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const { validateRange(start, end, count, indices_offset); - mMappable = FALSE; + mMappable = false; gGL.syncMatrices(); llassert(mNumVerts >= 0); @@ -602,7 +602,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const { llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); - mMappable = FALSE; + mMappable = false; gGL.syncMatrices(); llassert(mNumIndices >= 0); @@ -648,7 +648,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const { llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); - mMappable = FALSE; + mMappable = false; gGL.syncMatrices(); llassert(mNumVerts >= 0); @@ -688,23 +688,13 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const //static void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping) { - sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject ; - sDisableVBOMapping = sEnableVBOs && no_vbo_mapping ; + sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject; + sDisableVBOMapping = sEnableVBOs && no_vbo_mapping; - if(!sPrivatePoolp) + if (!sPrivatePoolp) { - sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC) ; + sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC); } - - sStreamVBOPool.mType = GL_ARRAY_BUFFER_ARB; - sStreamVBOPool.mUsage= GL_STREAM_DRAW_ARB; - sStreamIBOPool.mType = GL_ELEMENT_ARRAY_BUFFER_ARB; - sStreamIBOPool.mUsage= GL_STREAM_DRAW_ARB; - - sDynamicVBOPool.mType = GL_ARRAY_BUFFER_ARB; - sDynamicVBOPool.mUsage= GL_DYNAMIC_DRAW_ARB; - sDynamicIBOPool.mType = GL_ELEMENT_ARRAY_BUFFER_ARB; - sDynamicIBOPool.mUsage= GL_DYNAMIC_DRAW_ARB; } //static @@ -757,65 +747,79 @@ void LLVertexBuffer::cleanupClass() //---------------------------------------------------------------------------- -LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : - LLRefCount(), - - mNumVerts(0), - mNumIndices(0), - mUsage(usage), - mGLBuffer(0), - mGLArray(0), - mGLIndices(0), - mMappedData(NULL), - mMappedIndexData(NULL), - mVertexLocked(FALSE), - mIndexLocked(FALSE), - mFinal(FALSE), - mEmpty(TRUE), - mFence(NULL) +S32 LLVertexBuffer::determineUsage(S32 usage) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR); - mFence = NULL; + S32 ret_usage = usage; + if (!sEnableVBOs) { - mUsage = 0 ; + ret_usage = 0; } - - if (mUsage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) + + if (usage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) { - mUsage = 0; + ret_usage = 0; } - if (mUsage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) + if (usage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) { - mUsage = GL_STREAM_DRAW_ARB; + ret_usage = GL_STREAM_DRAW_ARB; } - - if (mUsage == 0 && LLRender::sGLCoreProfile) + + if (usage == 0 && LLRender::sGLCoreProfile) { //MUST use VBOs for all rendering - mUsage = GL_STREAM_DRAW_ARB; + ret_usage = GL_STREAM_DRAW_ARB; } - - if (mUsage && mUsage != GL_STREAM_DRAW_ARB) + + if (usage && usage != GL_STREAM_DRAW_ARB) { //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default if (sDisableVBOMapping) { //always use stream draw if VBO mapping is disabled - mUsage = GL_STREAM_DRAW_ARB; + ret_usage = GL_STREAM_DRAW_ARB; } else { - mUsage = GL_DYNAMIC_DRAW_ARB; + ret_usage = GL_DYNAMIC_DRAW_ARB; } } + return ret_usage; +} + +LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : + LLRefCount(), + + mNumVerts(0), + mNumIndices(0), + mAlignedOffset(0), + mAlignedIndexOffset(0), + mSize(0), + mIndicesSize(0), + mTypeMask(typemask), + mUsage(LLVertexBuffer::determineUsage(usage)), + mGLBuffer(0), + mGLIndices(0), + mGLArray(0), + mMappedData(NULL), + mMappedIndexData(NULL), + mMappedDataUsingVBOs(false), + mMappedIndexDataUsingVBOs(false), + mVertexLocked(false), + mIndexLocked(false), + mFinal(false), + mEmpty(true), + mMappable(false), + mFence(NULL) +{ + LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR); if (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping) { - mMappable = TRUE; + mMappable = true; } else { - mMappable = FALSE; + mMappable = false; } //zero out offsets @@ -824,12 +828,6 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : mOffsets[i] = 0; } - mTypeMask = typemask; - mSize = 0; - mIndicesSize = 0; - mAlignedOffset = 0; - mAlignedIndexOffset = 0; - sCount++; } @@ -1010,9 +1008,11 @@ void LLVertexBuffer::createGLBuffer(U32 size) return; } - mEmpty = TRUE; + mEmpty = true; - if (useVBOs()) + mMappedDataUsingVBOs = useVBOs(); + + if (mMappedDataUsingVBOs) { genBuffer(size); } @@ -1039,12 +1039,14 @@ void LLVertexBuffer::createGLIndices(U32 size) return; } - mEmpty = TRUE; + mEmpty = true; //pad by 16 bytes for aligned copies size += 16; - if (useVBOs()) + mMappedIndexDataUsingVBOs = useVBOs(); + + if (mMappedIndexDataUsingVBOs) { //pad by another 16 bytes for VBO pointer adjustment size += 16; @@ -1064,15 +1066,15 @@ void LLVertexBuffer::destroyGLBuffer() LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_BUFFER); if (mGLBuffer) { - if (useVBOs()) + if (mMappedDataUsingVBOs) { releaseBuffer(); } else { - FREE_MEM(sPrivatePoolp, (void*) mMappedData) ; + FREE_MEM(sPrivatePoolp, (void*) mMappedData); mMappedData = NULL; - mEmpty = TRUE; + mEmpty = true; } } @@ -1085,15 +1087,15 @@ void LLVertexBuffer::destroyGLIndices() LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_INDICES); if (mGLIndices) { - if (useVBOs()) + if (mMappedIndexDataUsingVBOs) { releaseIndices(); } else { - FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData) ; + FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData); mMappedIndexData = NULL; - mEmpty = TRUE; + mEmpty = true; } } @@ -1278,16 +1280,10 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) } } -BOOL LLVertexBuffer::useVBOs() const +bool LLVertexBuffer::useVBOs() const { //it's generally ineffective to use VBO for things that are streaming on apple - - if (!mUsage) - { - return FALSE; - } - - return TRUE; + return (mUsage != 0); } //---------------------------------------------------------------------------- @@ -1367,7 +1363,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo if (!mVertexLocked) { LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES); - mVertexLocked = TRUE; + mVertexLocked = true; sMappedCount++; stop_glerror(); @@ -1446,8 +1442,8 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo { log_glerror(); - //check the availability of memory - LLMemory::logMemoryInfo(TRUE) ; + //check the availability of memory + LLMemory::logMemoryInfo(TRUE) ; if(mMappable) { @@ -1546,7 +1542,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range { LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES); - mIndexLocked = TRUE; + mIndexLocked = true; sMappedCount++; stop_glerror(); @@ -1741,7 +1737,7 @@ void LLVertexBuffer::unmapBuffer() mMappedData = NULL; } - mVertexLocked = FALSE ; + mVertexLocked = false; sMappedCount--; } @@ -1808,13 +1804,13 @@ void LLVertexBuffer::unmapBuffer() mMappedIndexData = NULL ; } - mIndexLocked = FALSE ; + mIndexLocked = false ; sMappedCount--; } if(updated_all) { - mEmpty = FALSE; + mEmpty = false; } } @@ -1834,12 +1830,12 @@ template struct VertexBufferStrider if (ptr == NULL) { llwarns << "mapIndexBuffer failed!" << llendl; - return FALSE; + return false; } strider = (T*)ptr; strider.setStride(0); - return TRUE; + return true; } else if (vbo.hasDataType(type)) { @@ -1850,18 +1846,18 @@ template struct VertexBufferStrider if (ptr == NULL) { llwarns << "mapVertexBuffer failed!" << llendl; - return FALSE; + return false; } strider = (T*)ptr; strider.setStride(stride); - return TRUE; + return true; } else { llerrs << "VertexBufferStrider could not find valid vertex data." << llendl; } - return FALSE; + return false; } }; @@ -2014,7 +2010,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_BUFFER); //set up pointers if the data mask is different ... - BOOL setup = (sLastMask != data_mask); + bool setup = (sLastMask != data_mask); if (gDebugGL && data_mask != 0) { //make sure data requirements are fulfilled @@ -2048,21 +2044,17 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if (mGLArray) { bindGLArray(); - setup = FALSE; //do NOT perform pointer setup if using VAO + setup = false; //do NOT perform pointer setup if using VAO } else { - if (bindGLBuffer()) - { - setup = TRUE; - } - if (bindGLIndices()) - { - setup = TRUE; - } + const bool bindBuffer = bindGLBuffer(); + const bool bindIndices = bindGLIndices(); + + setup = setup || bindBuffer || bindIndices; } - BOOL error = FALSE; + bool error = false; if (gDebugGL && !mGLArray) { GLint buff; @@ -2071,7 +2063,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { if (gDebugSession) { - error = TRUE; + error = true; gFailLog << "Invalid GL vertex buffer bound: " << buff << std::endl; } else @@ -2087,7 +2079,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { if (gDebugSession) { - error = TRUE; + error = true; gFailLog << "Invalid GL index buffer bound: " << buff << std::endl; } else @@ -2119,12 +2111,12 @@ void LLVertexBuffer::setBuffer(U32 data_mask) glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); sBindCount++; sVBOActive = FALSE; - setup = TRUE; // ... or a VBO is deactivated + setup = true; // ... or a VBO is deactivated } if (sGLRenderBuffer != mGLBuffer) { sGLRenderBuffer = mGLBuffer; - setup = TRUE; // ... or a client memory pointer changed + setup = true; // ... or a client memory pointer changed } } if (mGLIndices) @@ -2221,19 +2213,19 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) { S32 loc = TYPE_WEIGHT; void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT]); - glVertexAttribPointerARB(loc, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], ptr); + glVertexAttribPointerARB(loc, 1, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], ptr); } if (data_mask & MAP_WEIGHT4) { S32 loc = TYPE_WEIGHT4; void* ptr = (void*)(base+mOffsets[TYPE_WEIGHT4]); - glVertexAttribPointerARB(loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], ptr); + glVertexAttribPointerARB(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], ptr); } if (data_mask & MAP_CLOTHWEIGHT) { S32 loc = TYPE_CLOTHWEIGHT; void* ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]); - glVertexAttribPointerARB(loc, 4, GL_FLOAT, TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr); + glVertexAttribPointerARB(loc, 4, GL_FLOAT, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr); } if (data_mask & MAP_TEXTURE_INDEX) { diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index e1cbfd3b61..a0d21b4a36 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -55,9 +55,14 @@ class LLVBOPool { public: static U32 sBytesPooled; + + LLVBOPool(U32 vboUsage, U32 vboType) + : mUsage(vboUsage) + , mType(vboType) + {} - U32 mUsage; - U32 mType; + const U32 mUsage; + const U32 mType; //size MUST be a power of 2 volatile U8* allocate(U32& name, U32 size); @@ -103,6 +108,7 @@ public: }; LLVertexBuffer(const LLVertexBuffer& rhs) + : mUsage(rhs.mUsage) { *this = rhs; } @@ -201,7 +207,7 @@ protected: void destroyGLIndices(); void updateNumVerts(S32 nverts); void updateNumIndices(S32 nindices); - virtual BOOL useVBOs() const; + bool useVBOs() const; void unmapBuffer(); public: @@ -274,18 +280,24 @@ protected: S32 mSize; S32 mIndicesSize; U32 mTypeMask; - S32 mUsage; // GL usage + + const S32 mUsage; // GL usage + U32 mGLBuffer; // GL VBO handle U32 mGLIndices; // GL IBO handle U32 mGLArray; // GL VAO handle volatile U8* mMappedData; // pointer to currently mapped data (NULL if unmapped) volatile U8* mMappedIndexData; // pointer to currently mapped indices (NULL if unmapped) - BOOL mVertexLocked; // if TRUE, vertex buffer is being or has been written to in client memory - BOOL mIndexLocked; // if TRUE, index buffer is being or has been written to in client memory - BOOL mFinal; // if TRUE, buffer can not be mapped again - BOOL mEmpty; // if TRUE, client buffer is empty (or NULL). Old values have been discarded. - mutable BOOL mMappable; // if TRUE, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) + + U32 mMappedDataUsingVBOs : 1; + U32 mMappedIndexDataUsingVBOs : 1; + U32 mVertexLocked : 1; // if TRUE, vertex buffer is being or has been written to in client memory + U32 mIndexLocked : 1; // if TRUE, index buffer is being or has been written to in client memory + U32 mFinal : 1; // if TRUE, buffer can not be mapped again + U32 mEmpty : 1; // if TRUE, client buffer is empty (or NULL). Old values have been discarded. + + mutable bool mMappable; // if TRUE, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) S32 mOffsets[TYPE_MAX]; std::vector mMappedVertexRegions; @@ -296,6 +308,7 @@ protected: void placeFence() const; void waitFence() const; + static S32 determineUsage(S32 usage); private: static LLPrivateMemoryPool* sPrivatePoolp ; -- cgit v1.2.3 From 17b21fc197f162a4070083c436920c0640431568 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 26 Jan 2012 12:50:24 -0600 Subject: Fix for windows build --- indra/llrender/llvertexbuffer.cpp | 36 ++++++++++++++++++------------------ indra/llrender/llvertexbuffer.h | 32 ++++++++++++++++---------------- 2 files changed, 34 insertions(+), 34 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 9069885341..a7151afeb1 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -65,19 +65,19 @@ U32 LLVertexBuffer::sSetCount = 0; S32 LLVertexBuffer::sCount = 0; S32 LLVertexBuffer::sGLCount = 0; S32 LLVertexBuffer::sMappedCount = 0; -BOOL LLVertexBuffer::sDisableVBOMapping = FALSE; -BOOL LLVertexBuffer::sEnableVBOs = TRUE; +bool LLVertexBuffer::sDisableVBOMapping = false; +bool LLVertexBuffer::sEnableVBOs = true; U32 LLVertexBuffer::sGLRenderBuffer = 0; U32 LLVertexBuffer::sGLRenderArray = 0; U32 LLVertexBuffer::sGLRenderIndices = 0; U32 LLVertexBuffer::sLastMask = 0; -BOOL LLVertexBuffer::sVBOActive = FALSE; -BOOL LLVertexBuffer::sIBOActive = FALSE; +bool LLVertexBuffer::sVBOActive = false; +bool LLVertexBuffer::sIBOActive = false; U32 LLVertexBuffer::sAllocatedBytes = 0; -BOOL LLVertexBuffer::sMapped = FALSE; -BOOL LLVertexBuffer::sUseStreamDraw = TRUE; -BOOL LLVertexBuffer::sUseVAO = FALSE; -BOOL LLVertexBuffer::sPreferStreamDraw = FALSE; +bool LLVertexBuffer::sMapped = false; +bool LLVertexBuffer::sUseStreamDraw = true; +bool LLVertexBuffer::sUseVAO = false; +bool LLVertexBuffer::sPreferStreamDraw = false; const U32 FENCE_WAIT_TIME_NANOSECONDS = 10000; //1 ms @@ -707,18 +707,18 @@ void LLVertexBuffer::unbind() #endif sGLRenderArray = 0; sGLRenderIndices = 0; - sIBOActive = FALSE; + sIBOActive = false; } if (sVBOActive) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - sVBOActive = FALSE; + sVBOActive = false; } if (sIBOActive) { glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - sIBOActive = FALSE; + sIBOActive = false; } sGLRenderBuffer = 0; @@ -1443,7 +1443,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo log_glerror(); //check the availability of memory - LLMemory::logMemoryInfo(TRUE) ; + LLMemory::logMemoryInfo(true) ; if(mMappable) { @@ -1621,7 +1621,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (!mMappedIndexData) { log_glerror(); - LLMemory::logMemoryInfo(TRUE) ; + LLMemory::logMemoryInfo(true) ; if(mMappable) { @@ -1956,7 +1956,7 @@ bool LLVertexBuffer::bindGLBuffer(bool force_bind) glBindBufferARB(GL_ARRAY_BUFFER_ARB, mGLBuffer); sGLRenderBuffer = mGLBuffer; sBindCount++; - sVBOActive = TRUE; + sVBOActive = true; if (mGLArray) { @@ -1988,7 +1988,7 @@ bool LLVertexBuffer::bindGLIndices(bool force_bind) sGLRenderIndices = mGLIndices; stop_glerror(); sBindCount++; - sIBOActive = TRUE; + sIBOActive = true; ret = true; } @@ -2101,7 +2101,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) #endif sGLRenderArray = 0; sGLRenderIndices = 0; - sIBOActive = FALSE; + sIBOActive = false; } if (mGLBuffer) @@ -2110,7 +2110,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); sBindCount++; - sVBOActive = FALSE; + sVBOActive = false; setup = true; // ... or a VBO is deactivated } if (sGLRenderBuffer != mGLBuffer) @@ -2125,7 +2125,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); sBindCount++; - sIBOActive = FALSE; + sIBOActive = false; } sGLRenderIndices = mGLIndices; diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index a0d21b4a36..0bf689bfad 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -124,9 +124,9 @@ public: static LLVBOPool sStreamIBOPool; static LLVBOPool sDynamicIBOPool; - static BOOL sUseStreamDraw; - static BOOL sUseVAO; - static BOOL sPreferStreamDraw; + static bool sUseStreamDraw; + static bool sUseVAO; + static bool sPreferStreamDraw; static void initClass(bool use_vbo, bool no_vbo_mapping); static void cleanupClass(); @@ -245,8 +245,8 @@ public: bool getClothWeightStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - BOOL isEmpty() const { return mEmpty; } - BOOL isLocked() const { return mVertexLocked || mIndexLocked; } + bool isEmpty() const { return mEmpty; } + bool isLocked() const { return mVertexLocked || mIndexLocked; } S32 getNumVerts() const { return mNumVerts; } S32 getNumIndices() const { return mNumIndices; } @@ -260,7 +260,7 @@ public: volatile U8* getMappedIndices() const { return mMappedIndexData; } S32 getOffset(S32 type) const { return mOffsets[type]; } S32 getUsage() const { return mUsage; } - BOOL isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW_ARB) ? TRUE : FALSE; } + bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW_ARB) ? true : false; } void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; @@ -292,12 +292,12 @@ protected: U32 mMappedDataUsingVBOs : 1; U32 mMappedIndexDataUsingVBOs : 1; - U32 mVertexLocked : 1; // if TRUE, vertex buffer is being or has been written to in client memory - U32 mIndexLocked : 1; // if TRUE, index buffer is being or has been written to in client memory - U32 mFinal : 1; // if TRUE, buffer can not be mapped again - U32 mEmpty : 1; // if TRUE, client buffer is empty (or NULL). Old values have been discarded. + U32 mVertexLocked : 1; // if true, vertex buffer is being or has been written to in client memory + U32 mIndexLocked : 1; // if true, index buffer is being or has been written to in client memory + U32 mFinal : 1; // if true, buffer can not be mapped again + U32 mEmpty : 1; // if true, client buffer is empty (or NULL). Old values have been discarded. - mutable bool mMappable; // if TRUE, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) + mutable bool mMappable; // if true, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) S32 mOffsets[TYPE_MAX]; std::vector mMappedVertexRegions; @@ -317,18 +317,18 @@ public: static S32 sCount; static S32 sGLCount; static S32 sMappedCount; - static BOOL sMapped; + static bool sMapped; typedef std::list buffer_list_t; - static BOOL sDisableVBOMapping; //disable glMapBufferARB - static BOOL sEnableVBOs; + static bool sDisableVBOMapping; //disable glMapBufferARB + static bool sEnableVBOs; static S32 sTypeSize[TYPE_MAX]; static U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; static U32 sGLRenderArray; static U32 sGLRenderIndices; - static BOOL sVBOActive; - static BOOL sIBOActive; + static bool sVBOActive; + static bool sIBOActive; static U32 sLastMask; static U32 sAllocatedBytes; static U32 sBindCount; -- cgit v1.2.3 From bbc265a9d5230603b7ee1b3f974ef27154d8507f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 26 Jan 2012 16:30:38 -0800 Subject: EXP-1846 FIX Text positioning issues in Floaters, Notifications, UI, and toasts with UI size smaller than 1 also, re-enabled floater_test_textbox.xml --- indra/llrender/llfontgl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 12f86cf599..a469581637 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -215,16 +215,17 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_y = ((F32)y * sScaleY) + origin.mV[VY]; // Offset y by vertical alignment. + // use unscaled font metrics here switch (valign) { case TOP: - cur_y -= getAscenderHeight(); + cur_y -= mFontFreetype->getAscenderHeight(); break; case BOTTOM: - cur_y += getDescenderHeight(); + cur_y += mFontFreetype->getDescenderHeight(); break; case VCENTER: - cur_y -= (getAscenderHeight() - getDescenderHeight()) / 2.f; + cur_y -= (mFontFreetype->getAscenderHeight() - mFontFreetype->getDescenderHeight()) / 2.f; break; case BASELINE: // Baseline, do nothing. -- cgit v1.2.3 From 22a6170a7b19b3a6f44536b7552b633416348775 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 27 Jan 2012 19:55:16 -0800 Subject: EXP-1513 FIX Underscore ( _ ) fails to show in first chat entry in Local Chat --- indra/llrender/llfontgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index a469581637..7d827ae483 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -219,10 +219,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons switch (valign) { case TOP: - cur_y -= mFontFreetype->getAscenderHeight(); + cur_y -= llceil(mFontFreetype->getAscenderHeight()); break; case BOTTOM: - cur_y += mFontFreetype->getDescenderHeight(); + cur_y += llceil(mFontFreetype->getDescenderHeight()); break; case VCENTER: cur_y -= (mFontFreetype->getAscenderHeight() - mFontFreetype->getDescenderHeight()) / 2.f; -- cgit v1.2.3 From c47c31fdbfb1c02de13bc7f17af1e7d173c048f3 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 31 Jan 2012 17:51:43 -0800 Subject: EXP-1513 FIX Underscore ( _ ) fails to show in first chat entry in Local Chat --- indra/llrender/llfontgl.cpp | 16 +++------------- indra/llrender/llfontgl.h | 4 +--- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 7d827ae483..4eb10b2c93 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -225,7 +225,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_y += llceil(mFontFreetype->getDescenderHeight()); break; case VCENTER: - cur_y -= (mFontFreetype->getAscenderHeight() - mFontFreetype->getDescenderHeight()) / 2.f; + cur_y -= llceil((llceil(mFontFreetype->getAscenderHeight()) - llceil(mFontFreetype->getDescenderHeight())) / 2.f); break; case BASELINE: // Baseline, do nothing. @@ -445,19 +445,9 @@ S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y } // font metrics - override for LLFontFreetype that returns units of virtual pixels -F32 LLFontGL::getLineHeight() const +S32 LLFontGL::getLineHeight() const { - return (F32)llceil(mFontFreetype->getLineHeight() / sScaleY); -} - -F32 LLFontGL::getAscenderHeight() const -{ - return (F32)llceil(mFontFreetype->getAscenderHeight() / sScaleY); -} - -F32 LLFontGL::getDescenderHeight() const -{ - return (F32)llceil(mFontFreetype->getDescenderHeight() / sScaleY); + return llceil(mFontFreetype->getAscenderHeight() / sScaleY) + llceil(mFontFreetype->getDescenderHeight() / sScaleY); } S32 LLFontGL::getWidth(const std::string& utf8text) const diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index dc8d848ed2..9d7e2891e3 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -115,9 +115,7 @@ public: S32 renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style = NORMAL, ShadowType shadow = NO_SHADOW) const; // font metrics - override for LLFontFreetype that returns units of virtual pixels - F32 getLineHeight() const; - F32 getAscenderHeight() const; - F32 getDescenderHeight() const; + S32 getLineHeight() const; S32 getWidth(const std::string& utf8text) const; S32 getWidth(const llwchar* wchars) const; -- cgit v1.2.3 From 5a14a67e060e7f325025e924c83489cfa236e3dc Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Feb 2012 13:03:46 -0800 Subject: converted a bunch of narrowing implicit conversions to explicit --- indra/llrender/llfontgl.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 4eb10b2c93..4519c5e789 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -115,23 +115,23 @@ static LLFastTimer::DeclareTimer FTM_RENDER_FONTS("Fonts"); S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRect& rect, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, F32* right_x, BOOL use_ellipses) const { - F32 x = rect.mLeft; + F32 x = (F32)rect.mLeft; F32 y = 0.f; switch(valign) { case TOP: - y = rect.mTop; + y = (F32)rect.mTop; break; case VCENTER: - y = rect.getCenterY(); + y = (F32)rect.getCenterY(); break; case BASELINE: case BOTTOM: - y = rect.mBottom; + y = (F32)rect.mBottom; break; default: - y = rect.mBottom; + y = (F32)rect.mBottom; break; } return render(wstr, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, rect.getWidth(), right_x, use_ellipses); @@ -251,7 +251,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_render_y = cur_y; cur_render_x = cur_x; - F32 start_x = llround(cur_x); + F32 start_x = (F32)llround(cur_x); const LLFontBitmapCache* font_bitmap_cache = mFontFreetype->getFontBitmapCache(); @@ -335,10 +335,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons (fgi->mXBitmapOffset + fgi->mWidth) * inv_width, (fgi->mYBitmapOffset - PAD_UVY) * inv_height); // snap glyph origin to whole screen pixel - LLRectf screen_rect(llround(cur_render_x + (F32)fgi->mXBearing), - llround(cur_render_y + (F32)fgi->mYBearing), - llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth, - llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight); + LLRectf screen_rect((F32)llround(cur_render_x + (F32)fgi->mXBearing), + (F32)llround(cur_render_y + (F32)fgi->mYBearing), + (F32)llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth, + (F32)llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight); if (glyph_count >= GLYPH_BATCH_SIZE) { @@ -636,7 +636,7 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch } // Round after kerning. - cur_x = llround(cur_x); + cur_x = (F32)llround(cur_x); drawn_x = cur_x; } @@ -707,7 +707,7 @@ S32 LLFontGL::firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_ } // Round after kerning. - total_width = llround(total_width); + total_width = (F32)llround(total_width); } if (drawable_chars == 0) @@ -790,7 +790,7 @@ S32 LLFontGL::charFromPixelOffset(const llwchar* wchars, S32 begin_offset, F32 t // Round after kerning. - cur_x = llround(cur_x); + cur_x = (F32)llround(cur_x); } return llmin(max_chars, pos - begin_offset); -- cgit v1.2.3 From e854db064547ae20a87bbeac399295a924cf1c8f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 3 Feb 2012 19:04:36 -0800 Subject: EXP-1513 FIX Underscore ( _ ) fails to show in first chat entry in Local Chat EXP-1854 FIX Text positioning in mini inspector a couple pixels too low --- indra/llrender/llfontgl.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 4519c5e789..6e6d02177d 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -185,9 +185,6 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons //gGL.translateUI(-pixel_offset_x, -pixel_offset_y, 0.f); LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY)); - // snap the text origin to a pixel grid to start with - origin.mV[VX] -= llround((F32)sCurOrigin.mX) - (sCurOrigin.mX); - origin.mV[VY] -= llround((F32)sCurOrigin.mY) - (sCurOrigin.mY); // Depth translation, so that floating text appears 'inworld' // and is correclty occluded. -- cgit v1.2.3 From ae7d475aebc836203984654912df036a11c365fc Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 6 Feb 2012 12:43:23 -0800 Subject: SH-2794, resolved merge conflict and corrected logic in LLVertexBuffer::determineUsage() to work the way it used to. --- indra/llrender/llvertexbuffer.cpp | 121 +++++++------------------------------- indra/llrender/llvertexbuffer.h | 17 +----- 2 files changed, 24 insertions(+), 114 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 230c1faa40..e4a5cd0299 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -204,26 +204,14 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) Record rec; rec.mGLName = name; rec.mClientData = buffer; -<<<<<<< local -======= - - sBytesPooled += size; ->>>>>>> other -<<<<<<< local if (buffer == NULL) -======= - if (!LLVertexBuffer::sDisableVBOMapping && mUsage == GL_DYNAMIC_DRAW_ARB) ->>>>>>> other { glDeleteBuffersARB(1, &rec.mGLName); } else { -<<<<<<< local sBytesPooled += size; -======= ->>>>>>> other mFreeList[i].push_back(rec); } } @@ -441,7 +429,7 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector& pos, con U32 count = pos.size(); llassert_always(norm.size() >= pos.size()); - llassert_always(count > 0) ; + llassert_always(count > 0); unbind(); @@ -559,11 +547,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const { validateRange(start, end, count, indices_offset); -<<<<<<< local mMappable = false; -======= - mMappable = FALSE; ->>>>>>> other gGL.syncMatrices(); llassert(mNumVerts >= 0); @@ -618,11 +602,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const { llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); -<<<<<<< local mMappable = false; -======= - mMappable = FALSE; ->>>>>>> other gGL.syncMatrices(); llassert(mNumIndices >= 0); @@ -668,11 +648,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const { llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); -<<<<<<< local mMappable = false; -======= - mMappable = FALSE; ->>>>>>> other gGL.syncMatrices(); llassert(mNumVerts >= 0); @@ -764,8 +740,8 @@ void LLVertexBuffer::cleanupClass() if(sPrivatePoolp) { - LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp) ; - sPrivatePoolp = NULL ; + LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp); + sPrivatePoolp = NULL; } } @@ -780,22 +756,22 @@ S32 LLVertexBuffer::determineUsage(S32 usage) ret_usage = 0; } - if (usage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) + if (ret_usage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) { ret_usage = 0; } - if (usage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) + if (ret_usage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) { ret_usage = GL_STREAM_DRAW_ARB; } - if (usage == 0 && LLRender::sGLCoreProfile) + if (ret_usage == 0 && LLRender::sGLCoreProfile) { //MUST use VBOs for all rendering ret_usage = GL_STREAM_DRAW_ARB; } - if (usage && usage != GL_STREAM_DRAW_ARB) + if (ret_usage && ret_usage != GL_STREAM_DRAW_ARB) { //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default if (sDisableVBOMapping) { //always use stream draw if VBO mapping is disabled @@ -837,55 +813,8 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : { LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR); - if (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping) - { - mMappable = true; - } - else - { - mMappable = false; - } - -<<<<<<< local -======= - if (mUsage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) - { - mUsage = 0; - } - - if (mUsage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) - { - mUsage = GL_STREAM_DRAW_ARB; - } - - if (mUsage == 0 && LLRender::sGLCoreProfile) - { //MUST use VBOs for all rendering - mUsage = GL_STREAM_DRAW_ARB; - } - - if (mUsage && mUsage != GL_STREAM_DRAW_ARB) - { //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default - if (sDisableVBOMapping) - { //always use stream draw if VBO mapping is disabled - mUsage = GL_STREAM_DRAW_ARB; - } - else - { - mUsage = GL_DYNAMIC_DRAW_ARB; - } - } - - - if (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping) - { - mMappable = TRUE; - } - else - { - mMappable = FALSE; - } + mMappable = (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping); ->>>>>>> other //zero out offsets for (U32 i = 0; i < TYPE_MAX; i++) { @@ -963,7 +892,7 @@ LLVertexBuffer::~LLVertexBuffer() mFence = NULL; - llassert_always(!mMappedData && !mMappedIndexData) ; + llassert_always(!mMappedData && !mMappedIndexData); }; void LLVertexBuffer::placeFence() const @@ -1136,11 +1065,7 @@ void LLVertexBuffer::destroyGLBuffer() } else { -<<<<<<< local FREE_MEM(sPrivatePoolp, (void*) mMappedData); -======= - FREE_MEM(sPrivatePoolp, (void*) mMappedData) ; ->>>>>>> other mMappedData = NULL; mEmpty = true; } @@ -1161,11 +1086,7 @@ void LLVertexBuffer::destroyGLIndices() } else { -<<<<<<< local FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData); -======= - FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData) ; ->>>>>>> other mMappedIndexData = NULL; mEmpty = true; } @@ -1515,16 +1436,16 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo log_glerror(); //check the availability of memory - LLMemory::logMemoryInfo(true) ; + LLMemory::logMemoryInfo(true); if(mMappable) { //-------------------- //print out more debug info before crash - llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ; - GLint size ; - glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size) ; - llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl ; + llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl; + GLint size; + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl; //-------------------- GLint buff; @@ -1539,7 +1460,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo } else { - llerrs << "memory allocation for vertex data failed." << llendl ; + llerrs << "memory allocation for vertex data failed." << llendl; } } } @@ -1693,7 +1614,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (!mMappedIndexData) { log_glerror(); - LLMemory::logMemoryInfo(true) ; + LLMemory::logMemoryInfo(true); if(mMappable) { @@ -1708,7 +1629,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range } else { - llerrs << "memory allocation for Index data failed. " << llendl ; + llerrs << "memory allocation for Index data failed. " << llendl; } } } @@ -1739,10 +1660,10 @@ void LLVertexBuffer::unmapBuffer() LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER); if (!useVBOs()) { - return ; //nothing to unmap + return; //nothing to unmap } - bool updated_all = false ; + bool updated_all = false; if (mMappedData && mVertexLocked) { @@ -1873,10 +1794,10 @@ void LLVertexBuffer::unmapBuffer() glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); stop_glerror(); - mMappedIndexData = NULL ; + mMappedIndexData = NULL; } - mIndexLocked = false ; + mIndexLocked = false; sMappedCount--; } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 036f535d81..d859199663 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -93,7 +93,7 @@ public: //============================================================================ // base class -class LLPrivateMemoryPool ; +class LLPrivateMemoryPool; class LLVertexBuffer : public LLRefCount { public: @@ -260,11 +260,7 @@ public: volatile U8* getMappedIndices() const { return mMappedIndexData; } S32 getOffset(S32 type) const { return mOffsets[type]; } S32 getUsage() const { return mUsage; } -<<<<<<< local bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW_ARB) ? true : false; } -======= - BOOL isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW_ARB) ? TRUE : FALSE; } ->>>>>>> other void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; @@ -293,7 +289,6 @@ protected: volatile U8* mMappedData; // pointer to currently mapped data (NULL if unmapped) volatile U8* mMappedIndexData; // pointer to currently mapped indices (NULL if unmapped) -<<<<<<< local U32 mMappedDataUsingVBOs : 1; U32 mMappedIndexDataUsingVBOs : 1; @@ -303,13 +298,7 @@ protected: U32 mEmpty : 1; // if true, client buffer is empty (or NULL). Old values have been discarded. mutable bool mMappable; // if true, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) -======= - BOOL mVertexLocked; // if TRUE, vertex buffer is being or has been written to in client memory - BOOL mIndexLocked; // if TRUE, index buffer is being or has been written to in client memory - BOOL mFinal; // if TRUE, buffer can not be mapped again - BOOL mEmpty; // if TRUE, client buffer is empty (or NULL). Old values have been discarded. - mutable BOOL mMappable; // if TRUE, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) ->>>>>>> other + S32 mOffsets[TYPE_MAX]; std::vector mMappedVertexRegions; @@ -323,7 +312,7 @@ protected: static S32 determineUsage(S32 usage); private: - static LLPrivateMemoryPool* sPrivatePoolp ; + static LLPrivateMemoryPool* sPrivatePoolp; public: static S32 sCount; -- cgit v1.2.3 From d56be1f1751f66bff09f0d223ed4712974e69e09 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 7 Feb 2012 12:31:48 -0800 Subject: EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates refactored LLCoord code to be templated, ultimately to support arbitrary conversions --- indra/llrender/llfontgl.cpp | 40 ++++++++++------------------------------ indra/llrender/llfontgl.h | 5 +++-- 2 files changed, 13 insertions(+), 32 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 6e6d02177d..fccbf37a8d 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -56,8 +56,9 @@ std::string LLFontGL::sAppDir; LLColor4 LLFontGL::sShadowColor(0.f, 0.f, 0.f, 1.f); LLFontRegistry* LLFontGL::sFontRegistry = NULL; -LLCoordFont LLFontGL::sCurOrigin; -std::vector LLFontGL::sOriginStack; +LLCoordGL LLFontGL::sCurOrigin; +F32 LLFontGL::sCurDepth; +std::vector > LLFontGL::sOriginStack; const F32 EXT_X_BEARING = 1.f; const F32 EXT_Y_BEARING = 0.f; @@ -68,20 +69,6 @@ const F32 PIXEL_CORRECTION_DISTANCE = 0.01f; const F32 PAD_UVY = 0.5f; // half of vertical padding between glyphs in the glyph texture const F32 DROP_SHADOW_SOFT_STRENGTH = 0.3f; -static F32 llfont_round_x(F32 x) -{ - //return llfloor((x-LLFontGL::sCurOrigin.mX)/LLFontGL::sScaleX+0.5f)*LLFontGL::sScaleX+LLFontGL::sCurOrigin.mX; - //return llfloor(x/LLFontGL::sScaleX+0.5f)*LLFontGL::sScaleY; - return x; -} - -static F32 llfont_round_y(F32 y) -{ - //return llfloor((y-LLFontGL::sCurOrigin.mY)/LLFontGL::sScaleY+0.5f)*LLFontGL::sScaleY+LLFontGL::sCurOrigin.mY; - //return llfloor(y+0.5f); - return y; -} - LLFontGL::LLFontGL() { } @@ -177,18 +164,11 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons gGL.loadUIIdentity(); - //gGL.translateUI(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ); - - // this code snaps the text origin to a pixel grid to start with - //F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX); - //F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY); - //gGL.translateUI(-pixel_offset_x, -pixel_offset_y, 0.f); - LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY)); - // Depth translation, so that floating text appears 'inworld' - // and is correclty occluded. - gGL.translatef(0.f,0.f,sCurOrigin.mZ); + // Depth translation, so that floating text appears 'in-world' + // and is correctly occluded. + gGL.translatef(0.f,0.f,sCurDepth); S32 chars_drawn = 0; S32 i; @@ -1134,22 +1114,22 @@ void LLFontGL::renderQuad(LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* c { S32 index = 0; - vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mRight), llfont_round_y(screen_rect.mTop), 0.f); + vertex_out[index] = LLVector3(screen_rect.mRight, screen_rect.mTop, 0.f); uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mTop); colors_out[index] = color; index++; - vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mLeft), llfont_round_y(screen_rect.mTop), 0.f); + vertex_out[index] = LLVector3(screen_rect.mLeft, screen_rect.mTop, 0.f); uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop); colors_out[index] = color; index++; - vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mLeft), llfont_round_y(screen_rect.mBottom), 0.f); + vertex_out[index] = LLVector3(screen_rect.mLeft, screen_rect.mBottom, 0.f); uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom); colors_out[index] = color; index++; - vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mRight), llfont_round_y(screen_rect.mBottom), 0.f); + vertex_out[index] = LLVector3(screen_rect.mRight, screen_rect.mBottom, 0.f); uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom); colors_out[index] = color; } diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 9d7e2891e3..74bdbb43e7 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -186,8 +186,9 @@ public: static std::string getFontPathLocal(); static std::string getFontPathSystem(); - static LLCoordFont sCurOrigin; - static std::vector sOriginStack; + static LLCoordGL sCurOrigin; + static F32 sCurDepth; + static std::vector > sOriginStack; static LLColor4 sShadowColor; -- cgit v1.2.3