• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Jason Z

[D3D11] Geometry Shader Input Vertex Ordering

8 posts in this topic

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!
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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!
0

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  
Followers 0