clip() HLSL

Started by
2 comments, last by phil_t 11 years, 6 months ago
Does clip() improves performance?
rendering a quad in a 2D texture
Is it better in performance than, using depht or alpha to discard pixels.
Advertisement
Yes, it does.
The pixel is not being written to the destination.
Alpha-blending requires a correct order of rendered meshes or even pixels, also.
Use clip only when it is necessary. Keep in mind that there are cases where clip isn't necessary such as rendering opaque geometry. Typically this leads to two permutations of the pixel shader, one with clip and another one without.

Clip may save pixels from being written to the screen buffer, but on the other hand, it may have detrimental effect on the z-buffering optimizations. So, if you absolutely need clip, call it as early as possible in the pixel shader.

Cheers!
clip() can really hurt performance if you're depending a lot of z-buffer rejection, since the pixel shader then will be run even for geometry that ends up being hidden.

This blog post has some good information on the topic: http://fgiesen.wordpress.com/2011/07/08/a-trip-through-the-graphics-pipeline-2011-part-7/

If you have no overlapping geometry in your draw call, then it might improve performance.

This topic is closed to new replies.

Advertisement