pouët.net

Texture size questions ...

category: general [glöplog]
I've just noticed (rather late I must confess) that these days you can have textures with any size rather than 2^n. They seem to behave exactly like 2^n textures (0->1 uv coordinates). But I wonder if there is a speed penalty for using them. What do you think ?

added on the 2009-01-09 12:02:31 by Navis Navis
as a side question, why would you need them ? to have render to texture match the screen resolution ?
i doubt it makes much difference to have mesh textures not being 2^n but am i right to make this assumption?
There are plenty of (non-demo) cases where I would need them to be non power of 2.
added on the 2009-01-09 12:10:26 by Navis Navis
I don't think it makes much of a difference on current hardware.. I never noticed differences. But then again, I never really did a comparison.
on most hardware, they perform worse than normal textures under rotation and or zooming.

so they are save to use for screen-space stuff (glare etc.), but i would hesitate to use them when i expect rotation / minification / mipmapping.
added on the 2009-01-09 12:12:28 by chaos chaos
There used to be a speed penalty on older GPUs (for obvious reasons) and, at least on hardware level (Xbox for ex.) it would expect non-normalized (e.g [0-640][0-480]) UVs -- but I guess D3D or OGL has the driver solve this for you these days.

A common use is, indeed, for UI graphics 'n stuff. Especially if you have fixed res. (e.g console display 720p) it can make sense.
added on the 2009-01-09 12:13:10 by superplek superplek
chaos has it more dead on as usual :)
added on the 2009-01-09 12:15:26 by superplek superplek
Be careful if you use them. I know that lots of ATI OpenGL implementation lets you use non power of two textures and the driver silently falls back into software-rendering if you do anything but simple blits with them.

Happens on cheap ATI cards as used in office computers.
added on the 2009-01-09 12:23:54 by torus torus
Navis: size is not important, the important thing is how you use it.
added on the 2009-01-09 12:25:12 by texel texel
opengl for 2d graphics...

I have seen a diagonal artifact when using npot textures+bilinear filtering, where the texels correspond to pixels and where the texture is clipped to the window rect.

Using pot textures and the artifact goes away. I have filed a bug report to apple.
added on the 2009-01-09 12:26:40 by neoneye neoneye
Quote:
on most hardware, they perform worse than normal textures under rotation and or zooming


heh you are still thinking about zoom rotators aren't you ;).

The only problems with npot textures is that mipmaps may take more memory than they should (it depends on implementation). Another problem is with DXT compression - I round to even both width and height. As for the performance - I really didn't found a case when it was a serious bottleneck. On the other hand it saves some work to artists and they will not mumble you about upscaling/downscaling artifacts.
added on the 2009-01-09 12:48:26 by bonzaj bonzaj
Quote:

Using pot textures and the artifact goes away. I have filed a bug report to apple.


just draw a giant triangle and align topleft, problem gone as well :) this is just caused by draw/sampler hardware implementation.

bonzaj: mipmaps for npow2 textures? never really used them (for reasons such as chaos mentioned). dxt'ing non pow2 textures it not an often seen usage pattern either (slight overhead no problem).

Quote:
Navis: size is not important, the important thing is how you use it.


hihi :)


added on the 2009-01-09 12:56:26 by superplek superplek
Size matters, click here to enlarge your <insert anything you talk about>
I encountered the problem torus described too. When it comes to OpenGL this is bad, because it is reported/expected to be supported in hardware, but it isn't and you have no way of detecting that... sucks.
added on the 2009-01-09 13:42:52 by raer raer
There's no good reason for NPOT-textures to perform worse than POT-textures. What Chaos describes sounds like the lack of texture-interleaving that earlier GPUs had for these textures - I don't think this is the case any more (at least I know very well of some GPUs where it isn't :P). To be able to effectively interleave textures, the pitch must be dividable by some small POT value (8, 16, 32). Luckily, the driver has the ability to choose the right pitch.

In fact, if you need to up-scale or pad an image to make it fit in a POT-texture, you're loosing some performance compared to NPOT-textures.
added on the 2009-01-09 13:50:27 by kusma kusma
so is it safe to say that modern cards (nvidia series 9 and those 260 280) as well as ati are safe ? or are ati prone to fail
added on the 2009-01-09 14:20:30 by Navis Navis
ati prone to fail for sure.
added on the 2009-01-09 14:22:09 by panic panic
I'm using NPOT textures in OpenGL since 2005 (for screen space effects mostly) and they seem to work very well, no problem at all. Navis, it's safe to do it evne in my (now 5 years old) AGP Radeon9800. I think it was ATI who implemented them first, nvidia waited for the 6 series afair.

For regular material textures I don't know. I guess it must be a nightmare to do mipmapping in a 1021 x 719 texture for example...?
added on the 2009-01-09 14:35:05 by iq iq
Non-Power-Of-Two-Textures are internally nothing else than a 2^(n+1)-Texture with the rest of each scanline left blank.
Of course a 2^n texture is smaller and thus performs better.
added on the 2009-01-09 14:45:03 by hfr hfr
lazy-san: nope.
added on the 2009-01-09 15:12:19 by smash smash
lazy-scan, are you sure of that?

Navis, I forgot about one practical restriction we found here at work with npots: in nVidia hardware don't work correctly if texture resolution is not a multiple of 4.
added on the 2009-01-09 15:13:04 by iq iq
Quote:
I think it was ATI who implemented them first


gf3 gpu could do it just fine as well. but, as kusma described, without the interleaving and just pure linear mem layout (hence 'linear textures' moniker back then).
added on the 2009-01-09 15:14:13 by superplek superplek
In '1995' some ATI cards crashed when our 3D texture depth wasn't a power of two so we had to insert empty textures to make it so. IIRC we've had some problems with npot 2d textures when used with glsl (ATI of course). With screen space effects (framebuffers) we've had no problems.
added on the 2009-01-09 15:18:08 by pommak pommak
iq: non-power-of-2 textures are not just subregions of power of 2 textures, no. if you load a non-pow2 texture with d3dx's load texture functions x it can however extend it to be a power of 2.
if you generate mipmaps for them, the next mip level down is extended to pow2, if i recall correctly.
dxt is only possible if the dimensions are multiples of 4.
added on the 2009-01-09 15:20:05 by smash smash
there's something about extra padding when using non-pow2 mipmaps as well afair. but that's driver/hw level.
added on the 2009-01-09 15:21:39 by superplek superplek

login