summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpool.cpp')
-rw-r--r--indra/newview/lldrawpool.cpp162
1 files changed, 107 insertions, 55 deletions
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index ba7d17cf21..74d7997a8d 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -409,22 +409,19 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type];
- LLVOAvatar* lastAvatar = nullptr;
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin = false;
for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)
{
LLDrawInfo* pparams = *k;
if (pparams)
{
- if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)
+ if (uploadMatrixPalette(pparams->mAvatar, pparams->mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- uploadMatrixPalette(*pparams);
- lastAvatar = pparams->mAvatar;
- lastMeshId = pparams->mSkinInfo->mHash;
+ pushBatch(*pparams, texture);
}
-
- pushBatch(*pparams, texture);
}
}
}
@@ -470,8 +467,9 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures
if (texture)
{
- LLVOAvatar* lastAvatar = nullptr;
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin = false;
auto* begin = gPipeline.beginRenderMap(type);
auto* end = gPipeline.endRenderMap(type);
for (LLCullResult::drawinfo_iterator i = begin; i != end; )
@@ -479,14 +477,10 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures
LLDrawInfo* pparams = *i;
LLCullResult::increment_iterator(i, end);
- if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash))
+ if (uploadMatrixPalette(pparams->mAvatar, pparams->mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- uploadMatrixPalette(*pparams);
- lastAvatar = pparams->mAvatar;
- lastMeshId = pparams->mSkinInfo->mHash;
+ pushBatch(*pparams, texture, batch_textures);
}
-
- pushBatch(*pparams, texture, batch_textures);
}
}
else
@@ -498,8 +492,9 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures
void LLRenderPass::pushUntexturedRiggedBatches(U32 type)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
- LLVOAvatar* lastAvatar = nullptr;
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin = false;
auto* begin = gPipeline.beginRenderMap(type);
auto* end = gPipeline.endRenderMap(type);
for (LLCullResult::drawinfo_iterator i = begin; i != end; )
@@ -507,14 +502,10 @@ void LLRenderPass::pushUntexturedRiggedBatches(U32 type)
LLDrawInfo* pparams = *i;
LLCullResult::increment_iterator(i, end);
- if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash))
+ if (uploadMatrixPalette(pparams->mAvatar, pparams->mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- uploadMatrixPalette(*pparams);
- lastAvatar = pparams->mAvatar;
- lastMeshId = pparams->mSkinInfo->mHash;
+ pushUntexturedBatch(*pparams);
}
-
- pushUntexturedBatch(*pparams);
}
}
@@ -535,8 +526,9 @@ void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures)
void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
- LLVOAvatar* lastAvatar = nullptr;
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin = false;
auto* begin = gPipeline.beginRenderMap(type);
auto* end = gPipeline.endRenderMap(type);
for (LLCullResult::drawinfo_iterator i = begin; i != end; )
@@ -547,23 +539,12 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text
llassert(pparams);
- if (LLGLSLShader::sCurBoundShaderPtr)
- {
- LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff);
- }
- else
- {
- gGL.flush();
- }
+ LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff);
- if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)
+ if (uploadMatrixPalette(pparams->mAvatar, pparams->mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- uploadMatrixPalette(*pparams);
- lastAvatar = pparams->mAvatar;
- lastMeshId = pparams->mSkinInfo->mHash;
+ pushBatch(*pparams, texture, batch_textures);
}
-
- pushBatch(*pparams, texture, batch_textures);
}
}
@@ -669,6 +650,8 @@ bool LLRenderPass::uploadMatrixPalette(LLDrawInfo& params)
//static
bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
+
if (!avatar)
{
return false;
@@ -690,6 +673,81 @@ bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinI
return true;
}
+// Returns true if rendering should proceed
+//static
+bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo, const LLVOAvatar*& lastAvatar, U64& lastMeshId, bool& skipLastSkin)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
+
+ llassert(skinInfo);
+ llassert(LLGLSLShader::sCurBoundShaderPtr);
+
+ if (!avatar)
+ {
+ return false;
+ }
+
+ if (avatar == lastAvatar && skinInfo->mHash == lastMeshId)
+ {
+ return !skipLastSkin;
+ }
+
+ const LLVOAvatar::MatrixPaletteCache& mpc = avatar->updateSkinInfoMatrixPalette(skinInfo);
+ U32 count = static_cast<U32>(mpc.mMatrixPalette.size());
+ // skipLastSkin -> skin info not loaded yet, don't render
+ skipLastSkin = !bool(count);
+ lastAvatar = avatar;
+ lastMeshId = skinInfo->mHash;
+
+ if (!skipLastSkin)
+ {
+ LLGLSLShader::sCurBoundShaderPtr->uniformMatrix3x4fv(LLViewerShaderMgr::AVATAR_MATRIX,
+ count,
+ false,
+ (GLfloat*)&(mpc.mGLMp[0]));
+ }
+
+ return !skipLastSkin;
+}
+
+// Returns true if rendering should proceed
+//static
+bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo, const LLVOAvatar*& lastAvatar, U64& lastMeshId, const LLGLSLShader*& lastAvatarShader, bool& skipLastSkin)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
+
+ llassert(skinInfo);
+ llassert(LLGLSLShader::sCurBoundShaderPtr);
+
+ if (!avatar)
+ {
+ return false;
+ }
+
+ if (avatar == lastAvatar && skinInfo->mHash == lastMeshId && lastAvatarShader == LLGLSLShader::sCurBoundShaderPtr)
+ {
+ return !skipLastSkin;
+ }
+
+ const LLVOAvatar::MatrixPaletteCache& mpc = avatar->updateSkinInfoMatrixPalette(skinInfo);
+ U32 count = static_cast<U32>(mpc.mMatrixPalette.size());
+ // skipLastSkin -> skin info not loaded yet, don't render
+ skipLastSkin = !bool(count);
+ lastAvatar = avatar;
+ lastMeshId = skinInfo->mHash;
+ lastAvatarShader = LLGLSLShader::sCurBoundShaderPtr;
+
+ if (!skipLastSkin)
+ {
+ LLGLSLShader::sCurBoundShaderPtr->uniformMatrix3x4fv(LLViewerShaderMgr::AVATAR_MATRIX,
+ count,
+ false,
+ (GLfloat*)&(mpc.mGLMp[0]));
+ }
+
+ return !skipLastSkin;
+}
+
void setup_texture_matrix(LLDrawInfo& params)
{
if (params.mTextureMatrix)
@@ -719,7 +777,7 @@ void LLRenderPass::pushGLTFBatches(U32 type, bool textured)
}
else
{
- pushRiggedGLTFBatches(type);
+ pushUntexturedGLTFBatches(type);
}
}
@@ -803,8 +861,9 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type, bool textured)
void LLRenderPass::pushRiggedGLTFBatches(U32 type)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
- LLVOAvatar* lastAvatar = nullptr;
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin = false;
auto* begin = gPipeline.beginRenderMap(type);
auto* end = gPipeline.endRenderMap(type);
@@ -814,15 +873,16 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type)
LLDrawInfo& params = **i;
LLCullResult::increment_iterator(i, end);
- pushRiggedGLTFBatch(params, lastAvatar, lastMeshId);
+ pushRiggedGLTFBatch(params, lastAvatar, lastMeshId, skipLastSkin);
}
}
void LLRenderPass::pushUntexturedRiggedGLTFBatches(U32 type)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
- LLVOAvatar* lastAvatar = nullptr;
+ const LLVOAvatar* lastAvatar = nullptr;
U64 lastMeshId = 0;
+ bool skipLastSkin = false;
auto* begin = gPipeline.beginRenderMap(type);
auto* end = gPipeline.endRenderMap(type);
@@ -832,34 +892,26 @@ void LLRenderPass::pushUntexturedRiggedGLTFBatches(U32 type)
LLDrawInfo& params = **i;
LLCullResult::increment_iterator(i, end);
- pushUntexturedRiggedGLTFBatch(params, lastAvatar, lastMeshId);
+ pushUntexturedRiggedGLTFBatch(params, lastAvatar, lastMeshId, skipLastSkin);
}
}
// static
-void LLRenderPass::pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId)
+void LLRenderPass::pushRiggedGLTFBatch(LLDrawInfo& params, const LLVOAvatar*& lastAvatar, U64& lastMeshId, bool& skipLastSkin)
{
- if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash))
+ if (uploadMatrixPalette(params.mAvatar, params.mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- uploadMatrixPalette(params);
- lastAvatar = params.mAvatar;
- lastMeshId = params.mSkinInfo->mHash;
+ pushGLTFBatch(params);
}
-
- pushGLTFBatch(params);
}
// static
-void LLRenderPass::pushUntexturedRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId)
+void LLRenderPass::pushUntexturedRiggedGLTFBatch(LLDrawInfo& params, const LLVOAvatar*& lastAvatar, U64& lastMeshId, bool& skipLastSkin)
{
- if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash))
+ if (uploadMatrixPalette(params.mAvatar, params.mSkinInfo, lastAvatar, lastMeshId, skipLastSkin))
{
- uploadMatrixPalette(params);
- lastAvatar = params.mAvatar;
- lastMeshId = params.mSkinInfo->mHash;
+ pushUntexturedGLTFBatch(params);
}
-
- pushUntexturedGLTFBatch(params);
}