Why is irrlicht storing the textures 3 times in directX?????

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
Pr3t3nd3r
Posts: 186
Joined: Tue Feb 08, 2005 6:02 pm
Location: Romania
Contact:

Why is irrlicht storing the textures 3 times in directX?????

Post by Pr3t3nd3r »

I believe that irrlicht is storing the texture 2 times when using D3DPOOL_MANAGED. (one time in system memory and one time in video memory)
And is keeping the texture the third time ( device independently ) in the Image pointer.
The image pointer is useful for creating the direct x surface but after that i believe is completely useless. (i see that openGl is not keeping any image pointer ...)

I removed the Image->grab();
and
if (Image)
Image->drop();

The result is that the application is using now 200M (from 400M). And can run even on the systems on what it was beginning to have an very low fps ...
And no functionality seems to be affected. (alt+tab etc)

Please be free to verify if I'm right!
And now maybe i get credits in the irrlicht files for finding this bug. (if i'm right ) :lol:
Galactic Dream Best RTS game
http://www.rageofwar.net
Engage in epic galactic warfare, guide your people through the galaxy! in the real time strategy game made with Irrlicht
http://www.evolutionvault.com
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I would say it depends. If loading a texture from a file, I believe the engine creates an IImage from the file. Then creates a deviceDependent texture and copies that IImage data into the texture. Aren't there some ways where the IImage is just passed to the getTexture call? I'll have to double check the API.
Image
Pr3t3nd3r
Posts: 186
Joined: Tue Feb 08, 2005 6:02 pm
Location: Romania
Contact:

Post by Pr3t3nd3r »

I think the IImage data is only left a pointer to it in the directX texture. (of curse is private and no method for later access, and is only used at creation).

But in the OpengGl texture is not even keeping the IImage ... is just using it to create the deviceDependent and let it be trowed away.
(of curse the pointer to the image form the directX texture is not useful and need to be removed too)

From my check i didn't find any place where the IImage to be used (except at the creation of the surface)...

Any way keeping the image 2-3 times ... is really requiring much more memory ... the performance boost on my application is really visible on the systems with low memory ... (when the swap begin to be used as memory for textures ... the fps drops ... to 1-2 ...)

Also all my tests didn't show any bad behavior ... losing textures, etc ...

I believe Niko can clarify this faster ... why this error got in to the code. (i believe he initially was thinking at manually restoring the lost surfaces ...
or maybe was necessary in directX 8... not sure ...)
Galactic Dream Best RTS game
http://www.rageofwar.net
Engage in epic galactic warfare, guide your people through the galaxy! in the real time strategy game made with Irrlicht
http://www.evolutionvault.com
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

It will be necessary when DeviceLost state is correctly handled (as textures are then recovered from images. And OpenGL also has an IImage stored, it's just shattered into pieces: All elements of IImage are also in the texture (except for one I don't remember for the moment), I just did not have the time to put it into an IImage.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

hybrid wrote:It will be necessary when DeviceLost state is correctly handled (as textures are then recovered from images.
If D3D is managing a texture then it's a waste to have irrlicht keep the bits around as well. It's a bug.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes, it is a bug. The textures are currently created in the D3DPOOL_MANAGED pool [see docs]. This means the D3D runtime keeps a copy in system memory and uploads it as needed. There is no need to keep the additional in memory copy.

Travis
Grey Lantern
Posts: 34
Joined: Sat Jul 30, 2005 9:45 am
Contact:

Post by Grey Lantern »

I may sound like a dummy but is this fixed in v1.2? It sounds nasty.

scrub that, just checked the svn patches tracker and it was only added on 2006-12-01 so I guess it's still pending.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, it's neither fixed nor is there someone to work out the proper code changes, yet. However, it's just system mem which is usually not really the main problem.
Post Reply