Jump to content

  • Log In with Google      Sign In   
  • Create Account


[D3D11] Geometry Shader Input Vertex Ordering


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Jason Z   Crossbones+   -  Reputation: 4843

Like
0Likes
Like

Posted 31 October 2010 - 11:26 PM

I am trying to figure out what order the vertices passed into a geometry shader are supplied in... I haven't been able to find it in the docs, and it seems that geometry shaders are as popular with the tutorial writers... Does anyone know of a place where this information is supplied? Specifically, I would like to know the difference between passing triangles strips and triangle lists with adjacency - is there a difference in the order of the vertices passed in, or are they supplied in the same format?

Thanks in advance for any help or suggestions!

Sponsor:

#2 smasherprog   Members   -  Reputation: 432

Like
0Likes
Like

Posted 01 November 2010 - 03:19 AM

the difference between triangles strips and triangle lists with adjacency is the vertex format that comes into the Gemometry shader. Valid types for input to the geometry shader are, point, line, triangle, lineadj, and triangleadj. Valid outputs are PointStream<OutputVertexType>, LineStream<OutputVertexType>, and TriangleStream<OutputVertexType>. So, for your triangleadj, your vertex stream format would need to be D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ or D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ. But, you need to supply the adjacent vertices. These vertices are ONLY used in the geometry shader, and do not get drawn at all.

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 Jason Z   Crossbones+   -  Reputation: 4843

Like
0Likes
Like

Posted 01 November 2010 - 04:13 AM

You didn't do too bad :) I am familiar with the process of creating the geometry in the Input Assembler with the various geometry types (including adjacency types), and I am also aware of the potential performance penalties surrounding the GS. However, there are some things that the GS can do that other stages can't, so it is still worth using in some cases.

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.

#4 smasherprog   Members   -  Reputation: 432

Like
0Likes
Like

Posted 01 November 2010 - 04:33 AM

Yeah, I realized that example 3 was the wrong one, it was example 2, but I think you found that one.

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

#5 DieterVW   Members   -  Reputation: 700

Like
0Likes
Like

Posted 01 November 2010 - 04:34 AM

These diagrams should be helpful.


#6 Jason Z   Crossbones+   -  Reputation: 4843

Like
0Likes
Like

Posted 01 November 2010 - 05:11 AM

Thanks for the info on the line primitives - that is very helpful.

@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.

#7 DieterVW   Members   -  Reputation: 700

Like
0Likes
Like

Posted 01 November 2010 - 05:51 AM

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.


#8 smasherprog   Members   -  Reputation: 432

Like
0Likes
Like

Posted 01 November 2010 - 06:21 AM

I think that the ordering does matter because in the pixel shader, only the real triangles are drawn. For example, you can have adj information, but not use a geometry shader at all and the pixel shader will draw the correct triangles. So, I think the pixel shader expects the adj information in a specific format.

#9 Jason Z   Crossbones+   -  Reputation: 4843

Like
0Likes
Like

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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS