Sign in to follow this  
user88

[hlsl] functions usage

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this