HLSL keywords in inout

Started by
3 comments, last by MJP 10 years, 4 months ago

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 ?

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.

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

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

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.

This topic is closed to new replies.

Advertisement