2
$\begingroup$

I am wondering is there a difference in performance between using floating point textures as my 2D float4 array vs just passing in 2D float4 arrays?

2D float arrays eliminate the need to do texture look ups to get the colour value, but i am not sure if perhaps textures have some kinda performance boost on GPUs that an array would not due to what ever clever optimisations GPUs can do.

$\endgroup$
0
$\begingroup$

It depends on what you’re doing. If any given thread of your shader is working with data from multiple nearby pixels, like by sampling from fractional between-pixel locations or doing some calculation involving a pixel’s immediate neighbors, then you should probably use a texture: the GPU can do some caching and even load multiple values in a single operation in that case. If your threads are more independent and working on individual values, an array is fine.

$\endgroup$
  • $\begingroup$ In my case i'm not using adjacent pixels, but i do a lot texture sampling, im curious if a texture sample is more expensive than just access the float array. $\endgroup$ – user10332 Mar 22 at 22:06
  • $\begingroup$ If you’re using texture filtering—i.e. reading from somewhere other than the center of any given pixel—then using the actual texture-sampling hardware for the interpolation will be faster than reading individual values and interpolating them yourself. Otherwise, I’d use an array. $\endgroup$ – Noah Witherspoon Mar 23 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.