Why isn't my other two constant buffers being updated to the shader?

I posted previously before about my two dynamic buffers not being dynamically updating the constant shader. The tessellation buffer isn't working because I have to manually update the tessellation factor inside the hull shader. I believe the camera position isn't updating either because when I perform distance adaptation the far edges are more tessellated then the what's truly in front of the camera. I have all the buffers set to dynamic. Inside the render loop I have them set as:

Here is the updating map and unmap functions.

 D3D11_MAPPED_SUBRESOURCE map;
CBUFFER_PER_OBJECT *cBufferTessPerObject;
ZeroMemory(&map, sizeof(D3D11_MAPPED_SUBRESOURCE));

// mesh.worldMatrix = XMMatrixIdentity();
mesh.worldMatrix = mesh.translationMatrix;
XMMATRIX world = XMMatrixTranspose(mesh.worldMatrix);
cBufferTessPerObject = (CBUFFER_PER_OBJECT*)map.pData;

cBufferTessPerObject->WorldMatrix = mesh.worldMatrix * CameraView * CameraProjection;
cBufferTessPerObject->viewMatrix = CameraView;
cBufferTessPerObject->projectionMatrix = CameraProjection;
cBufferTessPerObject->modelWorldMatrix = mesh.worldMatrix;
cBufferTessPerObject->isSelected = mesh.isSelected;

// Finally set the matrix constant buffer in the domain shader with the/ updated values.

devcon->Unmap(mesh.m_constantBuffer, 0);

cameraConstantBuffer *dataPtr1;
ZeroMemory(&map, sizeof(D3D11_MAPPED_SUBRESOURCE));
dataPtr1 = (cameraConstantBuffer*)map.pData;

float cx = XMVectorGetX(CameraPosition);
float cy = XMVectorGetY(CameraPosition);
float cz = XMVectorGetZ(CameraPosition);

dataPtr1->cameraPosition = XMFLOAT3(cx, cy, cz);
devcon->Unmap(camCbuffer, 0);

TessellationBufferType *dataPtr2;
ZeroMemory(&map, sizeof(D3D11_MAPPED_SUBRESOURCE));
dataPtr2 = (TessellationBufferType*)map.pData;

mesh.tessellationFactor = tessAmount;
dataPtr2->tessellationAmount = mesh.tessellationFactor;
devcon->Unmap(mesh.tessellationBuffer, 0);

mesh.multiBuffers[0] = mesh.m_constantBuffer;
mesh.multiBuffers[1] = camCbuffer;
mesh.multiBuffers[2] = mesh.tessellationBuffer;

devcon->VSSetConstantBuffers(0, 3, mesh.multiBuffers);
devcon->HSSetConstantBuffers(0, 3, mesh.multiBuffers);
devcon->DSSetConstantBuffers(0, 3, mesh.multiBuffers);
devcon->PSSetConstantBuffers(0, 3, mesh.multiBuffers);


I only got that from a directX Sample. Inside the shader file I have the three cbuffer structs.

cbuffer ConstantBuffer
{
float4x4 WorldMatrix;
float4x4 viewMatrix;
float4x4 projectionMatrix;
float4x4 modelWorldMatrix;    // the rotation matrix
float3 lightvec;      // the light's vector
float4 lightcol;      // the light's color
float4 ambientcol;    // the ambient light's color
bool isSelected;
}

cbuffer cameraBuffer
{
}

cbuffer TessellationBuffer
{
float tessellationAmount;

}


Am I missing something or would anyone know why wouldn't my buffers update to the shader file?

• Can you also post the code where you are actually updating the constant buffers on the CPU - i.e. using Map/Unmap, or UpdateSubresource? Also, are you using the D3D11 debug layer and checking for any errors/warnings from it? – Nathan Reed Nov 1 '13 at 4:30
• I'll be also working on my organization code skills because I realized that I have a hard time spotting issues in code. I can narrow it down but sometimes, it leaves me completely lost. A bit more error handling system would be in development too. – SICGames2013 Nov 2 '13 at 6:04

When you are calling the VSSetConstantBuffer(), it will locate the diffrent buffers on registers. It might do fine without register semantics in some cases, but this is really bad practice.
To start solving your problem you should start biding your constat buffers with register semantics.
In otherwords, like this:

cbuffer DataBuffer : register(b0) {};
cbuffer VertexHelperBuffer : register(b1) {};


I would refer you to this article, Microsoft clearly explains whats happening.
Buffer description

Next step is to make sure your Map/Updatesubresource function actualy works. In other words, know if itś returning S_OK or not.

After that, you can take a pix capture to see if the correct values went down the pipe.
this is a good video on how to use pix if you have visual studio 2012 <. video

• Today, I gave it a try to bind with register the sematics which I believe is working, so I'm going to see whether or not the device map and unmap are returning a S_OK hresult. Because most of the functions are being intergrated to C# for the editor side pix always crashes. – SICGames2013 Nov 2 '13 at 5:56