Run DirectX 11 stream output without drawing

Started by
10 comments, last by french_hustler 9 years, 10 months ago

How do you go about running a stream output shader without drawing anything to the screen? I want to use a geometry shader with stream output to skin my animated meshes, but the only way I know of to cause the geometry shader to execute is submitting a draw call. Is there any other way to execute the geometry shader so that I don't draw to the screen? The reason I'm doing it with stream output is because I'd rather incur the memory overhead of storing a deformed copy of the mesh, than the GPU overhead of having to calculate the deformation again for each rendering pass.

Advertisement

Sure, you can omit the rasterization if you use D3D11_SO_NO_RASTERIZED_STREAM for the RasterizedStream parameter.

Or you can set the pixel shader to null .

Thanks. That worked great.

Or you can set the pixel shader to null .

This will not achieve the same result as not rasterizing. If you do this, the triangles will still be rasterized, and if you have depth writes enabled the depth will be written to the depth buffer.

You're welcome. Since I haven't tried stream out with skinning, I always wondered how to go about this exactly. Because you unlikely want to operate on triangles to not blow the stream out buffer unnecessarily, does this work on points ?

Yes it does biggrin.png. Here's the setup:
  • Use a pass-through geometry shader (point->point), setup the streamout and set topology to point list.
  • Draw the whole buffer with context->Draw(). This gives a 1:1 mapping of the vertices.
  • Later bind the stream out buffer as vertex buffer. Bind the index buffer of the original mesh.
  • draw with DrawIndexed like you would with the original mesh (or whatever draw call you had).
Here a screenshot that it works. I (ab)use the texcoords from the original mesh, since they don't need skinning (only position and normal). The right spider is from the stream out buffer.

SpiderStreamout.png

(CC-BY Ricardo28roi)

I've also been considering using a compute shader to do skinning, but for now I'm just going to do stream out because I haven't written a compute framework in my engine yet.

Interesting. That would save one shader stage (and hopefully gain performance). Don't forget to post your findings.

I have a further question about SO.

I was going to post a new topic but since this thread is "sort of" similar, I might as well ask here.

I basically want to voxelize my geometry. I was trying to by-pass the rasterization pipeline to do so as to avoid doing conservative rasterization by using the geometry shader. Instead I take all my objects vertices and indices, and for each object create an associated buffer of triangles. I pass all these buffers into a kernel that creates my voxel grid datastructure.

Instead of pre-creating these buffers with triangles, I was thinking of rendering my scene regularly but streaming-out these triangles using an SO resource. What do I need to do to be able to use this resource in a compute kernel? Also is there a way to know how many elements are in an SO buffer?

Thank you.

Interesting. That would save one shader stage (and hopefully gain performance). Don't forget to post your findings.

I will if I end up getting it working. I might have something worth writing an article about by the end of the summer, but I won't know until I've finished integrating the compute shaders, which given my engine architecture, could take some time.

This topic is closed to new replies.

Advertisement