Regular 2D texture vs 3D volume texture

Regular 2D texture vs 3D volume texture

Post by Murrgo » Thu, 21 Jun 2007 01:32:10

Is there any extra overhead for using a volume texture?

For example, if I have a 128x128 image and I create a
128x128x1 volume texture from it, will there be extra memory
taken up by the fact that it is a volume compared to if I
had just created a regular 128x128 texture out of the same

Thank you

Regular 2D texture vs 3D volume texture

Post by legalize+j » Thu, 21 Jun 2007 06:33:12

[Please do not mail me a copy of your followup]

Murrgon < XXXX@XXXXX.COM > spake the secret code
< XXXX@XXXXX.COM > thusly:

I wouldn't expect the runtime performance of an NxMx1 volume texture
to be the same as an NxM texture.

You haven't stated why you want to do this, either...
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
< ~legalize/book/download/index.html>

Legalize *** hood! < ;


Regular 2D texture vs 3D volume texture

Post by Murrgo » Thu, 21 Jun 2007 23:09:29

I'm storing an array of textures representing simple sprites.
Now we want to add animated sprites and storing the frames in
a volume texture is rather convenient. Was simply wondering
if I was going to cause any grief if I also stored the simple,
unanimated sprites in an XxYx1 volume texture to keep things
simple. This way there would be no difference between an
animated or non-animated sprite.

Regular 2D texture vs 3D volume texture

Post by Jan Brun » Fri, 22 Jun 2007 01:05:07


I haven't used volume textures up to now. I think they haven't
been supported in hw for a long time.

The wasted memory for storing depth=1 volume-textures would
probably not be so enormous.

But it's probably a bit better to also use large rectangular
textures holding all frames for animated sprites:

1.) Depending on the hadware maybe better cache behaviour, because only
the actual frame has prefetch-activity. This would be am issue with
cards that optimize volume texture prefetches using 3D-blocks, what's
more likely the newer the gpu is, I'd guess.
2.) Simpler hardware texture lookup mechanism, probably resulting in
lower per-texel costs. This issue might be at least partially
"parallelized away" the newer the gpu is.

My guess would be that it's best to once allocate a large set of small
textures for as many frames as could maximally be needed at a time,
and never deallocate these small textures from the view of d3d.


Jan Bruns

Regular 2D texture vs 3D volume texture

Post by Clint East » Fri, 22 Jun 2007 01:23:49

Recent GPUs do a very good job of handling volume textures, and some
even support non-power-of-two volumes. I think there's really only
two things to be concerned about when storing your sprites in volumes:

1. On some GPUs, you will need to create your volumes as power-of-two
in size, so there may be some memory wastage depending on your sprite
2. Tri-linear interpolation (bilinear in XY, and another lerp in Z) is
generally more expensive than bilinear interpolation -- but it depends
on the texture format used and what generation of GPU you're using.
If you specify linear interpolation and are using a volume texture,
then you automatically get tri-linear sampling. Probably, you'll want
to use point-sampling if you're storing the sprites in volumes. If
it's important to smoothly up-scale the images, then storing them as
volumes is probably not a good idea.
3. At least on recent (last few years) of GPUs there's absolutely no
performance difference for point-sampling from a volume texture vs.
from a 2D texture.