diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-05-16 13:52:40 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-05-16 13:52:40 +0800 |
commit | 6d51e91895a7f2435c46a876410ccc6c63fe8c82 (patch) | |
tree | f2b48ebd99cb414227bf365f47665b8d4baa752b /indra/newview/lldrawpool.cpp | |
parent | d1b5917bb9c92e4e47eba19b43781e4d1328b1ca (diff) | |
parent | 094dcc07f8c1d90ae723dbe60eddacb90a09eae8 (diff) |
Merge tag '7.1.7-release'
source for viewer 7.1.7.8974243247
Diffstat (limited to 'indra/newview/lldrawpool.cpp')
-rw-r--r-- | indra/newview/lldrawpool.cpp | 422 |
1 files changed, 211 insertions, 211 deletions
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index a1fd7c02b2..6597a13125 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -1,25 +1,25 @@ -/** +/** * @file lldrawpool.cpp * @brief LLDrawPool class implementation * * $LicenseInfo:firstyear=2002&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$ */ @@ -60,81 +60,81 @@ S32 LLDrawPool::sNumDrawPools = 0; //============================= LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) { - LLDrawPool *poolp = NULL; - switch (type) - { - case POOL_SIMPLE: - poolp = new LLDrawPoolSimple(); - break; - case POOL_GRASS: - poolp = new LLDrawPoolGrass(); - break; - case POOL_ALPHA_MASK: - poolp = new LLDrawPoolAlphaMask(); - break; - case POOL_FULLBRIGHT_ALPHA_MASK: - poolp = new LLDrawPoolFullbrightAlphaMask(); - break; - case POOL_FULLBRIGHT: - poolp = new LLDrawPoolFullbright(); - break; - case POOL_GLOW: - poolp = new LLDrawPoolGlow(); - break; - case POOL_ALPHA_PRE_WATER: - poolp = new LLDrawPoolAlpha(LLDrawPool::POOL_ALPHA_PRE_WATER); - break; + LLDrawPool *poolp = NULL; + switch (type) + { + case POOL_SIMPLE: + poolp = new LLDrawPoolSimple(); + break; + case POOL_GRASS: + poolp = new LLDrawPoolGrass(); + break; + case POOL_ALPHA_MASK: + poolp = new LLDrawPoolAlphaMask(); + break; + case POOL_FULLBRIGHT_ALPHA_MASK: + poolp = new LLDrawPoolFullbrightAlphaMask(); + break; + case POOL_FULLBRIGHT: + poolp = new LLDrawPoolFullbright(); + break; + case POOL_GLOW: + poolp = new LLDrawPoolGlow(); + break; + case POOL_ALPHA_PRE_WATER: + poolp = new LLDrawPoolAlpha(LLDrawPool::POOL_ALPHA_PRE_WATER); + break; case POOL_ALPHA_POST_WATER: poolp = new LLDrawPoolAlpha(LLDrawPool::POOL_ALPHA_POST_WATER); break; - case POOL_AVATAR: - case POOL_CONTROL_AV: - poolp = new LLDrawPoolAvatar(type); - break; - case POOL_TREE: - poolp = new LLDrawPoolTree(tex0); - break; - case POOL_TERRAIN: - poolp = new LLDrawPoolTerrain(tex0); - break; - case POOL_SKY: - poolp = new LLDrawPoolSky(); - break; - case POOL_VOIDWATER: - case POOL_WATER: - poolp = new LLDrawPoolWater(); - break; - case POOL_BUMP: - poolp = new LLDrawPoolBump(); - break; - case POOL_MATERIALS: - poolp = new LLDrawPoolMaterials(); - break; - case POOL_WL_SKY: - poolp = new LLDrawPoolWLSky(); - break; - case POOL_GLTF_PBR: - poolp = new LLDrawPoolGLTFPBR(); + case POOL_AVATAR: + case POOL_CONTROL_AV: + poolp = new LLDrawPoolAvatar(type); + break; + case POOL_TREE: + poolp = new LLDrawPoolTree(tex0); + break; + case POOL_TERRAIN: + poolp = new LLDrawPoolTerrain(tex0); + break; + case POOL_SKY: + poolp = new LLDrawPoolSky(); + break; + case POOL_VOIDWATER: + case POOL_WATER: + poolp = new LLDrawPoolWater(); + break; + case POOL_BUMP: + poolp = new LLDrawPoolBump(); + break; + case POOL_MATERIALS: + poolp = new LLDrawPoolMaterials(); + break; + case POOL_WL_SKY: + poolp = new LLDrawPoolWLSky(); + break; + case POOL_GLTF_PBR: + poolp = new LLDrawPoolGLTFPBR(); break; case POOL_GLTF_PBR_ALPHA_MASK: poolp = new LLDrawPoolGLTFPBR(LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK); - break; - default: - LL_ERRS() << "Unknown draw pool type!" << LL_ENDL; - return NULL; - } + break; + default: + LL_ERRS() << "Unknown draw pool type!" << LL_ENDL; + return NULL; + } - llassert(poolp->mType == type); - return poolp; + llassert(poolp->mType == type); + return poolp; } LLDrawPool::LLDrawPool(const U32 type) { - mType = type; - sNumDrawPools++; - mId = sNumDrawPools; - mShaderLevel = 0; - mSkipRender = false; + mType = type; + sNumDrawPools++; + mId = sNumDrawPools; + mShaderLevel = 0; + mSkipRender = false; } LLDrawPool::~LLDrawPool() @@ -144,7 +144,7 @@ LLDrawPool::~LLDrawPool() LLViewerTexture *LLDrawPool::getDebugTexture() { - return NULL; + return NULL; } //virtual @@ -152,55 +152,55 @@ void LLDrawPool::beginRenderPass( S32 pass ) { } -//virtual -S32 LLDrawPool::getNumPasses() +//virtual +S32 LLDrawPool::getNumPasses() { - return 1; + return 1; } - -//virtual + +//virtual void LLDrawPool::beginDeferredPass(S32 pass) { } -//virtual +//virtual void LLDrawPool::endDeferredPass(S32 pass) { } -//virtual +//virtual S32 LLDrawPool::getNumDeferredPasses() { - return 0; + return 0; } -//virtual +//virtual void LLDrawPool::renderDeferred(S32 pass) { } -//virtual +//virtual void LLDrawPool::beginPostDeferredPass(S32 pass) { } -//virtual +//virtual void LLDrawPool::endPostDeferredPass(S32 pass) { } -//virtual +//virtual S32 LLDrawPool::getNumPostDeferredPasses() { - return 0; + return 0; } -//virtual +//virtual void LLDrawPool::renderPostDeferred(S32 pass) { @@ -209,29 +209,29 @@ void LLDrawPool::renderPostDeferred(S32 pass) //virtual void LLDrawPool::endRenderPass( S32 pass ) { - //make sure channel 0 is active channel - gGL.getTexUnit(0)->activate(); + //make sure channel 0 is active channel + gGL.getTexUnit(0)->activate(); } -//virtual +//virtual void LLDrawPool::beginShadowPass(S32 pass) { } -//virtual +//virtual void LLDrawPool::endShadowPass(S32 pass) { } -//virtual +//virtual S32 LLDrawPool::getNumShadowPasses() { - return 0; + return 0; } -//virtual +//virtual void LLDrawPool::renderShadow(S32 pass) { @@ -243,20 +243,20 @@ void LLDrawPool::renderShadow(S32 pass) LLFacePool::LLFacePool(const U32 type) : LLDrawPool(type) { - resetDrawOrders(); + resetDrawOrders(); } LLFacePool::~LLFacePool() { - destroy(); + destroy(); } void LLFacePool::destroy() { - if (!mReferences.empty()) - { - LL_INFOS() << mReferences.size() << " references left on deletion of draw pool!" << LL_ENDL; - } + if (!mReferences.empty()) + { + LL_INFOS() << mReferences.size() << " references left on deletion of draw pool!" << LL_ENDL; + } } void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures) @@ -265,59 +265,59 @@ void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures void LLFacePool::enqueue(LLFace* facep) { - mDrawFace.push_back(facep); + mDrawFace.push_back(facep); } // virtual BOOL LLFacePool::addFace(LLFace *facep) { - addFaceReference(facep); - return TRUE; + addFaceReference(facep); + return TRUE; } // virtual BOOL LLFacePool::removeFace(LLFace *facep) { - removeFaceReference(facep); + removeFaceReference(facep); - vector_replace_with_last(mDrawFace, facep); + vector_replace_with_last(mDrawFace, facep); - return TRUE; + return TRUE; } // Not absolutely sure if we should be resetting all of the chained pools as well - djs void LLFacePool::resetDrawOrders() { - mDrawFace.resize(0); + mDrawFace.resize(0); } LLViewerTexture *LLFacePool::getTexture() { - return NULL; + return NULL; } void LLFacePool::removeFaceReference(LLFace *facep) { - if (facep->getReferenceIndex() != -1) - { - if (facep->getReferenceIndex() != (S32)mReferences.size()) - { - LLFace *back = mReferences.back(); - mReferences[facep->getReferenceIndex()] = back; - back->setReferenceIndex(facep->getReferenceIndex()); - } - mReferences.pop_back(); - } - facep->setReferenceIndex(-1); + if (facep->getReferenceIndex() != -1) + { + if (facep->getReferenceIndex() != (S32)mReferences.size()) + { + LLFace *back = mReferences.back(); + mReferences[facep->getReferenceIndex()] = back; + back->setReferenceIndex(facep->getReferenceIndex()); + } + mReferences.pop_back(); + } + facep->setReferenceIndex(-1); } void LLFacePool::addFaceReference(LLFace *facep) { - if (-1 == facep->getReferenceIndex()) - { - facep->setReferenceIndex(mReferences.size()); - mReferences.push_back(facep); - } + if (-1 == facep->getReferenceIndex()) + { + facep->setReferenceIndex(mReferences.size()); + mReferences.push_back(facep); + } } void LLFacePool::pushFaceGeometry() @@ -330,49 +330,49 @@ void LLFacePool::pushFaceGeometry() BOOL LLFacePool::verify() const { - BOOL ok = TRUE; - - for (std::vector<LLFace*>::const_iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - const LLFace* facep = *iter; - if (facep->getPool() != this) - { - LL_INFOS() << "Face in wrong pool!" << LL_ENDL; - facep->printDebugInfo(); - ok = FALSE; - } - else if (!facep->verify()) - { - ok = FALSE; - } - } - - return ok; + BOOL ok = TRUE; + + for (std::vector<LLFace*>::const_iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + const LLFace* facep = *iter; + if (facep->getPool() != this) + { + LL_INFOS() << "Face in wrong pool!" << LL_ENDL; + facep->printDebugInfo(); + ok = FALSE; + } + else if (!facep->verify()) + { + ok = FALSE; + } + } + + return ok; } void LLFacePool::printDebugInfo() const { - LL_INFOS() << "Pool " << this << " Type: " << getType() << LL_ENDL; + LL_INFOS() << "Pool " << this << " Type: " << getType() << LL_ENDL; } BOOL LLFacePool::LLOverrideFaceColor::sOverrideFaceColor = FALSE; void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4& color) { - gGL.diffuseColor4fv(color.mV); + gGL.diffuseColor4fv(color.mV); } void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4U& color) { #if GL_VERSION_1_1 - glColor4ubv(color.mV); + glColor4ubv(color.mV); #endif } void LLFacePool::LLOverrideFaceColor::setColor(F32 r, F32 g, F32 b, F32 a) { - gGL.diffuseColor4f(r,g,b,a); + gGL.diffuseColor4f(r,g,b,a); } @@ -393,16 +393,16 @@ LLRenderPass::~LLRenderPass() void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, bool texture) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; + LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; - for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) - { - LLDrawInfo *pparams = *k; - if (pparams) + for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) + { + LLDrawInfo *pparams = *k; + if (pparams) { pushBatch(*pparams, texture); - } - } + } + } } void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool texture) @@ -411,11 +411,11 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - + for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo* pparams = *k; - if (pparams) + if (pparams) { if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { @@ -467,7 +467,7 @@ void LLRenderPass::pushUntexturedBatches(U32 type) void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - + if (texture) { LLVOAvatar* lastAvatar = nullptr; @@ -523,13 +523,13 @@ void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); - for (LLCullResult::drawinfo_iterator i = begin; i != end; ) - { + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) + { LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - pushBatch(*pparams, texture, batch_textures); - } + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); + pushBatch(*pparams, texture, batch_textures); + } } void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures) @@ -569,17 +569,17 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) { - if (params.mModelMatrix != gGLLastMatrix) - { - gGLLastMatrix = params.mModelMatrix; - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(gGLModelView); - if (params.mModelMatrix) - { - gGL.multMatrix((GLfloat*) params.mModelMatrix->mMatrix); - } - gPipeline.mMatrixOpCount++; - } + if (params.mModelMatrix != gGLLastMatrix) + { + gGLLastMatrix = params.mModelMatrix; + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.loadMatrix(gGLModelView); + if (params.mModelMatrix) + { + gGL.multMatrix((GLfloat*) params.mModelMatrix->mMatrix); + } + gPipeline.mMatrixOpCount++; + } } void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures) @@ -592,51 +592,51 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textur return; } - applyModelMatrix(params); - - bool tex_setup = false; - - { - if (batch_textures && params.mTextureList.size() > 1) - { - for (U32 i = 0; i < params.mTextureList.size(); ++i) - { - if (params.mTextureList[i].notNull()) - { - gGL.getTexUnit(i)->bindFast(params.mTextureList[i]); - } - } - } - else - { //not batching textures or batch has only 1 texture -- might need a texture matrix - if (params.mTexture.notNull()) - { - gGL.getTexUnit(0)->bindFast(params.mTexture); - if (params.mTextureMatrix) - { - tex_setup = true; - gGL.getTexUnit(0)->activate(); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix); - gPipeline.mTextureMatrixOps++; - } - } - else - { - gGL.getTexUnit(0)->unbindFast(LLTexUnit::TT_TEXTURE); - } - } - } - + applyModelMatrix(params); + + bool tex_setup = false; + + { + if (batch_textures && params.mTextureList.size() > 1) + { + for (U32 i = 0; i < params.mTextureList.size(); ++i) + { + if (params.mTextureList[i].notNull()) + { + gGL.getTexUnit(i)->bindFast(params.mTextureList[i]); + } + } + } + else + { //not batching textures or batch has only 1 texture -- might need a texture matrix + if (params.mTexture.notNull()) + { + gGL.getTexUnit(0)->bindFast(params.mTexture); + if (params.mTextureMatrix) + { + tex_setup = true; + gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + } + } + else + { + gGL.getTexUnit(0)->unbindFast(LLTexUnit::TT_TEXTURE); + } + } + } + params.mVertexBuffer->setBuffer(); params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); - if (tex_setup) - { + if (tex_setup) + { gGL.matrixMode(LLRender::MM_TEXTURE0); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - } + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } } void LLRenderPass::pushUntexturedBatch(LLDrawInfo& params) |