Function create

Synopsis

#include <Source/Falcor/Core/API/D3D12/D3D12DescriptorHeap.h>

static SharedPtr create(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t descCount, bool shaderVisible=true)

Description

Create a new descriptor heap.

Parameters

[ in ] type - Descriptor heap type.

[ in ] descCount - Descriptor count.

[ in ] shaderVisible - True if the descriptor heap should be shader visible.

Return
A new object, or throws an exception if creation failed.

Source

Lines 42-62 in Source/Falcor/Core/API/D3D12/D3D12DescriptorHeap.cpp. Line 51 in Source/Falcor/Core/API/D3D12/D3D12DescriptorHeap.h.

D3D12DescriptorHeap::SharedPtr D3D12DescriptorHeap::create(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t descCount, bool shaderVisible)
{
    assert(gpDevice);
    DeviceHandle pDevice = gpDevice->getApiHandle();
    uint32_t chunkCount = (descCount + kDescPerChunk - 1) / kDescPerChunk;
    D3D12DescriptorHeap::SharedPtr pHeap = SharedPtr(new D3D12DescriptorHeap(type, chunkCount));
    D3D12_DESCRIPTOR_HEAP_DESC desc = {};
    desc.Flags = shaderVisible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
    desc.Type = type;
    desc.NumDescriptors = chunkCount * kDescPerChunk;
    if (FAILED(pDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&pHeap->mApiHandle))))
    {
        throw std::exception("Failed to create descriptor heap");
    }
    pHeap->mCpuHeapStart = pHeap->mApiHandle->GetCPUDescriptorHandleForHeapStart();
    pHeap->mGpuHeapStart = pHeap->mApiHandle->GetGPUDescriptorHandleForHeapStart();
    return pHeap;
}





Add Discussion as Guest

Log in