iam trying to send a matrix array to the GPU but its not working >.<
This is what iam doing
Create a constant buffer to put the matrix array ( a XMMATRIX*)
#define MAX_BONE_MATRICES 100
...
// Create the constant buffers
D3D11_BUFFER_DESC bd;
ZeroMemory( &bd, sizeof(bd) );
bd.ByteWidth = sizeof(XMMATRIX) * MAX_BONE_MATRICES;
bd.Usage = D3D11_USAGE_DYNAMIC;
bd.BindFlags = D3D11_BIND_SHADER_RESOURCE;
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
hr = EngineStuff::EGraphicsDevice->CreateBuffer( &bd, NULL, &boneMatrixBuffer);
CheckError(hr);
Iam Updating the buffer using
(&obj.IOBJECT->GetMesh()->AbsoluteBone is the XMMATRIX*)
EngineStuff::EImediateDeviceContext->UpdateSubresource( boneMatrixBuffer, 0, NULL, &obj.IOBJECT->GetMesh()->AbsoluteBone, 0, 0 );
To send the buffer iam using
EngineStuff::EImediateDeviceContext->VSSetConstantBuffers( 1, 1, &boneMatrixBuffer); (in the hlsl, the buffer is binded to the b1 register)
The HLSL declaration of the buffer is
#define MAX_BONE_MATRICES 100
cbuffer cbChangeOnResize : register( b1 )
{
matrix BonesMatrix[MAX_BONE_MATRICES];
};
Iam the code that access the buffer is
(ibone is declared as a float, but constains a integer (like 1.00 ))
matrix m = BonesMatrix[ibone];
output.Pos += fweight * mul( pos, m );
The matrix that iam sending is declared as
AbsoluteBone = (XMMATRIX*) _aligned_malloc(sizeof(XMMATRIX) * 100,16);
(not all of the reserved space is used)
I tryed using pix, but its says that the buffer has only 48 float elements (and when i "cast" it to a matrix array it fails ... -> maybe i dont know how to use pix to debug constant buffers !!! >.<)
Is there a obvious mistake in this code ?
Thanks for every kind of help.