Merge branch 'release/2024.09-ExtraFPS' of https://github.com/secondlife/viewer

master
Ansariel 2024-12-05 23:26:47 +01:00
commit 215c2d2de0
14 changed files with 109 additions and 56 deletions

View File

@ -70,6 +70,7 @@ U32 LLTexUnit::sWhiteTexture = 0;
bool LLRender::sGLCoreProfile = false;
bool LLRender::sNsightDebugSupport = false;
LLVector2 LLRender::sUIGLScaleFactor = LLVector2(1.f, 1.f);
bool LLRender::sClassicMode = false;
struct LLVBCache
{
@ -994,9 +995,13 @@ void LLRender::syncLightState()
shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);
shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0);
//shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV);
//shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV);
//shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV);
if (sClassicMode)
{
shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV);
shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV);
shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV);
}
}
}

View File

@ -491,6 +491,7 @@ public:
static bool sGLCoreProfile;
static bool sNsightDebugSupport;
static LLVector2 sUIGLScaleFactor;
static bool sClassicMode; // classic sky mode active
private:
friend class LLLightState;

View File

@ -11232,7 +11232,18 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>RenderLowMemMinDiscardIncrement</key>
<map>
<key>Comment</key>
<string>Minimum increment of discard level if system memory gets low</string>
<string>Minimum increment of discard bias if available texture memory gets low</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.1</real>
</map>
<key>RenderHighMemMinDiscardDecrement</key>
<map>
<key>Comment</key>
<string>Minimum decrement of discard bias if excess texture memory is available</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -15167,12 +15178,12 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<real>20.0</real>
</map>
<key>TextureBiasDistanceScale</key>
<key>TextureCameraBoost</key>
<map>
<key>Comment</key>
<string>When biasing textures to lower resolution due to lack of vram, weight to put on distance factor.</string>
<string>Amount to boost resolution of textures that are important to the camera.</string>
<key>Persist</key>
<integer>1</integer>
<integer>0</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
@ -15193,19 +15204,6 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Backup</key>
<integer>0</integer>
</map>
<key>TextureBiasUnimportantFactor</key>
<map>
<key>Comment</key>
<string>When biasing textures to lower resolution due to lack of vram, the importance threshold below which is considered unimportant and getting an extra bias.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.25</real>
<key>Backup</key>
<integer>0</integer>
</map>
<key>TextureDecodeDisabled</key>
<map>
<key>Comment</key>

View File

@ -84,8 +84,6 @@ RenderCASSharpness 1 1
RenderExposure 1 4
RenderTonemapType 1 1
RenderTonemapMix 1 1
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderDisableVintageMode 1 1
//
@ -377,7 +375,6 @@ list Unknown
RenderShadowDetail 1 0
RenderDeferredSSAO 1 0
RenderMirrors 1 0
RenderEnableEmissiveBuffer 1 0
RenderDisableVintageMode 1 0
//
@ -420,10 +417,8 @@ RenderFSAASamples 0 0
RenderReflectionsEnabled 0 0
RenderReflectionProbeDetail 0 0
RenderMirrors 0 0
RenderEnableEmissiveBuffer 1 0
RenderGLMultiThreadedTextures 0 0
RenderGLMultiThreadedMedia 0 0
RenderHDREnabled 1 0
RenderDisableVintageMode 1 0
list TexUnit16orLess

View File

@ -322,7 +322,7 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings()
}
// Vintage mode
LLCachedControl<bool> is_not_vintage(gSavedSettings, "RenderDisableVintageMode");
static LLCachedControl<bool> is_not_vintage(gSavedSettings, "RenderDisableVintageMode");
LLSliderCtrl* tonemapMix = getChild<LLSliderCtrl>("TonemapMix");
LLComboBox* tonemapSelect = getChild<LLComboBox>("TonemapType");
LLTextBox* tonemapLabel = getChild<LLTextBox>("TonemapTypeText");

View File

@ -2396,13 +2396,14 @@ void LLSelectMgr::selectionRevertGLTFMaterials()
// Update material locally
objectp->setRenderMaterialID(te, asset_id, false /*wait for LLGLTFMaterialList update*/);
objectp->setTEGLTFMaterialOverride(te, nodep->mSavedGLTFOverrideMaterials[te]);
LLGLTFMaterial* material = new LLGLTFMaterial(*nodep->mSavedGLTFOverrideMaterials[te]);
objectp->setTEGLTFMaterialOverride(te, material);
// Enqueue update to server
if (asset_id.notNull())
{
// Restore overrides and base material
LLGLTFMaterialList::queueApply(objectp, te, asset_id, nodep->mSavedGLTFOverrideMaterials[te]);
LLGLTFMaterialList::queueApply(objectp, te, asset_id, material);
}
else
{
@ -3304,15 +3305,20 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)
material->mTextureTransform[i].mScale.set(scale_x, scale_y);
}
LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial();
if (render_mat)
const LLGLTFMaterial* base_material = tep->getGLTFMaterial();
if (base_material)
{
render_mat->applyOverride(*material);
LLGLTFMaterial* render_material = new LLFetchedGLTFMaterial();
*render_material = *base_material;
render_material->applyOverride(*material);
tep->setGLTFRenderMaterial(render_material);
}
if (send_to_sim)
{
LLGLTFMaterialList::queueModify(object, te_num, material);
LLGLTFMaterial new_override;
new_override = *material;
LLGLTFMaterialList::queueModify(object, te_num, &new_override);
}
}
send = send_to_sim;
@ -6213,12 +6219,12 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
LLGLTFMaterial* old_override = node->getObject()->getTE(i)->getGLTFMaterialOverride();
if (old_override)
{
LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_override);
override_materials.push_back(mat);
// saveGLTFMaterials will make a copy
override_materials.emplace_back(old_override);
}
else
{
override_materials.push_back(nullptr);
override_materials.emplace_back(nullptr);
}
}
// processObjectProperties does not include overrides so this
@ -7138,16 +7144,22 @@ void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_mat
mSavedGLTFMaterialIds.clear();
mSavedGLTFOverrideMaterials.clear();
for (uuid_vec_t::const_iterator materials_it = materials.begin();
materials_it != materials.end(); ++materials_it)
for (const LLUUID& id : materials)
{
mSavedGLTFMaterialIds.push_back(*materials_it);
mSavedGLTFMaterialIds.push_back(id);
}
for (gltf_materials_vec_t::const_iterator mat_it = override_materials.begin();
mat_it != override_materials.end(); ++mat_it)
for (const LLPointer<LLGLTFMaterial> &mat : override_materials)
{
mSavedGLTFOverrideMaterials.push_back(*mat_it);
if (mat.notNull())
{
LLGLTFMaterial* copy = new LLGLTFMaterial(*mat);
mSavedGLTFOverrideMaterials.emplace_back(copy);
}
else
{
mSavedGLTFOverrideMaterials.emplace_back(nullptr);
}
}
}
}

View File

@ -216,6 +216,8 @@ public:
// final gltf material that users see.
// Ids get applied and restored by tools floater,
// overrides get applied in live material editor
// @param override_materials' content will be copied to not
// affect originals
void saveGLTFMaterials(const uuid_vec_t& materials, const gltf_materials_vec_t& override_materials);
bool allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;

View File

@ -671,7 +671,7 @@ void LLSettingsVOSky::updateSettings()
// After some A/B comparison of relesae vs EEP, tweak to allow strength to fall below 2
// at night, for better match. (mSceneLightStrength is a divisor, so lower value means brighter
// local lights)
LLCachedControl<F32> sdr(gSavedSettings, "RenderSunDynamicRange", 1.f);
static LLCachedControl<F32> sdr(gSavedSettings, "RenderSunDynamicRange", 1.f);
F32 sun_dynamic_range = llmax(sdr(), 0.0001f);
mSceneLightStrength = 2.0f * (0.75f + sun_dynamic_range * dp);
@ -818,6 +818,8 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
shader->uniform1f(LLShaderMgr::SKY_AMBIENT_SCALE, ambient_scale);
shader->uniform1i(LLShaderMgr::CLASSIC_MODE, classic_mode);
LLRender::sClassicMode = classic_mode;
F32 probe_ambiance = getReflectionProbeAmbiance();
if (irradiance_pass)

View File

@ -1966,7 +1966,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
mRawImage = NULL;
mAuxImage = NULL;
llassert_always(mFormattedImage.notNull());
S32 discard = mHaveAllData ? 0 : mLoadedDiscard;
// if we have the entire image data (and the image is not J2C), decode the full res image
// DO NOT decode a higher res j2c than was requested. This is a waste of time and memory.
S32 discard = mHaveAllData && mFormattedImage->getCodec() != IMG_CODEC_J2C ? 0 : mLoadedDiscard;
mDecoded = false;
setState(DECODE_IMAGE_UPDATE);
LL_DEBUGS(LOG_TXT) << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard
@ -2587,6 +2590,10 @@ void LLTextureFetchWorker::callbackDecoded(bool success, const std::string &erro
mRawImage = raw;
mAuxImage = aux;
mDecodedDiscard = mFormattedImage->getDiscardLevel();
if (mDecodedDiscard < mDesiredDiscard)
{
LL_WARNS_ONCE(LOG_TXT) << "Decoded higher resolution than requested" << LL_ENDL;
}
LL_DEBUGS(LOG_TXT) << mID << ": Decode Finished. Discard: " << mDecodedDiscard
<< " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;
}

View File

@ -1424,6 +1424,7 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,
LLTextureEntry* te = hit_obj->getTE(hit_face);
if (te && !remove_pbr)
{
// saveGLTFMaterials will make a copy
override_materials.push_back(te->getGLTFMaterialOverride());
}
else
@ -1465,7 +1466,8 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,
LLTextureEntry* te = hit_obj->getTE(hit_face);
if (te && !remove_pbr)
{
nodep->mSavedGLTFOverrideMaterials[hit_face] = te->getGLTFMaterialOverride();
LLGLTFMaterial* copy = new LLGLTFMaterial(*te->getGLTFMaterialOverride());
nodep->mSavedGLTFOverrideMaterials[hit_face] = copy;
}
else
{

View File

@ -262,7 +262,7 @@ static bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader
static void add_common_permutations(LLGLSLShader* shader)
{
LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
static LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
if (emissive)
{
@ -786,7 +786,7 @@ std::string LLViewerShaderMgr::loadBasicShaders()
attribs["MAX_JOINTS_PER_MESH_OBJECT"] =
std::to_string(LLSkinningUtil::getMaxJointCount());
LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
static LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
if (emissive)
{

View File

@ -579,7 +579,10 @@ void LLViewerTexture::updateClass()
// lower discard bias over time when free memory is available
if (sDesiredDiscardBias > 1.f && over_pct < 0.f)
{
sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01f;
static LLCachedControl<F32> high_mem_discard_decrement(gSavedSettings, "RenderHighMemMinDiscardDecrement", .1f);
F32 decrement = high_mem_discard_decrement - llmin(over_pct, 0.f);
sDesiredDiscardBias -= decrement * gFrameIntervalSeconds;
}
}
@ -641,7 +644,7 @@ void LLViewerTexture::updateClass()
}
}
sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 5.f);
sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f);
LLViewerTexture::sFreezeImageUpdates = false;
}

View File

@ -904,7 +904,6 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
if (imagep->getBoostLevel() < LLViewerFetchedTexture::BOOST_HIGH) // don't bother checking face list for boosted textures
{
static LLCachedControl<F32> bias_distance_scale(gSavedSettings, "TextureBiasDistanceScale", 1.f);
static LLCachedControl<F32> texture_scale_min(gSavedSettings, "TextureScaleMinAreaFactor", 0.04f);
static LLCachedControl<F32> texture_scale_max(gSavedSettings, "TextureScaleMaxAreaFactor", 25.f);
@ -913,7 +912,12 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
U32 face_count = 0;
F32 bias = (F32) llroundf(powf(4, LLViewerTexture::sDesiredDiscardBias - 1.f));
// get adjusted bias based on image resolution
F32 max_discard = F32(imagep->getMaxDiscardLevel());
F32 bias = llclamp(max_discard - 2.f, 1.f, LLViewerTexture::sDesiredDiscardBias);
// convert bias into a vsize scaler
bias = (F32) llroundf(powf(4, bias - 1.f));
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
@ -927,7 +931,6 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
++face_count;
F32 radius;
F32 cos_angle_to_view_dir;
static LLCachedControl<F32> bias_unimportant_threshold(gSavedSettings, "TextureBiasUnimportantFactor", 0.25f);
if ((gFrameCount - face->mLastTextureUpdate) > 10)
{ // only call calcPixelArea at most once every 10 frames for a given face
@ -961,6 +964,13 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
vsize /= bias;
}
// boost resolution of textures that are important to the camera
if (face->mInFrustum)
{
static LLCachedControl<F32> texture_camera_boost(gSavedSettings, "TextureCameraBoost", 8.f);
vsize *= llmax(face->mImportanceToCamera*texture_camera_boost, 1.f);
}
max_vsize = llmax(max_vsize, vsize);
}
}
@ -1069,13 +1079,26 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time)
{
LLViewerFetchedTexture* imagep = mCreateTextureList.front();
llassert(imagep->mCreatePending);
imagep->createTexture();
// desired discard may change while an image is being decoded. If the texture in VRAM is sufficient
// for the current desired discard level, skip the texture creation. This happens more often than it probably
// should
bool redundant_load = imagep->hasGLTexture() && imagep->getDiscardLevel() <= imagep->getDesiredDiscardLevel();
if (!redundant_load)
{
imagep->createTexture();
}
imagep->postCreateTexture();
imagep->mCreatePending = false;
mCreateTextureList.pop();
if (imagep->hasGLTexture() && imagep->getDiscardLevel() < imagep->getDesiredDiscardLevel())
{
// NOTE: this may happen if the desired discard reduces while a decode is in progress and does not
// necessarily indicate a problem, but if log occurrences excede that of dsiplay_stats: FPS,
// something has probably gone wrong.
LL_WARNS_ONCE("Texture") << "Texture will be downscaled immediately after loading." << LL_ENDL;
imagep->scaleDown();
}

View File

@ -371,8 +371,9 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false)
U32 norm = GL_RGBA16F;
U32 emissive = GL_RGB16F;
bool hdr = gSavedSettings.getBOOL("RenderHDREnabled") && gGLManager.mGLVersion > 4.05f;
LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
static LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
bool hdr = has_hdr() && gGLManager.mGLVersion > 4.05f;
if (!hdr)
{
@ -869,7 +870,8 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
bool hdr = gGLManager.mGLVersion > 4.05f && gSavedSettings.getBOOL("RenderHDREnabled");
static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();
if (mRT == &mMainRT)
{ // hacky -- allocate auxillary buffer
@ -8095,7 +8097,8 @@ void LLPipeline::renderFinalize()
gGL.setColorMask(true, true);
glClearColor(0, 0, 0, 0);
bool hdr = gGLManager.mGLVersion > 4.05f && gSavedSettings.getBOOL("RenderHDREnabled");
static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();
if (hdr)
{