Skip to content

Commit

Permalink
Allow block scheduler selection for interactive renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Achilleas Anagnostopoulos committed Oct 2, 2016
1 parent 098c2d8 commit 2e3cd39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 2e3cd39

Please sign in to comment.