PDA

View Full Version : NPOTs - support / limitations etc.



James Lohr
09-19-2009, 04:48 AM
In the past I used to pack my textures into POTs, however I'm told that this is fairly redundant with NPOTs supported by most cards.

So, what exactly are the limitations of NPOTs? - I know they don't support repeat wrapping, but I'm used to this with my own packed textures anyway. Are there any other limitations?

How about support? - how old does a graphics card need to be to not support NPOTs?

Ilian Dinev
09-19-2009, 05:01 AM
>>How about support? - how old does a graphics card need to be to not support NPOTs?
Radeon 9550 . That card also includes the arb_texture_rectangle capability.

Jan
09-19-2009, 05:03 AM
"I know they don't support repeat wrapping"

Wrong. Rectangle textures don't support that. NPOT textures are just 2D textures that have NPOT dimensions, there are no limitations whatsoever.

The main reason to still keep an eye on POT dimensions is performance. NPOT textures are a bit slower, because the GPU needs to do more computations.

Rectangle textures are an entirely different species and should only be used for specific tasks.

I think NPOT textures are supported since the Geforce 6. But on those early cards they are much slower.

Jan.

James Lohr
09-19-2009, 05:16 AM
<quote>The main reason to still keep an eye on POT dimensions is performance. NPOT textures are a bit slower, because the GPU needs to do more computations.</quote>

How much slower? Also, when exactly and why? - suppose I'm not using mipmapping nor using any sort of repeat wrapping, will my NPOTs still be slower?

Lets suppose I have a very large texture (1280x1024), and it makes sense to use an NPOT (because 2048x1024 would waste a lot of memory as padding) - will to be significantly slower to render this very large texture?

Simply saying that they are slower isn't enough information to go on in making the decision.

If, by converting from my packed POTs to NPOTS, I'm trading in a bit of memory for the sake of performance, then that sounds like a very poor trade indeed.

[edit]

Haha! I make this thread, then 20 minuates later I google for "opengl performance of npots" and this very thread is the first link! Google getting faster or what? :eek:

Jan
09-19-2009, 05:32 AM
Can't tell you exactly how much slower, i never tested it. However you have to distinguish between rectangle and NPOT textures. Just take a look at these specs:

http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt
http://www.opengl.org/registry/specs/ARB/texture_non_power_of_two.txt

If rectangle textures fit your needs, use them (no mipmapping, only nearest or bilinear filtering, only clamp mode, not-normalized texture-coordinates) then use them. If however you use your texture just like you would use any other 2D texture, then go for a 2D NPOT texture. Wasting so much memory should almost never make sense these days, it is not THAT much slower.

My point was, don't make your texture NPOT, when it is easy to make them POT. For example, if you have normal textures, it doesn't matter whether they are 1000*1000 or 1024*1024, because you use them for normal texturing. But you should make them POT to gain more speed. However, if you have something else, like a render-target, so that you actually need it be exactly x*y pixels in size, then using a rectangle or NPOT texture makes sense.


Yeah, google is pretty amazing in this regard.

Jan.

James Lohr
09-19-2009, 06:14 AM
Thanks very much Jan. Unfortunately texture_non_power_of_two.txt doesn't really talk about performance.

As a bit of background, let me explain my reasoning for wanting NPOTs: the game I'm writing is essentially 2D. For cleanest looking results, I want a 1:1 mapping from texels to pixels. So, to support multiple user resolutions, I first downsample my master textures in software (using an expensive but high quality downsampler) such that texture sizes give a 1:1 mapping to screen pixels. It is then these downsampled textures that I load as OpenGL textures.

This gives much better results than what most games do for varying texture quality which is to simply change mipmap levels.

Note: Obviously this would be meaningless in a 3d game where the mapping from texels to pixels is constantly being transformed, and so maintaining a 1:1 mapping is not even remotely imaginable.

[edit]:

Just tested, and on my computer there's less than a 1% difference in render speed between POTs and NPOTs. :)

Jan
09-19-2009, 08:07 AM
If you are working in 2D rectangle textures are often very convenient. However, if NPOT textures are easier for you to handle, don't bother about the performance difference. I assume you are not using many textures. If you literally use hundreds of textures, i would think carefully about whether to use it or not, but with only a handful of textures, go for the one that is easiest for you, performance won't be a problem.


Jan.