Vertex stride in stream 0 is less than in the declaration

Started by
10 comments, last by superpig 17 years ago
Quote:Original post by sirob
IDirect3DDevice9::GetFVF?


Thank you for the reply, Sirob. If you noted my first post (last part), when I do GetFVF() it returns 0x42, which means 16 bytes. But the stride given to me by the user is only 12 bytes. This is how I first noted the error. If I just give the function to DrawPrimitivesUP() directly, it works.

But I'm trying to avoid using DrawPrimitivesUP(). I want to do the vertex processing in software and want to get the output vertices. So, back to the question: Is there a way I can get the FVF from the user-provided stride, user-provided buffer and the current pipeline state?

There must be a way, since DirectX can do DrawPrimitivesUP() itself. :)

Thank you once again for your time, DX Gurus,

Madiyaan.
a h31p1355 n00b
Advertisement
Quote:Original post by madiyaan
Next question, how do I get the FVF just from the stride information?
You can't. Consider the following FVF codes:

D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0)
D3DFVF_XYZW | D3DFVF_DIFFUSE

These are clearly very different vertex configurations, but they all pack down to the same stride (20 bytes). When FVF->stride is a many-to-one function, you can't invert it.

Quote:the current state of the pipeline from the device interface.
That's where you get the vertex configuration data from, indeed - but the point of my earlier post (which you seem to have missed) is that if you're writing a function to be used in place of DPUP then it's not your responsibility to calculate and set the vertex format - it's the caller's. DPUP doesn't do any work to set the FVF or vertex declaration, it assumes that the caller has already set that up (as part of the current pipeline state) and just pushes its draw calls through.

If you're doing something more interesting than DPUP that does require vertex layout data, though, then use IDirect3DDevice9::GetVertexDeclaration(). Do not use FVF codes if you want your function to work for any vertex format as there are many vertex formats that vertex declarations can express which FVFs can't.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement