Inout parameters GLSL functions

Hello everybody,

I was wondering about the performance cost of passing heavy parameters to GLSL functions cause of an eventual copy into a temporary variable. Like matrix, sample or struct.
Is someone know more about this issue?

And moreover is the “inout” qualifier avoid the copy?
I’m not sure but according to this, it doesn’t. I think it is not the case because it says that the modified variable is copied out into the given parameter at the end of the function.

I hope my questions are clear.
Thank you.

In most cases it would all get inlined, and there’d be no difference whatsoever. If it doesn’t get inlined, then the function parameters get allocated in a special place and out/inout get copied back to where you want them. The special place is a global range of temporaries, used only by that function, or exclusively accessed by various functions. Still, generally only functions that are either big or were medium-sized and used statically dozens of times, would not be inlined.

The only thing you should avoid is: passing arguments that would require int<->float conversion. The stuff would get inlined, but it will produce 2 extra instructions, to convert back and front.

Ok got it, thank you for your answer.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.