[Bug]Caching textures and stuff

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

[Bug]Caching textures and stuff

Post by DtD »

I was under the impression that if you had already loaded a texture (EG: "bricks.jpg") then Irrlicht would not load it again. However, when testing various things, I noticed that the game lagged significantly when I spawned a cube that used a 1 MB texture as opposed to a 852 Byte texture.

Is Irrlicht doing something weird or am I mistaken?

Also, from the documentation of irr::video::IDriver::getTexture
Loads the texture from disk if it is not already loaded
My code specifically:

Code: Select all

node = ares->getSmgr()->addCubeSceneNode(1,0,-1,core::vector3df(0,10,0));
node->setMaterialFlag(irr::video::EMF_LIGHTING,false);
node->getMaterial(0).setTexture(0,ares->getDriver()->getTexture("redbricks_color.jpg"));
Any help is greatly appreciated. :)

~DtD
Last edited by DtD on Sat Dec 12, 2009 4:48 am, edited 1 time in total.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Your question is a little incoherent. First of all, are we really talking about a 1,000,000 byte texture versus a 852 byte texture? If so, the lag is to be expected when loading one versus the other.

Furthermore, textures are cached, meaning that any subsequent calls to load the same texture after the first initial call will not read from the disk, but instead increase the reference count of the already loaded texture and use that.

Given your code example, you are only calling getTexture() once. Thus it loads the texture from disk as it should since it has not already been loaded. And as I said above, loading a 1 million byte texture versus a 852 byte texture will always result in a little more latency since you're loading 999,148 more bytes from a file.
Last edited by Halifax on Sat Dec 12, 2009 3:34 am, edited 1 time in total.
TheQuestion = 2B || !2B
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Funny thing is that I found a bug in that yesterday which has been in Irrlicht for a long time without anyone noticing. In short - if you use a FolderFileArchive, then caching won't work. I'm currently investigating if there are more problems, because I noticed I have the same problem with the textures of my truetypefonts even though they don't use the FolderFileArchive.

Bug-report is here: http://sourceforge.net/tracker/?func=de ... tid=540676
And we found the problem in the other tests which first succeeded also by now.

No solution yet - it turns out it's not that trivial to fix and I also need to debug first why I get similar problems with my font-textures unless we ignore something. But we're working on it.

If you're problem is another one, then a test-case would be appreciated.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

@Halifax
Sorry if I wasn't clear. It lags on subsequent calls, not just the first one.

@CuteAlien
That is my problem exactly! I removed the file folder archive (which I had added just to test the function in Irrlicht) and referenced the image exactly and it no longer lagged!

~DtD
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I've added a fix to svn. But it's more a proposal, lets see what others in the team think of it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply