Jump to content
  • Advertisement
Sign in to follow this  
niexuchina

Question on IDirect3DDevice9::ProcessVertices()

This topic is 3868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a question on the method IDirect3DDevice9::ProcessVertices(). The document says that the method "Applies the vertex processing defined by the vertex shader to the set of input data streams, generating a single stream of interleaved vertex data to the destination vertex buffer". But the remarks section of the document mentions nothing at all about vertex shader. It seems that this method only transforms vertices to screen space and projection space. Can I use this method to process vertices with a vertex shader and store them in the destination vertex buffer?

Share this post


Link to post
Share on other sites
Advertisement
I've never used this method, but I'm guessing that it if you have a vertex shader set it will use that or otherwise will use standard fixed-function processing. It looks like the "remarks" section might be mostly leftover from an older version in D3D8, or something to that effect (just guessing here! I don't even know if D3D8 had this function. [smile])

Share this post


Link to post
Share on other sites
Eeek, ProcessVertices() - last time I used that was in DirectX7, thought they'd removed it since!


0. I think it should work using the shader and source stream(s) currently set on the device. But it isn't as simple as that:


1a. ProcessVertices() *always* happens in software using the CPU (because you can't read vertices back after vertex processing on current GPUs).

1b. So if you want to do something simple like pre-transform all the positions in a mesh into some space, it's simpler, cleaner and a little quicker to do it yourself using something like D3DXVec3ProjectArray().


2a. Because PV() uses software vertex processing, the source vertex buffer and destination vertex buffer need to have been created with D3DUSAGE_SOFTWAREPROCESSING.

2b. I think you may also need to create your device as D3DCREATE_MIXED_VERTEXPROCESSING.

2c. And you'll need to use IDirect3DDevice9::SetSoftwareVertexProcessing() to set the device into software mode before you create your vertex shader otherwise the shader will get passed off to the GPU device driver (and GPUs don't support ProcessVertices()).

2d. If you want to use hardware vertex processing after you've called ProcessVertices() then you'll need to re-enable hardware vertex processing. IIRC SetSoftwareVertexProcessing() is an extremely expensive call, almost akin to resetting the device.


3. Long story short - ProcessVertices() isn't very useful in most cases these days.

Share this post


Link to post
Share on other sites
Even if it does work, the output vertex buffer needs to be a FVF VB, so that would mean that D3D would have to convert the shader output to a FVF-compatible format, which would likely make it even slower.

As others said; what are you trying to achieve here? If this is some sort of optimisation for vertices that aren't going to change position, I wouldn't bother using PV(), shaders on the GPU are practically free.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Even if it does work, the output vertex buffer needs to be a FVF VB

Not true. Read the docs. If you use shader model 3, you can use a vertex declaration. That's one of the parameters to the function.

That said, the above is just nit-picking. Evil Steve's claim may be wrong, but the idea of not using ProcessVertices is right, as S1CA clearly explained.

What to use instead would depend on what you want to do. There are alternatives, like ATI's R2VB (render to vertex buffer) functionality.

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
Quote:
Original post by Evil Steve
Even if it does work, the output vertex buffer needs to be a FVF VB

Not true. Read the docs. If you use shader model 3, you can use a vertex declaration. That's one of the parameters to the function.
Whoops, good point. I only skimmed the docs and saw the remark about FVF codes. Ignore what I said [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!