Lars Andreas Ek

Hi, I have two questions regarding geometry shaders:

1) Can a geometry shader write to a Stream Out while passing the data down the pipeline at the same time I've read such indications, but I can't seem to find it documented anywhere. I.e. a dynamic particle system where particles are added to a point stream out AND rendered in one pass.

2) Can a geometry shader have multiple output streams I.e. a dynamic particle system where particles are added to a point stream out, while triangle point sprites are sent to the rasterizer (in one pass, that is).

Thanks!



Re: Direct3D 10 Geometry Shaders - Multiple Streams

Bill Kristiansen

1) Yes, you can stream out and rasterize at the same time.

2) Yes, you can have up to four streams as long as you stream only single element data per stream. The single stream out buffer configuration allows writing to an array-of-structs and the stream must be bound to slot 0. When streaming to more than one output stream (or to a stream bound to a slot other than slot 0) you can only stream single elements per stream. With single buffer stream out the stride is provided in the CreateGeometryShaderWithStreamOutput() call. Multiple stream out configurations have an implicit stride equal to the size of the element type associated with the slot. All elements, whether multiple-stream or single-stream must be 32-bit integers or 32-bit floats with one to four components per element.

-Bill






Re: Direct3D 10 Geometry Shaders - Multiple Streams

Larsvin

Thanks alot, that clears things up a bit!

Some quick follow-ups:

1) What would the signature of the geometry shader look like when streaming to more than one output stream And how do you specify which stream to Append() data to I've tried guessing around a bit, but only receive compilation errors such as "error X4570: geometry shader can only emit to 1 stream", "error X4577: Not all elements of SV_Position were written", and "error X4576: Output signature parameter SV_POSITION (1-based Entry 1) type must be float32 and mask must be xyzw".

2) How do I specify which stream(s) the pixel shader gets its data from My guess is by using semantics somehow, but if I'm right I'd like it confirmed :)

3) Can I specificy the SO layout in the fx-file when using multiple output streams, like possible when using a single "array-of-structs" stream

4) Can the geometry shader have output stream of different primitive types, such as one triangle stream and one point list stream (And then using the triangle stream in the rasterizer, and the point list stream as a vertex buffer in a subsequent pass)

Again, thanks!





Re: Direct3D 10 Geometry Shaders - Multiple Streams

Ian McIntyre

1. The signature of the GS does not change when stream out is enabled. A GS with stream out is created by appending an SODecl to a GS without stream out using ConstructGSWithSO.

When creating the Geometry shader using ConstructGSWithSO, the SODecl specifies the output slot before each entry. For example ConstructGSWithSO( myGS, ¡°0:TEXCOORD.xyz; 1:SV_POSITION.xy; 2:SPECULAR¡± ). You can only have one entry per output slot.

All these buffers are filled at the same time with a single call to Append(). For example, to use the SODecl above, the GS output signature must have TEXCOORD, SV_POSITION, and SPECULAR entries, then when Appand() is called, the TEXCOORD entry is written to output slot 0, SV_POSITION to output slot 1, and SPECULAR to output slot 2.

2. The input to the pixel shader is independent of stream output. So as long as the input to the PS is a subset of the output of the GS (just as in any other stage), then you're good. That is, the PS doesn't get any data from the output streams, it get's it through the rasterizer which gets data directly from the GS.

3. Answered in question 1.

4. No. The output stream(s) must be of the same primitive as the rasterizing stream. Note that, except for point streams, the Append()s are specified in strip order but the primitives are expanded to list order in the output streams. Now, if you are rasterizing and outputting triangles to a stream, you can still interpret the stream out buffer as a list of points in a subsequent pass, but if your GS outputs triangle strips of more than one triangle, because of the strip-to-list conversion, there will be a duplication of points in the stream. That is, if your GS is only outputting one triangle per invocation, then the triangle strip ordering (with cut vertices removed) is exacly the same as the triangle list ordering which is exactly the same as the point ordering so you can use your SO decl as a triangle list or a point list.

I hope this helps,

Ian.





Re: Direct3D 10 Geometry Shaders - Multiple Streams

Larsvin

Yes that helps alot!

Thanks for your answer!

Lars