[hlsl] functions usage

Started by
3 comments, last by user88 14 years, 1 month ago
Hello everybody! There are places in my hlsl effect file where some code is duplicates. As i know hlsl allow to define functions where i can move duplicated code. Question: will performance decrease with functions usage in compare to use duplicated code snippet?
Advertisement
Performance should be the same - all functions calls will be inlined at compile time.

If you want to test it to be sure you can use a tool like Nvidia's ShaderPerf or AMD's GPUShaderAnalizer.
Thanks for fast answer, Adam. Now i can start move all duplicated code to functions with no any doubt..
Quote:Original post by Adam_42
Performance should be the same - all functions calls will be inlined at compile time.


Technically it's possible for the compiler to use a "call" instruction instead of inlining. However, I've never actually seen it happen. If you want to be sure about these things, you should always have a look at the compiled assembly. And of course ShaderPerf + GPUShaderAnalyzer are invaluable tools.

Quote:Nvidia's ShaderPerf or AMD's GPUShaderAnalizer


never heard about such tools. interesting, i will have a look..

This topic is closed to new replies.

Advertisement