mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- reverse the order of the texture list before resolving it.
Since this deletes the resolved elements one by one and needs to start at the front to ensure consistency, it is better to reverse the order so that the deletions take place at the end of the list which requires a lot less data movement. On Total Chaos this slowed down texture setup to the point where the mod was basically unlaunchable.
This commit is contained in:
parent
bc648015c7
commit
0160841dde
4 changed files with 55 additions and 3 deletions
18
src/tarray.h
18
src/tarray.h
|
@ -497,6 +497,14 @@ public:
|
|||
Array = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Swap(TArray<T, TT> &other)
|
||||
{
|
||||
std::swap(Array, other.Array);
|
||||
std::swap(Count, other.Count);
|
||||
std::swap(Most, other.Most);
|
||||
}
|
||||
|
||||
private:
|
||||
T *Array;
|
||||
unsigned int Count;
|
||||
|
@ -760,6 +768,7 @@ struct FMap
|
|||
hash_t NumUsed;
|
||||
};
|
||||
|
||||
|
||||
template<class KT, class VT, class MapType> class TMapIterator;
|
||||
template<class KT, class VT, class MapType> class TMapConstIterator;
|
||||
|
||||
|
@ -947,6 +956,14 @@ public:
|
|||
DelKey(key);
|
||||
}
|
||||
|
||||
void Swap(MyType &other)
|
||||
{
|
||||
std::swap(Nodes, other.Nodes);
|
||||
std::swap(LastFree, other.LastFree);
|
||||
std::swap(Size, other.Size);
|
||||
std::swap(NumUsed, other.NumUsed);
|
||||
}
|
||||
|
||||
protected:
|
||||
struct IPair // This must be the same as Pair above, but with a
|
||||
{ // non-const Key.
|
||||
|
@ -1518,4 +1535,3 @@ private:
|
|||
T *Array;
|
||||
unsigned int Count;
|
||||
};
|
||||
|
||||
|
|
|
@ -89,8 +89,30 @@ struct BuildInfo
|
|||
int LeftOffset[2] = {};
|
||||
int TopOffset[2] = {};
|
||||
FImageTexture *tex = nullptr;
|
||||
|
||||
void swap(BuildInfo &other)
|
||||
{
|
||||
Name.Swap(other.Name);
|
||||
Parts.Swap(other.Parts);
|
||||
Inits.Swap(other.Inits);
|
||||
std::swap(Width, other.Width);
|
||||
std::swap(Height, other.Height);
|
||||
std::swap(Scale, other.Scale);
|
||||
std::swap(bWorldPanning, other.bWorldPanning);
|
||||
std::swap(DefinitionLump, other.DefinitionLump);
|
||||
std::swap(bComplex, bComplex);
|
||||
std::swap(textual, other.textual);
|
||||
std::swap(bNoDecals, other.bNoDecals);
|
||||
std::swap(LeftOffset[0], other.LeftOffset[0]);
|
||||
std::swap(LeftOffset[1], other.LeftOffset[1]);
|
||||
std::swap(TopOffset[0], other.TopOffset[0]);
|
||||
std::swap(TopOffset[1], other.TopOffset[1]);
|
||||
std::swap(tex, other.tex);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FMultipatchTextureBuilder
|
||||
{
|
||||
FTextureManager &TexMan;
|
||||
|
|
|
@ -922,11 +922,21 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
|
|||
}
|
||||
// Now try to resolve the images. We only can do this at the end when all multipatch textures are set up.
|
||||
int i = 0;
|
||||
|
||||
// reverse the list so that the Delete operation in the loop below deletes at the end.
|
||||
// For normal sized lists this is of no real concern, but Total Chaos has over 250000 textures where this becomes a performance issue.
|
||||
for (unsigned i = 0; i < BuiltTextures.Size() / 2; i++)
|
||||
{
|
||||
// std::swap is VERY inefficient here...
|
||||
BuiltTextures[i].swap(BuiltTextures[BuiltTextures.Size() - 1 - i]);
|
||||
}
|
||||
|
||||
|
||||
while (BuiltTextures.Size() > 0)
|
||||
{
|
||||
bool donesomething = false;
|
||||
|
||||
for (unsigned i = 0; i < BuiltTextures.Size(); i++)
|
||||
for (int i = BuiltTextures.Size()-1; i>= 0; i--)
|
||||
{
|
||||
auto &buildinfo = BuiltTextures[i];
|
||||
bool hasEmpty = false;
|
||||
|
@ -969,7 +979,6 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
|
|||
}
|
||||
|
||||
BuiltTextures.Delete(i);
|
||||
i--;
|
||||
donesomething = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,6 +148,11 @@ public:
|
|||
char *LockBuffer(); // Obtain write access to the character buffer
|
||||
void UnlockBuffer(); // Allow shared access to the character buffer
|
||||
|
||||
void Swap(FString &other)
|
||||
{
|
||||
std::swap(Chars, other.Chars);
|
||||
}
|
||||
|
||||
operator const char *() const { return Chars; }
|
||||
|
||||
const char *GetChars() const { return Chars; }
|
||||
|
|
Loading…
Reference in a new issue