Function createStructured

Summary

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

(1) static SharedPtr createStructured(uint32_t structSize, uint32_t elementCount, ResourceBindFlags bindFlags=Resource::BindFlags::ShaderResource|Resource::BindFlags::UnorderedAccess, CpuAccess cpuAccess=Buffer::CpuAccess::None, const void *pInitData=nullptr, bool createCounter=true)

(2) static SharedPtr createStructured(const Program *pProgram, const std::string &name, uint32_t elementCount, ResourceBindFlags bindFlags=Resource::BindFlags::ShaderResource|Resource::BindFlags::UnorderedAccess, CpuAccess cpuAccess=Buffer::CpuAccess::None, const void *pInitData=nullptr, bool createCounter=true)

(3) static SharedPtr createStructured(const ShaderVar &shaderVar, uint32_t elementCount, ResourceBindFlags bindFlags=Resource::BindFlags::ShaderResource|Resource::BindFlags::UnorderedAccess, CpuAccess cpuAccess=Buffer::CpuAccess::None, const void *pInitData=nullptr, bool createCounter=true)

Function overload

Synopsis

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

static SharedPtr createStructured(uint32_t structSize, uint32_t elementCount, ResourceBindFlags bindFlags=Resource::BindFlags::ShaderResource|Resource::BindFlags::UnorderedAccess, CpuAccess cpuAccess=Buffer::CpuAccess::None, const void *pInitData=nullptr, bool createCounter=true)

Description

Create a new structured buffer.

Parameters:

[ in ] structSize - Size of the struct in bytes.

[ in ] elementCount - Number of elements.

[ in ] bindFlags - Buffer bind flags.

[ in ] cpuAccess - Flags indicating how the buffer can be updated.

[ in ] pInitData - Optional parameter. Initial buffer data. Pointed buffer should hold at least 'elementCount' elements.

[ in ] createCounter - True if the associated UAV counter should be created.

Return
A pointer to a new buffer object, or throws an exception if creation failed.

Source

Lines 84-104 in Source/Falcor/Core/API/Buffer.cpp. Line 120 in Source/Falcor/Core/API/Buffer.h.

Buffer::SharedPtr Buffer::createStructured(
    uint32_t structSize,
    uint32_t elementCount,
    ResourceBindFlags bindFlags,
    CpuAccess cpuAccess,
    const void* pInitData,
    bool createCounter)
{
    size_t size = structSize * elementCount;
    Buffer::SharedPtr pBuffer = create(size, bindFlags, cpuAccess, pInitData);
    assert(pBuffer);
    pBuffer->mElementCount = elementCount;
    pBuffer->mStructSize = structSize;
    static const uint32_t zero = 0;
    if (createCounter)
    {
        pBuffer->mpUAVCounter = Buffer::create(sizeof(uint32_t), Resource::BindFlags::UnorderedAccess, Buffer::CpuAccess::None, &zero);
    }
    return pBuffer;
}

Synopsis

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

static SharedPtr createStructured(const Program *pProgram, const std::string &name, uint32_t elementCount, ResourceBindFlags bindFlags=Resource::BindFlags::ShaderResource|Resource::BindFlags::UnorderedAccess, CpuAccess cpuAccess=Buffer::CpuAccess::None, const void *pInitData=nullptr, bool createCounter=true)

Description

Create a new structured buffer.

Parameters:

[ in ] pProgram - Program declaring the buffer.

[ in ] name - Variable name in the program.

[ in ] elementCount - Number of elements.

[ in ] bindFlags - Buffer bind flags.

[ in ] cpuAccess - Flags indicating how the buffer can be updated.

[ in ] pInitData - Optional parameter. Initial buffer data. Pointed buffer should hold at least 'elementCount' elements.

[ in ] createCounter - True if the associated UAV counter should be created.

Return
A pointer to a new buffer object, or throws an exception if creation failed.

Source

Lines 117-133 in Source/Falcor/Core/API/Buffer.cpp. Line 138 in Source/Falcor/Core/API/Buffer.h.

Buffer::SharedPtr Buffer::createStructured(
    const Program* pProgram,
    const std::string& name,
    uint32_t elementCount,
    ResourceBindFlags bindFlags,
    CpuAccess cpuAccess,
    const void* pInitData,
    bool createCounter)
{
    const auto& pDefaultBlock = pProgram->getReflector()->getDefaultParameterBlock();
    const ReflectionVar* pVar = pDefaultBlock ? pDefaultBlock->getResource(name).get() : nullptr;
    if (pVar == nullptr)
    {
        throw std::exception(("Can't find a structured buffer named '" + name + "' in the program").c_str());
    }
    return createStructuredFromType(pVar->getType().get(), name, elementCount, bindFlags, cpuAccess, pInitData, createCounter);
}

Synopsis

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

static SharedPtr createStructured(const ShaderVar &shaderVar, uint32_t elementCount, ResourceBindFlags bindFlags=Resource::BindFlags::ShaderResource|Resource::BindFlags::UnorderedAccess, CpuAccess cpuAccess=Buffer::CpuAccess::None, const void *pInitData=nullptr, bool createCounter=true)

Description

Create a new structured buffer.

Parameters:

[ in ] shaderVar - ShaderVar pointing to the buffer variable.

[ in ] elementCount - Number of elements.

[ in ] bindFlags - Buffer bind flags.

[ in ] cpuAccess - Flags indicating how the buffer can be updated.

[ in ] pInitData - Optional parameter. Initial buffer data. Pointed buffer should hold at least 'elementCount' elements.

[ in ] createCounter - True if the associated UAV counter should be created.

Return
A pointer to a new buffer object, or throws an exception if creation failed.

Source

Lines 106-115 in Source/Falcor/Core/API/Buffer.cpp. Line 156 in Source/Falcor/Core/API/Buffer.h.

Buffer::SharedPtr Buffer::createStructured(
    const ShaderVar& shaderVar,
    uint32_t elementCount,
    ResourceBindFlags bindFlags,
    CpuAccess cpuAccess,
    const void* pInitData,
    bool createCounter)
{
    return createStructuredFromType(shaderVar.getType().get(), "<Unknown ShaderVar>", elementCount, bindFlags, cpuAccess, pInitData, createCounter);
}





Add Discussion as Guest

Log in to DocsForge