private void PopulateStructInfo(Type classType, BindingFlags bFlags) { Type[] nestedTypes = classType.GetNestedTypes(bFlags); foreach (Type t in nestedTypes) { if (!t.IsValueType) { continue; } ConstantBufferAttribute cbAttribute = t.GetCustomAttribute <ConstantBufferAttribute>(); if (cbAttribute != null) { RegisterAttribute[] regAttributes = t.GetCustomAttributes <RegisterAttribute>().ToArray(); MappedConstantBuffer cbm = new MappedConstantBuffer() { TypeInfo = t, }; ConstantBuffers.Add(t.Name, cbm); } else { Structures.Add(t.Name, t); } } }
internal virtual void Initialize(ShaderType type, FieldInfo info) { Type = type; Attributes = info.GetCustomAttributes(); Info = info; Name = info.Name; if (type.IsMatrix) { if (Attributes.Any(x => x is RowMajorAttribute)) { StructureType = ShaderStructureType.MatrixRowMajor; } else if (Attributes.Any(x => x is ColumnMajorAttribute)) { StructureType = ShaderStructureType.MatrixColumnMajor; } else { StructureType = ShaderStructureType.MatrixDefaultMajor; } } else if (type.IsVector) { StructureType = ShaderStructureType.Vector; } else if (type.Dimensions.Count == 1 && type.Dimensions[0] == 1) { StructureType = ShaderStructureType.Scalar; } else if (type.OriginalType.IsValueType) { ConstantBufferAttribute attConstBuffer = type.OriginalType.GetCustomAttribute <ConstantBufferAttribute>(); if (attConstBuffer != null) { ResourceType = ShaderResourceType.ConstantBuffer; } } else if (!type.OriginalType.IsValueType) { // TODO Improve this StructureType = ShaderStructureType.Class; if (typeof(IShaderResource).IsAssignableFrom(type.OriginalType)) { (ResourceType, ResourceBaseType) = ShaderResource.GetResourceType(type.OriginalType); } else { return; } } }