Skip to content

XMFLOAT3X4 data type and load/store functions#71

Merged
walbourn merged 1 commit intomasterfrom
dxr
Jun 1, 2018
Merged

XMFLOAT3X4 data type and load/store functions#71
walbourn merged 1 commit intomasterfrom
dxr

Conversation

@walbourn
Copy link
Member

@walbourn walbourn commented Jun 1, 2018

The XMFLOAT4X3 type is a row-major 4x4 matrix with the last column implicitly [0 0 0 1]. It is a compact way to represent affine transformations (translation, scale, rotation, etc.). It can't capture projective transformations, but this is often more than adequate for doing world->local->view transformations.

HLSL uses column-major storage of matrices by default, so typically you perform a transpose of a 4x4 matrix to store it in an XMMATRIX or XMFLOAT4X4 going from CPU to GPU. In the cases where you want a 4x3 column-major, you typically had to do the following:

XMMATRIX mT = XMMatrixTranspose(m);
XMStoreFloat4(reinterpret_cast<XMFLOAT4*>(...), mT.r[0]);
XMStoreFloat4(reinterpret_cast<XMFLOAT4*>(...), mT.r[1]);
XMStoreFloat4(reinterpret_cast<XMFLOAT4*>(...), mT.r[2]);

Or if you were able to use three XMVECTOR types in aligned constant buffers, you could make it:

XMMATRIX mT = XMMatrixTranspose(m);
cb.row[0] = mT.r[0];
cb.row[1] = mT.r[1];
cb.row[2] = mT.r[2];

As it turns out the DirectX Raytracing API also needs wants the transposed 12-float matrix form as well. Therefore, this change adds a XMFLOAT3X4 to simplify this usage.

@walbourn walbourn self-assigned this Jun 1, 2018
@walbourn walbourn merged commit 0fad211 into master Jun 1, 2018
@walbourn walbourn deleted the dxr branch June 1, 2018 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant