Apart from the obvious D3D11_BIND_STREAM_OUTPUT flag, your buffer additionally needs D3D11_BIND_SHADER_RESOURCE (or even D3D11_BIND_UNORDERED_ACCESS). You probably have to play around a bit: I once tested if one could use D3D11_BIND_VERTEX_BUFFER in combination with the latter two and it only worked with raw and typed buffers, not structured buffers, unfortunately.What do I need to do to be able to use this resource in a compute kernel?
Then you create the appropriate views which you bind to your compute shader (shader resource view/unordered access view).
Since I haven't done this, I can't say this works at all (the runtime is quite reluctant about combining "unusual" flags). Turn up the debug runtime, it will tell you exactly what is off.
Edit: Is this for vanilla DX11 ? Because 11.1 allows writing to UAVs from every shader stage. You wouldn't even need stream out functionality.
There are a couple of stream out related queries, of particular interest here is D3D11_QUERY_SO_STATISTICS (or the STREAMX versions thereof). Note that queries have a latency.Also is there a way to know how many elements are in an SO buffer?