pouët.net

Go to bottom

Creating a texture larger than your video ram in OpenGL

category: code [glöplog]
 
Hi all,

I'm experimenting with raymarching over large datasets and one of the problems I have (which should have been very straightforward to fix) is this:

I cannot determine whether a 3D texture that I create (through glTexImage3DEXT) "fits" in memory or not. I thought that:


glTexImage3DEXT(GL_TEXTURE_3D, 0, GL_LUMINANCE, 1024,1024,1000, 0, GL_LUMINANCE,
GL_UNSIGNED_BYTE, data);
GLenum err = glGetError();


this would return an error if it went over my available memory, but not!

Is there a safe/reliable way to:

* know how much memory (in bytes) there is left on the card memory
* know that a texture of x size will fit

I have also tried GL_PROXY_TEXTURE_3D (with glTexImage3D) but doesn't seem to make any difference.
added on the 2011-05-25 13:29:31 by Navis Navis
There's no way in core OpenGL, but if you're using nvidia you should look into GL_NVX_gpu_memory_info.
added on the 2011-05-25 13:43:13 by kusma kusma
Thanks. What about ATIs (or even intel integrated) ? I have one
added on the 2011-05-25 13:45:28 by Navis Navis
WGL_AMD_gpu_association should in theory be able to help you with ATI-gpus, but I'm just getting crashes from it. I don't know any option on Intel, but their OpenGL support is so rubbish anyway that it's probably not worth the hassle to support them.
added on the 2011-05-25 13:48:04 by kusma kusma
I can't see the amount of free memory in the WGL_AMD_gpu_association extension, only total (but that may be good enough ofcourse).
But you can use dx9 to query the amount of free memory...
added on the 2011-05-25 13:59:37 by Psycho Psycho
Psycho: True, but you can know the ball-park if you know roughly how much you've uploaded. Having 10MB free isn't the same thing as being able to upload a 10MB texture either; you often need a contiguous block of memory also.
added on the 2011-05-25 14:04:19 by kusma kusma
So how is it done so that you don't get a crash (but rather an exception or glerror or something) if you try to upload more than is there? I'm sure somebody must have worked this one out, in Opengl...

I get the mapped memory size from doing something like that:

http://stackoverflow.com/questions/341243/how-can-i-find-the-amount-of-video-ram-installed-through-a-wmi-call

although it is not always right. My 4850 has 512mb vram but I get twice that from the function above.

added on the 2011-05-25 14:20:22 by Navis Navis
One thing I've found is that the max texture size comes into play with stuff like this. E.g. on my card here, the max texture size is 4k * 4k, but that seems to be a memory limit, NOT a pixel size limit. So for 32bit/channel textures, the max texture size is just 1024x1024.

If that applies to your 3d texture too, you're probably way over the max texture size.
added on the 2011-05-25 14:34:49 by psonice psonice
(and if that's the case, and you're trying to use 1k*1k*1k of RGBA8 data, you need a card that supports 32k*32k textures, does such a beast exist?)
added on the 2011-05-25 14:39:45 by psonice psonice
Oh, you're just using luminance - in that case, if it is a memory limitation relating to max texture size, you need "just" 16k*16k texture support.
added on the 2011-05-25 14:42:02 by psonice psonice
did you try using gdebugger? it's free now.
http://www.gremedy.com/

It allows you to see all the allocated memory, free memory, buffers, textures, etc.
added on the 2011-05-25 15:22:39 by xernobyl xernobyl
1024,1024,1000

didn't 3d textures have to be power of 2 btw?
added on the 2011-05-25 16:55:06 by nystep nystep
depends on hardware support for npot i think. Also, is it not supposed to use system RAM if there's not enough space in VRAM?
added on the 2011-05-25 16:58:44 by psonice psonice
When making 1995 we encountered a feature with ATI that 3d textures had to be pow2 (opengl naturally). There wasn't a crash or anything but the texture lookup just didn't work. On nvidia it didn't matter. Don't know if ATI has improved their drivers regarding the matter.
added on the 2011-05-26 08:53:34 by pommak pommak
Quote:
Also, is it not supposed to use system RAM if there's not enough space in VRAM?

That is really slow. That's why integrated graphics using "Sideband-Memory" or something like that are bad.
And afaik textures are always in system RAM too anyway.

Btw. There is "glAreTexturesResident" and "glPrioritizeTextures", but I've never seen that working...
added on the 2011-05-26 09:58:46 by raer raer
Oh, it'll be slow as hell (especially with a 1GB texture, I've been there with an experiment I did some times back, 1GB of textures per frame, 256MB VRAM, extreme pain to the point where the computer is basically unusable while it's rendering...) But if it at least works, it helps, because you know the problem is not just lack of VRAM. (You still need 1GB of contiguous system RAM though I think, so you'd want to try this on a system with plenty of memory straight after a reboot..)
added on the 2011-05-26 10:07:12 by psonice psonice

login

Go to top