**0**

# [D3D11] Geometry Shader Input Vertex Ordering

###
#1
Crossbones+ - Reputation: **6405**

Posted 31 October 2010 - 11:26 PM

Thanks in advance for any help or suggestions!

Jason Zink :: DirectX MVP

Direct3D 11 engine on CodePlex: Hieroglyph 3

Direct3D Books: Practical Rendering and Computation with Direct3D 11, Programming Vertex, Geometry, and Pixel Shaders

Articles: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article (original):: Fast Silhouettes Article

Games: Lunar Rift

###
#2
Members - Reputation: **568**

Posted 01 November 2010 - 03:19 AM

So, if you want to use triangle lists with adjacency, you need to supply a vertex buffer with the adjacency, then you can read them in the geometry shader. For triangles or triangle lists, the geometry shader reads them in the same way, and there is no difference. The Geometry shader will always read in three triangles. So, if you are drawing 4 vertices and using a triangle string, the geometry shader will run twice, once for vertex 0, 1, 2, and again for vertex 1, 2, 3.

However, I would caution against using the geometry shader for anything large, as it causes major slowdowns. You can expect a 50% decrease in your shader by adding a geometry shader, period. It is used for very small scale modifications/changes.

EDIT

I didnt do a good job explaining. For specific example, refer to the direct x SDK broswer, Direct x 10 examples, named Direct3D 10 Shader Model 4.0 Workshop. It is under exersise03 in that example. It covers triangle adj in the geometry shader.

###
#3
Crossbones+ - Reputation: **6405**

Posted 01 November 2010 - 04:13 AM

I think you indirectly answered my question, although I would like to clarify. From the sample program you mentioned (which is precisely what I am interested in - nice link!) I see in the shader that the three vertices of the current triangle are located in the input array as:

input[0], input[2], and input[4]

and it appears that the adjacent triangles are appearing like so:

input[0], input[1], and input[2]

input[2], input[3], and input[4]

input[4], input[5], and input[0]

Is this correct? If so, then does this pattern hold true for both triangle primitive topologies with adjacency (strips and lists)? I would also like to know about the ordering in the geometry shader for the line types too, although I suspect it is similar in nature to the triangle versions...

Thanks for the help - your post was very helpful.

Jason Zink :: DirectX MVP

Direct3D 11 engine on CodePlex: Hieroglyph 3

Direct3D Books: Practical Rendering and Computation with Direct3D 11, Programming Vertex, Geometry, and Pixel Shaders

Articles: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article (original):: Fast Silhouettes Article

Games: Lunar Rift

###
#4
Members - Reputation: **568**

Posted 01 November 2010 - 04:33 AM

I cant say for certain on your next question, but I believe the answer should be yes the ordering is the same.

Linestrips should enter as two points 0 and 1

linestrips_adj 1 an 2 should be the real line, and 0 and 3 should be the adj points

###
#6
Crossbones+ - Reputation: **6405**

Posted 01 November 2010 - 05:11 AM

@DieterVW: I'm pretty sure those diagrams apply to the input to the Input Assembler - i.e. the order you load your vertex/index buffer with. Do similar diagrams exist for the five different input types for the geometry shader? For example, is the input for a triangleadj the same regardless of if the VB/IB data is sent in as a triangle strip with adjacency or a triangle list with adjacency?

It would appear from smasherprog's response that this is the case, and it would make sense too since the type identifier would be the same in both cases.

Jason Zink :: DirectX MVP

Direct3D 11 engine on CodePlex: Hieroglyph 3

Direct3D Books: Practical Rendering and Computation with Direct3D 11, Programming Vertex, Geometry, and Pixel Shaders

Articles: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article (original):: Fast Silhouettes Article

Games: Lunar Rift

###
#7
Members - Reputation: **724**

Posted 01 November 2010 - 05:51 AM

Quote:

The inputs to the Geometry Shader are like a single primitive of any of the "list" primitive topologies (with or without adjacency) in the diagram above. When adjacency is available, the Geometry Shader will see the appropriate adjacent vertices along with the primitive's vertices. So for example if the Geometry Shader is invoked with a triangle including adjacency (the source could have been a strip with adjacency), this would mean that data for 6 vertices would be available as input in the Geometry Shader: 3 vertices for the triangle, and 3 for the adjacency.

###
#8
Members - Reputation: **568**

Posted 01 November 2010 - 06:21 AM

###
#9
Crossbones+ - Reputation: **6405**

Posted 01 November 2010 - 07:53 AM

Quote:

Original post by DieterVW

The ordering will be consistent throughout the pipeline, and that should include the conversion of a triangle strip with adjacency into triangles for the geometry shader. The best I could find in the spec was:Quote:

The inputs to the Geometry Shader are like a single primitive of any of the "list" primitive topologies (with or without adjacency) in the diagram above. When adjacency is available, the Geometry Shader will see the appropriate adjacent vertices along with the primitive's vertices. So for example if the Geometry Shader is invoked with a triangle including adjacency (the source could have been a strip with adjacency), this would mean that data for 6 vertices would be available as input in the Geometry Shader: 3 vertices for the triangle, and 3 for the adjacency.

Ahh yes, that is what I was looking for. That isn't 100% clear, but it indicates that both types will be treated the same way. To be honest, now that I have seen your responses it seems somewhat obvious that they should be the same - the rasterizer interprets the primitives the same way regardless of whether they are from strips or lists, so there isn't any reason to think that the GS would do any different.

Thanks a bunch for your help to both DieterVW and smasherprog!

Jason Zink :: DirectX MVP

Direct3D 11 engine on CodePlex: Hieroglyph 3

Articles: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article (original):: Fast Silhouettes Article

Games: Lunar Rift