示例#1
0
        static void GenerateKeywordPragmaStrings(
            string keywordReferenceName,
            KeywordDefinition keywordDefinition,
            KeywordScope keywordScope,
            KeywordShaderStage keywordStages,
            string keywordVariantsString,
            Action <string> PragmaStringAction)
        {
            string definitionString = keywordDefinition.ToDeclarationString();
            string scopeString      = keywordScope.ToDeclarationSuffix();

            // check the active shader stages
            if ((keywordStages == KeywordShaderStage.All) || (keywordStages == 0))  // 0 is a default, so assume that means ALL
            {
                PragmaStringAction($"#pragma {definitionString}{scopeString} {keywordVariantsString}");
            }
            else
            {
                // have to process each stage separately
                for (int shaderStage = (int)KeywordShaderStage.Vertex; shaderStage <= (int)keywordStages; shaderStage = shaderStage * 2)
                {
                    if (((int)keywordStages & shaderStage) != 0)
                    {
                        var keywordStage = (KeywordShaderStage)shaderStage;
                        var stageString  = keywordStage.ToKeywordStagesString();
                        PragmaStringAction($"#pragma {definitionString}{scopeString}{stageString} {keywordVariantsString}");
                    }
                }
            }
        }
示例#2
0
        public static string ToDeclarationSuffix(this KeywordScope scope)
        {
            switch (scope)
            {
            case KeywordScope.Local:
                return("_local");

            default:
                return(string.Empty);
            }
        }
示例#3
0
 public static void GenerateBooleanKeywordPragmaStrings(
     string keywordReferenceName,
     KeywordDefinition keywordDefinition,
     KeywordScope keywordScope,
     KeywordShaderStage keywordStages,
     Action <string> pragmaStringAction)
 {
     if (keywordDefinition != KeywordDefinition.Predefined)
     {
         string variantsString = $"_ {keywordReferenceName}";
         GenerateKeywordPragmaStrings(keywordReferenceName, keywordDefinition, keywordScope, keywordStages, variantsString, pragmaStringAction);
     }
 }
示例#4
0
 public static void GenerateEnumKeywordPragmaStrings(
     string keywordReferenceName,
     KeywordDefinition keywordDefinition,
     KeywordScope keywordScope,
     KeywordShaderStage keywordStages,
     IEnumerable <KeywordEntry> keywordEntries,
     Action <string> pragmaStringAction)
 {
     if (keywordDefinition != KeywordDefinition.Predefined)
     {
         var    entryStrings   = keywordEntries.Select(x => $"{keywordReferenceName}_{x.referenceName}");
         string variantsString = string.Join(" ", entryStrings);
         GenerateKeywordPragmaStrings(keywordReferenceName, keywordDefinition, keywordScope, keywordStages, variantsString, pragmaStringAction);
     }
 }