Jump to content
  • Advertisement
Sign in to follow this  
user88

[hlsl] functions usage

This topic is 3117 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
Thanks for fast answer, Adam. Now i can start move all duplicated code to functions with no any doubt..

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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!