public static bool TryCompile(string code, ShaderModel model, string entrypoint, out string error)
        {
            lock (locker)
            {
                string id   = Thread.CurrentThread.ManagedThreadId.ToString();
                string path = string.Format("{0}\\tmp{1}.fx", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), id);

                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    byte[] data = Encoding.ASCII.GetBytes(code);
                    fs.Write(data, 0, data.Length);
                }

                string fxc = Path.Combine(new Uri(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)).AbsolutePath, @"fxc.exe");

                if (!File.Exists(fxc))
                {
                    error = "No effect compiler executable!";
                    return(false);
                }

                ProcessStartInfo psi = new ProcessStartInfo(fxc);
                psi.CreateNoWindow        = true;
                psi.UseShellExecute       = false;
                psi.RedirectStandardError = true;
                psi.Arguments             = string.Format("/T {1} /E {2} /Fo\"{0}.obj\" \"{0}\"", path, model.Key, entrypoint);

                error = string.Empty;

                using (Process p = Process.Start(psi))
                {
                    StreamReader sr = p.StandardError;
                    error = sr.ReadToEnd().Replace(path, "Line ");

                    if (!p.WaitForExit(5000))
                    {
                        error = "General failure while compiling (timeout).";
                        return(false);
                    }
                }

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                if (File.Exists(path + ".obj"))
                {
                    File.Delete(path + ".obj");
                }

                if (error == string.Empty)
                {
                    return(true);
                }

                error = error.Replace("compilation failed; no code produced", "");
                error = error.Trim();

                return(false);
            }
        }
 public static int GetProfileIndex(ShaderModel model)
 {
     return(Array.IndexOf(profiles.Keys.ToArray(), model.Key));
 }