4 using System.Collections.Generic;
6 using SiliconStudio.Core.Extensions;
7 using SiliconStudio.Paradox.Effects;
9 namespace SiliconStudio.
Paradox.Shaders.Compiler
13 private CompositionComparer compositionComparer;
17 compositionComparer =
new CompositionComparer(
this);
22 if (x == null && y == null)
25 if (x == null || y == null)
28 if (x.GetType() != y.GetType())
33 var x1 = (ShaderClassSource)x;
34 var y1 = (ShaderClassSource)y;
35 return x1.ClassName == y1.ClassName
36 && ArrayExtensions.ArraysEqual(x1.GenericArguments, y1.GenericArguments);
40 var x1 = (ShaderMixinSource)x;
41 var y1 = (ShaderMixinSource)y;
42 return ArrayExtensions.ArraysEqual(x1.Mixins, y1.Mixins,
this)
43 &&
ArrayExtensions.ArraysEqual(x1.Compositions.OrderBy(item => item.Key).ToArray(), y1.Compositions.OrderBy(item => item.Key).ToArray(), compositionComparer);
47 var x1 = (ShaderArraySource)x;
48 var y1 = (ShaderArraySource)y;
49 return ArrayExtensions.ArraysEqual(x1.Values, y1.Values,
this);
52 throw new InvalidOperationException(
"Invalid ShaderSource comparison.");
64 var obj1 = (ShaderClassSource)obj;
65 return obj1.ClassName.GetHashCode()
70 var obj1 = (ShaderMixinSource)obj;
71 return ArrayExtensions.ComputeHash(obj1.Mixins,
this)
72 ^
ArrayExtensions.ComputeHash(obj1.Compositions.OrderBy(item => item.Key).ToArray(), compositionComparer);
76 var obj1 = (ShaderArraySource)obj;
77 return ArrayExtensions.ComputeHash(obj1.Values,
this);
80 throw new InvalidOperationException(
"Invalid ShaderSource comparison.");
84 private class CompositionComparer : EqualityComparer<KeyValuePair<string, ShaderSource>>
90 this.shaderSourceComparer = shaderSourceComparer;
93 public override bool Equals(KeyValuePair<string, ShaderSource> x, KeyValuePair<string, ShaderSource>
y)
95 return x.Key == y.Key && shaderSourceComparer.Equals(x.Value, y.Value);
98 public override int GetHashCode(KeyValuePair<string, ShaderSource> obj)
100 return obj.Key.GetHashCode() ^ shaderSourceComparer.
GetHashCode(obj.Value);
A mixin performing a combination of ShaderClassSource and other mixins.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
override bool Equals(ShaderSource x, ShaderSource y)
An array of ShaderSource used only in shader mixin compositions.
override int GetHashCode(ShaderSource obj)
A shader class used for mixin.