1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <vector>
#include "common/DeviceRT.h"
#include "common/OSPCommon.h"
#include "rkcommon/containers/AlignedVector.h"
namespace ospray {
/* manages error per tile and adaptive regions, for variance estimation
Implementation based on Dammertz et al., "A Hierarchical Automatic Stopping
Condition for Monte Carlo Global Illumination", WSCG 2010 */
class OSPRAY_SDK_INTERFACE TaskError
{
public:
TaskError(devicert::Device &device, const vec2i &numTasks);
// The default constructor will make an empty task error region
TaskError() = default;
void clear();
float operator[](const int id) const;
void update(const vec2i &task, const float error);
float refine(const float errorThreshold);
// Return the error buffer, or null if there are no tiles that error is
// tracked for
float *errorBuffer();
protected:
vec2i numTasks = vec2i(0);
// holds error per task
BufferSharedUq<float> taskErrorBuffer;
// image regions (in #tasks) that do not yet estimate the error on
// per-task basis
std::vector<box2i> errorRegion;
};
} // namespace ospray
|