Related Discussions
...

Hi,
MeshBatcher at row 154

if(item.texture != lastTexture || vertexCount + itemVertexCount > short.MaxValue)

it compare two texture, we can improve the check.
If we create different skeleton with the same file atlas, this check will detect as different texture because they are different instance, and it call FlushVertexArray many time.
Let's compare texture path and the fps for 100 different atlas increase over 20%
only two change:
in XnaTextureLoader class I insert at row 67

texture.Name = path;

otherwise is null.
in MeshBatcher class change the row 154 to:

if (i==0 || String.Equals(item.texture.Name , lastTexture.Name,StringComparison.OrdinalIgnoreCase) == false|| vertexCount + itemVertexCount > short.MaxValue)

best
Cristian

I think what would be better than loading multiple times and performing a string comparison every time is to load the texture only once in XnaTextureLoader.Load() and returning the reference to an already loaded Texture. Loaded textures could be stored and queried in a Dictionary<string, Texture>. Unloading must be performed accordingly then.

Using a Dictionary would also save memory. Same atlas same texture :-)
Dictionary keys is based on hash, it is fast too

If we create different skeleton with the same file atlas

As Harri mentioned, you should not load the atlas twice. Use the same atlas for multiple skeleton datas. Nothing will be faster than the == comparison.

Nate wrote

If we create different skeleton with the same file atlas

As Harri mentioned, you should not load the atlas twice. Use the same atlas for multiple skeleton datas. Nothing will be faster than the == comparison.

At the moment the runtime does not distinguish if an identical texture has already been used. Even if I use the same atlas, then the textureloader in the runtimes loads a multiple instance of the same texture and does not distinguish them because the comparision is do on the Texture2D class that are new istance, then different for comparition cause hash and other datas. This is the reason because I suggest to compare a unique data like texture path.
In my example I use string comparation with OrdinalIgnoreCase that is better than == :p but I don't check the loading of same texture

Actually what Nate pointed out makes even more sense, sorry for the confusion. I was wrong with saying XnaTextureLoader.Load() should only load a texture once and keep a map of loaded textures. Actually two atlas assets will never point to a single texture.

So the proper clean solution, as Nate proposed, is to ensure that the Atlas is loaded only once. E.g. by keeping a Dictionary<string, Spine.Atlas> and only load the Atlas if an Atlas at the given path has not been loaded before.

ok now I understand better!!! Sorry for my bad english
I will do as suggested, thank you at all :yes: :yes:

No need to apologize! Glad you've figured it out! 🙂