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 ?
Jump to content
Posted 08 December 2013 - 04:17 PM
'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.
Posted 08 December 2013 - 05:39 PM
The documentation for those HLSL keywords can be found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb509606%28v=vs.85%29.aspx
Posted 09 December 2013 - 02:21 PM
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.