public static byte[] Generate(AsmTechnique technique, Platform platform) { string techniqueCode; AsmToHlslConverter vsConvert = new AsmToHlslConverter(technique.VertexShader, "vs", platform, technique.VertexShader.RegisterSet.FloatRegisterCount, technique.VertexShader.RegisterSet.BooleanRegisterCount); AsmToHlslConverter psConvert = new AsmToHlslConverter(technique.PixelShader, "ps", platform, technique.PixelShader.RegisterSet.FloatRegisterCount, technique.PixelShader.RegisterSet.BooleanRegisterCount); if (platform == Platform.Windows) { StringBuilder constantSetup = new StringBuilder(); // technique.ConstructTechniqueConstants(constantSetup, false); string vsAsm = technique.VertexShader.ToString(); vsAsm = vsAsm.Replace(Environment.NewLine, Environment.NewLine + "\t\t\t\t"); string psAsm = technique.PixelShader.ToString(); psAsm = psAsm.Replace(Environment.NewLine, Environment.NewLine + "\t\t\t\t"); techniqueCode = string.Format( @" uniform float4 _vs_c[11] : register(vs, c0); {4} technique Shader {0} pass {0} VertexShader = asm {0} {2} {1}; PixelShader = asm {0} {3} {1}; {1} {1}", "{", "}", vsAsm, psAsm, constantSetup); } else { string vsSource = vsConvert.GetSource(); string psSource = psConvert.GetSource(); //setup the technique. techniqueCode = string.Format( @" {2} {3} technique Shader {0} pass {0} VertexShader = compile {4} vsMain(); PixelShader = compile {5} psMain(); {1} {1}", "{", "}", vsSource, psSource, vsConvert.GetProfile().ToString().ToLower(), psConvert.GetProfile().ToString().ToLower()); } TargetPlatform target = TargetPlatform.Unknown; switch (platform) { case Platform.Both: throw new ArgumentException(); case Platform.Windows: target = TargetPlatform.Windows; break; case Platform.Xbox: target = TargetPlatform.Xbox360; break; } CompiledEffect effectSource = Effect.CompileEffectFromSource(techniqueCode, null, null, CompilerOptions.None, target); if (effectSource.Success == false) Common.ThrowError(effectSource.ErrorsAndWarnings, techniqueCode); byte[] code = effectSource.GetEffectCode(); Effect effect = new Effect(Graphics.GraphicsDevice, code, CompilerOptions.None, new EffectPool()); Vector4[] valuesV = new Vector4[11]; for (int i = 0; i < valuesV.Length; i++) { valuesV[i] = new Vector4(i,0,0,0); } //Vector4[] valuesP = new Vector4[24]; //for (int i = 0; i < valuesP.Length; i++) //{ // valuesP[i] = new Vector4(0, i, 0, 0); //} effect.Parameters[0].SetValue(valuesV); Vector4[] test = effect.Parameters[0].GetValueVector4Array(11); //effect.Parameters[1].SetValue(valuesP); //effect.Parameters[2].SetValue(new bool[] { false, false }); GraphicsDevice gd = Graphics.GraphicsDevice; effect.CurrentTechnique = effect.Techniques[0]; effect.Begin(); effect.Techniques[0].Passes[0].Begin(); Vector4[] outputV = gd.GetVertexShaderVector4ArrayConstant(0, 255); Vector4[] outputP = gd.GetPixelShaderVector4ArrayConstant(0, 24); //bool[] outputPB = gd.GetPixelShaderBooleanConstant(0, 2); effect.Techniques[0].Passes[0].End(); effect.End(); string asm = effect.Disassemble(false); return code; }