Class RtProgram

Synopsis

#include <Source/Falcor/Raytracing/RtProgram/RtProgram.h>

class dlldecl RtProgram : public Program

Description

Ray tracing program. See GraphicsProgram and ComputeProgram to manage other types of programs.

Inheritance

Ancestors: Program

Classes

Desc
DescExtra

Methods

createCreate a new ray tracing program.
createEntryPointGroupKernels
getDescExtra
getHitIndex
getHitProgramCount
getMaxTraceRecursionDepthGet the max recursion depth
getMissIndex
getMissProgramCount
getRayGenIndex
getRayGenProgramCount
getRtsoGet the raytracing state object for this program
init
setSceneSet the scene

Source

Lines 39-148 in Source/Falcor/Raytracing/RtProgram/RtProgram.h.

class dlldecl RtProgram : public Program
{
public:
    using SharedPtr = std::shared_ptr<RtProgram>;
    using SharedConstPtr = std::shared_ptr<const RtProgram>;
    using DefineList = Program::DefineList;
    struct dlldecl DescExtra
    {
    public:
        struct GroupInfo
        {
            int32_t groupIndex = -1;
        };
        /** Set the max recursion depth
        */
        void setMaxTraceRecursionDepth(uint32_t maxDepth) { mMaxTraceRecursionDepth = maxDepth; }
        std::vector<GroupInfo> mRayGenEntryPoints;
        std::vector<GroupInfo> mMissEntryPoints;
        std::vector<GroupInfo> mHitGroups;
        uint32_t mMaxTraceRecursionDepth = 1;
    };
    class dlldecl Desc : public DescExtra
    {
    public:
        Desc() { init(); }
        Desc(const std::string& filename) : mBaseDesc(filename) { init(); }
        Desc& addShaderLibrary(const std::string& filename);
        Desc& setRayGen(const std::string& raygen);
        Desc& addRayGen(const std::string& raygen);
        Desc& addMiss(uint32_t missIndex, const std::string& miss);
        Desc& addHitGroup(uint32_t hitIndex, const std::string& closestHit, const std::string& anyHit = "", const std::string& intersection = "");
        Desc& addDefine(const std::string& define, const std::string& value);
        Desc& addDefines(const DefineList& defines);
        /** Set the compiler flags. Replaces any previously set flags.
        */
        Desc& setCompilerFlags(Shader::CompilerFlags flags) { mBaseDesc.setCompilerFlags(flags); return *this; }
    private:
        friend class RtProgram;
        void init();
        Program::Desc mBaseDesc;
        DefineList mDefineList;
    };
    /** Create a new ray tracing program.
        \param[in] desc The program description.
        \param[in] maxPayloadSize The maximum ray payload size in bytes.
        \param[in] maxAttributesSize The maximum attributes size in bytes.
        \return A new object, or an exception is thrown if creation failed.
    */
    static RtProgram::SharedPtr create(const Desc& desc, uint32_t maxPayloadSize = FALCOR_RT_MAX_PAYLOAD_SIZE_IN_BYTES, uint32_t maxAttributesSize = D3D12_RAYTRACING_MAX_ATTRIBUTE_SIZE_IN_BYTES);
    /** Get the max recursion depth
    */
    uint32_t getMaxTraceRecursionDepth() const { return mDescExtra.mMaxTraceRecursionDepth; }
    /** Get the raytracing state object for this program
    */
    RtStateObject::SharedPtr getRtso(RtProgramVars* pVars);
    // Ray-gen
    uint32_t getRayGenProgramCount() const { return (uint32_t) mDescExtra.mRayGenEntryPoints.size(); }
    uint32_t getRayGenIndex(uint32_t index) const { return mDescExtra.mRayGenEntryPoints[index].groupIndex; }
    // Hit
    uint32_t getHitProgramCount() const { return (uint32_t) mDescExtra.mHitGroups.size(); }
    uint32_t getHitIndex(uint32_t index) const { return mDescExtra.mHitGroups[index].groupIndex; }
    // Miss
    uint32_t getMissProgramCount() const { return (uint32_t) mDescExtra.mMissEntryPoints.size(); }
    uint32_t getMissIndex(uint32_t index) const { return mDescExtra.mMissEntryPoints[index].groupIndex; }
    /** Set the scene
    */
    void setScene(const Scene::SharedPtr& pScene);
    DescExtra const& getDescExtra() const { return mDescExtra; }
protected:
    void init(const Desc& desc);
    EntryPointGroupKernels::SharedPtr createEntryPointGroupKernels(
        const std::vector<Shader::SharedPtr>& shaders,
        EntryPointGroupReflection::SharedPtr const& pReflector) const override;
private:
    RtProgram(RtProgram const&) = delete;
    RtProgram& operator=(RtProgram const&) = delete;
    RtProgram(const Desc& desc, uint32_t maxPayloadSize = FALCOR_RT_MAX_PAYLOAD_SIZE_IN_BYTES, uint32_t maxAttributesSize = D3D12_RAYTRACING_MAX_ATTRIBUTE_SIZE_IN_BYTES);
    DescExtra mDescExtra;
    uint32_t mMaxPayloadSize;
    uint32_t mMaxAttributesSize;
    using StateGraph = Falcor::StateGraph<RtStateObject::SharedPtr, void*>;
    StateGraph mRtsoGraph;
    Scene::SharedPtr mpScene;
};





Add Discussion as Guest

Log in