Sign in to follow this  
MEX

Append/Consume Structured Buffers

Recommended Posts

MEX    100
I have two Compute Shaders. The first one appends an arbitrary number of elements to a buffer and the second one should consume elements as long as there are some left. But how can I get the number of elements in that buffer? I have tried GetDimensions() but this method only seems to return the maximum number of elements possible.

I would really appreciate your help.

Share this post


Link to post
Share on other sites
Waterlimon    4398
Maybe you could use a variable that holds the lenght of the buffer and incremented by the thing that adds data to the buffer and decremented when some is removed?

Share this post


Link to post
Share on other sites
MEX    100
[quote name='Waterlimon' timestamp='1306864294' post='4817955']
Maybe you could use a variable that holds the lenght of the buffer and incremented by the thing that adds data to the buffer and decremented when some is removed?
[/quote]

Thanks for the reply. That's something I want to avoid, because there must be some kind of counter used by the gpu that should be accessable in an "easy" way (at least in a perfect world).

Share this post


Link to post
Share on other sites
Jason Z    6434
You need to use the ID3D11DeviceContext::CopyStructureCount() method to get the count into a buffer. You can then bind that buffer (or copy the value to another suitable constant buffer) to a pipeline stage such as the compute shader to get the value in HLSL, or map the value back to the CPU if you need it there.

Share this post


Link to post
Share on other sites
MEX    100
[quote name='Jason Z' timestamp='1306873072' post='4818005']
You need to use the ID3D11DeviceContext::CopyStructureCount() method to get the count into a buffer. You can then bind that buffer (or copy the value to another suitable constant buffer) to a pipeline stage such as the compute shader to get the value in HLSL, or map the value back to the CPU if you need it there.
[/quote]

Thanks :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this