I'm new to DirectX11 and I'm trying to adapt a file written using DirectX Legacy to new DirectX but I'm having some trouble with template XMVectorPermute, which used to be a function in Legacy file.
I'm trying to make compiler recognize the template in DirectXMath.h
:
// General permute template
template<uint32_t PermuteX, uint32_t PermuteY, uint32_t PermuteZ, uint32_t PermuteW>
inline XMVECTOR XM_CALLCONV XMVectorPermute(FXMVECTOR V1, FXMVECTOR V2)
{
//...Definition
by using the following code:
template DirectX::XMVECTOR DirectX::XMVectorPermute<PermuteXXY.i[0], PermuteXXY.i[1], PermuteXXY.i[2], PermuteXXY.i[3]>(FXMVECTOR V1, FXMVECTOR V2);
in which PermuteXXY
is defined as:
static CONST DirectX::XMVECTORI32 PermuteXXY =
{
DirectX::XM_PERMUTE_0X, DirectX::XM_PERMUTE_0X, DirectX::XM_PERMUTE_0Y, DirectX::XM_PERMUTE_0W
};
but the compiler or the linker cannot make a match: Error reported
XM_PERMUTE_...
is defined as a const uint32_t
in DirectXMath.h
, and XMVECTORI32
is defined as a union:
union
{
int32_t i[4];
XMVECTOR v;
};
I'm not very good at c++ template so please help me with this as thoroughly as possible. Thanks a lot!