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.
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.
There's no way in core OpenGL, but if you're using nvidia you should look into GL_NVX_gpu_memory_info.
Thanks. What about ATIs (or even intel integrated) ? I have one
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.
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...
But you can use dx9 to query the amount of free memory...
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.
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.
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.
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.
If that applies to your 3d texture too, you're probably way over the max texture size.
(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?)
GL_ATI_meminfo
http://www.opengl.org/registry/specs/ATI/meminfo.txt
http://www.opengl.org/registry/specs/ATI/meminfo.txt
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.
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.
http://www.gremedy.com/
It allows you to see all the allocated memory, free memory, buffers, textures, etc.
1024,1024,1000
didn't 3d textures have to be power of 2 btw?
didn't 3d textures have to be power of 2 btw?
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?
Use Windows Management Instrumentation?
http://msdn.microsoft.com/en-us/library/ee419018%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/ee419018%28v=vs.85%29.aspx
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.
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...
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..)