コード例 #1
0
ファイル: KeywordUtil.cs プロジェクト: zacharycarter/Graphics
        public static bool NeedsMultiStageDefinition(this KeywordDescriptor keyword, ref List <KeywordShaderStage> dstStages)
        {
            dstStages.Clear();

            // All doesn't need special treatment.
            if (keyword.stages == KeywordShaderStage.All)
            {
                return(false);
            }

            if ((keyword.stages & KeywordShaderStage.Vertex) == KeywordShaderStage.Vertex)
            {
                dstStages.Add(KeywordShaderStage.Vertex);
            }
            if ((keyword.stages & KeywordShaderStage.Hull) == KeywordShaderStage.Hull)
            {
                dstStages.Add(KeywordShaderStage.Hull);
            }
            if ((keyword.stages & KeywordShaderStage.Domain) == KeywordShaderStage.Domain)
            {
                dstStages.Add(KeywordShaderStage.Domain);
            }
            if ((keyword.stages & KeywordShaderStage.Geometry) == KeywordShaderStage.Geometry)
            {
                dstStages.Add(KeywordShaderStage.Geometry);
            }
            if ((keyword.stages & KeywordShaderStage.RayTracing) == KeywordShaderStage.RayTracing)
            {
                dstStages.Add(KeywordShaderStage.RayTracing);
            }

            return(dstStages.Count > 1);
        }
コード例 #2
0
        public static ShaderKeyword CreateBuiltInKeyword(KeywordDescriptor descriptor)
        {
            if (descriptor.entries != null)
            {
                for (int i = 0; i < descriptor.entries.Length; i++)
                {
                    if (descriptor.entries[i].id == -1)
                    {
                        descriptor.entries[i].id = i + 1;
                    }
                }
            }

            return(new ShaderKeyword()
            {
                isBuiltIn = true,
                displayName = descriptor.displayName,
                overrideReferenceName = descriptor.referenceName,
                keywordType = descriptor.type,
                keywordDefinition = descriptor.definition,
                keywordScope = descriptor.scope,
                value = descriptor.value,
                entries = descriptor.entries.ToList(),
            });
        }
コード例 #3
0
        public static string ToDefineString(this KeywordDescriptor keyword, int value)
        {
            switch (keyword.type)
            {
            case KeywordType.Boolean:
                return(value == 1 ? $"#define {keyword.referenceName} 1" : string.Empty);

            case KeywordType.Enum:
                return($"#define {keyword.referenceName}_{keyword.entries[value].referenceName}");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #4
0
 public static ShaderKeyword Create(KeywordDescriptor descriptor)
 {
     return(new ShaderKeyword()
     {
         m_IsExposable = false,
         m_IsEditable = false,
         displayName = descriptor.displayName,
         overrideReferenceName = descriptor.referenceName,
         keywordType = descriptor.type,
         keywordDefinition = descriptor.definition,
         keywordScope = descriptor.scope,
         value = descriptor.value,
         entries = descriptor.entries
     });
 }
コード例 #5
0
        public static string ToDeclarationString(this KeywordDescriptor keyword)
        {
            // Get definition type using scope
            string scopeString      = keyword.scope == KeywordScope.Local ? "_local" : string.Empty;
            string definitionString = $"{keyword.definition.ToDeclarationString()}{scopeString}";

            switch (keyword.type)
            {
            case KeywordType.Boolean:
                return($"#pragma {definitionString} _ {keyword.referenceName}");

            case KeywordType.Enum:
                var    enumEntryDefinitions = keyword.entries.Select(x => $"{keyword.referenceName}_{x.referenceName}");
                string enumEntriesString    = string.Join(" ", enumEntryDefinitions);
                return($"#pragma {definitionString} {enumEntriesString}");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #6
0
 public void Add(KeywordDescriptor descriptor, int index, FieldCondition[] fieldConditions)
 {
     m_Items.Add(new Item(descriptor, index, fieldConditions));
 }
コード例 #7
0
 public void Add(KeywordDescriptor descriptor, int index, FieldCondition fieldCondition)
 {
     m_Items.Add(new Item(descriptor, index, new FieldCondition[] { fieldCondition }));
 }
コード例 #8
0
 public void Add(KeywordDescriptor descriptor, int index)
 {
     m_Items.Add(new Item(descriptor, index, null));
 }
コード例 #9
0
 public Item(KeywordDescriptor descriptor, int index, FieldCondition[] fieldConditions)
 {
     this.descriptor      = descriptor;
     this.fieldConditions = fieldConditions;
     this.index           = index;
 }
コード例 #10
0
 public void Add(KeywordDescriptor descriptor)
 {
     m_Items.Add(new Item(descriptor, null));
 }
コード例 #11
0
 public Item(KeywordDescriptor descriptor, FieldCondition[] fieldConditions)
 {
     this.descriptor      = descriptor;
     this.fieldConditions = fieldConditions;
 }
コード例 #12
0
 public DefineCollection Add(KeywordDescriptor descriptor, int index, FieldCondition[] fieldConditions)
 {
     m_Items.Add(new Item(descriptor, index, fieldConditions));
     return(this);
 }
コード例 #13
0
 public DefineCollection Add(KeywordDescriptor descriptor, int index)
 {
     m_Items.Add(new Item(descriptor, index, null));
     return(this);
 }
コード例 #14
0
 public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition[] fieldConditions)
 {
     m_Items.Add(new Item(descriptor, fieldConditions));
     return(this);
 }
コード例 #15
0
 public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition fieldCondition)
 {
     m_Items.Add(new Item(descriptor, new FieldCondition[] { fieldCondition }));
     return(this);
 }
コード例 #16
0
 public KeywordCollection Add(KeywordDescriptor descriptor)
 {
     m_Items.Add(new Item(descriptor, null));
     return(this);
 }