Compute Shader Pass RWStructuredBuffer by Reference

I was curious if there is a way to pass a structured buffer around by reference. With both structured buffers and arrays I don’t want them to be copied entirely when passed to a function, because this would be ridiculously inefficient. Is there a way to do this properly in HLSL for compute shaders?

I saw the in, out, and inout keywords, but the documentation makes it seem like this just performs a copy anyway. Is a copy for structured buffers and arrays just a pointer copy? Or is it by values?

Yeah good question, I’m wondering the same thing now…

It seems like from Microsoft’s HLSL documentation that all function arguments are copied every time, and passed by value only.

But in this forum post (elsewhere), they say it’s fine and that it does use references… so I’m like which is it? xD

For now, I’m going to be on the safe side and just keep all the methods I would have wanted to give in StructuredBuffers as arguments in the same compute shader instead, so I can just access the buffer globally. At least until I find someone who has a definitive answer, or find concrete documentation/evidence saying it is okay to do.