Function resourceBarrier

Synopsis

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

bool resourceBarrier(const Resource *pResource, Resource::State newState, const ResourceViewInfo *pViewInfo=nullptr)

Description

Insert a resource barrier if pViewInfo is nullptr, will transition the entire resource. Otherwise, it will only transition the subresource in the view

Return
true if a barrier commands were recorded for the entire resource-view, otherwise false (for example, when the current resource state is the same as the new state or when only some subresources were transitioned)

Source

Lines 82-110 in Source/Falcor/Core/API/CopyContext.cpp. Line 87 in Source/Falcor/Core/API/CopyContext.h.

bool CopyContext::resourceBarrier(const Resource* pResource, Resource::State newState, const ResourceViewInfo* pViewInfo)
{
    const Texture* pTexture = dynamic_cast<const Texture*>(pResource);
    if (pTexture)
    {
        bool globalBarrier = pTexture->isStateGlobal();
        if (pViewInfo)
        {
            globalBarrier = globalBarrier && pViewInfo->firstArraySlice == 0;
            globalBarrier = globalBarrier && pViewInfo->mostDetailedMip == 0;
            globalBarrier = globalBarrier && pViewInfo->mipCount == pTexture->getMipCount();
            globalBarrier = globalBarrier && pViewInfo->arraySize == pTexture->getArraySize();
        }
        if (globalBarrier)
        {
            return textureBarrier(pTexture, newState);
        }
        else
        {
            return subresourceBarriers(pTexture, newState, pViewInfo);
        }
    }
    else
    {
        const Buffer* pBuffer = dynamic_cast<const Buffer*>(pResource);
        return bufferBarrier(pBuffer, newState);
    }
}





Add Discussion as Guest

Log in to DocsForge