Skip to content

File Tracer.h

File List > Intern > rayx-core > src > Tracer > Tracer.h

Go to the documentation of this file

#pragma once

#include <memory>
#include <string>
#include <vector>

#include "Core.h"
#include "DeviceConfig.h"
#include "DeviceTracer.h"
#include "Rays.h"

// Abstract Tracer base class.
namespace rayx {

// this value is picked in a 'good' way if it can divide number of rays without rest. for a number of rays picked by humans, this
// value is probably good. though, if it could be power of two, the shader would benefit
constexpr int DEFAULT_BATCH_SIZE = 100000;

constexpr int defaultMaxEvents(const int numObjects) { return numObjects * 2 + 8; }

class RAYX_API Tracer {
  public:
    Tracer(const DeviceConfig& deviceConfig = DeviceConfig().enableBestDevice());

    // This will call the trace implementation of a subclass
    // See `BundleHistory` for information about the return value.
    // `max_batch_size` corresponds to the maximal number of rays that will be put into `traceRaw` in one batch.

    Rays trace(const Group& group, const Sequential sequential = Sequential::No, const ObjectMask& objectRecordMask = ObjectMask::all(),
               const RayAttrMask attrRecordMask = RayAttrMask::All, std::optional<int> maxEvents = std::nullopt,
               std::optional<int> maxBatchSize = std::nullopt);

  private:
    std::shared_ptr<DeviceTracer> m_deviceTracer;
};

}  // namespace rayx