Do Bitmap Masks Consume Texture Memory?

Trying to work out where my texture memory is being used and don’t know if bitmap masks consume texture memory or not.

I calculated my masks should consume 15 MB of texture memory (230 individual image files by 65 KB each [they are about 128 px x 128 px] is about 15 MB) but when I modified my app to not use any masks, the texture memory reduction was only about 4 MB.

Hi Steve,

I’m not an “authority” on texture memory and low-level OpenGL, but according to a test I just did, bitmap masks do occupy texture memory. However , not at the full 4-layer" depth of RGB+A. I believe Corona converts bitmap masks internally to just 1 “channel”, so they take up 1/4 the texture memory as a normal image.

These are my figures:

  1. Bitmap mask image NOT yet converted to a mask using “graphics.newMask()”:

512 (width) x 512 (height) x 4 (RGB+A “layers”) = 1048576

1048576 / 1024 / 1024 = 1 MB texture memory!

  1. Same bitmap mask image converted to a mask in Corona:

512 (width) x 512 (height) = 262144

262144 / 1024 / 1024 = 0.25 MB texture memory!

So, this stands to reason, that if you load in ~15 MB of bitmap image texture memory, then convert them all to masks, you should be using 1/4 of that amount. Not sure why you’re getting just a 25% reduction. Can you check all of your calculations again to make sure?

Thanks!

Brent Sorrentino

Hi Brent,

I’m using storyboard.printMemUsage() to check the texture memory usage. I suspect there’s maybe more going on than my (simple!) understanding.

What you said makes sense though - a black & white mask would only need one channel.

Thanks!

Stephen.

Hi Steve,

I’m not an “authority” on texture memory and low-level OpenGL, but according to a test I just did, bitmap masks do occupy texture memory. However , not at the full 4-layer" depth of RGB+A. I believe Corona converts bitmap masks internally to just 1 “channel”, so they take up 1/4 the texture memory as a normal image.

These are my figures:

  1. Bitmap mask image NOT yet converted to a mask using “graphics.newMask()”:

512 (width) x 512 (height) x 4 (RGB+A “layers”) = 1048576

1048576 / 1024 / 1024 = 1 MB texture memory!

  1. Same bitmap mask image converted to a mask in Corona:

512 (width) x 512 (height) = 262144

262144 / 1024 / 1024 = 0.25 MB texture memory!

So, this stands to reason, that if you load in ~15 MB of bitmap image texture memory, then convert them all to masks, you should be using 1/4 of that amount. Not sure why you’re getting just a 25% reduction. Can you check all of your calculations again to make sure?

Thanks!

Brent Sorrentino

Hi Brent,

I’m using storyboard.printMemUsage() to check the texture memory usage. I suspect there’s maybe more going on than my (simple!) understanding.

What you said makes sense though - a black & white mask would only need one channel.

Thanks!

Stephen.