ID3D12Device::CreateDescriptorHeap method (d3d12.h)
Creates a descriptor heap object.
Syntax
HRESULT CreateDescriptorHeap(
[in] const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc,
REFIID riid,
[out] void **ppvHeap
);
Parameters
[in] pDescriptorHeapDesc
Type: const D3D12_DESCRIPTOR_HEAP_DESC*
A pointer to a D3D12_DESCRIPTOR_HEAP_DESC structure that describes the heap.
riid
Type: REFIID
The globally unique identifier (GUID) for the descriptor heap interface. See Remarks. An input parameter.
[out] ppvHeap
Type: void**
A pointer to a memory block that receives a pointer to the descriptor heap. ppvHeap can be NULL, to enable capability testing. When ppvHeap is NULL, no object will be created and S_FALSE will be returned when pDescriptorHeapDesc is valid.
Return value
Type: HRESULT
This method returns E_OUTOFMEMORY if there is insufficient memory to create the descriptor heap object. See Direct3D 12 Return Codes for other possible return values.
Remarks
The REFIID, or GUID, of the interface to the descriptor heap can be obtained by using the __uuidof() macro. For example, __uuidof(ID3D12DescriptorHeap) will get the GUID of the interface to a descriptor heap.
Examples
The D3D12HelloWorld sample uses ID3D12Device::CreateDescriptorHeap as follows:
Describe and create a render target view (RTV) descriptor heap.
// Create descriptor heaps.
{
// Describe and create a render target view (RTV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {};
rtvHeapDesc.NumDescriptors = FrameCount;
rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_rtvHeap)));
m_rtvDescriptorSize = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
}
// Create frame resources.
{
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart());
// Create a RTV for each frame.
for (UINT n = 0; n < FrameCount; n++)
{
ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_renderTargets[n])));
m_device->CreateRenderTargetView(m_renderTargets[n].Get(), nullptr, rtvHandle);
rtvHandle.Offset(1, m_rtvDescriptorSize);
}
Refer to the Example Code in the D3D12 Reference.
Requirements
Requirement | Value |
---|---|
Target Platform | Windows |
Header | d3d12.h |
Library | D3D12.lib |
DLL | D3D12.dll |