Skip to content

Commit f891b66

Browse files
committed
Merge remote-tracking branch 'origin/release/2024.09-ExtraFPS' into develop
# Conflicts: # indra/newview/pipeline.cpp
2 parents a0b5649 + a88373a commit f891b66

File tree

6 files changed

+46
-18
lines changed

6 files changed

+46
-18
lines changed

indra/llinventory/llsettingssky.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,14 @@ F32 LLSettingsSky::getTonemapMix() const
20642064
return mTonemapMix;
20652065
}
20662066

2067+
void LLSettingsSky::setTonemapMix(F32 mix)
2068+
{
2069+
if (mCanAutoAdjust)
2070+
return;
2071+
2072+
mTonemapMix = mix;
2073+
}
2074+
20672075
void LLSettingsSky::setGamma(F32 val)
20682076
{
20692077
mGamma = val;

indra/llinventory/llsettingssky.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class LLSettingsSky: public LLSettingsBase
213213
F32 getHDRMax() const;
214214
F32 getHDROffset() const;
215215
F32 getTonemapMix() const;
216+
void setTonemapMix(F32 mix);
216217

217218
void setGamma(F32 val);
218219

indra/newview/llmodelpreview.cpp

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void LLModelPreview::rebuildUploadData()
555555
{
556556
// in case user provided a missing file later
557557
texture->setIsMissingAsset(false);
558-
texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, this, &mCallbackTextureList, false);
558+
texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, new LLHandle<LLModelPreview>(getHandle()), &mCallbackTextureList, false);
559559
texture->forceToSaveRawImage(0, F32_MAX);
560560
texture->updateFetch();
561561
if (mModelLoader)
@@ -784,6 +784,10 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
784784
std::map<std::string, std::string> joint_alias_map;
785785
getJointAliases(joint_alias_map);
786786

787+
LLHandle<LLModelPreview> preview_handle = getHandle();
788+
auto load_textures_cb =
789+
[preview_handle](LLImportMaterial& material, void* opaque) { return LLModelPreview::loadTextures(material, preview_handle); };
790+
787791
// three possible file extensions, .dae .gltf .glb
788792
// check for .dae and if not then assume one of the .gl??
789793
std::string filename_lc(filename);
@@ -795,7 +799,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
795799
lod,
796800
&LLModelPreview::loadedCallback,
797801
&LLModelPreview::lookupJointByName,
798-
&LLModelPreview::loadTextures,
802+
load_textures_cb,
799803
&LLModelPreview::stateChangedCallback,
800804
this,
801805
mJointTransformMap,
@@ -812,7 +816,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
812816
lod,
813817
&LLModelPreview::loadedCallback,
814818
&LLModelPreview::lookupJointByName,
815-
&LLModelPreview::loadTextures,
819+
load_textures_cb,
816820
&LLModelPreview::stateChangedCallback,
817821
this,
818822
mJointTransformMap,
@@ -3130,9 +3134,9 @@ LLJoint* LLModelPreview::lookupJointByName(const std::string& str, void* opaque)
31303134
return NULL;
31313135
}
31323136

3133-
U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque)
3137+
U32 LLModelPreview::loadTextures(LLImportMaterial& material, LLHandle<LLModelPreview> handle)
31343138
{
3135-
if (material.mDiffuseMapFilename.size())
3139+
if (material.mDiffuseMapFilename.size() && !handle.isDead())
31363140
{
31373141
material.mOpaqueData = new LLPointer< LLViewerFetchedTexture >;
31383142
LLPointer< LLViewerFetchedTexture >& tex = (*reinterpret_cast< LLPointer< LLViewerFetchedTexture > * >(material.mOpaqueData));
@@ -3143,10 +3147,8 @@ U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque)
31433147
// file was loaded previosly, reload image to get potential changes
31443148
tex->clearFetchedResults();
31453149
}
3146-
// Todo: might cause a crash if preview gets closed before we get the callback.
3147-
// Use a callback list or guard callback in some way
3148-
LLModelPreview* preview = (LLModelPreview*)opaque;
3149-
tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, &preview->mCallbackTextureList, false);
3150+
LLModelPreview* preview = (LLModelPreview*)handle.get();
3151+
tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, new LLHandle<LLModelPreview>(handle), &preview->mCallbackTextureList, false);
31503152
tex->forceToSaveRawImage(0, F32_MAX);
31513153
material.setDiffuseMap(tex->getID()); // record tex ID
31523154
return 1;
@@ -4003,16 +4005,29 @@ void LLModelPreview::textureLoadedCallback(
40034005
bool final,
40044006
void* userdata)
40054007
{
4006-
LLModelPreview* preview = (LLModelPreview*)userdata;
4007-
preview->refresh();
4008+
if (!userdata)
4009+
return;
4010+
4011+
LLHandle<LLModelPreview>* handle = (LLHandle<LLModelPreview>*)userdata;
40084012

4009-
if (final && preview->mModelLoader)
4013+
if (!handle->isDead())
40104014
{
4011-
if (preview->mModelLoader->mNumOfFetchingTextures > 0)
4015+
LLModelPreview* preview = static_cast<LLModelPreview*>(handle->get());
4016+
preview->refresh();
4017+
4018+
if (final && preview->mModelLoader)
40124019
{
4013-
preview->mModelLoader->mNumOfFetchingTextures--;
4020+
if (preview->mModelLoader->mNumOfFetchingTextures > 0)
4021+
{
4022+
preview->mModelLoader->mNumOfFetchingTextures--;
4023+
}
40144024
}
40154025
}
4026+
4027+
if (final || !success)
4028+
{
4029+
delete handle;
4030+
}
40164031
}
40174032

40184033
// static

indra/newview/llmodelpreview.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static const std::string lod_label_name[NUM_LOD + 1] =
111111
"I went off the end of the lod_label_name array. Me so smart."
112112
};
113113

114-
class LLModelPreview : public LLViewerDynamicTexture, public LLMutex
114+
class LLModelPreview : public LLViewerDynamicTexture, public LLMutex, public LLHandleProvider<LLModelPreview>
115115
{
116116
LOG_CLASS(LLModelPreview);
117117

@@ -211,7 +211,7 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex
211211
static void stateChangedCallback(U32 state, void* opaque);
212212

213213
static LLJoint* lookupJointByName(const std::string&, void* opaque);
214-
static U32 loadTextures(LLImportMaterial& material, void* opaque);
214+
static U32 loadTextures(LLImportMaterial& material, LLHandle<LLModelPreview> handle);
215215

216216
void lookupLODModelFiles(S32 lod);
217217

indra/newview/llsettingsvo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,16 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
804804
static LLCachedControl<F32> sunlight_scale(gSavedSettings, "RenderSkySunlightScale", 1.5f);
805805
static LLCachedControl<F32> sunlight_hdr_scale(gSavedSettings, "RenderHDRSkySunlightScale", 1.5f);
806806
static LLCachedControl<F32> ambient_scale(gSavedSettings, "RenderSkyAmbientScale", 1.5f);
807+
static LLCachedControl<F32> tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f);
807808

808809
// sky is a "classic" sky following pre SL 7.0 shading
809810
bool classic_mode = psky->canAutoAdjust();
810811

812+
if (!classic_mode)
813+
{
814+
psky->setTonemapMix(tonemap_mix_setting);
815+
}
816+
811817
shader->uniform1f(LLShaderMgr::SKY_SUNLIGHT_SCALE, hdr ? sunlight_hdr_scale : sunlight_scale);
812818
shader->uniform1f(LLShaderMgr::SKY_AMBIENT_SCALE, ambient_scale);
813819
shader->uniform1i(LLShaderMgr::CLASSIC_MODE, classic_mode);

indra/newview/pipeline.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,8 +7152,6 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst, bool gamma_co
71527152

71537153
static LLCachedControl<U32> tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U);
71547154
shader->uniform1i(tonemap_type, tonemap_type_setting);
7155-
7156-
static LLCachedControl<F32> tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f);
71577155
shader->uniform1f(tonemap_mix, psky->getTonemapMix());
71587156

71597157
mScreenTriangleVB->setBuffer();

0 commit comments

Comments
 (0)