Class Desc

Synopsis

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

class dlldecl Desc

Description

Description of a program to be created.

Structures

EntryPoint
EntryPointGroup
SourceNo description but mentioned in...

Methods

DescBegin building a description, that initially has no source files or entry points.
addDefaultVertexShaderIfNeeded
addShaderLibraryAdd a file of source code to use
addShaderStringAdd a string of source code to use
beginEntryPointGroup
csEntry
dsEntry
dumpIntermediatesEnable/disable pre-processed shader dump
entryPointAdds an entry point based on the "active" source.
getCompilerFlagsGet the compiler flags
gsEntry
hasEntryPoint
hsEntry
psEntry
setCompilerFlagsSet the compiler flags
setShaderModelSet the shader model string
vsEntry
warningsAsErrorsEnable/disable treat-warnings-as-error compilation flag

Source

Lines 49-162 in Source/Falcor/Core/Program/Program.h.

class dlldecl Desc
{
public:
    /** Begin building a description, that initially has no source files or entry points.
    */
    Desc();
    /** Begin building a description, based on a single path for source code.
        This is equivalent to: `Desc().sourceFile(path)`
    */
    explicit Desc(std::string const& filename);
    /** Add a file of source code to use.
        This also sets the given file as the "active" source for subsequent entry points.
    */
    Desc& addShaderLibrary(const std::string& path);
    /** Add a string of source code to use.
        This also sets the given string as the "active" source for subsequent entry points.
    */
    Desc& addShaderString(const std::string& shader);
    /** Adds an entry point based on the "active" source.
    */
    Desc& entryPoint(ShaderType shaderType, const std::string& name);
    Desc& vsEntry(const std::string& name) { return entryPoint(ShaderType::Vertex, name); }
    Desc& hsEntry(const std::string& name) { return entryPoint(ShaderType::Hull, name); }
    Desc& dsEntry(const std::string& name) { return entryPoint(ShaderType::Domain, name); }
    Desc& gsEntry(const std::string& name) { return entryPoint(ShaderType::Geometry, name); }
    Desc& psEntry(const std::string& name) { return entryPoint(ShaderType::Pixel, name); }
    Desc& csEntry(const std::string& name) { return entryPoint(ShaderType::Compute, name); }
    /** Enable/disable treat-warnings-as-error compilation flag
    */
    Desc& warningsAsErrors(bool enable) { enable ? mShaderFlags |= Shader::CompilerFlags::TreatWarningsAsErrors : mShaderFlags &= ~(Shader::CompilerFlags::TreatWarningsAsErrors); return *this; }
    /** Enable/disable pre-processed shader dump
    */
    Desc& dumpIntermediates(bool enable) { enable ? mShaderFlags |= Shader::CompilerFlags::DumpIntermediates : mShaderFlags &= ~(Shader::CompilerFlags::DumpIntermediates); return *this; }
    /** Set the shader model string. This depends on the API you are using.
        For DirectX it should be `4_0`, `4_1`, `5_0`, `5_1`, `6_0`, `6_1`, `6_2`, or `6_3`. The default is `6_0`. Shader model `6.x` will use dxcompiler, previous shader models use fxc.
        For Vulkan, it should be `400`, `410`, `420`, `430`, `440` or `450`. The default is `450`
    */
    Desc& setShaderModel(const std::string& sm);
    /** Get the compiler flags
    */
    Shader::CompilerFlags getCompilerFlags() const { return mShaderFlags; }
    /** Set the compiler flags. Replaces any previously set flags.
    */
    Desc& setCompilerFlags(Shader::CompilerFlags flags) { mShaderFlags = flags; return *this; }
    bool hasEntryPoint(ShaderType stage) const;
protected:
    friend class Program;
    friend class GraphicsProgram;
    friend class RtProgram;
    Desc& beginEntryPointGroup();
    Desc& addDefaultVertexShaderIfNeeded();
    struct Source
    {
        enum class Type
        {
            String,
            File
        };
        Source(ShaderLibrary::SharedPtr pLib) : pLibrary(pLib), type(Type::File) {};
        Source(std::string s) : str(s), type(Type::String) {};
        Type type;
        ShaderLibrary::SharedPtr pLibrary;
        std::string str;
        uint32_t firstEntryPoint = 0;
        uint32_t entryPointCount = 0;
    };
    struct EntryPointGroup
    {
        uint32_t firstEntryPoint;
        uint32_t entryPointCount;
    };
    struct EntryPoint
    {
        std::string name;
        ShaderType stage;
        int32_t sourceIndex;
        int32_t groupIndex;
    };
    std::vector<Source> mSources;
    std::vector<EntryPointGroup> mGroups;
    std::vector<EntryPoint> mEntryPoints;
    int32_t mActiveSource = -1;
    int32_t mActiveGroup = -1;
    Shader::CompilerFlags mShaderFlags = Shader::CompilerFlags::None;
ALCOR_VK
    std::string mShaderModel = "450";
fined FALCOR_D3D12
    std::string mShaderModel = "6_2";
};





Add Discussion as Guest

Log in to DocsForge