PDA

View Full Version : Texture memory allocation



Aurelien
10-29-2013, 06:22 AM
Hi,

I'm using a GeForce GTX 580 with driver 327.23, and I've noticed that some of my textures use a lot of memory !

After some GPU-Z memory monitoring, it seems that all my textures allocations are rounded-up to the next POT size.

For example, I allocate a 1024*1025*RGBA32F texture using glTextureStorage2D(). (no mipmap, no anisotropic filtering)

It should takes 1024*1025*4*4 = 16793600 octets = 16.015 Mo

But according to GPU-Z, it takes 32 Mo ! (next POT after 16)

I've done some tests with various sizes, and it seems to always be the case... is it the expected behaviour or did I missed something ?

Thanks

mhagain
10-29-2013, 06:29 AM
There's no expected behaviour; GL implementations are free to handle this whatever way they want.

In this case, and it's totally a guess, but I'd bet that the NVIDIA guys profiled their driver and determined that using the extra memory was a useful tradeoff and gave them higher performance.

It's also a possibility that GPU-Z is reporting the memory usage incorrectly, of course...

Aurelien
10-29-2013, 06:33 AM
In this case, and it's totally a guess, but I'd bet that the NVIDIA guys profiled their driver and determined that using the extra memory was a useful tradeoff and gave them higher performance.

I've thought about that, but if it is really the reason, it's a brute force optimization, because I have some 3D textures which should take 130 Mo and they take 256 Mo !


It's also a possibility that GPU-Z is reporting the memory usage incorrectly, of course...

Do you know anoher/better way to monitor OpenGL memory ?

Thanks.

mhagain
10-29-2013, 07:40 AM
Do you know anoher/better way to monitor OpenGL memory ?Thanks.

My standard advice is to not bother. Instead you should have a good idea of how much memory your program needs, and you set that as your minimum requirement. That's perfectly OK - it's totally unrealistic to expect to be able to target "all hardware" as there is just such a wide variety of hardware out there.

Aurelien
10-29-2013, 07:56 AM
My problem is that my application should use "in theory" less than 1Go of GPU ram, but it uses about 2Go "in real", so I can't just don't bother, because it should run without problem on a GPU with 1.5Go and it can't....

malexander
10-29-2013, 04:32 PM
If that is the case, then you should at least recommend 2G. If your textures are larger than the installed VRAM, it'll still work, just slower. There is nothing you can do about how the driver allocates memory for your textures, other than perhaps resampling to a lower power of 2 if it's close (but that's really implementation specific).