Does the other physical address have a texture referencing "the same texture", is there really a problem?
I started the default model game project, but installed it for Obj-C. I have a texture atlas that will be something like the image below. However, note that I passed this through TexturePacker. Thus, the actually created Xcode atlas is different.
I do as you said and created 2 textures with the same name.
self.myTextureAtlas = [SKTextureAtlas atlasNamed:@"MyTexture"]; self.tex0 = [self.myTextureAtlas textureNamed:@"tex0"]; self.tex1 = [self.myTextureAtlas textureNamed:@"tex0"];
As you said, pointers to tex0
and tex1
different. So at least there is a match between Swift and Obj-C.
However, I do not think this is a problem / error. I suspect that they changed the implementation, so the returned SKTexture
is a new "instance", however the basic texture remains the same.
I will talk about OpenGL, as this is what I write in my machines. Metal will still have similarities. A basic sub-texture does have only 2 important properties: the name of the texture (this is the name of the OpenGL texture) and UVs. If you were thinking about what would be considered โequalityโ for Equatable
, most likely it would experience equality against these two items. The name of the texture is the name of the texture of the atlas, and UV is the UV in the atlas, which represent the region of a particular substructure.
To test this hypothesis, I launched GPU frame capture. With Xcode 8, this seems rather unsuccessful. Using metal, it crashed in 100% of cases. I made him use OpenGL and managed to get a frame capture. As expected, when I look at all the texture resources, I see only one texture for my atlas.
Texture # 3 is MyTexture.
If I unload a texture that seems UV, I see that they are the same:
Tex0 Rect 0.001618 0.793765 0.1339159 0.203837
Tex1 Rect 0.001618 0.793765 0.1339159 0.203837
Based on this, it would seem that self.tex0
and self.tex1
, although they have different physical addresses, still point to the same sub-texture.
Please note that I no longer use SpriteKit. My current renderer uses texture descriptors, however, when restoring, you can handle objects with different physical addresses. They are still playing out the true texture, since they are still referring to the same underlying texture instance.
I assume that in fact I do not see a problem with the difference pointers, provided that they still refer to the same base texture (i.e. texture memory is no longer allocated).