Hi Guys,
I have been scratching my head trying to figure this one out for hours.
I have a shader which is working fine when I send World, View, and Projection matrices to it and everything is rendering correctly.
char cameraData[sizeof(DirectX::XMMATRIX) * 3];
memcpy(cameraData + sizeof(DirectX::XMMATRIX) * 0, &matWorld, sizeof(DirectX::XMMATRIX));
memcpy(cameraData + sizeof(DirectX::XMMATRIX) * 1, &matView, sizeof(DirectX::XMMATRIX));
memcpy(cameraData + sizeof(DirectX::XMMATRIX) * 2, &matProjection, sizeof(DirectX::XMMATRIX));
renderer.GetContext()->UpdateSubresource(renderer.d3dWvpCB, 0, 0, &cameraData, 0, 0);
renderer.GetContext()->VSSetConstantBuffers(0, 1, &renderer.d3dWvpCB);
And the shader input side;
cbuffer WVPCB : register(b0)
{
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
}
But when I try to send the matrix data in separate buffers, the scene renders blank.
char worldData[sizeof(DirectX::XMMATRIX)];
memcpy(worldData, &matWorld, sizeof(DirectX::XMMATRIX));
char viewData[sizeof(DirectX::XMMATRIX)];
memcpy(viewData, &matView, sizeof(DirectX::XMMATRIX));
char projData[sizeof(DirectX::XMMATRIX)];
memcpy(projData, &matProjection, sizeof(DirectX::XMMATRIX));
renderer.GetContext()->UpdateSubresource(renderer.worldCB, 0, 0, &matWorld, 0, 0);
renderer.GetContext()->UpdateSubresource(renderer.viewCB, 0, 0, &matView, 0, 0);
renderer.GetContext()->UpdateSubresource(renderer.projectionCB, 0, 0, &matProjection, 0, 0);
renderer.GetContext()->VSSetConstantBuffers(0, 1, &renderer.worldCB);
renderer.GetContext()->VSSetConstantBuffers(1, 1, &renderer.viewCB);
renderer.GetContext()->VSSetConstantBuffers(2, 1, &renderer.projectionCB);
With the shader input now being;
cbuffer WorldCB : register(b0)
{
matrix worldMatrix;
}
cbuffer ViewCB : register(b1)
{
matrix viewMatrix;
}
cbuffer ProjCB : register(b2)
{
matrix projectionMatrix;
}
This has got me completely at a loss. I have checked over everything many many times, but just can't put my finger on what is wrong.
I am running in debug mode and the DX debug is also enabled and verified to be working (by test forcing a few errors). But the are no errors being reported. Just a blank render window.
I have even tried taking out the memcpy sections in the latter part of the code and pointing directly to the matrix data but the fault still persists.
The contant buffers have been created with sizeof(XMMatrix) and confirmed that they are 64 bytes wide. Which should also rule out an alignment issue as the buffers are evenly 16 byte aligned.
This has got me truly bewildered and any help would be greatly appreciated.
Many thanks in advance.