示例#1
0
 public RealtimeBenchmark(bool showGUI, int threads)
 {
     IDisplay display = /*showGUI ? new FastDisplay() :*/ new FileDisplay(false);
     UI.printInfo(UI.Module.BENCH, "Preparing benchmarking scene ...");
     // settings
     parameter("threads", threads);
     // spawn regular priority threads
     parameter("threads.lowPriority", false);
     parameter("resolutionX", 512);
     parameter("resolutionY", 512);
     parameter("aa.min", -3);
     parameter("aa.max", 0);
     parameter("depths.diffuse", 1);
     parameter("depths.reflection", 1);
     parameter("depths.refraction", 0);
     parameter("bucket.order", "hilbert");
     parameter("bucket.size", 32);
     options(SunflowAPI.DEFAULT_OPTIONS);
     // camera
     Point3 eye = new Point3(30, 0, 10.967f);
     Point3 target = new Point3(0, 0, 5.4f);
     Vector3 up = new Vector3(0, 0, 1);
     parameter("transform", Matrix4.lookAt(eye, target, up));
     parameter("fov", 45.0f);
     camera("camera", "pinhole");
     parameter("camera", "camera");
     options(SunflowAPI.DEFAULT_OPTIONS);
     // geometry
     createGeometry();
     // this first render is not timed, it caches the acceleration data
     // structures and tesselations so they won't be
     // included in the main timing
     UI.printInfo(UI.Module.BENCH, "Rendering warmup frame ...");
     render(SunflowAPI.DEFAULT_OPTIONS, display);
     // now disable all output - and run the benchmark
     UI.set(null);
     Timer t = new Timer();
     t.start();
     float phi = 0;
     int frames = 0;
     while (phi < 4 * Math.PI)
     {
         eye.x = 30 * (float)Math.Cos(phi);
         eye.y = 30 * (float)Math.Sin(phi);
         phi += (float)(Math.PI / 30);
         frames++;
         // update camera
         parameter("transform", Matrix4.lookAt(eye, target, up));
         camera("camera", null);
         render(SunflowAPI.DEFAULT_OPTIONS, display);
     }
     t.end();
     UI.set(new ConsoleInterface());
     UI.printInfo(UI.Module.BENCH, "Benchmark results:");
     UI.printInfo(UI.Module.BENCH, "  * Average FPS:         {0,6:0.00", frames / t.seconds());
     UI.printInfo(UI.Module.BENCH, "  * Total time:          {0}", t);
 }