summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rw-r--r--indra/newview/llvovolume.cpp143
1 files changed, 104 insertions, 39 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 9b63875ffe..6b3dccf89c 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -639,6 +639,19 @@ void LLVOVolume::animateTextures()
if (!facep->mTextureMatrix)
{
facep->mTextureMatrix = new LLMatrix4();
+ if (facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
+ {
+ // Fix the one edge case missed in
+ // LLVOVolume::updateTextureVirtualSize when the
+ // mTextureMatrix is not yet present
+ gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
+ LLSpatialGroup* group = mDrawable->getSpatialGroup();
+ if (group)
+ {
+ group->dirtyGeom();
+ gPipeline.markRebuild(group);
+ }
+ }
}
LLMatrix4& tex_mat = *facep->mTextureMatrix;
@@ -782,11 +795,29 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
for (S32 i = 0; i < num_faces; i++)
{
LLFace* face = mDrawable->getFace(i);
- if (!face) continue;
+ if (!face || face->mExtents[0].equals3(face->mExtents[1])) continue;
const LLTextureEntry *te = face->getTextureEntry();
- LLViewerTexture *imagep = face->getTexture();
- if (!imagep || !te ||
- face->mExtents[0].equals3(face->mExtents[1]))
+ if (!te) continue;
+
+ LLViewerTexture *imagep = nullptr;
+ U32 ch_min;
+ U32 ch_max;
+ if (!te->getGLTFRenderMaterial())
+ {
+ ch_min = LLRender::DIFFUSE_MAP;
+ ch_max = LLRender::SPECULAR_MAP;
+ }
+ else
+ {
+ ch_min = LLRender::BASECOLOR_MAP;
+ ch_max = LLRender::EMISSIVE_MAP;
+ }
+ for (U32 ch = ch_min; (!imagep && ch <= ch_max); ++ch)
+ {
+ // Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else)
+ imagep = face->getTexture(ch);
+ }
+ if (!imagep)
{
continue;
}
@@ -812,12 +843,28 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
// if the face has gotten small enough to turn off texture animation and texture
// animation is running, rebuild the render batch for this face to turn off
// texture animation
+ // Do the opposite when the face gets big enough.
+ // If a face is animatable, it will always have non-null mTextureMatrix
+ // pointer defined after the first call to LLVOVolume::animateTextures,
+ // although the animation is not always turned on.
if (face->mTextureMatrix != NULL)
{
- if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
- (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
+ if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
+ // dirtyGeom+markRebuild tells the engine to call
+ // LLVolumeGeometryManager::rebuildGeom, which rebuilds the
+ // LLDrawInfo for the spatial group containing this LLFace,
+ // safely copying the mTextureMatrix from the LLFace the the
+ // LLDrawInfo. While it's not ideal to call it here, prims with
+ // animated faces get moved to a smaller partition to reduce
+ // side-effects of their updates (see shrinkWrap in
+ // LLVOVolume::animateTextures).
+ if (mDrawable->getSpatialGroup())
+ {
+ mDrawable->getSpatialGroup()->dirtyGeom();
+ gPipeline.markRebuild(mDrawable->getSpatialGroup());
+ }
}
}
@@ -3210,6 +3257,7 @@ void LLVOVolume::updateSpotLightPriority()
{
return;
}
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
F32 r = getLightRadius();
LLVector3 pos = mDrawable->getPositionAgent();
@@ -3656,7 +3704,7 @@ const LLMeshSkinInfo* LLVOVolume::getSkinInfo() const
// virtual
bool LLVOVolume::isRiggedMesh() const
{
- return isMesh() && getSkinInfo();
+ return getSkinInfo() != nullptr;
}
//----------------------------------------------------------------------------
@@ -3817,7 +3865,6 @@ void LLVOVolume::updateRiggingInfo()
LLVolume *volume = getVolume();
if (skin && avatar && volume)
{
- LL_DEBUGS("RigSpammish") << "starting, vovol " << this << " lod " << getLOD() << " last " << mLastRiggingInfoLOD << LL_ENDL;
if (getLOD()>mLastRiggingInfoLOD || getLOD()==3)
{
// Rigging info may need update
@@ -3833,9 +3880,6 @@ void LLVOVolume::updateRiggingInfo()
}
// Keep the highest LOD info available.
mLastRiggingInfoLOD = getLOD();
- LL_DEBUGS("RigSpammish") << "updated rigging info for LLVOVolume "
- << this << " lod " << mLastRiggingInfoLOD
- << LL_ENDL;
}
}
}
@@ -5698,13 +5742,23 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
continue;
}
- LLFetchedGLTFMaterial *gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFRenderMaterial();
+ LLFetchedGLTFMaterial* gltf_mat = nullptr;
+ const LLTextureEntry* te = facep->getTextureEntry();
+ if (te)
+ {
+ gltf_mat = (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial();
+ } // if not te, continue?
bool is_pbr = gltf_mat != nullptr;
if (is_pbr)
{
// tell texture streaming system to ignore blinn-phong textures
- facep->setTexture(LLRender::DIFFUSE_MAP, nullptr);
+ // except the special case of the diffuse map containing a
+ // media texture that will be reused for swapping on to the pbr face
+ if (!facep->hasMedia())
+ {
+ facep->setTexture(LLRender::DIFFUSE_MAP, nullptr);
+ }
facep->setTexture(LLRender::NORMAL_MAP, nullptr);
facep->setTexture(LLRender::SPECULAR_MAP, nullptr);
@@ -5760,10 +5814,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{
cur_total += facep->getGeomCount();
- const LLTextureEntry* te = facep->getTextureEntry();
LLViewerTexture* tex = facep->getTexture();
- if (te->getGlow() > 0.f)
+ if (te && te->getGlow() > 0.f)
{
emissive = true;
}
@@ -5857,6 +5910,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
facep->mLastUpdateTime = gFrameTimeSeconds;
}
+ if (te)
{
LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial();
@@ -5864,7 +5918,23 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{
if (gltf_mat != nullptr)
{
- add_face(sPbrFaces, pbr_count, facep);
+ // In theory, we should never actually get here with alpha blending.
+ // How this is supposed to work is we check if the surface is alpha blended, and we assign it to the
+ // alpha draw pool. For rigged meshes, this apparently may not happen consistently. For now, just
+ // discard it here if the alpha is 0 (fully transparent) to achieve parity with blinn-phong materials in
+ // function.
+ bool should_render = true;
+ if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)
+ {
+ if (gltf_mat->mBaseColor.mV[3] == 0.0f)
+ {
+ should_render = false;
+ }
+ }
+ if (should_render)
+ {
+ add_face(sPbrFaces, pbr_count, facep);
+ }
}
else
{
@@ -5905,6 +5975,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
add_face(sFullbrightFaces, fullbright_count, facep);
}
}
+ else // no texture entry
+ {
+ facep->setState(LLFace::FULLBRIGHT);
+ add_face(sFullbrightFaces, fullbright_count, facep);
+ }
}
}
else
@@ -6026,8 +6101,8 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
group->mBuilt = 1.f;
- const U32 MAX_BUFFER_COUNT = 4096;
- LLVertexBuffer* locked_buffer[MAX_BUFFER_COUNT];
+ static std::vector<LLVertexBuffer*> locked_buffer;
+ locked_buffer.resize(0);
U32 buffer_count = 0;
@@ -6072,8 +6147,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
group->dirtyGeom();
gPipeline.markRebuild(group);
}
-
- buff->unmapBuffer();
}
}
}
@@ -6089,17 +6162,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
{
LL_PROFILE_ZONE_NAMED("rebuildMesh - flush");
- for (LLVertexBuffer** iter = locked_buffer, ** end_iter = locked_buffer+buffer_count; iter != end_iter; ++iter)
- {
- (*iter)->unmapBuffer();
- }
-
- // don't forget alpha
- if(group != NULL &&
- !group->mVertexBuffer.isNull())
- {
- group->mVertexBuffer->unmapBuffer();
- }
+ LLVertexBuffer::flushBuffers();
}
group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO);
@@ -6498,6 +6561,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)
{
registerFace(group, facep, LLRenderPass::PASS_ALPHA);
+ is_alpha = true;
}
else if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK)
{
@@ -6670,8 +6734,11 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
{ //shiny
if (tex->getPrimaryFormat() == GL_ALPHA)
{ //invisiprim+shiny
- registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY);
- registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
+ if (!facep->getViewerObject()->isAttachment() && !facep->getViewerObject()->isRiggedMesh())
+ {
+ registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY);
+ registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
+ }
}
else if (!hud_group)
{ //deferred rendering
@@ -6707,7 +6774,10 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
{ //not alpha and not shiny
if (!is_alpha && tex->getPrimaryFormat() == GL_ALPHA)
{ //invisiprim
- registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
+ if (!facep->getViewerObject()->isAttachment() && !facep->getViewerObject()->isRiggedMesh())
+ {
+ registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
+ }
}
else if (fullbright || bake_sunlight)
{ //fullbright
@@ -6781,11 +6851,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
++face_iter;
}
-
- if (buffer)
- {
- buffer->unmapBuffer();
- }
}
group->mBufferMap[mask].clear();