Class ReflectionStructType

Synopsis

#include <Source/Falcor/Core/Program/ProgramReflection.h>

class dlldecl ReflectionStructType : public ReflectionType

Description

Represents a struct type in shader code.

Inheritance

Ancestors: ReflectionType

Structures

BuildState

Methods

addMemberAdd a new member
addMemberIgnoringNameConflicts
createCreate a new structure type
findMemberByOffsetFind a member based on a byte offset.
getMemberGet member by index
getMemberCountGet the total number members
getMemberIndexGet the index of a member
getNameGet the name of the struct type
operator==Compare types for equality.

Source

Lines 808-880 in Source/Falcor/Core/Program/ProgramReflection.h.

class dlldecl ReflectionStructType : public ReflectionType
{
public:
    using SharedPtr = std::shared_ptr<ReflectionStructType>;
    using SharedConstPtr = std::shared_ptr<const ReflectionStructType>;
    /** Get the name of the struct type
    */
    const std::string& getName() const { return mName; }
    /** Get the total number members
    */
    uint32_t getMemberCount() const { return (uint32_t)mMembers.size(); }
    /** Get member by index
    */
    const std::shared_ptr<const ReflectionVar>& getMember(size_t index) const { return mMembers[index]; }
    /** Get member by name
    */
    const std::shared_ptr<const ReflectionVar>& getMember(const std::string& name) const;
    /** Constant used to indicate that member lookup failed.
    */
    static const int32_t kInvalidMemberIndex = -1;
    /** Get the index of a member
    Returns `kInvalidMemberIndex` if no such member exists.
    */
    int32_t getMemberIndex(const std::string& name) const;
    /** Find a member based on a byte offset.
    */
    TypedShaderVarOffset findMemberByOffset(size_t offset) const;
    bool operator==(const ReflectionStructType& other) const;
    bool operator==(const ReflectionType& other) const override;
    // TODO(tfoley): The following members are only needed to construct a type.
    /** Create a new structure type
        \param[in] size The size of the struct in bytes
        \param[in] name The name of the struct
    */
    static SharedPtr create(
        size_t              byteSize,
        const std::string& name,
        slang::TypeLayoutReflection*    pSlangTypeLayout);
    struct BuildState
    {
        uint32_t cbCount = 0;
        uint32_t srvCount = 0;
        uint32_t uavCount = 0;
        uint32_t samplerCount = 0;
    };
    /** Add a new member
    */
    int32_t addMember(const std::shared_ptr<const ReflectionVar>& pVar, BuildState& ioBuildState);
    int32_t addMemberIgnoringNameConflicts(const std::shared_ptr<const ReflectionVar>& pVar, BuildState& ioBuildState);
private:
    ReflectionStructType(
        size_t size,
        const std::string& name,
        slang::TypeLayoutReflection*    pSlangTypeLayout);
    std::vector<std::shared_ptr<const ReflectionVar>> mMembers;   // Struct members
    std::unordered_map<std::string, int32_t> mNameToIndex; // Translates from a name to an index in mMembers
    std::string mName;
};





Add Discussion as Guest

Log in to DocsForge