FIXED
I am facing problem sin binding constant buffers to proper constant buffer registers in shader.
Here's how I am trying to making everything work -
rootparam[0] -> b1 (cb1) >> g_TempConstBuffer_PerFrameCamera -> PerFrameCameraVSPS
rootparam[1] -> b0 (cb0) >> g_TempConstBuffer_PerObjWorldMat -> PerObjWorldMat
But for some reason g_TempConstBuffer_PerFrameCamera
constant buffer is binding to register 0 (instead of 1) and g_TempConstBuffer_PerObjWorldMat
constantBuffer is binding to register 1 (instead of 0). I confirmed this in renderdoc.
On C++ side I have a Rootsignature with -
1) RootParam [0] initialized as constant buffer bound to BaseRegisterAddress 0
2) RootParam [1] initialized as DescriptorRange bound to BaseRegisterAddress 1
rootSigDesc[ 0 ].InitAsConstantBuffer( 1, D3D12_SHADER_VISIBILITY_VERTEX );
rootSigDesc[ 1 ].InitAsDescriptorRange( D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 0, 1, D3D12_SHADER_VISIBILITY_VERTEX );
Code I am using in Frameloop to bind constant buffers -
chDescriptorHandle descHandle = staticTempDevice.GetDescHeapGPU_CbvSrvUav()->AllocateDescriptor( 1 );
g_TempConstBuffer_PerFrameCamera.GetCBV( 0, sizeof( _CommonVSPSData_Camera ), descHandle );
cmdList.m_pCmdList->SetGraphicsRootDescriptorTable( 1, descHandle.GetGpuHandle() );
cmdList.m_pCmdList->SetGraphicsRootConstantBufferView( 0, g_TempConstBuffer_PerObjWorldMat.GetRHI()->GetGPUVirtualAddress() + offset );
Here is the shader code -
cbuffer PerFrameCameraVSPS : register ( b1 )
{
matrix viewProj;
matrix viewProj1;
matrix viewProj2;
matrix viewProj3;
};
cbuffer PerObjWorldMat : register ( b0 )
{
matrix worldMat;
matrix worldMat_Inv;
float3 posW;
float _pad0;
float4 col;
};
Shader compiler output -
//
// Resource Bindings:
//
// Name Type Format Dim ID HLSL Bind Count
// ------------------------------ ---------- ------- ----------- ------- -------------- ------
// PerObjWorldMat cbuffer NA NA CB0 cb0 1
// PerFrameCameraVSPS cbuffer NA NA CB1 cb1 1