Esempio n. 1
0
        /// <summary>
        /// Entry point - pass "verbose" as a command-line
        /// argument to initialize Embree in verbose mode.
        /// </summary>
        public static int Main(String[] args)
        {
            try
            {
                var verbose = (args.Length == 1 && args[0].ToLower() == "verbose");

                if (verbose)
                {
                    Console.WriteLine("Embree.NET Sample [VERBOSE]");
                    Console.WriteLine("===========================");
                    RTC.Register("verbose=999"); // max verbosity?
                }
                else
                {
                    Console.WriteLine("Embree.NET Sample");
                    Console.WriteLine("=================");
                }

                Console.WriteLine(""); // this is for debugging
                Console.WriteLine("[+] " + Bits + "-bit mode.");
                Console.WriteLine("[+] Building a test scene.");

                using (var renderer = new Renderer())
                {
                    var pixBuf = new PixelBuffer(1920, 1080);
                    Console.WriteLine("[+] Now rendering.");
                    renderer.Render(pixBuf); // benchmark?

                    Console.WriteLine("[+] Saving image to 'render.png'.");
                    pixBuf.SaveToFile("render.png"); // save to png format
                }

                if (verbose)
                {
                    RTC.Unregister();
                }

                return(EXIT_SUCCESS);
            }
            catch (Exception e)
            {
                var msg = e is AggregateException ? e.InnerException.Message : e.Message;
                Console.WriteLine(String.Format("[!] Error: {0}.", msg));
                Console.WriteLine("\n========= STACK TRACE =========\n");
                Console.WriteLine(e.StackTrace);
                //return EXIT_FAILURE;
            }

            Console.ReadKey();
            return(0);
        }
Esempio n. 2
0
        /// <summary>
        /// Entry point - pass "verbose" as a command-line
        /// argument to initialize Embree in verbose mode.
        /// </summary>
        public static int Main(String[] args)
        {
            try
            {
                var verbose = (args.Select(s => s.ToLower()).Contains("verbose"));
                if (verbose)
                {
                    args.Select(s => s != "verbose"); // Clean up arglist
                }
                ParseCommandLineArguments(args);      // For selecting ray packet sizes

                if (verbose)
                {
                    Console.WriteLine("Embree.NET Benchmark [VERBOSE]");
                    Console.WriteLine("==============================");
                    RTC.Register("verbose=999"); // max verbosity?
                }
                else
                {
                    Console.WriteLine("Embree.NET Benchmark");
                    Console.WriteLine("====================");
                }

                Console.WriteLine(""); // this is for debugging
                Console.WriteLine("[+] " + Bits + "-bit mode.");

                // Note this is similar to the original Embree benchmark program
                Console.WriteLine("[+] Performance indicators are per-thread.");

                {
                    // Benchmark parameters
                    int w = 1024, h = 1024;

                    Console.WriteLine("[+] Benchmarking intersection queries.");

                    foreach (var item in Benchmarks.Intersections(SceneFlags.Static, Flags, 501, w, h))
                    {
                        Measure(item.Item2, item.Item3, (s) => Console.WriteLine("    {0} = {1}", item.Item1.PadRight(35), s));
                    }

                    Console.WriteLine("[+] Benchmarking occlusion queries.");

                    foreach (var item in Benchmarks.Occlusions(SceneFlags.Static, Flags, 501, w, h))
                    {
                        Measure(item.Item2, item.Item3, (s) => Console.WriteLine("    {0} = {1}", item.Item1.PadRight(35), s));
                    }
                }

                /*{
                 *  Console.WriteLine("[+] Benchmarking geometry manipulations.");
                 *
                 *  foreach (var item in Benchmarks.Geometries(SceneFlags.Static, Flags))
                 *      Measure(item.Item2, item.Item3, (s) => Console.WriteLine("    {0} = {1}", item.Item1.PadRight(35), s));
                 * }*/

                if (verbose)
                {
                    RTC.Unregister();
                }

                return(EXIT_SUCCESS);
            }
            catch (Exception e)
            {
                var msg = e is AggregateException ? e.InnerException.Message : e.Message;
                Console.WriteLine(String.Format("[!] Error: {0}.", msg));
                Console.WriteLine("\n========= STACK TRACE =========\n");
                Console.WriteLine(e.StackTrace);
                return(EXIT_FAILURE);
            }
        }