Texture memory usage

  • Follow


How to accurately compute the memory used by a texture ?
I do the following (for RGB 2D textures):
{
 GLint red, green, blue, alpha, width, height;
 glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width
);
 glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
&height );
 glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red
);
 glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE,
&green );
 glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE,
&blue );
 glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE,
&alpha );
 int nPixelMemorySize = ( red + green + blue + alpha );
 int nTextureMemoryUsage = ( width * height ) * nPixelMemorySize / 8;
}

but it looks like it takes more memory than this is used (if I can
trust the Windows Task Manager !)

Any hints ?
0
Reply jaz 1/22/2004 10:29:16 AM

jaymz wrote:

> How to accurately compute the memory used by a texture ?
> 

There's all sorts of complications, including mipmapping,
and anisotropic filtering.

> but it looks like it takes more memory than this is used (if I can
> trust the Windows Task Manager !)
> 

LOL!

He said "trust the Windows Task Manager"!!!



-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


0
Reply fungus 1/22/2004 10:52:05 AM


"jaymz" <jaz@boursorama.com> wrote in message
news:b27c2a59.0401220229.5455562d@posting.google.com...
> How to accurately compute the memory used by a texture ?
> I do the following (for RGB 2D textures):
> {
>  GLint red, green, blue, alpha, width, height;
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width
> );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
> &height );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red
> );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE,
> &green );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE,
> &blue );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE,
> &alpha );
>  int nPixelMemorySize = ( red + green + blue + alpha );
>  int nTextureMemoryUsage = ( width * height ) * nPixelMemorySize / 8;
> }
>
> but it looks like it takes more memory than this is used (if I can
> trust the Windows Task Manager !)
>
> Any hints ?

yes, dont trust Task Manager!
Allan


0
Reply Allan 1/22/2004 11:23:07 AM

> but it looks like it takes more memory than this is used (if I can
> trust the Windows Task Manager !)
how do you seperate texture memory usage from the memory used by the rest of
your application in task manager???


regards,
severin


0
Reply Severin 1/22/2004 3:34:25 PM

"jaymz" <jaz@boursorama.com> wrote in message
news:b27c2a59.0401220229.5455562d@posting.google.com...
> How to accurately compute the memory used by a texture ?
> I do the following (for RGB 2D textures):
> {
>  GLint red, green, blue, alpha, width, height;
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width
> );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
> &height );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red
> );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE,
> &green );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE,
> &blue );
>  glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE,
> &alpha );
>  int nPixelMemorySize = ( red + green + blue + alpha );
>  int nTextureMemoryUsage = ( width * height ) * nPixelMemorySize / 8;
> }
>
> but it looks like it takes more memory than this is used (if I can
> trust the Windows Task Manager !)
>
> Any hints ?

Don't mess with it... It depends on driver. Some OpenGL implementations make
copy of texture in system memory. Memory usage can be twice more than you
expect.

yooyo



0
Reply news 1/22/2004 3:41:09 PM

news.individual.net wrote:
> 
> Don't mess with it... It depends on driver.

Yep.

> Some OpenGL implementations make
> copy of texture in system memory.

Ummm...make that "all of them. OpenGL needs to be able
to re-upload the texture to the graphics card if the
texture is lost for any reason (texture paging, other
programs using the graphics card, etc).


-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


0
Reply fungus 1/22/2004 11:54:11 PM

The problem is that I have a 3D texture cache. And I want to know when
to flush it, that means when the amount of memory used by 3D texture
reach a certain level, to avoid swapping memory to disk.
For that, I need to know how much one texture cost in main memory
(let's say I don't care about the on-board memory, it's a bonus)
When I ask openGL (as detailed in the first message), I get an
estimate of memory, but when I create the texture, the f*** task
manager shows that more memory is really used. And it looks almost
real, as Windows start swapping although my cache is not yet full (and
its size is 30% of system RAM, so it should fit as it's the only app
running)

So, whatever the driver or texture configuration (in my case, I do not
use mimapping or anything else), as I want to ask the driver how much
memory it took for a given texture.
That's it... 
No one ever used a 3D texture cache ?
0
Reply jaz 1/23/2004 8:32:04 AM

jaymz wrote:
> The problem is that I have a 3D texture cache. And I want to know when
> to flush it, that means when the amount of memory used by 3D texture
> reach a certain level, to avoid swapping memory to disk.
> For that, I need to know how much one texture cost in main memory
> (let's say I don't care about the on-board memory, it's a bonus)
> When I ask openGL (as detailed in the first message), I get an
> estimate of memory, but when I create the texture, the f*** task
> manager shows that more memory is really used. And it looks almost
> real, as Windows start swapping although my cache is not yet full (and
> its size is 30% of system RAM, so it should fit as it's the only app
> running)
> 
> So, whatever the driver or texture configuration (in my case, I do not
> use mimapping or anything else), as I want to ask the driver how much
> memory it took for a given texture.
> That's it... 
> No one ever used a 3D texture cache ?

If you're concernd about swapping, why not just not set the heap of the 
application to non swapable and watch the free heap space.

Wolfgang

0
Reply Wolfgang 1/23/2004 5:18:08 PM

7 Replies
232 Views

(page loaded in 0.554 seconds)

Similiar Articles:













7/23/2012 4:42:03 PM


Reply: