3 using System.Collections.Generic;
4 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_DIRECT3D
6 using SharpDX.Direct3D11;
7 using SiliconStudio.Core;
9 namespace SiliconStudio.
Paradox.Graphics
11 internal partial class VertexArrayLayout
13 private static readonly Dictionary<VertexArrayLayout, VertexArrayLayout> RegisteredLayouts =
new Dictionary<VertexArrayLayout, VertexArrayLayout>();
15 private VertexArrayLayout()
19 private readonly
int hashCode;
20 public readonly InputElement[] InputElements;
27 public VertexArrayLayout(InputElement[] inputElements)
29 if (inputElements == null)
throw new ArgumentNullException(
"inputElements");
31 this.InputElements = inputElements;
32 hashCode = inputElements.Length;
33 for (
int i = 0; i < inputElements.Length; i++)
35 hashCode = (hashCode * 397) ^ inputElements[i].GetHashCode();
44 public static VertexArrayLayout GetOrCreateLayout(VertexArrayLayout layout)
46 VertexArrayLayout registeredLayout;
47 lock (RegisteredLayouts)
49 if (!RegisteredLayouts.TryGetValue(layout, out registeredLayout))
51 RegisteredLayouts.Add(layout, layout);
52 registeredLayout = layout;
55 return registeredLayout;
58 public bool Equals(VertexArrayLayout other)
60 if (ReferenceEquals(
this, other))
62 return hashCode == other.hashCode && Utilities.Compare(InputElements, other.InputElements);
65 public override int GetHashCode()
70 public override bool Equals(
object obj)
72 if (ReferenceEquals(null, obj))
return false;
73 if (ReferenceEquals(
this, obj))
return true;
74 if (obj.GetType() != this.GetType())
return false;
75 return Equals((VertexArrayLayout)obj);
78 public override string ToString()
80 var description =
" Input Parameters: ";
82 for (
int i = 0; i < InputElements.Length; i++)
84 description += InputElements[i].SemanticName + InputElements[i].SemanticIndex;
86 if (i != InputElements.Length - 1)