• Advertisement
Sign in to follow this  

[hlsl] functions usage

This topic is 2910 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Nvidia's ShaderPerf or AMD's GPUShaderAnalizer


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement