B.1 System Startup, Cleanup, and Options

Two structures that are defined in the options.h header represent various user-specified options that are generally not part of the scene description file but are instead specified using command-line arguments to pbrt. pbrt’s main() function allocates the structure and then overrides its default values as appropriate.

BasicPBRTOptions stores the options that are used in both the CPU and GPU rendering pipelines. How most of them are used should be self-evident, though seed deserves note: any time an RNG is initialized in pbrt, the seed value in the options should be incorporated in the seed passed to its constructor. In this way, the renderer will generate independent images if the user specifies different –seed values using command-line arguments.

<<BasicPBRTOptions Definition>>= 
struct BasicPBRTOptions { int seed = 0; bool quiet = false; bool disablePixelJitter = false, disableWavelengthJitter = false; bool disableTextureFiltering = false; bool forceDiffuse = false; bool useGPU = false; bool wavefront = false; RenderingCoordinateSystem renderingSpace = RenderingCoordinateSystem::CameraWorld; };

<<RenderingCoordinateSystem Definition>>= 
enum class RenderingCoordinateSystem { Camera, CameraWorld, World };

The PBRTOptions structure, not included here, inherits from BasicPBRTOptions and adds a number of additional options that are mostly used when processing the scene description and not during rendering. A number of these options are std::strings that are not accessible in GPU code. Splitting the options in this way allows GPU code to access a BasicPBRTOptions instance to get the particular option values that are relevant to it.

The options are passed to InitPBRT(), which should be called before any of pbrt’s other classes or interfaces are used. It handles system-wide initialization and configuration. When rendering completes, CleanupPBRT() should be called so that the system can gracefully shut down. Both of these functions are defined in the file pbrt.cpp.

<<Initialization and Cleanup Function Declarations>>= 
void InitPBRT(const PBRTOptions &opt); void CleanupPBRT();

In code that only runs on the CPU, the options can be accessed via a global variable.

<<Options Global Variable Declaration>>= 
extern PBRTOptions *Options;

For code that runs on both the CPU and GPU, options must be accessed through the GetOptions() function, which returns a copy of the options that is either stored in CPU or GPU memory, depending on which type of processor the code is executing.

<<Options Inline Functions>>= 
const BasicPBRTOptions &GetOptions();