PDA

View Full Version : how to keep textures in video card's memory?



crankygoo
01-05-2010, 02:56 PM
since when i use glTexture2D with client memory pointer, it seems it stores texture in system memory.
maybe i should use buffers to load texture into video card's memory?

ZbuffeR
01-05-2010, 03:49 PM
it seems it stores texture in system memory
And makes you think this is the case ?

Typically the GL driver will keep a "backup" copy of the texture in system memory, but it will also be copied to the GPU. Unless you get short on video ram, in this case the texture may be deleted from GPU to free some space. Whenever it is needed again, the driver will re-upload the texture from sys mem to vid mem automatically.

crankygoo
01-05-2010, 04:01 PM
got the idea, but any way to get 'video-ram-only' storage?
i like memory device context in windows that allows to keep buffers in video card memory,
dunno if it does always but i was lucky to store big bitmaps without any system memory consumption.

ZbuffeR
01-05-2010, 04:07 PM
No.
Just be sure to delete the buffer on your application side as soon you did the glTexImage, at least this avoids a third copy.

Do you have a case for this ? Like a constrained system ram and large unused video ram ?

crankygoo
01-05-2010, 04:17 PM
no constrains, i'd just like to have smaller memory consumption.
so i guess buffer objects also have system memory copies?

ZbuffeR
01-05-2010, 04:21 PM
Yes. When you map the buffer, you application is given a pointer to the driver controlled buffer, this is interesting for regularly updating a texture:
Instead of having to keep the third copy on your side, to resupply the updated texture, you just update the driver one, which then update the gpu once you unmap it.

Explanations here :
http://www.songho.ca/opengl/gl_pbo.html#map

crankygoo
01-06-2010, 04:34 AM
thanx, man :)