ID3D12Device::CreateConstantBufferView method

Creates a constant-buffer view for accessing resource data.

Syntax


void CreateConstantBufferView(
  [in, optional] const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc,
  [in]                 D3D12_CPU_DESCRIPTOR_HANDLE     DestDescriptor
);

Parameters

pDesc [in, optional]

Type: const D3D12_CONSTANT_BUFFER_VIEW_DESC*

A pointer to a D3D12_CONSTANT_BUFFER_VIEW_DESC structure that describes the constant-buffer view.

DestDescriptor [in]

Type: D3D12_CPU_DESCRIPTOR_HANDLE

Describes the CPU descriptor handle that represents the start of the heap that holds the constant-buffer view.

Return value

Returns nothing.

Examples

The D3D12HelloWorld sample uses ID3D12Device::CreateConstantBufferView as follows:


// Describe and create a constant buffer view.
D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {};
cbvDesc.BufferLocation = m_constantBuffer->GetGPUVirtualAddress();
cbvDesc.SizeInBytes = (sizeof(ConstantBuffer) + 255) & ~255;    // CB size is required to be 256-byte aligned.
m_device->CreateConstantBufferView(&cbvDesc, m_cbvHeap->GetCPUDescriptorHandleForHeapStart());


Refer to the Example Code in the D3D12 Reference.

Requirements

Header

D3D12.h

Library

D3D12.lib

DLL

D3D12.dll

See also

ID3D12Device

 

 

Show: