Jump to content
  • Advertisement
Sign in to follow this  
ryt

HLSL keywords in inout

This topic is 2142 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

For what are used in CG and HLSL keywords in and inout ? I did find the list on internet of keywords in shading languages but not explanation of their use.

Are they maybe the same as in c# like ref and out ?

Share this post


Link to post
Share on other sites
Advertisement

'in' IIRC, denotes a vertex input going into a main function in CG.

'out' acts just like 'out' in C#, no value is passed into the function, but the function must write a value to it, which then gets passed back to the calling function.

'inout' acts like 'ref' in C# as you guessed, the argument gets passed both ways, allowing the function to read and modify the value.

Share this post


Link to post
Share on other sites

Considering performance I suppose that is best than to use "inout" so parameters don't get copied.

Edited by ryt

Share this post


Link to post
Share on other sites

Using "in" doesn't mean that values always get physically copied from one register to another, it means that any changes to the value won't be visible to the calling code. This *may* require the compiler to allocate another register and copy the value to it if you do decide to to change the value of the parameter, but if you don't change it then the compiler is perfectly capable of detecting that and will generate code that avoids any copies.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!