From 2e3cd390be875105a60665baaff7077c52de28eb Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Sun, 2 Oct 2016 09:01:46 +0300 Subject: [PATCH] Allow block scheduler selection for interactive renderer --- cmd/render.go | 15 ++++++++++++++- main.go | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/render.go b/cmd/render.go index 0db0fa0..8eb03bd 100644 --- a/cmd/render.go +++ b/cmd/render.go @@ -122,6 +122,19 @@ func RenderInteractive(ctx *cli.Context) error { opts.MinBouncesForRR = opts.NumBounces + 1 } + // Setup block scheduler + schedulerType := ctx.String("scheduler") + var scheduler tracer.BlockScheduler + switch schedulerType { + case "naive": + scheduler = tracer.NaiveScheduler() + case "perfect": + scheduler = tracer.PerfectScheduler() + default: + return fmt.Errorf("invalid scheduler algorithm %q; supported algorithms: naive, perfect", schedulerType) + } + logger.Noticef("using %q block scheduler", schedulerType) + // Load scene if ctx.NArg() != 1 { return errors.New("missing scene file argument") @@ -141,7 +154,7 @@ func RenderInteractive(ctx *cli.Context) error { pipeline := opencl.DefaultPipeline(opencl.NoDebug) // Create renderer - r, err := renderer.NewInteractive(sc, tracer.PerfectScheduler(), pipeline, opts) + r, err := renderer.NewInteractive(sc, scheduler, pipeline, opts) if err != nil { return err } diff --git a/main.go b/main.go index 9638624..25e6ff7 100644 --- a/main.go +++ b/main.go @@ -166,6 +166,11 @@ func main() { Value: "", Usage: "force a particular device name as the primary device", }, + cli.StringFlag{ + Name: "scheduler", + Value: "perfect", + Usage: "select a particular block scheduling algorithm; supported algorithms: naive, perfect", + }, }, Action: cmd.RenderInteractive, },