Function aliasResource

Synopsis

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

static SharedPtr aliasResource(Resource::SharedPtr pBaseResource, GpuAddress offset, size_t size, Resource::BindFlags bindFlags)

Description

No description yet.

Source

Lines 135-163 in Source/Falcor/Core/API/Buffer.cpp. Line 164 in Source/Falcor/Core/API/Buffer.h.

Buffer::SharedPtr Buffer::aliasResource(Resource::SharedPtr pBaseResource, GpuAddress offset, size_t size, Resource::BindFlags bindFlags)
{
    assert(pBaseResource->asBuffer()); // Only aliasing buffers for now
    CpuAccess cpuAccess = pBaseResource->asBuffer() ? pBaseResource->asBuffer()->getCpuAccess() : CpuAccess::None;
    if (cpuAccess != CpuAccess::None)
    {
        logError("Buffer::aliasResource() - trying to alias a buffer with CpuAccess::" + to_string(cpuAccess) + " which is illegal. Aliased resource must have CpuAccess::None");
        return nullptr;
    }
    if ((pBaseResource->getBindFlags() & bindFlags) != bindFlags)
    {
        logError("Buffer::aliasResource() - requested buffer bind-flags don't match the aliased resource bind flags.\nRequested = " + to_string(bindFlags) + "\nAliased = " + to_string(pBaseResource->getBindFlags()));
        return nullptr;
    }
    if (offset >= pBaseResource->getSize() || (offset + size) >= pBaseResource->getSize())
    {
        logError("Buffer::aliasResource() - requested offset and size don't fit inside the alias resource dimensions. Requested size = " +
            std::to_string(size) + ", offset = " + std::to_string(offset) + ". Aliased resource size = " + std::to_string(pBaseResource->getSize()));
        return nullptr;
    }
    SharedPtr pBuffer = SharedPtr(new Buffer(size, bindFlags, CpuAccess::None));
    pBuffer->mpAliasedResource = pBaseResource;
    pBuffer->mApiHandle = pBaseResource->getApiHandle();
    pBuffer->mGpuVaOffset = offset;
    return pBuffer;
}





Add Discussion as Guest

Log in to DocsForge