d3d9 equivalent of D3DXFVFFromDeclarator?

Henri Verbeet hverbeet at gmail.com
Fri Aug 27 22:53:03 CDT 2010


On 28 August 2010 02:44, Misha Koshelev <misha680 at gmail.com> wrote:
> I am looking again at d3d9, but feel like I am running in circles a
> little bit trying to chase down where convFVF and convertedDecls is
> coming from.
>
> If you have any hints/advice, much appreciated. If there is a better
> place to look as well (like wined3d), please let me know.
>
We only convert from FVF to declaration in d3d9 / wined3d, not the
other way around. Converting from declaration to FVF may be a little
harder, but essentially you'd do FVF to declaration conversion in
reverse. I.e., you consume declaration elements from the declaration,
and check if they (exactly) match something that can be mapped to an
FVF.

Suppose for example that you have the following declaration:
{
    {0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0},
    {0, 12, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0},
    {0, 16, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 0},
    D3DDECL_END()
}

You'd check the first declaration element, and see that is matches
D3DFVF_XYZ. Then you look at the next and see that it matches e.g.
D3DFVF_DIFFUSE. The next element would match D3DFVF_NORMAL, but you
can't have that, because normal data should come before color data in
the vertex buffer, so this declaration can't be mapped to an FVF.
I.e., ordering of declaration elements matters, you can't have holes /
padding, etc. It may be interesting to test if just the order of the
data in the vertex buffer matters, or also the order of elements in
the declaration. Example:

{
    {0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0},
    {0, 12, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0},
    D3DDECL_END()
}
and
{
    {0, 12, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0},
    {0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0},
    D3DDECL_END()
}

describe the same vertex buffer layout, but may behave differently for
D3DXFVFFromDeclarator().



More information about the wine-devel mailing list