Closed walbourn closed 3 years ago
size_t ComputeVertexSize(uint32_t fvfCode);
size_t ComputeVertexSize(const D3DVERTEXELEMENT9* pDecl, uint32_t stream);
size_t ComputeVertexSize(const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength, uint32_t stream);
size_t GetDeclLength(const D3DVERTEXELEMENT9* pDecl);
bool CreateDeclFromFVF(uint32_t fvfCode, std::vector<D3DVERTEXELEMENT9>& decl);
If the <d3d11.h>
header is included before you include FlexibleVertexFormat.h, you get:
bool CreateInputLayoutFromFVF(uint32_t fvfCode, std::vector<D3D11_INPUT_ELEMENT_DESC>& il)
If the <d3d12.h>
header is included before you include FlexibleVertexFormat.h, you get:
bool CreateInputLayoutFromFVF(uint32_t fvfCode, std::vector<D3D12_INPUT_ELEMENT_DESC>& il)
uint32_t ComputeFVF(const D3DVERTEXELEMENT9* pDecl);
uint32_t ComputeFVF(const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength);
I didn't bother with a
ComputeFVF
from a Direct3D 11 or Direct3D 12 input layout, but let me know if that's important.
Porting table:
D3DX | FlexibleVertexFormat.h |
---|---|
D3DXGetFVFVertexSize | ComputeVertexSize |
D3DXGetDeclVertexSize | ComputeVertexSize |
D3DXGetDeclLength | GetDeclLength |
D3DXDeclaratorFromFVF | CreateDeclFromFVF CreateInputLayoutFromFVF |
D3DXFVFFromDeclarator | ComputeFVF |
While my functions are equivalent to these older ones, I have improved them somewhat. They have a few more bounds checks, invalid FVFs return 0 or false in more cases, and the original functions didn't handle D3DFVF_XYZW
.
This PR adds a new utility header to the DirectXMesh repo. This contains helper functions for working with Direct3D 9 legacy FVF codes and Direct3D 9 decls. This is useful for tools parsing through older resources, Xfiles, etc. Also added secure versions of two functions that really need bounds to be SAL annotatable.