Performance advantage of using TextureArray over array of textures?

Let's say I have an nbFramesAnimation * 3 float4 Texture2D that I want to pass to my GPU and:

  • I don't need to interpolate between textures;
  • The textures are the same size;
  • I don't know if this matters, but I don't have any mip cards;

I use these textures as a G-buffer to which I apply some post-effect. So I might need to access them with a non-literal expression for the index. Also, since I use them as G-buffers, I have to load them very often. They give me positions and normal data, which should be accurate, and UV + IndexObject (only 3 of 4 floats are effectively used this way).

Now, for each render frame, I load three textures individually using SetResource. It is very slow and far from real time.

I wanted to know if:

  • It is more efficient to have an array of Texture2DArrays, each Texture2dArray has three textures (in my case) and pass one Texture2DArray in each frame;
  • Or is it the same as passing 3 separate Texture2Ds ?;
  • It would be more efficient to do multiple nbFramesAnimation / X * 3 texture textures and load one of them on every X frame.

I would also like to get an idea of ​​how I can further optimize this transmission.

+3


source to share


1 answer


Texture2DArray

were introduced to make it easier to link multiple textures with a similar purpose that go together but do not represent the whole as a volume (in other words, no need for trilinear interpolation). Depth indexing is used to access different parts of an array.

Similar to the notion of an array in C ++ (or any other language under the sky), the goal is to allow dynamic indexing, which is not possible with multiple separate ones. Performance considerations don't go beyond the cost of binding items to the pipeline, it's a matter of convenience, not clogging up anchor points.



With DirectX 12, the latter consideration has been removed with the introduction of an unbound model and things like descriptor heaps where you can swap a metric ton of almost any shader-related resource with pre-computed root signatures. Further still with "infinite" descriptor ranges and dynamic indexing introduced with the HLSL Shader Model 5.1. Interesting stuff.

Either way, don't worry about performance in between. Worry about the grace of your job. If stuff goes together and your design requires sampling all of them at some point, group them inside Texture2DArray

.

+4


source







All Articles