Skip to content

Commit 459f6a8

Browse files
committed
Revert "Temporary textures cleanup (#3978)"
This reverts commit f91e1de. Details on revert: #4031 (comment) (to find out if it's the original culprit)
1 parent 81af84e commit 459f6a8

File tree

3 files changed

+7
-61
lines changed

3 files changed

+7
-61
lines changed

Client/mods/deathmatch/logic/CClientManager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ void CClientManager::DoPulse(bool bDoStandardPulses, bool bDoVehicleManagerPulse
218218
m_pColManager->DoPulse();
219219
m_pGUIManager->DoPulse();
220220
m_pWeaponManager->DoPulse();
221-
m_pRenderElementManager->DoPulse();
222221
}
223222
else
224223
{

Client/mods/deathmatch/logic/CClientRenderElementManager.cpp

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#include "StdInc.h"
1212
#include "CClientVectorGraphic.h"
1313

14-
constexpr std::int64_t TEMPORARY_TEXTURES_CLEANUP_PERIOD = 5000ll;
15-
constexpr std::int64_t TEMPORARY_TEXTURES_CLEANUP_THRESHOLD = 10000ll;
16-
constexpr std::size_t TEMPORARY_TEXTURES_DELETE_THRESHOLD = 10u;
17-
1814
////////////////////////////////////////////////////////////////
1915
//
2016
// CClientRenderElementManager::CClientRenderElementManager
@@ -287,24 +283,20 @@ CClientVectorGraphic* CClientRenderElementManager::CreateVectorGraphic(uint widt
287283
CClientTexture* CClientRenderElementManager::FindAutoTexture(const SString& strFullFilePath, const SString& strUniqueName)
288284
{
289285
// Check if we've already done this file
290-
SAutoTexture* ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
286+
CClientTexture** ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
291287
if (!ppTextureElement)
292288
{
293289
// Try to create
294290
CClientTexture* pNewTextureElement = CreateTexture(strFullFilePath);
295291
if (!pNewTextureElement)
296-
return nullptr;
297-
298-
pNewTextureElement->MakeSystemEntity();
292+
return NULL;
299293

300294
// Add to automap if created
301-
MapSet(m_AutoTextureMap, strUniqueName, SAutoTexture{pNewTextureElement});
295+
MapSet(m_AutoTextureMap, strUniqueName, pNewTextureElement);
302296
ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
303297
}
304298

305-
ppTextureElement->lastUse = CTickCount::Now();
306-
307-
return ppTextureElement->texture;
299+
return *ppTextureElement;
308300
}
309301

310302
////////////////////////////////////////////////////////////////
@@ -326,9 +318,9 @@ void CClientRenderElementManager::Remove(CClientRenderElement* pElement)
326318
// Remove from auto texture map
327319
if (pElement->IsA(CClientTexture::GetClassId()))
328320
{
329-
for (auto iter = m_AutoTextureMap.begin(); iter != m_AutoTextureMap.end(); ++iter)
321+
for (std::map<SString, CClientTexture*>::iterator iter = m_AutoTextureMap.begin(); iter != m_AutoTextureMap.end(); ++iter)
330322
{
331-
if (iter->second.texture == pElement)
323+
if (iter->second == pElement)
332324
{
333325
m_AutoTextureMap.erase(iter);
334326
break;
@@ -358,39 +350,3 @@ void CClientRenderElementManager::Remove(CClientRenderElement* pElement)
358350
CRenderItem* pRenderItem = pElement->GetRenderItem();
359351
SAFE_RELEASE(pRenderItem);
360352
}
361-
362-
void CClientRenderElementManager::DoPulse()
363-
{
364-
if (m_texturePulseTimer.Get() < TEMPORARY_TEXTURES_CLEANUP_PERIOD)
365-
return;
366-
367-
m_texturePulseTimer.Reset();
368-
369-
const CTickCount now = CTickCount::Now();
370-
371-
std::vector<CClientTexture*> deleteCandidates;
372-
deleteCandidates.reserve(TEMPORARY_TEXTURES_DELETE_THRESHOLD);
373-
374-
for (const auto& [texName, texInfo] : m_AutoTextureMap)
375-
{
376-
const std::int64_t timeElapsedMs = (now - texInfo.lastUse).ToLongLong();
377-
if (timeElapsedMs < TEMPORARY_TEXTURES_CLEANUP_THRESHOLD)
378-
continue;
379-
380-
CTextureItem* textureItem = texInfo.texture->GetTextureItem();
381-
if (textureItem && textureItem->m_iRefCount > 1)
382-
continue;
383-
384-
// CElementDeleter::Delete causes changes in m_AutoTextureMap
385-
// and we cannot delete a texture while iterating over it
386-
deleteCandidates.push_back(texInfo.texture);
387-
388-
// The deletion procedure can be expensive
389-
// and we're interested in capping on the number of deleted texture at once
390-
if (deleteCandidates.size() == TEMPORARY_TEXTURES_DELETE_THRESHOLD)
391-
break;
392-
}
393-
394-
for (CClientTexture* texture : deleteCandidates)
395-
g_pClientGame->GetElementDeleter()->Delete(texture);
396-
}

Client/mods/deathmatch/logic/CClientRenderElementManager.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class CClientRenderElementManager
3939
CClientTexture* FindAutoTexture(const SString& strFullFilePath, const SString& strUniqueName);
4040
void Remove(CClientRenderElement* pElement);
4141

42-
void DoPulse();
43-
4442
uint GetDxFontCount() { return m_uiStatsDxFontCount; }
4543
uint GetGuiFontCount() { return m_uiStatsGuiFontCount; }
4644
uint GetTextureCount() { return m_uiStatsTextureCount; }
@@ -51,16 +49,9 @@ class CClientRenderElementManager
5149
uint GetVectorGraphicCount() { return m_uiStatsVectorGraphicCount; }
5250

5351
protected:
54-
struct SAutoTexture
55-
{
56-
CClientTexture* texture{};
57-
CTickCount lastUse;
58-
};
59-
60-
CElapsedTime m_texturePulseTimer;
6152
CClientManager* m_pClientManager;
6253
CRenderItemManagerInterface* m_pRenderItemManager;
63-
std::map<SString, SAutoTexture> m_AutoTextureMap;
54+
std::map<SString, CClientTexture*> m_AutoTextureMap;
6455
std::map<CRenderItem*, CClientRenderElement*> m_ItemElementMap;
6556
uint m_uiStatsGuiFontCount;
6657
uint m_uiStatsDxFontCount;

0 commit comments

Comments
 (0)