Skip to content

Commit bb4edbf

Browse files
Merge pull request #3026 from secondlife/v-2768
#2768: Fix for PBR texture animations sometimes not starting
2 parents 6b448af + a01548d commit bb4edbf

File tree

6 files changed

+40
-25
lines changed

6 files changed

+40
-25
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: indent-with-spaces
1313
files: \.(cpp|c|h|inl|py|glsl|cmake)$
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.4.0
15+
rev: v5.0.0
1616
hooks:
1717
- id: check-xml
1818
- id: mixed-line-ending

indra/newview/llface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ bool LLFace::getGeometryVolume(const LLVolume& volume,
15571557
}
15581558

15591559
U8 texgen = getTextureEntry()->getTexGen();
1560-
if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT)
1560+
if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
15611561
{ //planar texgen needs binormals
15621562
mVObjp->getVolume()->genTangents(face_index);
15631563
}

indra/newview/llspatialpartition.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class LLDrawInfo final : public LLRefCount
123123

124124
std::vector<LLPointer<LLViewerTexture> > mTextureList;
125125

126-
LLUUID mMaterialID; // id of LLGLTFMaterial or LLMaterial applied to this draw info
126+
LLUUID mMaterialHash; // hash of LLGLTFMaterial or LLMaterial applied to this draw info
127127

128128
U32 mShaderMask = 0;
129129
F32 mEnvIntensity = 0.f;
@@ -272,8 +272,7 @@ class LLSpatialGroup : public LLOcclusionCullingGroup
272272
IN_IMAGE_QUEUE = (ALPHA_DIRTY << 1),
273273
IMAGE_DIRTY = (IN_IMAGE_QUEUE << 1),
274274
MESH_DIRTY = (IMAGE_DIRTY << 1),
275-
NEW_DRAWINFO = (MESH_DIRTY << 1),
276-
IN_BUILD_Q1 = (NEW_DRAWINFO << 1),
275+
IN_BUILD_Q1 = (MESH_DIRTY << 1),
277276
IN_BUILD_Q2 = (IN_BUILD_Q1 << 1),
278277
STATE_MASK = 0x0000FFFF,
279278
} eSpatialState;

indra/newview/llviewermenu.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9894,7 +9894,6 @@ void initialize_menus()
98949894
view_listener_t::addMenu(new LLAdvancedClickGLTFEdit(), "Advanced.ClickGLTFEdit", cb_info::UNTRUSTED_BLOCK);
98959895
view_listener_t::addMenu(new LLAdvancedClickResizeWindow(), "Advanced.ClickResizeWindow", cb_info::UNTRUSTED_BLOCK);
98969896
view_listener_t::addMenu(new LLAdvancedPurgeShaderCache(), "Advanced.ClearShaderCache", cb_info::UNTRUSTED_BLOCK);
9897-
view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain", cb_info::UNTRUSTED_BLOCK);
98989897

98999898
#ifdef TOGGLE_HACKED_GODLIKE_VIEWER
99009899
view_listener_t::addMenu(new LLAdvancedHandleToggleHackedGodmode(), "Advanced.HandleToggleHackedGodmode");
@@ -9912,10 +9911,10 @@ void initialize_menus()
99129911
view_listener_t::addMenu(new LLAdvancedResetInterestLists(), "Advanced.ResetInterestLists");
99139912

99149913
// Develop > Terrain
9915-
view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain");
9916-
view_listener_t::addMenu(new LLAdvancedTerrainCreateLocalPaintMap(), "Advanced.TerrainCreateLocalPaintMap");
9917-
view_listener_t::addMenu(new LLAdvancedTerrainEditLocalPaintMap(), "Advanced.TerrainEditLocalPaintMap");
9918-
view_listener_t::addMenu(new LLAdvancedTerrainDeleteLocalPaintMap(), "Advanced.TerrainDeleteLocalPaintMap");
9914+
view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain", cb_info::UNTRUSTED_BLOCK);
9915+
view_listener_t::addMenu(new LLAdvancedTerrainCreateLocalPaintMap(), "Advanced.TerrainCreateLocalPaintMap", cb_info::UNTRUSTED_BLOCK);
9916+
view_listener_t::addMenu(new LLAdvancedTerrainEditLocalPaintMap(), "Advanced.TerrainEditLocalPaintMap", cb_info::UNTRUSTED_BLOCK);
9917+
view_listener_t::addMenu(new LLAdvancedTerrainDeleteLocalPaintMap(), "Advanced.TerrainDeleteLocalPaintMap", cb_info::UNTRUSTED_BLOCK);
99199918

99209919
// Advanced > UI
99219920
registrar.add("Advanced.WebBrowserTest", boost::bind(&handle_web_browser_test, _2)); // sigh! this one opens the MEDIA browser

indra/newview/llvovolume.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,15 @@ void LLVOVolume::animateTextures()
641641
if (!facep->mTextureMatrix)
642642
{
643643
facep->mTextureMatrix = new LLMatrix4();
644+
if (facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
645+
{
646+
// Fix the one edge case missed in
647+
// LLVOVolume::updateTextureVirtualSize when the
648+
// mTextureMatrix is not yet present
649+
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
650+
mDrawable->getSpatialGroup()->dirtyGeom();
651+
gPipeline.markRebuild(mDrawable->getSpatialGroup());
652+
}
644653
}
645654

646655
LLMatrix4& tex_mat = *facep->mTextureMatrix;
@@ -832,12 +841,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
832841
// if the face has gotten small enough to turn off texture animation and texture
833842
// animation is running, rebuild the render batch for this face to turn off
834843
// texture animation
844+
// Do the opposite when the face gets big enough.
845+
// If a face is animatable, it will always have non-null mTextureMatrix
846+
// pointer defined after the first call to LLVOVolume::animateTextures,
847+
// although the animation is not always turned on.
835848
if (face->mTextureMatrix != NULL)
836849
{
837-
if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
838-
(vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
850+
if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
839851
{
840852
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
853+
// dirtyGeom+markRebuild tells the engine to call
854+
// LLVolumeGeometryManager::rebuildGeom, which rebuilds the
855+
// LLDrawInfo for the spatial group containing this LLFace,
856+
// safely copying the mTextureMatrix from the LLFace the the
857+
// LLDrawInfo. While it's not ideal to call it here, prims with
858+
// animated faces get moved to a smaller partition to reduce
859+
// side-effects of their updates (see shrinkWrap in
860+
// LLVOVolume::animateTextures).
861+
mDrawable->getSpatialGroup()->dirtyGeom();
862+
gPipeline.markRebuild(mDrawable->getSpatialGroup());
841863
}
842864
}
843865

@@ -5409,7 +5431,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
54095431
info->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange &&
54105432
info->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange &&
54115433
#endif
5412-
info->mMaterialID == mat_id &&
5434+
info->mMaterialHash == mat_id &&
54135435
info->mFullbright == fullbright &&
54145436
info->mBump == bump &&
54155437
(!mat || (info->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different
@@ -5468,11 +5490,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
54685490
if (gltf_mat)
54695491
{
54705492
// just remember the material ID, render pools will reference the GLTF material
5471-
draw_info->mMaterialID = mat_id;
5493+
draw_info->mMaterialHash = mat_id;
54725494
}
54735495
else if (mat)
54745496
{
5475-
draw_info->mMaterialID = mat_id;
5497+
draw_info->mMaterialHash = mat_id;
54765498

54775499
// We have a material. Update our draw info accordingly.
54785500

@@ -5504,10 +5526,10 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
55045526
}
55055527
}
55065528

5507-
// if (type == LLRenderPass::PASS_ALPHA) // always populate the draw_info ptr
5508-
{ //for alpha sorting
5509-
facep->setDrawInfo(draw_info);
5510-
}
5529+
// This backpointer is used by alpha sorting and avatar attachment
5530+
// accounting.
5531+
// To be safe, always populate the draw_info ptr.
5532+
facep->setDrawInfo(draw_info);
55115533

55125534
if (index < FACE_DO_NOT_BATCH_TEXTURES)
55135535
{ //initialize texture list for texture batching
@@ -6129,7 +6151,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
61296151
LLVertexBuffer::flushBuffers();
61306152
}
61316153

6132-
group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO);
6154+
group->clearState(LLSpatialGroup::MESH_DIRTY);
61336155
}
61346156
}
61356157
}

indra/newview/pipeline.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,11 +3520,6 @@ void LLPipeline::postSort(LLCamera &camera)
35203520
continue;
35213521
}
35223522

3523-
if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY) && !gCubeSnapshot)
3524-
{ // no way this group is going to be drawable without a rebuild
3525-
group->rebuildGeom();
3526-
}
3527-
35283523
for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j)
35293524
{
35303525
LLSpatialGroup::drawmap_elem_t &src_vec = j->second;

0 commit comments

Comments
 (0)