Direct3D 12 STATE_CREATION ERROR #649: CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE

Every time my constant buffer helper creates the "Constant buffer view" with the CreateConstantBufferView method i get an error which states:

D3D12 ERROR: ID3D12Device::CreateConstantBufferView: pDesc->BufferLocation 0x00000000a9df6000 does not belong to any existing Resource or Heap. [ STATE_CREATION ERROR #649: CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE]

this makes no sense as the resource is created and used (just like in the previous working usages of this method) the only thing that is different is the descriptor heap and obviously the instance of the constant buffer helper.

Also it is used by a different command list and Pipeline state object (PSO), this may be the problem but I am unsure.

here is the relevant code for the creation of the constant buffer view:

D3D12_CONSTANT_BUFFER_VIEW_DESC desc = {};
desc.SizeInBytes = size;
m_deviceResources->GetD3DDevice()->CreateConstantBufferView(&desc, cbvCpuHandle);
sizeInBytes = desc.SizeInBytes;


Below is for the creation of the descriptor heap and constant buffer helper:

 m_cbvSrvHeapManager = std::make_shared<DescriptorHeapManager>(DX::c_frameCount + 1, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, m_deviceResources);
m_cbvDescriptorSize = m_cbvSrvHeapManager->GetDescriptorSize();

m_mvpConstantBufferManager = std::make_unique<ConstantBufferManager<Structures::ModelViewProjectionConstantBuffer>>(DX::c_frameCount, m_mvpConstantBufferManager->GetAlignedSize(), m_deviceResources, m_commandListManager);
for (int n = 0; n < DX::c_frameCount; n++)
{
m_mvpConstantBufferManager->CreateBufferDesc(m_mvpConstantBufferManager->GetAlignedSize(), n, m_cbvSrvHeapManager, m_cbvDescriptorSize);

}


Below is for the previous working usage of the creation of the descriptor heap and and constant buffer helper:

m_cbvSrvHeapManager = std::make_shared<DescriptorHeapManager>(DX::c_frameCount + 2, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, m_deviceResources);

m_cbvDescriptorSize = m_cbvSrvHeapManager->GetDescriptorSize();
m_mvpConstantBufferManager = std::make_unique<ConstantBufferManager<Structures::ModelViewProjectionConstantBuffer>>(DX::c_frameCount, m_mvpConstantBufferManager->GetAlignedSize(), m_deviceResources, m_commandListManager);
for (int n = 0; n < DX::c_frameCount; n++)
{
m_mvpConstantBufferManager->CreateBufferDesc(m_mvpConstantBufferManager->GetAlignedSize(), n + 2, m_cbvSrvHeapManager, m_cbvDescriptorSize);
}

• You've got a lot of bespoke classes/methods being used here, so I don't think we can debug your problem for you from this. Note that you should take a look at DirectX Tool Kit for DX12, and in particular the GraphicsMemory and LinearAllocator classes. – Chuck Walbourn Mar 1 '18 at 17:28