Search Results for

    Show / Hide Table of Contents

    Class ShaderAnalyzer

    Analyzer for shader code.

    Inheritance
    object
    ShaderAnalyzer
    Namespace: Evergine.Framework.Graphics.Effects.Analyzer
    Assembly: Evergine.Framework.dll
    Syntax
    public class ShaderAnalyzer

    Constructors

    ShaderAnalyzer()

    Initializes a new instance of the ShaderAnalyzer class.

    Declaration
    public ShaderAnalyzer()

    Fields

    BeginLibraryKeyword

    The begin library keyword.

    Declaration
    protected const string BeginLibraryKeyword = "Begin_Library"
    Field Value
    Type Description
    string

    BeginPassKeyword

    The begin pass keyword.

    Declaration
    protected const string BeginPassKeyword = "Begin_Pass"
    Field Value
    Type Description
    string

    BeginResourceLayoutKeyword

    The keyword at the beginning of the resource layout block.

    Declaration
    protected const string BeginResourceLayoutKeyword = "Begin_ResourceLayout"
    Field Value
    Type Description
    string

    CodeLines

    The code lines.

    Declaration
    public LineInfo[] CodeLines
    Field Value
    Type Description
    LineInfo[]

    EndLibraryKeyword

    The end library keyword.

    Declaration
    protected const string EndLibraryKeyword = "End_Library"
    Field Value
    Type Description
    string

    EndPassKeyword

    The end pass keyword.

    Declaration
    protected const string EndPassKeyword = "End_Pass"
    Field Value
    Type Description
    string

    EndResourceLayoutKeyword

    The end resource layout keyword.

    Declaration
    protected const string EndResourceLayoutKeyword = "End_ResourceLayout"
    Field Value
    Type Description
    string

    ExternalLibraryResolver

    Override the library resolver mechanism. (Useful when you want to resolve the library on limited context).

    Declaration
    public Func<IncludeLibrary, (LibrarySection librarySection, HashSet<IncludeLibrary> Includes)> ExternalLibraryResolver
    Field Value
    Type Description
    Func<IncludeLibrary, (LibrarySection librarySection, HashSet<IncludeLibrary> Includes)>

    GlobalSection

    The global section.

    Declaration
    public GlobalSection GlobalSection
    Field Value
    Type Description
    GlobalSection

    IncludeKeyword

    The include library keyword.

    Declaration
    protected const string IncludeKeyword = "Include_Library"
    Field Value
    Type Description
    string

    Includes

    The include libraries collection.

    Declaration
    public HashSet<IncludeLibrary> Includes
    Field Value
    Type Description
    HashSet<IncludeLibrary>

    LibrarySection

    The library section.

    Declaration
    public LibrarySection LibrarySection
    Field Value
    Type Description
    LibrarySection

    PassSections

    The list of the pass sections.

    Declaration
    public List<PassSection> PassSections
    Field Value
    Type Description
    List<PassSection>

    ResourceLayoutSection

    The resource layout section.

    Declaration
    public ResourceLayoutSection ResourceLayoutSection
    Field Value
    Type Description
    ResourceLayoutSection

    Properties

    DirectivesGroups

    Gets the directive groups.

    Declaration
    public List<DirectivesGroup> DirectivesGroups { get; }
    Property Value
    Type Description
    List<DirectivesGroup>

    PassesNames

    Gets the list of pass names.

    Declaration
    public string[] PassesNames { get; }
    Property Value
    Type Description
    string[]

    ResourceLayoutInfo

    Gets the cloned resource layout info.

    Declaration
    public GraphicsResourceInfo[] ResourceLayoutInfo { get; }
    Property Value
    Type Description
    GraphicsResourceInfo[]

    StructsInfo

    Gets the defined structs.

    Declaration
    public List<StructInfo> StructsInfo { get; }
    Property Value
    Type Description
    List<StructInfo>

    Methods

    ArrayCopy(LineInfo[], int, out LineInfo[], int)

    Copies the array.

    Declaration
    protected void ArrayCopy(LineInfo[] source, int codeIndex, out LineInfo[] destination, int length)
    Parameters
    Type Name Description
    LineInfo[] source

    The source array.

    int codeIndex

    The index of the code.

    LineInfo[] destination

    The destination array.

    int length

    The length of the array.

    CollectDirectivesRecursive(IncludeLibrary, List<DirectivesGroup>, List<Guid>)

    Collect directives on libraries recursively.

    Declaration
    protected bool CollectDirectivesRecursive(IncludeLibrary include, List<DirectivesGroup> directives, List<Guid> visitedLibraries)
    Parameters
    Type Name Description
    IncludeLibrary include

    The IncludeLibrary instance.

    List<DirectivesGroup> directives

    The global directives collection.

    List<Guid> visitedLibraries

    The visited libraries collection. (To detect cross references).

    Returns
    Type Description
    bool

    Indicating whether had errors.

    CollectIncludeDirectives()

    Collect directives on include libraries.

    Declaration
    protected List<DirectivesGroup> CollectIncludeDirectives()
    Returns
    Type Description
    List<DirectivesGroup>

    The directives group collection.

    CombinationBetweenTwoGroup(DirectivesCombination[], DirectivesCombination[])

    Combinations for the two groups of directives.

    Declaration
    protected DirectivesCombination[] CombinationBetweenTwoGroup(DirectivesCombination[] combinations1, DirectivesCombination[] combinations2)
    Parameters
    Type Name Description
    DirectivesCombination[] combinations1

    First group of directives.

    DirectivesCombination[] combinations2

    Second group of directives.

    Returns
    Type Description
    DirectivesCombination[]

    The combinations of the two groups of directives.

    ConcatCode(List<CodeBlock>, string[])

    Concatenates the given code blocks using the specified directives.

    Declaration
    protected List<LineInfo> ConcatCode(List<CodeBlock> codeBlocks, string[] directives)
    Parameters
    Type Name Description
    List<CodeBlock> codeBlocks

    The code blocks.

    string[] directives

    The directives.

    Returns
    Type Description
    List<LineInfo>

    The concatenated lines of code.

    DirectiveExists(string, out Guid)

    Checks if the given directive exists in entire context even libraries references .

    Declaration
    public bool DirectiveExists(string directive, out Guid id)
    Parameters
    Type Name Description
    string directive

    The directive.

    Guid id

    The resulting directive identifier.

    Returns
    Type Description
    bool

    True if the specified directive exists, otherwise false.

    DivideInSections(LineInfo[])

    Divides the given lines into sections.

    Declaration
    protected void DivideInSections(LineInfo[] lines)
    Parameters
    Type Name Description
    LineInfo[] lines

    The lines.

    Error(int, string)

    Sets the result as an error in the specified line with the given message.

    Declaration
    protected void Error(int line, string msg)
    Parameters
    Type Name Description
    int line

    The line.

    string msg

    The message.

    Evaluate(string, string[])

    Evaluates the specified expression using the given directives.

    Declaration
    protected bool Evaluate(string expression, string[] directives)
    Parameters
    Type Name Description
    string expression

    The expression.

    string[] directives

    The directives.

    Returns
    Type Description
    bool

    The logical evaluation of the expression.

    FindPass(string)

    Returns the Pass information.

    Declaration
    public PassSection FindPass(string passName)
    Parameters
    Type Name Description
    string passName

    Pass name.

    Returns
    Type Description
    PassSection

    Pass information.

    GenerateAllDirectivesCombination()

    Generates all combinations of directives.

    Declaration
    public List<string[]> GenerateAllDirectivesCombination()
    Returns
    Type Description
    List<string[]>

    An array list of directives.

    GenerateAllPassAndDirectivesCombination()

    Generates all directive combinations for all passes.

    Declaration
    public PassCombination[] GenerateAllPassAndDirectivesCombination()
    Returns
    Type Description
    PassCombination[]

    Directive list.

    GetEffectType()

    Get Effect Type. (Graphics or Compute).

    Declaration
    public ShaderAnalyzer.EffectTypes GetEffectType()
    Returns
    Type Description
    ShaderAnalyzer.EffectTypes

    The type of Effect.

    GetHLSLInputLayout(PreprocessShader, string)

    Gets the HLSL input layout.

    Declaration
    protected InputLayouts GetHLSLInputLayout(PreprocessShader source, string vertexEntryPoint)
    Parameters
    Type Name Description
    PreprocessShader source

    The source.

    string vertexEntryPoint

    The vertex entry point.

    Returns
    Type Description
    InputLayouts

    The HLSL input layout.

    GetHLSLInputStructCode(string, string)

    Gets the HLSL input structure code.

    Declaration
    protected string GetHLSLInputStructCode(string source, string vertexEntryPoint)
    Parameters
    Type Name Description
    string source

    The source.

    string vertexEntryPoint

    The vertex entry point.

    Returns
    Type Description
    string

    The HLSL input structure code.

    GetHLSLResourceLayout(ResourceLayoutSection)

    Gets the HLSL resource layout from the given section and stores it in the ResourceLayoutInfo variable.

    Declaration
    protected void GetHLSLResourceLayout(ResourceLayoutSection section)
    Parameters
    Type Name Description
    ResourceLayoutSection section

    The section.

    GetInputLayout(string, PreprocessShader)

    Gets estimated inputLayout from shader source.

    Declaration
    public InputLayouts GetInputLayout(string passName, PreprocessShader cleanSource)
    Parameters
    Type Name Description
    string passName

    Pass name.

    PreprocessShader cleanSource

    Source with active pass and directives.

    Returns
    Type Description
    InputLayouts

    Input layouts.

    HLSLPreprocess(List<CodeBlock>, string[])

    Preprocess the HLSL shader.

    Declaration
    protected PreprocessShader HLSLPreprocess(List<CodeBlock> codeBlocks, string[] activeDirectives)
    Parameters
    Type Name Description
    List<CodeBlock> codeBlocks

    The code blocks collection.

    string[] activeDirectives

    The active directives.

    Returns
    Type Description
    PreprocessShader

    The preprocess result.

    HLSLToElementFormat(string)

    Transforms HLSL to element format.

    Declaration
    protected ElementFormat HLSLToElementFormat(string format)
    Parameters
    Type Name Description
    string format

    The format.

    Returns
    Type Description
    ElementFormat

    The element format.

    HLSLToElementSemanticType(string)

    Transforms HLSL to element semantic type.

    Declaration
    protected ElementSemanticType HLSLToElementSemanticType(string semantic)
    Parameters
    Type Name Description
    string semantic

    The semantic.

    Returns
    Type Description
    ElementSemanticType

    The element semantic type.

    LineToString(LineInfo[])

    Appends the given lines of text.

    Declaration
    protected string LineToString(LineInfo[] lines)
    Parameters
    Type Name Description
    LineInfo[] lines

    The lines.

    Returns
    Type Description
    string

    The appended lines of text.

    PreProcess(string[])

    Return shader code with active directives.

    Declaration
    public PreprocessShader PreProcess(string[] activeDirectives)
    Parameters
    Type Name Description
    string[] activeDirectives

    Active directives.

    Returns
    Type Description
    PreprocessShader

    Cleaned shader code.

    Preprocess(string, string[])

    Returns shader code with active directives.

    Declaration
    public PreprocessShader Preprocess(string passName, string[] activeDirectives)
    Parameters
    Type Name Description
    string passName

    Pass name.

    string[] activeDirectives

    Active directives.

    Returns
    Type Description
    PreprocessShader

    Cleaned shader code.

    PreprocessInclude(List<LineInfo>, IncludeLibrary, int, int, int, string[], List<Guid>)

    Preprocess Include library effect.

    Declaration
    protected void PreprocessInclude(List<LineInfo> lines, IncludeLibrary include, int baseIncludeLine, int deep, int order, string[] activeDirectives, List<Guid> visitedLibraries)
    Parameters
    Type Name Description
    List<LineInfo> lines

    The result line collection.

    IncludeLibrary include

    The include library effect.

    int baseIncludeLine

    The include line number of the shader.

    int deep

    The reference deep.

    int order

    The library order in the same deep.

    string[] activeDirectives

    The active directives collection.

    List<Guid> visitedLibraries

    The library id visited collection. (So important to detect cross references).

    ReadDirective(string, int)

    Reads a directives group.

    Declaration
    protected DirectivesGroup ReadDirective(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    DirectivesGroup

    Return the directives group read.

    ReadEntryPoints(string, int)

    Reads the section entry points.

    Declaration
    protected EntryPoints ReadEntryPoints(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    EntryPoints

    The entrypoints read.

    ReadGlobalSection(GlobalSection)

    Reads the Global section. (orphan lines, written outside of ResourceLayout, Pass or Library sections).

    Declaration
    protected void ReadGlobalSection(GlobalSection section)
    Parameters
    Type Name Description
    GlobalSection section

    The section.

    ReadInclude(string, int)

    Reads a include library.

    Declaration
    protected IncludeLibrary? ReadInclude(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    IncludeLibrary?

    Return the include library read.

    ReadLibrarySection(LibrarySection)

    Reads the library section.

    Declaration
    protected void ReadLibrarySection(LibrarySection section)
    Parameters
    Type Name Description
    LibrarySection section

    The section.

    ReadLibrarySettings(LibrarySection, string, int)

    Reads the library settings.

    Declaration
    protected bool ReadLibrarySettings(LibrarySection section, string line, int lineNumber)
    Parameters
    Type Name Description
    LibrarySection section

    The section.

    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    bool

    True if the section has been processed, otherwise returns false.

    ReadMode(string, int)

    Reads the compilation mode.

    Declaration
    protected CompilationMode ReadMode(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    CompilationMode

    The compilation mode read.

    ReadPassSection(PassSection)

    Reads the specified section.

    Declaration
    protected void ReadPassSection(PassSection section)
    Parameters
    Type Name Description
    PassSection section

    The section.

    ReadPassSettings(PassSection, string, int, ref List<OverridedRenderLayerProperty>)

    Reads the shader settings.

    Declaration
    protected bool ReadPassSettings(PassSection section, string line, int lineNumber, ref List<OverridedRenderLayerProperty> overridedProperties)
    Parameters
    Type Name Description
    PassSection section

    The section.

    string line

    The line.

    int lineNumber

    The line number.

    List<OverridedRenderLayerProperty> overridedProperties

    The overrided RenderLayer properties list.

    Returns
    Type Description
    bool

    True if the section has been processed, otherwise returns false.

    ReadProfile(string, int)

    Reads the section profile.

    Declaration
    protected GraphicsProfile ReadProfile(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    GraphicsProfile

    Return the graphics profile readed.

    ReadRequiredWith(string, int)

    Reads the 'requiredwith' section.

    Declaration
    protected string[] ReadRequiredWith(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    string[]

    Array of required directives.

    ReadResourceLayoutSection(ResourceLayoutSection)

    Reads the resource layout section.

    Declaration
    protected void ReadResourceLayoutSection(ResourceLayoutSection section)
    Parameters
    Type Name Description
    ResourceLayoutSection section

    The section.

    ReadSource(string)

    Analyzes shader source code.

    Declaration
    public AnalyzerResult ReadSource(string source)
    Parameters
    Type Name Description
    string source

    The shader source code.

    Returns
    Type Description
    AnalyzerResult

    The analysis result.

    ReadUsedDirectives(string, int)

    Reads the 'usedDirectives' section.

    Declaration
    protected string[] ReadUsedDirectives(string line, int lineNumber)
    Parameters
    Type Name Description
    string line

    The line.

    int lineNumber

    The line number.

    Returns
    Type Description
    string[]

    Array of required directives.

    Warning(int, string)

    Sets the result as a warning on the specified line with the given message.

    Declaration
    protected void Warning(int line, string msg)
    Parameters
    Type Name Description
    int line

    The line.

    string msg

    The message.

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In this article
    Back to top
    Generated by DocFX