/// <summary> /// /// </summary> public static int GetVertexStride(VertexElement[] elements) { Int32 num2 = 0; for (Int32 i = 0; i < elements.Length; i++) { Int32 num3 = elements [i].Offset + GetTypeSize (elements [i].VertexElementFormat); if (num2 < num3) { num2 = num3; } } return num2; }
/// <summary> /// checks that an effect supports the given vert decl /// </summary> //public static void Validate (IShader effect, VertexDeclaration vertexDeclaration) //{ // throw new NotImplementedException (); // } /// <summary> /// /// </summary> public static void Validate(int vertexStride, VertexElement[] elements) { if (vertexStride <= 0) { throw new ArgumentOutOfRangeException ("vertexStride"); } if ((vertexStride & 3) != 0) { throw new ArgumentException ("VertexElementOffsetNotMultipleFour"); } var numArray = new Int32[vertexStride]; for (Int32 i = 0; i < vertexStride; i++) { numArray [i] = -1; } for (Int32 j = 0; j < elements.Length; j++) { Int32 offset = elements [j].Offset; Int32 typeSize = GetTypeSize (elements [j].VertexElementFormat); if ((elements [j].VertexElementUsage < VertexElementUsage.Position) || (elements [j].VertexElementUsage > VertexElementUsage.TessellateFactor)) { throw new ArgumentException ("FrameworkResources.VertexElementBadUsage"); } if ((offset < 0) || ((offset + typeSize) > vertexStride)) { throw new ArgumentException ("FrameworkResources.VertexElementOutsideStride"); } if ((offset & 3) != 0) { throw new ArgumentException ("VertexElementOffsetNotMultipleFour"); } for (Int32 k = 0; k < j; k++) { if ((elements [j].VertexElementUsage == elements [k].VertexElementUsage) && (elements [j].UsageIndex == elements [k].UsageIndex)) { throw new ArgumentException ("DuplicateVertexElement"); } } for (Int32 m = offset; m < (offset + typeSize); m++) { if (numArray [m] >= 0) { throw new ArgumentException ("VertexElementsOverlap"); } numArray [m] = j; } } }