I've heard fetching a texture is quite expensive operation. But how much? like ten-times of arithmetic multiplication.
For instance, there are 3D-Look-up table technique to process an image which requires 3d texture fetch once:
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
Even if the conversion can be achieved with only some matrix and vector product in shader, can I expect that 3D-LUT is still useful in terms of performance?
3D-LUT vs matrix/vector product is just an example. What I want to know is general way to estimate the overhead by texture fetch before measuring the exact running time. Or, is there something like 'cheat-sheet' for GLSL overhead?
It's relatively expensive. If you set a texture to be filtered with 8x AF, the GPU actually has to take 64 samples of the texture for each tex2D call. It is however highly optimized to do this and in most cases you won't notice a speed difference with a situation without AF.
To sample the color of a texture we use GLSL's built-in texture function that takes as its first argument a texture sampler and as its second argument the corresponding texture coordinates. The texture function then samples the corresponding color value using the texture parameters we set earlier.
Texture sampling is the process of reading textures through the GPU. Graphics Hardware embeds a set of texture units that are able to read texture pixels directly or sample these textures using different algorithms.
A texture is an OpenGL Object that contains one or more images that all have the same image format. A texture can be used in two ways: it can be the source of a texture access from a Shader, or it can be used as a render target.
It always depends. One concern with texture fetches is memory bandwidth and - quite related to that - cache efficiency. The caching is optimized for the case where neighboring fragments access neighboring texels. I did some benchmarks, and in such a scenario, I did not even notice any difference between sampling with nearest or sampling with bilinear filter and directly using texelFetch
.
In another scenario where I used a 3D texture as color lookup, the cache efficiency became a major concern. The image content actually influences the performance significantly. My benchmark scenario was post-processing a 1920x1080 frame, and with a quite cache-friendly content (screenshot of ms office), I measured about 0.35ms for the operation, while with an image containing random noise, processing time went up to ~4ms (with bilinear filtering) or ~2ms (nearest/texelFetch
).
Of course, this depends very much on your specific scenario and the hardware, so the only advice I can give is: benchmark/profile it.
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