Function apiInit

Synopsis

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

void apiInit(bool hasInitData)

Description

No description yet.

Source

Lines 81-115 in Source/Falcor/Core/API/D3D12/D3D12Buffer.cpp. Line 287 in Source/Falcor/Core/API/Buffer.h.

void Buffer::apiInit(bool hasInitData)
{
    if (mCpuAccess != CpuAccess::None && is_set(mBindFlags, BindFlags::Shared))
    {
        throw std::exception("Can't create shared resource with CPU access other than 'None'.");
    }
    if (mBindFlags == BindFlags::Constant)
    {
        mSize = align_to(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT, mSize);
    }
    if (mCpuAccess == CpuAccess::Write)
    {
        mState.global = Resource::State::GenericRead;
        if(hasInitData == false) // Else the allocation will happen when updating the data
        {
            assert(gpDevice);
            mDynamicData = gpDevice->getUploadHeap()->allocate(mSize, getBufferDataAlignment(this));
            mApiHandle = mDynamicData.pResourceHandle;
            mGpuVaOffset = mDynamicData.offset;
        }
    }
    else if (mCpuAccess == CpuAccess::Read && mBindFlags == BindFlags::None)
    {
        mState.global = Resource::State::CopyDest;
        mApiHandle = createBuffer(mState.global, mSize, kReadbackHeapProps, mBindFlags);
    }
    else
    {
        mState.global = Resource::State::Common;
        if (is_set(mBindFlags, BindFlags::AccelerationStructure)) mState.global = Resource::State::AccelerationStructure;
        mApiHandle = createBuffer(mState.global, mSize, kDefaultHeapProps, mBindFlags);
    }
}





Add Discussion as Guest

Log in to DocsForge