Profiling Mock Renderer

class RendererInfoPlugin : public FnKat::RendererInfo::RendererInfoBase
#include <ProfilingMockRendererInfoPlugin.h>

This plug-in registers and defines the Profiling Mock Renderer render plug-in.

The display name of the renderer is profilingMockRenderer. It supports Preview Render and Disk Render.

Public Functions

RendererInfoPlugin()

Constructor.

~RendererInfoPlugin() override

Destructor.

void configureBatchRenderMethod(FnKat::RendererInfo::DiskRenderMethod &batchRenderMethod) const override

Reimplemented from RendererInfoBase.

The Batch Render method is always available. Although the Profiling Mock Renderer plug-in does not require any specific configuration, this function allows customization if needed.

void fillRenderMethods(std::vector<FnKat::RendererInfo::RenderMethod*> &renderMethods) const override

Reimplemented from RendererInfoBase.

Other render methods can be added here. Disk Render and Preview Render are the two methods (apart from the Batch Render method) that will be added for this plug-in.

Parameters:

renderMethods – Output list where the new render methods will be added.

void fillRendererObjectTypes(std::vector<std::string> &renderObjectTypes, const std::string &type) const override

Reimplemented from RendererInfoBase.

The Profiling Mock Renderer does not add extra renderer objects.

void fillRendererObjectNames(std::vector<std::string> &rendererObjectNames, const std::string &type, const std::vector<std::string> &typeTags) const override

Reimplemented from RendererInfoBase.

The Profiling Mock Renderer does not add extra renderer objects.

std::string getRegisteredRendererName() const override

Reimplemented from RendererInfoBase.

The Profiling Mock Renderer is registered as profilingMockRenderer.

std::string getRegisteredRendererVersion() const override

Reimplemented from RendererInfoBase.

This returns the version of the Profiling Mock Renderer plug-in.

bool buildRendererObjectInfo(FnAttribute::GroupBuilder &rendererObjectInfo, const std::string &name, const std::string &type, const FnAttribute::GroupAttribute inputAttr) const override

Reimplemented from RendererInfoBase.

The Profiling Mock Renderer does not add extra renderer objects.

void fillLiveRenderTerminalOps(OpDefinitionQueue &terminalOps, const FnAttribute::GroupAttribute &stateArgs) const override

Reimplemented from RendererInfoBase.

Declares the attributes names that the Profiling Mock Renderer is interested in during a Live Render.

Public Static Functions

static FnKat::RendererInfo::RendererInfoBase *create()

Constructs an intance of the class.

This is used by the DEFINE_RENDERERINFO_PLUGIN macro.

Returns:

A pointer to the new instance.

static inline void flush()
class RenderPlugin : public FnKat::Render::RenderBase
#include <ProfilingMockRenderPlugin.h>

The Profiling Mock Renderer is a mock renderer plug-in that provides scene traversal profiling information.

The Profiling Mock Renderer performs no rendering, but instead traverses the entire scene graph as quickly as possible using a given traversal strategy.

Preview Render and Disk Render (from a Render node) are the two render methods supported. When rendering a scene with either of these methods, the plug-in will time and log how long it took for a location to be expanded, as well as the rate of locations expanded per second. In UI mode, the log will be visible in the Render Log tab. This is the format in which the log messages are reported:

>> Depth-first search: 0.00s 0.00 ms/loc        1  /root
>> Depth-first search: 0.00s 0.48 ms/loc        2  /root/world
>> Depth-first search: 0.00s 0.45 ms/loc        3  /root/world/geo
>> Depth-first search: 0.01s 2.03 ms/loc        4  /root/world/geo/primitive
>> Depth-first search: 0.01s 1.70 ms/loc        5  /root/world/cam
>> Depth-first search: 0.01s 1.46 ms/loc        6  /root/world/cam/camera
>> Depth-first search: 0.01s 1.31 ms/loc        7  /root/world/lgt
>> Depth-first search: 0.01s 1.19 ms/loc        8  /root/world/lgt/light
   --------1---------  --2-- -----3-----       -4- -----------5-------------

 - 1 Traversal strategy log prefix
 - 2 Elapsed time since the beginning of the render
 - 3 Current traversal rate (time per location)
 - 4 Number of locations that have been expanded
 - 5 The current location path

Traversal strategies

Three traversal strategies are available:

  • Depth-first search (dfs)

  • Breadth-first search (bfs)

  • Parallel search (parallel)

Depth-first search

This approach starts at the root location and explores as far as possible along each branch before backtracking.

Depth-first traversal within a single thread makes best use of scene data caching within that thread’s allocated Geolib runtime, while minimising memory consumption (matching the current best practice for single-threaded rendering).

Breadth-first search

This approach starts at the root location and explores all of the neighbor locations at the present depth prior to moving on to the locations at the next depth level.

Breadth-first traversal within a single thread makes poor use of scene data caching. Evaluating data from distant subtrees evicts data from previously computed locations. By the time the program execution returns to a certain subtree, all its previous data may have already been evicted.

Parallel search

This approach uses multiple threads to traverse subtrees, with each thread using a depth-first search. Idle threads acquire work from busy threads by stealing their oldest, and therefore shallowest task. This constitutes breadth-first division of work across multiple threads. Since different threads spawn distinct Geolib runtimes for concurrent evaluation, this strategy aims to minimise redundancy in scene cooking.

See How Task Scheduling Works for detailed information.

Global parameters

The ProfilingMockRendererGlobalSettings node provides several configuration parameters:

  • profilingMockRendererGlobalStatements.options.traversalStrategy: Available traversal strategies are dfs, bfs and parallel. Default is dfs.

  • profilingMockRendererGlobalStatements.options.maxLogDepth: Log timing information for locations up to this depth. Default is 5.

  • profilingMockRendererGlobalStatements.options.maxThreads: Max threads to use for the traversal. Relevant for the parallel traversal strategy only. If set to 0, the number of threads will be automatically determined based on hardware configuration. Default is 0.

Note

Profiling Mock Renderer plug-in does not support live rendering.

Public Functions

RenderPlugin(FnKat::FnScenegraphIterator rootIterator, FnAttribute::GroupAttribute arguments)

Constructor.

Parameters:
  • rootIterator – The root FnScenegraphIterator used to traverse the Katana recipe.

  • arguments – Render arguments (e.g. render time).

~RenderPlugin() override

Destructor.

int start() override

Reimplemented from RenderBase.

This function is called at the start of the render process.

Reads the configurable renderer global setting from the /root location.

int stop() override

Reimplemented from RenderBase.

Called at the end of the render process. The Profiling Mock Renderer does not perform any action when this message is received.

void configureDiskRenderOutputProcess(FnKat::Render::DiskRenderOutputProcess &diskRenderOutputProcess, const std::string &outputName, const std::string &outputPath, const std::string &renderMethodName, const float &frameTime) const override

Reimplemented from RenderBase.

The Profiling Mock Renderer disables the monitor output, as no image is generated (Render::RenderAction::setLoadOutputInMonitor).

int queueDataUpdates(FnAttribute::GroupAttribute updateAttribute) override

Reimplemented from RenderBase.

Invoked when location updates are available. Updates are only queued for later processing.

bool hasPendingDataUpdates() const override

Reimplemented from RenderBase.

Returns whether previous updates are still queued.

int applyPendingDataUpdates() override

Reimplemented from RenderBase.

Invoked periodically (provided there are updates in the queue). Updates will be processed here, where applicable, or discarded if not relevant.

Public Static Functions

static FnKat::Render::RenderBase *create(FnKat::FnScenegraphIterator rootIterator, FnAttribute::GroupAttribute arguments)

Constructs an intance of the class.

This is used by the DEFINE_RENDER_PLUGIN macro.

Parameters:
  • rootIterator – The root FnScenegraphIterator used to traverse the Katana recipe.

  • arguments – Render arguments (e.g. render time).

Returns:

A pointer to the new instance.

static inline void flush()

Private Functions

void liveRenderingLogLoop()

Private Members

std::vector<FnAttribute::GroupAttribute> m_pendingUpdates
std::unique_ptr<std::thread> m_thread
bool m_stopped = {false}
std::condition_variable m_conditionVariable
tbb::spin_mutex m_mutex
size_t m_processedLiveUpdates = {0}
size_t m_processedLocationUpdates = {0}
std::chrono::milliseconds m_updateTimestamp = {0}