In trying to optimize my Metal rendering performance in the fragment shader, I've noticed that there are several ways to read from a texture, depending on the scenario. I was wondering if the texture read approach has performance implications.
Here are three different alternatives I've tried:
tex2D.read() without a sampler (uses uint2 coordinates).tex2D.sample() with pixel coordinates (uses float2 coordinates)tex2D.sample() with normalized coordinates (uses float2 coordinates).Should I expect performance differences in iOS between these options?
They are generally similar. One might require more work than another to convert between uint2 / float2 for the coordinate, but this effect should be minor.
Read has undefined behavior for reading outside the image, so that is something to consider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With