Sign in to follow this  
giugio

Stream Out dx 10

Recommended Posts

Hy. I'm not understand at all the stream out in dx 10 . I'm read some documentation in the dx 10 sdk ,but,if a character is rendered more than one time (for example to render more lights shadows)how the stream out save the prestation? Thanks.

Share this post


Link to post
Share on other sites
The idea behind stream out is that instead of sending primitives to the rasterizer, you store them in the GPU memory. Then, you can either read them back to the system memory, or use the stored geometry on the GPU as input for a different draw pass.

In the specific case of multi-pass character rendering, it is beneficial to do the skinning logic only once even though you need to render the resulting geometry in many passes.

Hence, the rendering logic could be split into two phases, second of which will hold n sub-passes:

First phase:
-set the vertex shader that does the skinning and all other transformations.
-optionally, set a geometry shader that processes geometry.
NOTE: either the vertex shader or geometry shader must be created by CreateGeometryShaderWithStreamOutput function which takes in either vs or gs bytecode and validates the SO layout.
-set a stream-out buffer as the destination for the skinned geometry.
-skip rasterization in this phase (but see below *).
-call Draw* to fill the SO buffer.

Second phase:
-bind the stream-out buffer, that was filled in the first phase, as input for the device.
-set a simple vertex shader that only passes thru the incoming geometry.
-for each needed sub-pass:
--set necessary states
--draw pixels using DrawAuto which automatically knows the amount of geometry in the SO buffer.

This way, you only need to do the heavy maths (skinning) once, even if you would need to render in multiple passes.

Note that you should weigh the cost of necessary API calls versus the benefits of using SO, when you evaluate whether to use the technique or not. The balance is dependent on the amount of geometry, the complexity of the work that the vertex shader has to do, and the number of sub-passes inside the second phase.

If the VS is simple to begin with and you don't use the results more than a couple of times, SO can actually slow the performance down.

Using geometry shader when filling SO buffers is not actually required, but since the geometry shader is usually slower than the vertex shader, you will gain more benefit by combining the two if you need to use a GS to begin with.

* It is worth noting that you can actually send the stuff to the rasterizer as well in addition to SO buffer, so you can save one sub-pass in the second phase by implementing the first sub-pass in the first phase.

[Edited by - Nik02 on July 23, 2009 5:33:54 AM]

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