PDA

View Full Version : Weird Texture Creation Failure



ronag
09-21-2010, 02:00 PM
Im creating textures of different sizes in my application. Which doesn't seem to be a problem most of the time(which you would expect).

However I have a case where when i once create a texture with the size 720x576, I can no longer create texture with the size 1280x720. In order to get around this I have to create all my 1280x720 first. This is a somewhat weird problem.

I have not tested with other texture sizes.

I get the error code 1282, invalid operation i believe it is?



glGenTextures(1, &texture_);
GL_CHECK();

glBindTexture(GL_TEXTURE_2D, texture_);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
GL_CHECK(); // 1282


What might be causing this?

glsl09
09-21-2010, 02:35 PM
if you dont use texture rectangle. your texture width and height must be power of two
512*512
1024*1024....

ZbuffeR
09-21-2010, 02:47 PM
Memory fragmentation ?
Compare an estimate of the vram used by your texture to the actual vram. If it is near, then creation/destruction order may well be relevant. Create largest textures first, if you can.
Do you destroy textures also ?

@glsl09 : 3 wrongs in your post :
1) nothing to do with texture rectangle, but with Non Power Of Two (NPOT) textures. Rectangle is a much more limited form of NPOT, without mipmaps and non-normalized texture coordinates
2) as the original poster said, it works with a different creation order, so this is not about "must" or "must not", as the hardware clearly supports NPOT textures
3) Power Of Two does not mean that width and height must be the same. Your confusion is due to rectangle texture, which is a misnomer. Ie 2048*1024 is perfectly legal POT even for GL 1.x

ronag
09-21-2010, 02:54 PM
No I do not destroy textures. They are pooled.

I guess I will have to fill the pools with enough texture in size order, and simply disallow any more texture creations.

EDIT:

I only create these 2 rather small textures in the entire application when i get the error... so I don't see how vram memory could affect it?

ronag
09-21-2010, 03:31 PM
My problem is that some texture are create at runtime with sizes I cannot know beforehand.

How could I solve this?

ZbuffeR
09-22-2010, 06:36 AM
Please provide the answer to my second question, about memory usage.

Put GL_CHECK() after each GL call, to be sure to catch the good one.
Then read the relevant section in the man page, example for glTexImage2D :
http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml

"Is it between glbegin/glEnd" etc

macarter
09-22-2010, 06:38 AM
Sounds like a driver bug. Here are approaches I have used.

Solution 1: Create the simplest example that reproduces the problem and submit it to your driver vendor and wait for a fix.

Solution 2: Experiment and hope to find a way around the driver bug.

I often try both approaches. Occasionally you may find your own mistake in the process.

Have you tried using GL_CLAMP_TO_EDGE instead of GL_CLAMP?

RefleX
09-22-2010, 06:55 AM
Update your video drivers. This ensures that you using the latest GL version for your current card. I've noticed that drivers can mess up if you run opengl apps vigorously during testing. Reinstalling them fixed the problems for me.

What is the specs of your system?

ronag
09-22-2010, 07:16 AM
Will try all suggestions as soon as i get time. It is not between glBegin, glEnd

My specs are:

Nvidia Quadro FX1700M

Driver Version: nv_4disp 6.14.12.5896 (Forceware 258.96) / XP

EDIT:

Should I maybe also ask this question on NVIDIAs forums?

ronag
09-22-2010, 07:35 AM
Please provide the answer to my second question, about memory usage.

Put GL_CHECK() after each GL call, to be sure to catch the good one.
Then read the relevant section in the man page, example for glTexImage2D :
http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml

"Is it between glbegin/glEnd" etc


I suppose you mean


Compare an estimate of the vram used by your texture to the actual vram. If it is near, then creation/destruction order may well be relevant.

Not sure how I would do this. Could you please explain how vram can affect this issue? Ive got 512mb video memory, soo creating two small texture shouldn't be a problem?

ZbuffeR
09-22-2010, 07:49 AM
2 small textures is not a problem, but a load of textures + 2 small textures may be.
So, how much "load of textures" do you have ?

ronag
09-22-2010, 09:34 AM
No other textures loaded. Only the small first and then the large and then it crashes.

Driver update solved the problem.

ZbuffeR
09-22-2010, 12:11 PM
You had pretty recent drivers, I am really surprised such a simple case had a bug.

Good to know.

RefleX
09-23-2010, 12:11 AM
I've had problems with that driver. It seems to mess up after running an OpenGL app countless times. My fix was to reinstall the exact same driver and it was fixed.