Function create

Synopsis

#include <Source/Falcor/Core/API/ResourceViews.h>

static SharedPtr create(ConstBufferSharedPtrRef pBuffer)

Description

No description yet.

Source

Lines 443-467 in Source/Falcor/Core/API/D3D12/D3D12ResourceViews.cpp. Line 172 in Source/Falcor/Core/API/ResourceViews.h.

ConstantBufferView::SharedPtr ConstantBufferView::create(ConstBufferSharedPtrRef pBuffer)
{
    if (!pBuffer && getNullView()) return getNullView();
    D3D12_CONSTANT_BUFFER_VIEW_DESC desc;
    Resource::ApiHandle resHandle = nullptr;
    if (pBuffer)
    {
        desc.BufferLocation = pBuffer->getGpuAddress();
        desc.SizeInBytes = (uint32_t)pBuffer->getSize();
        resHandle = pBuffer->getApiHandle();
    }
    else
    {
        desc = {};
    }
    DescriptorSet::Layout layout;
    layout.addRange(DescriptorSet::Type::Cbv, 0, 1);
    ApiHandle handle = DescriptorSet::create(gpDevice->getCpuDescriptorPool(), layout);
    gpDevice->getApiHandle()->CreateConstantBufferView(&desc, handle->getCpuHandle(0));
    SharedPtr pObj = SharedPtr(new ConstantBufferView(pBuffer, handle));
    return pObj;
}





Add Discussion as Guest

Log in to DocsForge