private static void CoherentIntersect1(Scene<Sphere> scene, int w, int h) { float invW = 1.0f / w, invH = 1.0f / h; for (var y = 0; y < h; ++y) for (var x = 0; x < w; ++x) { var traversal = new Ray(Vector.Zero, new Vector((float)x * invW, 1, (float)y * invH)); scene.Intersects<Ray>(traversal); } }
public static IEnumerable<Tuple<String, Action, Func<Double, String>>> Occlusions(SceneFlags sceneFlags, TraversalFlags traversalFlags, int numPhi, int w, int h) { Func<Double, String> timer = (t) => String.Format("{0:N3} Mrays/s", 1e-6 * w * h / t); using (var scene = new Scene<Sphere>(sceneFlags, traversalFlags)) { scene.Add(new Sphere(sceneFlags, traversalFlags, numPhi)); scene.Commit(); if (traversalFlags.HasFlag(TraversalFlags.Single)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion1", () => CoherentOcclusion1(scene, w, h), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet4)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion4", () => CoherentOcclusion4(scene, w, h), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet8)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion8", () => CoherentOcclusion8(scene, w, h), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet16)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion16", () => CoherentOcclusion16(scene, w, h), timer); var random = new Random(); var rays = new Ray[w * h]; for (var t = 0; t < w * h; ++t) rays[t] = new Ray(Vector.Zero, new Vector(2 * (float)random.NextDouble() - 1, 2 * (float)random.NextDouble() - 1, 2 * (float)random.NextDouble() - 1)); if (traversalFlags.HasFlag(TraversalFlags.Single)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion1", () => IncoherentOcclusion1(scene, w * h, rays), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet4)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion4", () => IncoherentOcclusion4(scene, w * h, rays), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet8)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion8", () => IncoherentOcclusion8(scene, w * h, rays), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet16)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion16", () => IncoherentOcclusion16(scene, w * h, rays), timer); } }
private static void IncoherentOcclusion16(Scene<Sphere> scene, int nray, Ray[] rays) { for (var t = 0; t < nray / 16; ++t) { var rays2 = new[] { rays[t * 16 + 0], rays[t * 16 + 1], rays[t * 16 + 2], rays[t * 16 + 3], rays[t * 16 + 4], rays[t * 16 + 5], rays[t * 16 + 6], rays[t * 16 + 7], rays[t * 16 + 8], rays[t * 16 + 9], rays[t * 16 + 10], rays[t * 16 + 11], rays[t * 16 + 12], rays[t * 16 + 13], rays[t * 16 + 14], rays[t * 16 + 15], }; scene.Occludes16(rays2); } }
private static void IncoherentOcclusion8(Scene<Sphere> scene, int nray, Ray[] rays) { for (var t = 0; t < nray / 8; ++t) { var rays2 = new[] { rays[t * 8 + 0], rays[t * 8 + 1], rays[t * 8 + 2], rays[t * 8 + 3], rays[t * 8 + 4], rays[t * 8 + 5], rays[t * 8 + 6], rays[t * 8 + 7], }; scene.Occludes8(rays2); } }
private static void IncoherentOcclusion4(Scene<Sphere> scene, int nray, Ray[] rays) { for (var t = 0; t < nray / 4; ++t) { var rays2 = new[] { rays[t * 4 + 0], rays[t * 4 + 1], rays[t * 4 + 2], rays[t * 4 + 3], }; scene.Occludes4(rays2); } }
private static void IncoherentOcclusion1(Scene<Sphere> scene, int nray, Ray[] rays) { for (var t = 0; t < nray; ++t) scene.Occludes<Ray>(rays[t]); }
private static void IncoherentIntersect4(Scene<Sphere> scene, int nray, Ray[] rays) { for (var t = 0; t < nray / 4; ++t) { var rays2 = new[] { rays[t * 4 + 0], rays[t * 4 + 1], rays[t * 4 + 2], rays[t * 4 + 3], }; scene.Intersects4(rays2); } }
private static void IncoherentIntersect1(Scene<Sphere> scene, int nray, Ray[] rays) { for (var t = 0; t < nray; ++t) scene.Intersects<Ray>(rays[t]); }