Function getCSO

Synopsis

#include <Source/Falcor/Core/State/ComputeState.h>

ComputeStateObject::SharedPtr getCSO(const ComputeVars *pVars)

Description

Get the active compute state object

Source

Lines 39-81 in Source/Falcor/Core/State/ComputeState.cpp. Line 67 in Source/Falcor/Core/State/ComputeState.h.

ComputeStateObject::SharedPtr ComputeState::getCSO(const ComputeVars* pVars)
{
    auto pProgramKernels = mpProgram ? mpProgram->getActiveVersion()->getKernels(pVars) : nullptr;
    bool newProgram = (pProgramKernels.get() != mCachedData.pProgramKernels);
    if (newProgram)
    {
        mCachedData.pProgramKernels = pProgramKernels.get();
        mpCsoGraph->walk((void*)mCachedData.pProgramKernels);
    }
    RootSignature::SharedPtr pRoot = pProgramKernels ? pProgramKernels->getRootSignature() : RootSignature::getEmpty();
    if (mCachedData.pRootSig != pRoot.get())
    {
        mCachedData.pRootSig = pRoot.get();
        mpCsoGraph->walk((void*)mCachedData.pRootSig);
    }
    ComputeStateObject::SharedPtr pCso = mpCsoGraph->getCurrentNode();
    if(pCso == nullptr)
    {
        mDesc.setProgramKernels(pProgramKernels);
        mDesc.setRootSignature(pRoot);
        StateGraph::CompareFunc cmpFunc = [&desc = mDesc](ComputeStateObject::SharedPtr pCso) -> bool
        {
            return pCso && (desc == pCso->getDesc());
        };
        if (mpCsoGraph->scanForMatchingNode(cmpFunc))
        {
            pCso = mpCsoGraph->getCurrentNode();
        }
        else
        {
            pCso = ComputeStateObject::create(mDesc);
            mpCsoGraph->setCurrentNodeData(pCso);
        }
    }
    return pCso;
}





Add Discussion as Guest

Log in to DocsForge