Skip to main content
GameDev.net gamedev.net
🔒 Locked

Differences between Device9::ProcessVertices and Device9::DrawPrimitive?

Started by dessler.michelle Nov 1, 2011 at 2:37 PM 6 replies 2k views
Original Post
dessler.michelle
dessler.michelle
Hi there,

Can someone tell me what are the differences between Device9::ProcessVertices and Device9::DrawPrimitive?

In which scenario is better ProcessVertices?

Thank you,

Michelle.
InvalidPointer
InvalidPointer
ProcessVertices just runs the vertex shader you specify on each element in the buffer(s) you bound to the pipeline, then saves out the result in the pDestBuffer argument-- see the MSDN documentation here. In most cases, I'd wager that you'll never actually need to do this unless you absolutely must use features in a more modern vertex shader model specification than is available or need to do some other special processing that doesn't work well in your traditional graphics pipeline. Additionally, I recall hearing that using this requires that software vertex processing be forced for the device, but I don't see any mention of this on the mentioned MSDN documentation page, so you'll probably want to test this and find out.

DrawPrimitive and friends, on the other hand, will actually go through the entire set of vertex and pixel shader stages, and will thus rasterize everything you feed it. This is the primary drawing workhorse in D3D; for the most part everything else exists to configure how these functions behave when invoked.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
Juliean
Juliean
These are complete two different methods. I never used ProcessVertices but from what I understand from msdn, it is used to manipulate vertices with a vertex shader and output them to a new vertex buffer. Draw primitive is used to display vertices on the screen.
dessler.michelle
dessler.michelle

ProcessVertices just runs the vertex shader you specify on each element in the buffer(s) you bound to the pipeline, then saves out the result in the pDestBuffer argument-- see the MSDN documentation here. In most cases, I'd wager that you'll never actually need to do this unless you absolutely must use features in a more modern vertex shader model specification than is available or need to do some other special processing that doesn't work well in your traditional graphics pipeline. Additionally, I recall hearing that using this requires that software vertex processing be forced for the device, but I don't see any mention of this on the mentioned MSDN documentation page, so you'll probably want to test this and find out.

DrawPrimitive and friends, on the other hand, will actually go through the entire set of vertex and pixel shader stages, and will thus rasterize everything you feed it. This is the primary drawing workhorse in D3D; for the most part everything else exists to configure how these functions behave when invoked.


Once that vertex buffer is returned how we can draw its content in the screen? Do we have to use Device.DrawPrimitive() or there's a "special" command to send the vertices to the display avoiding traveling through the whole pipepline?
Adam_42
Adam_42
You would still need to use DrawPrimitive(), but you can simplify the vertex shader.

Also note that DrawPrimitive() will be significantly slower than DrawIndexedPrimitive() unless the number of primitives is very small, because the index buffer enables the graphics card to cache results from the vertex shader.
dessler.michelle
dessler.michelle

You would still need to use DrawPrimitive(), but you can simplify the vertex shader.


What do you mean with "you can simplify the vertex shader"?

I'm sorry by my silly questions but I'm new in DirectX.


Also note that DrawPrimitive() will be significantly slower than DrawIndexedPrimitive() unless the number of primitives is very small, because the index buffer enables the graphics card to cache results from the vertex shader.


Yes I knew that I just use DrawPrimitive() as an example but thanks anyways.
InvalidPointer
InvalidPointer

[quote name='Adam_42' timestamp='1320169883' post='4879306']
You would still need to use DrawPrimitive(), but you can simplify the vertex shader.


What do you mean with "you can simplify the vertex shader"?

I'm sorry by my silly questions but I'm new in DirectX.


Also note that DrawPrimitive() will be significantly slower than DrawIndexedPrimitive() unless the number of primitives is very small, because the index buffer enables the graphics card to cache results from the vertex shader.


Yes I knew that I just use DrawPrimitive() as an example but thanks anyways.
[/quote]

Well remember that you've already done all the fancy skinning, etc. inside ProcessVertices() so you can make a very simple pass-through vertex shader that just shuttles things off to the rasterizer/pixel shader stage. There's no need to run your transformations, etc. again.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
dessler.michelle
dessler.michelle

Well remember that you've already done all the fancy skinning, etc. inside ProcessVertices() so you can make a very simple pass-through vertex shader that just shuttles things off to the rasterizer/pixel shader stage. There's no need to run your transformations, etc. again.


Now it makes sense to me.

Thank you guys once again for your help

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.