Merge branch 'DRTVWR-546' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-546

meow-7.2.2
Runitai Linden 2021-12-09 14:02:05 -06:00
commit f475644bb1
6 changed files with 50 additions and 44 deletions

View File

@ -679,9 +679,8 @@ void LLDrawPoolWater::renderWater()
{
face->renderIndexed();
// If not occlusion culling, record non-void water being drawn
// (If occlusion is enabled, these are set within LLOcclusionCullingGroup::checkOcclusion() )
if (!edge && !LLPipeline::sUseOcclusion)
// Note non-void water being drawn, updates required
if (!edge) // SL-16461 remove !LLPipeline::sUseOcclusion check
{
sNeedsReflectionUpdate = TRUE;
sNeedsDistortionUpdate = TRUE;

View File

@ -727,7 +727,6 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit)
switch (mode)
{
case LLModelPreview::MESH_OPTIMIZER_AUTO:
case LLModelPreview::MESH_OPTIMIZER:
case LLModelPreview::MESH_OPTIMIZER_SLOPPY:
case LLModelPreview::MESH_OPTIMIZER_COMBINE:
mModelPreview->onLODMeshOptimizerParamCommit(lod, enforce_tri_limit, mode);
@ -1736,7 +1735,6 @@ void LLFloaterModelPreview::onLoDSourceCommit(S32 lod)
LLComboBox* lod_source_combo = getChild<LLComboBox>("lod_source_" + lod_name[lod]);
S32 index = lod_source_combo->getCurrentIndex();
if (index == LLModelPreview::MESH_OPTIMIZER_AUTO
|| index == LLModelPreview::MESH_OPTIMIZER
|| index == LLModelPreview::MESH_OPTIMIZER_SLOPPY
|| index == LLModelPreview::MESH_OPTIMIZER_COMBINE)
{ //rebuild LoD to update triangle counts

View File

@ -1380,6 +1380,7 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe
S32 buf_positions_copied = 0;
S32 buf_indices_copied = 0;
indices_idx_shift = 0;
S32 valid_faces = 0;
// Crude method to copy indices back into face
for (U32 face_idx = 0; face_idx < base_model->getNumVolumeFaces(); ++face_idx)
@ -1478,6 +1479,8 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe
U32 tex_size = (buf_positions_copied * sizeof(LLVector2) + 0xF)&~0xF;
LLVector4a::memcpyNonAliased16((F32*)new_face.mTexCoords, (F32*)buffer_tex_coords, tex_size);
valid_faces++;
}
indices_idx_shift += face.mNumVertices;
@ -1490,7 +1493,7 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe
ll_aligned_free_16(buffer_indices);
ll_aligned_free_32(combined_indices);
if (new_indices < 3)
if (new_indices < 3 || valid_faces == 0)
{
// Model should have at least one visible triangle
@ -1734,7 +1737,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d
// but combine all submodels with origin model as well
if (model_meshopt_mode == MESH_OPTIMIZER_COMBINE)
{
// Run meshoptimizer for each model/object, up to 8 faces in one model
// Run meshoptimizer for each model/object, up to 8 faces in one model.
// Ideally this should run not per model,
// but combine all submodels with origin model as well
@ -1748,15 +1751,6 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d
}
}
}
if (model_meshopt_mode == MESH_OPTIMIZER)
{
// Run meshoptimizer for each face
for (U32 face_idx = 0; face_idx < base->getNumVolumeFaces(); ++face_idx)
{
genMeshOptimizerPerFace(base, target_model, face_idx, indices_decimator, lod_error_threshold, false);
}
}
if (model_meshopt_mode == MESH_OPTIMIZER_SLOPPY)
{
@ -1765,10 +1759,15 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d
{
genMeshOptimizerPerFace(base, target_model, face_idx, indices_decimator, lod_error_threshold, true);
}
LL_INFOS() << "Model " << target_model->getName()
<< " lod " << which_lod
<< " simplified using per face method." << LL_ENDL;
}
if (model_meshopt_mode == MESH_OPTIMIZER_AUTO)
{
// Switches between 'combine' method and 'per model sloppy' based on combine's result.
F32 allowed_ratio_drift = 2.f;
F32 res_ratio = genMeshOptimizerPerModel(base, target_model, indices_decimator, lod_error_threshold, false);
@ -1779,25 +1778,44 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d
{
genMeshOptimizerPerFace(base, target_model, face_idx, indices_decimator, lod_error_threshold, false);
}
LL_INFOS() << "Model " << target_model->getName()
<< " lod " << which_lod
<< " per model method overflow, defaulting to per face." << LL_ENDL;
}
else if (res_ratio * allowed_ratio_drift < indices_decimator)
{
// Try sloppy variant if normal one failed to simplify model enough.
res_ratio = genMeshOptimizerPerModel(base, target_model, indices_decimator, lod_error_threshold, true);
LL_INFOS() << "Model " << target_model->getName()
<< " lod " << which_lod
<< " sloppily simplified using per model method." << LL_ENDL;
// Sloppy has a tendecy to error into lower side, so a request for 100
// triangles turns into ~70, so check for significant difference from target decimation
F32 sloppy_ratio_drift = 1.4f;
if (lod_mode == LIMIT_TRIANGLES
&& (res_ratio > indices_decimator * sloppy_ratio_drift || res_ratio < 0))
{
// Apply a correction to compensate.
// (indices_decimator / res_ratio) by itself is likely to overshoot to a differend
// side due to overal lack of precision, and we don't need an ideal result, which
// likely does not exist, just a better one, so a partial correction is enough.
F32 sloppy_decimator = indices_decimator * (indices_decimator / res_ratio + 1) / 2;
res_ratio = genMeshOptimizerPerModel(base, target_model, sloppy_decimator, lod_error_threshold, true);
}
if (res_ratio < 0)
{
// Sloppy variant failed to generate triangles.
// Can happen with models that are too simple as is.
// Fallback to normal method.
// Fallback to normal method or use lower decimator.
genMeshOptimizerPerModel(base, target_model, indices_decimator, lod_error_threshold, false);
LL_INFOS() << "Model " << target_model->getName()
<< " lod " << which_lod
<< " simplified using per model method." << LL_ENDL;
}
else
{
LL_INFOS() << "Model " << target_model->getName()
<< " lod " << which_lod
<< " sloppily simplified using per model method." << LL_ENDL;
}
}
else

View File

@ -125,9 +125,8 @@ public:
{
LOD_FROM_FILE = 0,
MESH_OPTIMIZER_AUTO, // automatically selects method based on model or face
MESH_OPTIMIZER_COMBINE,
MESH_OPTIMIZER,
MESH_OPTIMIZER_SLOPPY,
MESH_OPTIMIZER_COMBINE, // combines faces into a single model, simplifies, then splits back into faces
MESH_OPTIMIZER_SLOPPY, // uses sloppy method, works per face
USE_LOD_ABOVE,
} eLoDMode;
@ -226,8 +225,12 @@ private:
// Count amount of original models, excluding sub-models
static U32 countRootModels(LLModelLoader::model_list models);
// functions for meshoptimizer, return reached simplification ratio
// Merges faces into single mesh, simplifies using mesh optimizer,
// then splits back into faces.
// Returns reached simplification ratio. -1 in case of a failure.
F32 genMeshOptimizerPerModel(LLModel *base_model, LLModel *target_model, F32 indices_ratio, F32 error_threshold, bool sloppy);
// Simplifies specified face using mesh optimizer.
// Returns reached simplification ratio. -1 in case of a failure.
F32 genMeshOptimizerPerFace(LLModel *base_model, LLModel *target_model, U32 face_idx, F32 indices_ratio, F32 error_threshold, bool sloppy);
protected:

View File

@ -1140,6 +1140,10 @@ void LLOcclusionCullingGroup::checkOcclusion()
#if LL_TRACK_PENDING_OCCLUSION_QUERIES
sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
#endif
#if 0 // (12/2021) occasional false-negative occlusion tests produce water reflection errors, SL-16461
// If/when water occlusion queries become 100% reliable, re-enable this optimization
if (LLPipeline::RENDER_TYPE_WATER == mSpatialPartition->mDrawableType)
{
// Note any unoccluded water, for deciding on reflection/distortion passes
@ -1150,7 +1154,7 @@ void LLOcclusionCullingGroup::checkOcclusion()
LLDrawPoolWater::sNeedsDistortionUpdate = TRUE;
}
}
#endif
if (query_result > 0)
{
clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);

View File

@ -194,10 +194,6 @@
name="MeshOptCombine"
label="Generate Precise"
value="MeshOptCombine" />
<item
name="MeshOpt"
label="Generate per face"
value="MeshOpt" />
<item
name="MeshOptSloppy"
label="Generate Sloppy"
@ -335,10 +331,6 @@
name="MeshOptCombine"
label="Generate Precise"
value="MeshOptCombine" />
<item
name="MeshOpt"
label="Generate per face"
value="MeshOpt" />
<item
name="MeshOptSloppy"
label="Generate Sloppy"
@ -480,10 +472,6 @@
name="MeshOptCombine"
label="Generate Precise"
value="MeshOptCombine" />
<item
name="MeshOpt"
label="Generate per face"
value="MeshOpt" />
<item
name="MeshOptSloppy"
label="Generate Sloppy"
@ -625,10 +613,6 @@
name="MeshOptCombine"
label="Generate Precise"
value="MeshOptCombine" />
<item
name="MeshOpt"
label="Generate per face"
value="MeshOpt" />
<item
name="MeshOptSloppy"
label="Generate Sloppy"