texture upload question

I asked this in the beginners forums, but have not yet gotten a response. Maybe you guys could help me out. Here’s my question:

I assume that when I call glTexImage2D () the OpenGL driver attempts to put the texture into video memory, and if it cannot, then it stuffs it into the next most likely place (AGP?). Is there an easy way to make it simply fail to upload the texture if it cannot fit it into video memory?

Originally posted by rgreene:
Is there an easy way to make it simply fail to upload the texture if it cannot fit it into video memory?

No. OpenGL is supposed to hide such details from you.

A hack:
glAreTexturesResident(…); //good luck getting reliable info from this
if (!) glDeleteTextures(…);

But what would you win this way?

I guess you don’t really want to do that. Implement a user controlled texture detail setting and be done with it.

wasn’t there a way to check for it with so called “proxy textures” ?
as far i remember, a proxy texture is a way to call your texture-allocation-code without doing any actual reservation. After this call you can determine if this texture would fit into videomem or not.

(i think this is also described in the original ogl1.1 specs)

but i am not really sure…just check out the specs and try it out.

I always thought that proxy textures are for verifying maximum texture sizes…a mechanism to check that a call to glTexImage with a “real” texture image will actually succeed. But I’ve never used proxy textures myself, so I might be wrong.

…another idea: maybe you will take also a look at the texture-priorty thing in openGL ?
this could also help you, to make sure that some textures are allways in videomem.

maybe this would solve your actual problem.
i don’t really know why you want to know where your texture is located, but i guess that’s because you have some more important textures, which have to stay always in videomem…am i right ?

in this case you could solve this problem it easier with
glPrioritizeTextures calls.

Originally posted by Asgard:
I always thought that proxy textures are for verifying maximum texture sizes…a mechanism to check that a call to glTexImage with a “real” texture image will actually succeed. But I’ve never used proxy textures myself, so I might be wrong.

as i said: i am not sure, but it might be worth to check it out. and so i suggested it.

First answer from Asgard hit the nail on the head.
There are no means to distinguish the placement of textures on user side. They are either downloaded to OpenGL somewhere or not.
Proxy textures will only report if they can be downloaded, not to which memory.
Prioritize will also only be a hint.
And all this is hardware dependent! Imagine older hardware which could only access textures in video memory. The driver needs to page them in an out for rendering.
Or your texture memory management is completely virtualized and only the necessary parts of a texture are on the board.
Or… lots of other arguments.

Thanks for the replys guys. Right now I’m working on a project that has a minumum requirment of a GF4 with 128 megs of memory, needlessly to say I have not yet filled it up with textures . However, I wanted to be able to stop textures from loading if we do hit the ceiling on, say a GF3 (which should still be able to run my app). It’s kind of a moot point, I was just wondering.

Thanks!

Originally posted by AdrianD:
[b]…another idea: maybe you will take also a look at the texture-priorty thing in openGL ?
this could also help you, to make sure that some textures are allways in videomem.

maybe this would solve your actual problem.
i don’t really know why you want to know where your texture is located, but i guess that’s because you have some more important textures, which have to stay always in videomem…am i right ?

in this case you could solve this problem it easier with
glPrioritizeTextures calls.[/b]

In a perfect OpenGL world this would work – Unfortunately I have never seen these calls work, but I’ve never tried it on an NVidia card.