Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Buffer arguments to functions in HLSL (Compute Shaders)

$
0
0

I want to write a function in a compute shader that takes a StructuredBuffer or an RWStructuredBuffer as an argument.  Something like this:

void SomeFunction(StructuredBuffer<CustomStruct> buffer) {
   // ...
}

This seems to work, but I'm concerned that the buffer will actually be copied into the parameter each time the function is called.  It seems counter-intuitive to me that it would work that way,  I would think that the buffer would somehow be passed by reference.  I searched for a bit and could not find a definite answer as to whether the entire buffer is copied or not.  Does anyone here know how this works?


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>