/// <summary> /// /// </summary> /// <param name="?"></param> void Enumerate(Type enumType, Ubershader ubershader, Action <PipelineState, int> enumAction) { pipelineStates = new Dictionary <int, PipelineState>(); combinerEnum = enumType; // // validate enum : // if (Enum.GetUnderlyingType(enumType) != typeof(int)) { throw new ArgumentException("Underlying type should be Int32"); } Dictionary <string, int> enumDict = new Dictionary <string, int>(); foreach (var enumValue in Enum.GetValues(enumType)) { if (!MathUtil.IsPowerOfTwo((int)enumValue) && (int)enumValue != 0) { throw new ArgumentException("Each value must be zero or power of two"); } enumDict.Add(enumValue.ToString(), (int)enumValue); } // // Enumerate : // var defineList = ubershader.Defines; foreach (var defines in defineList) { int combination = 0; if (GetCombinerSet(enumDict, defines, out combination)) { var ps = new PipelineState(device); ps.PixelShader = ubershader.GetPixelShader(defines); ps.VertexShader = ubershader.GetVertexShader(defines); ps.GeometryShader = ubershader.GetGeometryShader(defines); ps.HullShader = ubershader.GetHullShader(defines); ps.DomainShader = ubershader.GetDomainShader(defines); ps.ComputeShader = ubershader.GetComputeShader(defines); enumAction(ps, combination); pipelineStates.Add(combination, ps); } } }
/// <summary> /// /// </summary> /// <param name="?"></param> void Enumerate ( Type enumType, Ubershader ubershader, Action<PipelineState,int> enumAction ) { pipelineStates = new Dictionary<int,PipelineState>(); combinerEnum = enumType; // // validate enum : // if (Enum.GetUnderlyingType(enumType)!=typeof(int)) { throw new ArgumentException("Underlying type should be Int32"); } Dictionary<string,int> enumDict = new Dictionary<string,int>(); foreach ( var enumValue in Enum.GetValues( enumType ) ) { if ( !MathUtil.IsPowerOfTwo( (int)enumValue ) && (int)enumValue!=0 ) { throw new ArgumentException("Each value must be zero or power of two"); } enumDict.Add( enumValue.ToString(), (int)enumValue ); } // // Enumerate : // var defineList = ubershader.Defines; foreach ( var defines in defineList ) { int combination = 0; if ( GetCombinerSet( enumDict, defines, out combination ) ) { var ps = new PipelineState( device ); ps.PixelShader = ubershader.GetPixelShader ( defines ); ps.VertexShader = ubershader.GetVertexShader ( defines ); ps.GeometryShader = ubershader.GetGeometryShader ( defines ); ps.HullShader = ubershader.GetHullShader ( defines ); ps.DomainShader = ubershader.GetDomainShader ( defines ); ps.ComputeShader = ubershader.GetComputeShader ( defines ); enumAction( ps, combination ); pipelineStates.Add( combination, ps ); } } }