public void SamplerStateTestHashCollision() { var samA = new SamplerStateDescription() { Filter = TextureFilter.MinMagLinearMipPoint }; var samB = new SamplerStateDescription() { Filter = TextureFilter.MinMagLinear }; var hashA = samA.GetHashCode(); var hashB = samB.GetHashCode(); Report.Line("SamA={0}, SamB={1}", samA, samB); Report.Line("HashA={0}, HashB={1}", hashA, hashB); Report.Line("Equal={0}", Object.Equals(samA, samB)); if (hashA == hashB) { Report.Line("BAD HASH :("); } else { Report.Line("Good Hash :)"); } }
public SamplerState CreateSamplerState(TextureAddressMode texMode, Filter filter, Comparison comparisonFunction = Comparison.Never, int aniso = 1, float minLod = 0.0f, float maxLod = float.MaxValue) { var samplerStateDescription = new SamplerStateDescription { AddressU = texMode, AddressV = texMode, AddressW = texMode, Filter = filter, ComparisonFunction = comparisonFunction, MinimumLod = minLod, MaximumLod = maxLod, MaximumAnisotropy = Math.Max(1, aniso), }; var hash = samplerStateDescription.GetHashCode(); if (samplerStates.ContainsKey(hash)) { return(samplerStates[hash]); } var sampler = new SamplerState(Device, samplerStateDescription); if (sampler != null) { samplerStates.Add(hash, sampler); } return(sampler); }