Texture Memory Optimization Problem (PoT rule)

Hello , first of all, sorry for my bad english

I will explain the problem with one example:

I have an image sized 1020x1040 , and recently I read the “Conserving texture memory” guide, and understood the PoT rule. So, with an 1020x1040 image, the memory consumption should be like 1024x2048, isn’t right? (aprox 8 MB )

Then, I wanted to test the texture memory reduction resizing the same image to 1020x1020 (with PoT 1024x1024 there should be a half memory consumption)

So I print “system.getInfo(“TextureMemoryUsed”)” after load the image of 1020x1040, and then loading the image resized to 1020x1020 , and there is only a difference of 100KB, not 4MB…

I resized more and more the image, and I could see how the Texture Memory consumption was reduced only a bit each time. 

The texture memory used is exactly the size of the image, not the next PoT size as I see in the Performance and Optimization guide…

Could you check please what I tested? Am I doing something wrong, or I’m missing some info? 

I tested and obtained the same results in Corona Simulator, and in mobile devices (Android)

I’m developing an app with high detailed graphics, so it is extremely important for me to optimize the texture memory used

Thanks for the reply!!

Could someone test it or say something please? 

@hector,

There are two kinds of memory you should measure:

  • video memory
  • system memory

Now, I believe what will happen here is, when you load a new texture into ‘memory’ it will be loaded into ‘system memory’.  This is where you will see the big jump.  

Additionally, you will see a small jump in texture memory, but this only increases as you display more and more objects.

Consider this sequence:

  1. Load and display a 1024 x 1024 texture via display.newRect().
  • System Memory increases by 4MB (or a little more)
  • Video Memory increases by some small amount (lets say 2K)
  1. Call display.newRect() 1023 more times, each time using the same texture as step 1
  • System Memory increases a little bit for each call, but not by 4MB.
  • Video Memory increases by 2K each time, till we hit near 2MB of texture memory used.

Note: These are rough numbers and purely for example. 

Also, I have not run this experiment, but when I find time I will and I’ll post back if my findings are different.

For now, try measuring:

  • system memory 

    collectgarbage() – Clear first to get more accurate count collectgarbage(“count”)

  • video memory

    sysGetInfo( “textureMemoryUsed” ) / 1024

Thank you so much for your reply

Maybe I couldn’t express exactly my issue.

Anyway, I tested your reply with a 2700x3045 sprite divided in 110x110 animation image size, and the results were:

Displaying 100 animations and playing all: 

  • Initial and final system “textureMemoryUsed” were identical, not a bit bigger
  • Each animation displayed increased the garbage count by 1KB only (this is not a problem)

What I am trying to say, is I cant see that increased Memory Used, with PoT 2 Rule if I load an image or spritesheet with bigger or smaller size.

For example, in “Conserving texture memory” guide, they say:

Image(sheet) sized 350×500:

512×512 (pixels) × 4 (bytes) = 1,048,576 bytes = 1 MB

But I cant see that “1 MB” memory used, I just see in texture memory used the real size: 350x500 * 4bytes = 700 KB (not 1MB)

And I am displaying the results in Android devices… 

So I have many questions…:

  • Is still happening that OPENGL obey the PoT 2 rule? 
  • Am I missunderstanding some information?
  • Is there missing some system function that displays the real OpenGL texture usage?
  • Is there missing some information?
  • Can someone show a real demostration about this behaviour? (a code displaying what is the “Conserving texture memory” Guide saying

Please I need some Corona Developer explaining me what is happening here

And again, thank you so much for your reply

The guide that you are referencing to is outdated. the “Power of 2” (PoT) rule applied to openGL 1.x in Corona’s Graphics 1 days. Our current CoronaSDK uses openGL 2.x which doesn’t have the PoT limitation. This means the texture memory number that is returned should match the actual size of the images loaded.

  Btw, I think Corona Staffs should update your Doc. 

  I read many of them which are outdated or invalid.

Thank you for posting your question and letting us know about the PoT texture issue.

If you find other doc pages wrong or out of date, you can always provide feedback by clicking on the “Report an Issue” button at the bottom of each page. We do respond to those reports and update the docs if we confirm the problem.

Wow…

I was 1 month waiting the answer to this issue… Finally thanks for the explanation of the problem

Please, It is very important to update the documentation. For instance I have 100+ images in my game, and I could waste plenty of hours resizing animations trying to optimize the performance without any success… 

To sum up, can I request a “performance and optimization” Guide up to date? Or getting a full review on the actual guide? Maybe there are new important features. I would be very grateful, I want to optimize my app as better as possible.

Thank you!

Wait wait what??? WFT? Uhm, Tom, could you please make a BIG and CLEAR blog post about this? Your docs are superoutdated if this is true, and I want to know everything there is to know and that is affected by this as soon as possible.

Sheesh. These are gamechangers in how people structure their graphical assets and this stuff just flies under the radar? How are imageSheets affected?

Oooooh snap  :blink:  So many hours wasted :( This is kind of really important news  :huh: How can I have missed this  :wacko:

The PoT rule is still not a bad rule to follow as it’s worst case.

Once again, this change is such a big change that I feel it should be mentioned on the blog, in my opinion.

Could someone test it or say something please? 

@hector,

There are two kinds of memory you should measure:

  • video memory
  • system memory

Now, I believe what will happen here is, when you load a new texture into ‘memory’ it will be loaded into ‘system memory’.  This is where you will see the big jump.  

Additionally, you will see a small jump in texture memory, but this only increases as you display more and more objects.

Consider this sequence:

  1. Load and display a 1024 x 1024 texture via display.newRect().
  • System Memory increases by 4MB (or a little more)
  • Video Memory increases by some small amount (lets say 2K)
  1. Call display.newRect() 1023 more times, each time using the same texture as step 1
  • System Memory increases a little bit for each call, but not by 4MB.
  • Video Memory increases by 2K each time, till we hit near 2MB of texture memory used.

Note: These are rough numbers and purely for example. 

Also, I have not run this experiment, but when I find time I will and I’ll post back if my findings are different.

For now, try measuring:

  • system memory 

    collectgarbage() – Clear first to get more accurate count collectgarbage(“count”)

  • video memory

    sysGetInfo( “textureMemoryUsed” ) / 1024

Thank you so much for your reply

Maybe I couldn’t express exactly my issue.

Anyway, I tested your reply with a 2700x3045 sprite divided in 110x110 animation image size, and the results were:

Displaying 100 animations and playing all: 

  • Initial and final system “textureMemoryUsed” were identical, not a bit bigger
  • Each animation displayed increased the garbage count by 1KB only (this is not a problem)

What I am trying to say, is I cant see that increased Memory Used, with PoT 2 Rule if I load an image or spritesheet with bigger or smaller size.

For example, in “Conserving texture memory” guide, they say:

Image(sheet) sized 350×500:

512×512 (pixels) × 4 (bytes) = 1,048,576 bytes = 1 MB

But I cant see that “1 MB” memory used, I just see in texture memory used the real size: 350x500 * 4bytes = 700 KB (not 1MB)

And I am displaying the results in Android devices… 

So I have many questions…:

  • Is still happening that OPENGL obey the PoT 2 rule? 
  • Am I missunderstanding some information?
  • Is there missing some system function that displays the real OpenGL texture usage?
  • Is there missing some information?
  • Can someone show a real demostration about this behaviour? (a code displaying what is the “Conserving texture memory” Guide saying

Please I need some Corona Developer explaining me what is happening here

And again, thank you so much for your reply

The guide that you are referencing to is outdated. the “Power of 2” (PoT) rule applied to openGL 1.x in Corona’s Graphics 1 days. Our current CoronaSDK uses openGL 2.x which doesn’t have the PoT limitation. This means the texture memory number that is returned should match the actual size of the images loaded.

  Btw, I think Corona Staffs should update your Doc. 

  I read many of them which are outdated or invalid.

Thank you for posting your question and letting us know about the PoT texture issue.

If you find other doc pages wrong or out of date, you can always provide feedback by clicking on the “Report an Issue” button at the bottom of each page. We do respond to those reports and update the docs if we confirm the problem.

Wow…

I was 1 month waiting the answer to this issue… Finally thanks for the explanation of the problem

Please, It is very important to update the documentation. For instance I have 100+ images in my game, and I could waste plenty of hours resizing animations trying to optimize the performance without any success… 

To sum up, can I request a “performance and optimization” Guide up to date? Or getting a full review on the actual guide? Maybe there are new important features. I would be very grateful, I want to optimize my app as better as possible.

Thank you!

Wait wait what??? WFT? Uhm, Tom, could you please make a BIG and CLEAR blog post about this? Your docs are superoutdated if this is true, and I want to know everything there is to know and that is affected by this as soon as possible.

Sheesh. These are gamechangers in how people structure their graphical assets and this stuff just flies under the radar? How are imageSheets affected?