diff options
Diffstat (limited to 'indra/newview/lldrawpool.cpp')
-rw-r--r-- | indra/newview/lldrawpool.cpp | 205 |
1 files changed, 97 insertions, 108 deletions
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 3de0e8a7c4..187e290066 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -53,7 +53,6 @@ #include "llvoavatar.h" #include "llviewershadermgr.h" - S32 LLDrawPool::sNumDrawPools = 0; //============================= @@ -385,13 +384,13 @@ void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, bool texture) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; 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) { - pushBatch(*pparams, texture); + pushBatch(*pparams, texture); } } } @@ -420,91 +419,7 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu } } -void setup_texture_matrix(LLDrawInfo& params) -{ - if (params.mTextureMatrix) - { //special case implementation of texture animation here because of special handling of textures for PBR batches - gGL.getTexUnit(0)->activate(); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadMatrix((GLfloat*)params.mTextureMatrix->mMatrix); - gPipeline.mTextureMatrixOps++; - } -} - -void teardown_texture_matrix(LLDrawInfo& params) -{ - if (params.mTextureMatrix) - { - gGL.matrixMode(LLRender::MM_TEXTURE0); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - } -} - -void LLRenderPass::pushGLTFBatches(U32 type) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - auto* begin = gPipeline.beginRenderMap(type); - auto* end = gPipeline.endRenderMap(type); - for (LLCullResult::drawinfo_iterator i = begin; i != end; ) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushGLTFBatch"); - LLDrawInfo& params = **i; - LLCullResult::increment_iterator(i, end); - - pushGLTFBatch(params); - } -} - -void LLRenderPass::pushGLTFBatch(LLDrawInfo& params) -{ - auto& mat = params.mGLTFMaterial; - - mat->bind(params.mTexture); - - LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); - - setup_texture_matrix(params); - - applyModelMatrix(params); - - params.mVertexBuffer->setBuffer(); - params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); - - teardown_texture_matrix(params); -} - -void LLRenderPass::pushRiggedGLTFBatches(U32 type) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - LLVOAvatar* lastAvatar = nullptr; - U64 lastMeshId = 0; - - auto* begin = gPipeline.beginRenderMap(type); - auto* end = gPipeline.endRenderMap(type); - for (LLCullResult::drawinfo_iterator i = begin; i != end; ) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushRiggedGLTFBatch"); - LLDrawInfo& params = **i; - LLCullResult::increment_iterator(i, end); - - pushRiggedGLTFBatch(params, lastAvatar, lastMeshId); - } -} - -void LLRenderPass::pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId) -{ - if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash)) - { - uploadMatrixPalette(params); - lastAvatar = params.mAvatar; - lastMeshId = params.mSkinInfo->mHash; - } - - pushGLTFBatch(params); -} - -void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) +void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -514,12 +429,11 @@ void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures, bool LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); - pushBatch(*pparams, texture, batch_textures, reset_gltf); - reset_gltf = false; + pushBatch(*pparams, texture, batch_textures); } } -void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) +void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; @@ -538,12 +452,11 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, texture, batch_textures, reset_gltf); - reset_gltf = false; + pushBatch(*pparams, texture, batch_textures); } } -void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) +void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -553,12 +466,11 @@ void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures, LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - pushBatch(*pparams, texture, batch_textures, reset_gltf); - reset_gltf = false; + pushBatch(*pparams, texture, batch_textures); } } -void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) +void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; @@ -571,6 +483,8 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text LLCullResult::increment_iterator(i, end); + llassert(pparams); + if (LLGLSLShader::sCurBoundShaderPtr) { LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); @@ -587,8 +501,7 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, texture, batch_textures, reset_gltf); - reset_gltf = false; + pushBatch(*pparams, texture, batch_textures); } } @@ -607,14 +520,7 @@ void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) } } -void LLRenderPass::resetGLTFTextureTransform() -{ - F32 ignore_gltf_transform[8]; - LLGLTFMaterial::sDefault.mTextureTransform[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR].getPacked(ignore_gltf_transform); - LLGLSLShader::sCurBoundShaderPtr->uniform4fv(LLShaderMgr::TEXTURE_BASE_COLOR_TRANSFORM, 2, (F32*)ignore_gltf_transform); -} - -void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures, bool reset_gltf) +void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; if (!params.mCount) @@ -623,7 +529,6 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textur } applyModelMatrix(params); - if (reset_gltf) { resetGLTFTextureTransform(); } bool tex_setup = false; @@ -702,3 +607,87 @@ bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinI return true; } +void setup_texture_matrix(LLDrawInfo& params) +{ + if (params.mTextureMatrix) + { //special case implementation of texture animation here because of special handling of textures for PBR batches + gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadMatrix((GLfloat*)params.mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + } +} + +void teardown_texture_matrix(LLDrawInfo& params) +{ + if (params.mTextureMatrix) + { + gGL.matrixMode(LLRender::MM_TEXTURE0); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } +} + +void LLRenderPass::pushGLTFBatches(U32 type) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushGLTFBatch"); + LLDrawInfo& params = **i; + LLCullResult::increment_iterator(i, end); + + pushGLTFBatch(params); + } +} + +void LLRenderPass::pushGLTFBatch(LLDrawInfo& params) +{ + auto& mat = params.mGLTFMaterial; + + mat->bind(params.mTexture); + + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); + + setup_texture_matrix(params); + + applyModelMatrix(params); + + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + + teardown_texture_matrix(params); +} + +void LLRenderPass::pushRiggedGLTFBatches(U32 type) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + LLVOAvatar* lastAvatar = nullptr; + U64 lastMeshId = 0; + + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushRiggedGLTFBatch"); + LLDrawInfo& params = **i; + LLCullResult::increment_iterator(i, end); + + pushRiggedGLTFBatch(params, lastAvatar, lastMeshId); + } +} + +void LLRenderPass::pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId) +{ + if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash)) + { + uploadMatrixPalette(params); + lastAvatar = params.mAvatar; + lastMeshId = params.mSkinInfo->mHash; + } + + pushGLTFBatch(params); +} + |