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); }
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(), }); }
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(); } }
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 }); }
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(); } }
public void Add(KeywordDescriptor descriptor, int index, FieldCondition[] fieldConditions) { m_Items.Add(new Item(descriptor, index, fieldConditions)); }
public void Add(KeywordDescriptor descriptor, int index, FieldCondition fieldCondition) { m_Items.Add(new Item(descriptor, index, new FieldCondition[] { fieldCondition })); }
public void Add(KeywordDescriptor descriptor, int index) { m_Items.Add(new Item(descriptor, index, null)); }
public Item(KeywordDescriptor descriptor, int index, FieldCondition[] fieldConditions) { this.descriptor = descriptor; this.fieldConditions = fieldConditions; this.index = index; }
public void Add(KeywordDescriptor descriptor) { m_Items.Add(new Item(descriptor, null)); }
public Item(KeywordDescriptor descriptor, FieldCondition[] fieldConditions) { this.descriptor = descriptor; this.fieldConditions = fieldConditions; }
public DefineCollection Add(KeywordDescriptor descriptor, int index, FieldCondition[] fieldConditions) { m_Items.Add(new Item(descriptor, index, fieldConditions)); return(this); }
public DefineCollection Add(KeywordDescriptor descriptor, int index) { m_Items.Add(new Item(descriptor, index, null)); return(this); }
public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition[] fieldConditions) { m_Items.Add(new Item(descriptor, fieldConditions)); return(this); }
public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition fieldCondition) { m_Items.Add(new Item(descriptor, new FieldCondition[] { fieldCondition })); return(this); }
public KeywordCollection Add(KeywordDescriptor descriptor) { m_Items.Add(new Item(descriptor, null)); return(this); }