Author Topic: Better texture manger  (Read 969 times)

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Better texture manger
« on: June 18, 2012, 04:21:37 am »
I've had a couple of out of memory issues(outside of JPCT) and doesn't help that I keep all my textures in memory for fast reloading. So was looking into this: http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html

But wondering if JPCT should have more advance texture manager options built in.

-If the app runs low on memory it will use the new virtualizer class for textures.
-If it still is out of memory then resize the textures down(largest first) until there is enough free memory.
-If textures are too small and still out of memory then unload unused textures until memory enough memory free.

Extra
-Have priority options for which textures should be resized smaller first.
-No longer use virtualizer once you get enough free memory back.
-If the textures been resized to be smaller previously, resize them back up if there is enough free memory(maybe resume only).

Such options would help me so much and I believe would help everyone else too.
« Last Edit: June 18, 2012, 04:24:31 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: Better texture manger
« Reply #1 on: June 18, 2012, 08:27:34 am »
While i understand the idea, i tend to leave this to the application instead. One problem would be that in the case of low memory, it's actually to late to solve the issue by rescaling the textures because you would get a peek in memory usage while doing so...and because you actually don't have this memory available, you would write some complex rescale-on-low-memory-logic that might actually cause more problems than it fixes. In my opinon, the application should detect the environment it's running on and use the appropriate set of textures.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Better texture manger
« Reply #2 on: June 18, 2012, 09:21:19 am »
Maybe I'll give it a go if I get spare time at work.

Quote
One problem would be that in the case of low memory, it's actually to late to solve the issue by rescaling the textures because you would get a peek in memory usage while doing so
Following like the above link I would have it using X% amount of heap which the user can set. Therefore should allow resizing without any problems. Of course it's not perfect but I believe it would minimise out of memory issues.

Quote
the application should detect the environment it's running on and use the appropriate set of textures
That's what I'm doing, a lot of work and testing was needed and its perfect enough now for the little 3d we have got. However for me lots can happen outside the JPCT code and that's where the out of memory issues are happening and freeing textures will help.