Using Texture Arrays

Started by
1 comment, last by mark ds 10 years, 2 months ago

I'm currently binding diffuse,normal,spec etc to TEXTURE_0,1,2

Is there any downside to throwing those 3 things into a texture array per object? I save a handful of opengl calls so that is a positive, but is there any downside to having a bunch of texture arrays? My instinct would be no. But I don't know if there is some cache issue where texture unit 0 1 2 have their own cache and throwing these into a texture array changes some memory layout or something.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Advertisement

Only few details are known about the low level architecture of modern GPUs, so I may be wrong with the following.

Giving each texture unit as can be accessed in OpenGL its own cache is probably not done, because it would mean to let cache memory lounge around unused if less than the total number of texture units is in use. I think that no manufacturer will waste performance this way. Caching is usually be done with the memory address as key, which is itself independent on the unit.

Texels are rearranged when placed in GPU main memory. This is because in general there is no preferred direction (e.g. neither rows nor columns are preferred) when being sampled. So the texels are stored in tiles (2D) or blocks (3D), and these define the content that will be cached. I assume that a 2D texture array is still stored in tiles.

In summary I think that there is no penalty in using a texture array here. You could measure both ways, but that will give you a hint only for your own GPUs, of course.

As per the opengl spec:

"An array texture is a collection of one- and two-dimensional images of identical size and format"

So no, you can't... unless you use the same format for both diffuse and normals which isn't ideal, but... you could potentially use three GL_RG textures - one storing red and green, another storing blue and specular, and the third storing two components from the normal. Alternatively, use DXT5 (with spec in the alpha) and just accept some wasted space in the normal map (you only need two of the four channels).

This topic is closed to new replies.

Advertisement