2

I'm following "Game Programming using DirectX12" ch.6 codes.

But in at ID3DDevice::CreateConstantBufferView, I found D3D12 Error.

D3D12 ERROR: ID3D12Device::CreateConstantBufferView: pDesc->BufferLocation + SizeInBytes - 1 (0x00000000087b00ff) exceeds end of the virtual address range of Resource (0x0DA64DA0:'Unnamed ID3D12Resource Object', GPU VA Range: 0x00000000087b0000 - 0x00000000087b003f). [ STATE_CREATION ERROR #649: CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE]

And this is my code.

void BoxApp::BuildConstantBuffers()
{
    mObjectCB = std::make_unique<UploadBuffer<ObjectConstants>>(md3dDevice.Get(), 1, true);

    UINT objCBByteSize = calcConstantBufferByteSize(sizeof(ObjectConstants));

    D3D12_GPU_VIRTUAL_ADDRESS cbAddress = mObjectCB->Resource()->GetGPUVirtualAddress();

    int boxCBufIndex = 0;
    cbAddress += static_cast<UINT64>(boxCBufIndex) * static_cast<UINT64>(objCBByteSize);

    D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc;
    cbvDesc.BufferLocation = cbAddress;
    cbvDesc.SizeInBytes = calcConstantBufferByteSize(sizeof(ObjectConstants));
    md3dDevice->CreateConstantBufferView(&cbvDesc, mCbvHeap->GetCPUDescriptorHandleForHeapStart());
}


static UINT calcConstantBufferByteSize(UINT byteSize)
{
    return (byteSize + 255) & ~255;
}

What occurs error, and How to fix it?

Asesh
  • 3,186
  • 2
  • 21
  • 31
RedChiken
  • 21
  • 2

0 Answers0