Skip to content

Commit

Permalink
Ensure that the trace accum. is cleared once when doing muti-spp
Browse files Browse the repository at this point in the history
rendering
  • Loading branch information
Achilleas Anagnostopoulos committed Oct 5, 2016
1 parent a9cfb94 commit c7c186f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion renderer/opengl.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (r *interactiveGLRenderer) Render() error {
// Render frame unless we have reached our target SPP
if r.options.SamplesPerPixel == 0 || (r.options.SamplesPerPixel != 0 && r.accumulatedSamples < r.defaultRenderer.options.SamplesPerPixel) {
err := r.renderFrame(r.accumulatedSamples)
r.accumulatedSamples++
if err != nil {
r.Unlock()
return err
Expand Down
5 changes: 0 additions & 5 deletions tracer/opencl/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ func MonteCarloIntegrator(debugFlags DebugFlag) PipelineStage {

var activeRayBuf uint32 = 0

_, err = tr.resources.ClearTraceAccumulator(blockReq)
if err != nil {
return time.Since(start), err
}

// Intersect primary rays outside of the loop
// Use packet query intersector for GPUs as opencl forces CPU
// to use a local workgroup size equal to 1
Expand Down
9 changes: 8 additions & 1 deletion tracer/opencl/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"sync"
"time"

"github.com/achilleasa/gopencl/v1.2/cl"
"github.com/achilleasa/polaris/asset/scene"
"github.com/achilleasa/polaris/log"
"github.com/achilleasa/polaris/tracer"
"github.com/achilleasa/polaris/tracer/opencl/device"
"github.com/achilleasa/polaris/types"
"github.com/achilleasa/gopencl/v1.2/cl"
)

type Tracer struct {
Expand Down Expand Up @@ -212,6 +212,11 @@ func (tr *Tracer) Trace(blockReq *tracer.BlockRequest) (time.Duration, error) {
}
}

_, err = tr.resources.ClearTraceAccumulator(blockReq)
if err != nil {
return time.Since(start), err
}

var sample uint32
for sample = 0; sample < blockReq.SamplesPerPixel; sample++ {
blockReq.Seed = rand.Uint32()
Expand All @@ -231,6 +236,8 @@ func (tr *Tracer) Trace(blockReq *tracer.BlockRequest) (time.Duration, error) {
return time.Since(start), err
}
}

blockReq.AccumulatedSamples++
}

tr.stats.BlockW = blockReq.BlockW
Expand Down

0 comments on commit c7c186f

Please sign in to comment.