using ComputeSharp.SourceGeneration.Helpers; namespace ComputeSharp.SourceGeneration.Models; /// /// A base type for a model describing a given captured field in a shader. /// /// The path of the field with respect to the shader instance. /// The full metadata name for the primitive type. internal abstract record FieldInfo(EquatableArray FieldPath, string TypeName) { /// /// A captured primitive value (either a scalar, a vector, or a linear matrix). /// /// /// /// The byte offset of the value within the root signature. public sealed record Primitive(EquatableArray FieldPath, string TypeName, int Offset) : FieldInfo(FieldPath, TypeName); /// /// A captured non linear matrix value. /// /// /// /// The name of each element in the matrix type. /// The number of rows in the matrix. /// The number of columns in the matrix. /// The sequence of byte offsets for each row within the root signature. public sealed record NonLinearMatrix( EquatableArray FieldPath, string TypeName, string ElementName, int Rows, int Columns, EquatableArray Offsets) : FieldInfo(FieldPath, TypeName); } /// /// A model for a part of a field path, ie. the name of the immediate parent field, and whether it's accessible. /// /// The name of the immediate parent field to access (or self). /// Whether the current path part is accessible from the compilation. internal abstract record FieldPathPart(string Name, bool IsAccessible) { /// /// A model for a leaf part of a field path. /// /// /// public sealed record Leaf(string Name, bool IsAccessible) : FieldPathPart(Name, IsAccessible); /// /// A model for a nested field part path (ie. going through a nested struct type). /// /// /// /// The fully qualified type name of the containing type. public sealed record Nested(string Name, bool IsAccessible, string TypeName) : FieldPathPart(Name, IsAccessible); }