PDA

View Full Version : NPOTS



devdept
10-29-2008, 01:45 AM
Hi All,


Which is the OpenGL version that include the GL_ARB_texture_non_power_of_two extension? 2.0 or 2.1?

So I can write:


if (GL_ARB_texture_non_power_of_two == true ||
Opengl.Version >= 2.0)
{
LoadTexture(bitmap);
}
else
{
MakePowerOfTwo(bitmap);
LoadTexture(bitmap);
}

Thanks,

Alberto

aqnuep
10-29-2008, 02:05 AM
If you check the specifications, you can see that NPOT textures were added to the core in version 2.0

devdept
10-29-2008, 02:08 AM
Can you please send me the specification link?

Thanks.

Alberto

devdept
10-29-2008, 02:51 AM
I found this one BUT it is for OpenGL 2.1
http://www.opengl.org/documentation/specs/version2.1/glspec21.pdf

Should I believe to you or to this spec?


Thanks,

Alberto

martinsm
10-29-2008, 04:46 AM
Have you looked into your linked pdf document?
Section 3 in Appendix I clearly says that NPOT textures have been moved into core of OpenGL 2.0 (that is what Appendix I is about - v2.0).

devdept
10-29-2008, 05:33 AM
I was mislead by the document entitled OpenGL 2.1 specification.

Thanks!

Alberto

devdept
10-30-2008, 02:55 AM
Hi Guys,


I added the code to skip MakePowerOfTwo in the case the OpenGL version is bigger or equal to 2.0

The problem now is that when I load a 333x888 texture the fps drops below one and the drawing takes seconds in the line of code below.

Is there something special we need to do?


Thanks,

Alberto


gl.Begin(gl.QUADS);

gl.TexCoord2i(0, 1);
gl.Vertex2f(left, bottom);
gl.TexCoord2i(1, 1);
gl.Vertex2f(right, bottom);
gl.TexCoord2i(1, 0);
gl.Vertex2f(right, top);
gl.TexCoord2i(0, 0);
gl.Vertex2f(left, top);

gl.End(); <<<< takes seconds here

To load the texture we are doing (no need for mipmaps):


uint[] names = new uint[1];

glGenTextures(1, names);

texName = names[0];

glBindTexture(GL_TEXTURE_2D, texName);

GL_TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, data.Width, data.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, scan0);

GL_TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

martinsm
10-30-2008, 03:47 AM
If you have older ATI video card, then unfortunately it supports NPOT textures only with GL_NEAREST MIN/MAG filters (even if it supports GL2.0). Also S/T_WRAP mode should be CLAMP_TO_EDGE if I remember correctly.
I think latest ATI cards (HDxxxx) supports NPOT textures correctly with all kind of texture parameters.

devdept
10-30-2008, 03:55 AM
Oh yes, I'm using an ATI FireGL V7200 card.

So we cannot rely on this opengl 2.0 spec. Any official documentation on this issue with ATI?

Thanks so much martinsm,


Alberto

martinsm
10-30-2008, 04:59 AM
No, you can rely on opengl 2.0 spec. But you can not rely on ATI :)
I do not think this NPOT "issue" is mentioned in any official docs. But there is some information about it available here in forum.

devdept
10-30-2008, 05:40 AM
If you know how to find it, please help me.

I want to know the whole story although there is not much to do with it.

Thanks.

Alberto

_NK47
10-30-2008, 08:11 AM
so if you enable nearest filtering does it work alright?
NPOT textures are some sort of GUI related i think and do not perform filtering. the workaround would be to stick to POT textures, since you could do absolutely same things (and more apparently) but vram would be more consumed depending on how well you organize the data.

aqnuep
10-30-2008, 08:18 AM
You can rely on opengl 2.0 spec and ATI too.
The opengl spec doesn't says anything about the performance of NPOTS textures. If you check the NPOT extension's spec then you will see that it is mentioned that using NPOTS textures can be slower than POTS textures. Of course this can be understood differently by different people. Manufacturers makes their cards e.g. opengl 2.0 compatible even if some extensions run only in software mode. This is because of marketing. That doesn't has anything to do with ATI. Even NVIDIA has some hacks like these but for less relevant features.
If I would like to be honest in most of the cases there is no big advantage in using NPOTS textures. Of course you can save memory or texture detail with them, but I think it's not as crucial as some other things.

songho
10-30-2008, 11:28 AM
After read this topic, I quickly tested my ATI X1900 card. I noticed that GL_ARB_texture_non_power_of_two extension is finally added in OpenGL extension string (with v8.10 for Windows driver).

I tested mipmap filtering for NPOT textures with automatic mipmap generation token(GL_GENERATE_MIPMAP). But, mipmapping is still NOT working properly on ATI card. The visuals are corrupted when mipmapping is applied.

Here are the findings for ATI cards;
- any MIPMAP does not work for min filter. (But no performance penalty)
- GL_LINEAR works for min/mag filter.
- GL_REPEAT works for s/t wrap.

devdept
10-30-2008, 03:04 PM
aqnuep,

In my opinion a fps drop from ~300 to 0.566 doesn't correspond to a software implemented feature but to an unsupported one.

The product becomes completely unusable. My ATI card is a FireGL V7200 with ATI driver ver 8.501.0.0

I agree with the other guys, it is too risky to rely on this and there is no such a big advantage in using NPOTS textures.

Thanks,

Alberto

dletozeun
10-30-2008, 03:29 PM
In my opinion a fps drop from ~300 to 0.566 doesn't correspond to a software implemented feature but to an unsupported one.


If it was unsupported, you would not see anything and your program would not probably even run. Software fall back may be disastrous in performance terms.

dukey
11-01-2008, 11:37 AM
non power of 2 textures was added to opengl 2.0
all of the older ATI cards claim opengl 2.0 support, then simply dont bother to impliment non power of two textures

devdept
11-02-2008, 08:20 AM
Yes, this can work for marketing but for developers it's very dangerous...

Alberto