d3d9 equivalent of D3DXFVFFromDeclarator?

Misha Koshelev misha680 at gmail.com
Sat Aug 28 16:35:46 CDT 2010


On Fri, Aug 27, 2010 at 10:53 PM, Henri Verbeet <hverbeet at gmail.com> wrote:
> 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().
>

Thank you for the thorough explanation.

One point of clarification if possible.

The need for D3DXFVFFromDeclarator() from the standpoint ID3DXMesh is
for the GetFVF() function.

It seems, per dlls/d3d9/tests/vertexdeclaration.c test_decl_to_fvf
that the same functionality (to return an FVF from a device) exists in
d3d9 as well.

I was wondering how this is done, and whether a similar mechanism
would be acceptable for ID3DXMesh?

Thank you
Misha



More information about the wine-devel mailing list