madiyaan

Hello,

I have an application that has a function that emulates the DrawPrimitivesUp() function without actually calling DrawPrimitivesUp() for educational/debug purposes (it actually does the vertex shading and outputs the vertices to see whether they're correct output).

In this function, this is what I do (input parameters are parameters to DrawPrimitiveUp):

1. Get the FVF via GetFVF() and store it locally.
2. Create a VertexBuffer via CreateVertexBuffer(), giving it the input_primitives * stride for length, and the FVF obtained in step 1.
3. Call SetStreamSource() of stream 0 with this VertexBuffer and the stride that was given as the input paramter to this function.
4. Create an output vertex buffer with DECLs in the format that the vertex shader will output.
5. Call ProcessVertices() with this output buffer as the output vertex buffer parameter.

The problem is that ProcessVertices() fails and upon inspecting closely I get the error that's in the subject:

Vertex stride in stream 0 is less than in the declaration

I don't know what the reason is for this error. Can anyone tell me what two things it is comparing and seeing if one quantity is less than the other Thing is that I'm not even using a declaration for the input stream 0... I CreateVertexBuffer() using the FVF I obtain in the first step. So is the problem with the output buffer

I'd appreciate any comments/answers. I would be happy to clarify anything since I know I'm poor at English and it's not my first language.

Thank you,



Re: Game Technologies: DirectX 101 Vertex stride in stream 0 is less than in the declaration

Ralf Kornmann

It sounds like the FVF defines a vertex format that have a larger stride than that one that you use for the function call. You could use D3DXGetFVFVertexSize to get the minimum stride size required for a given FVF.






Re: Game Technologies: DirectX 101 Vertex stride in stream 0 is less than in the declaration

madiyaan

Thank you for the reply, but I'm still getting the same error. Let me re-iterate what I'm trying to do and the code:

I am given a user-defined vertex buffer, a user-defined stride in the buffer and a user-defined vertex shader. Using these, I want to get the output vertex buffer. Here are the steps that I take:

1. CreateVertexBuffer for the input vertex buffer. This time I used an FVF of 0.
According to me, giving an FVF of 0 should take care of this error. Earlier I was setting the FVF to DIFFUSE | XYZ, which was incorrect. Ideally, I want it NOT to use the FVF at all and use my own user-defined stride.

2. SetStreamSource with this newly created Vertex buffer in step 1 and I set the stride to the user-defined stride.

3. Create an output vertex buffer and call ProcessVertices(). Once again, I get the same error, i.e. Vertex stride in stream 0 is less than in the declaration.

In the light of the above, I'd appreciate if someone could tell me:

1. What exactly is it comparing the stride in stream 0 to I know that the stride in stream 0 is user-defined and exactly what I want it to be. I guess I need to fix the other value it is comparing the stride to. I thought giving the FVF to 0 when creating the vertex buffer will negate that stride and only use the one I give in setstreamsource.

2. How to fix the error.

Thank you,





Re: Game Technologies: DirectX 101 Vertex stride in stream 0 is less than in the declaration

Alexey Barkovoy

Before calling ProcessVertices() or Draw[Indexed]Primitives() Direct3D runtime needs to know format of your vertices, so it can correctly assign data from VertexBufers to registers in vertex shader (the same is true for fixed function processing). Just setting stride is not enough. In D3D there are two functions that can define vertex format inside Vertexbuffer: SetFVF() or SetVertexDeclaration(). So, you need to call one of them with correct description of your data.