[hlsl] functions usage
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?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement