RenderMan API  23.0
RixShadingPlugin Class Referenceabstract

#include <RixShading.h>

Inheritance diagram for RixShadingPlugin:
RixBxdfFactory RixDisplacementFactory RixDisplayFilter RixIntegratorFactory RixLightFactory RixLightFilter RixPattern RixProjectionFactory RixSampleFilter

Classes

struct  InstanceData
 

Public Types

enum  SynchronizeHints { k_None = 0x00000000, k_All = 0xFFFFFFFF }
 

Public Member Functions

virtual int GetVersion () const
 
virtual int GetInterface () const
 
virtual int Init (RixContext &ctx, RtUString const pluginPath)=0
 
virtual void Finalize (RixContext &ctx)=0
 
virtual RixSCParamInfo const * GetParamTable ()=0
 
virtual void Synchronize (RixContext &ctx, RixSCSyncMsg syncMsg, RixParameterList const *syncParams)=0
 
virtual void CreateInstanceData (RixContext &rixCtx, RtUString const handle, RixParameterList const *parameterList, InstanceData *instanceData)
 
virtual void SynchronizeInstanceData (RixContext &rixCtx, RtUString const handle, RixParameterList const *instanceParams, uint32_t const editHints, InstanceData *instanceData)
 

Protected Member Functions

 RixShadingPlugin (int version)
 
virtual ~RixShadingPlugin ()
 

Protected Attributes

int m_version
 

Detailed Description

RixShadingPlugin is the base class for RixBxdfFactory, RixDisplacementFactory, RixDisplayFilter, RixIntegrator, RixLightFilter, RixLightFactory, RixPattern, RixProjection, and RixSampleFilter. These are plugins that implement services for the renderer.

Here, it is important to distinguish between two types of plugins: ones that need to create short-lived lightweight instances during the course of a render, and ones that do not. RixBxdf, RixDisplacement, and RixLight represent lightweight instances that may be created many times during the course of a single render, and therefore are not directly subclasses of RixShadingPlugin. Instead, instancees of those classes are returned by the appropriate Factory (e.g. RixBxdfFactory), with the Factory itself being the subclass of RixShadingPlugin.

RixIntegrator, RixDisplayFilter, RixLightFilter, RixPattern, RixProjection, and RixSampleFilter do not create many lightweight instances. As such, these classes are directly subclasses of RixShadingPlugin.

All RixShadingPlugins share common methods related to initialization, synchronization with the renderer, and management of lightweight instances.

Definition at line 168 of file RixShading.h.

Member Enumeration Documentation

◆ SynchronizeHints

The renderer offers the ability to shading plugins to track custom data with every instance of the plugin reference. This is useful primarily to plugin types like Bxdf and Pattern that expect to see multiple instances. Instance data is usually a function of the instance parameters, and plugins that operate in performance sensitive conditions may "bake" an understanding of their behavior/requirements into custom representation for tracking with the instance. The instance data can be recovered from the operating context associated with the plugin type, or via inspection of the parameter list (using RixParameterList::EvalParam). Note that in the latter case, the ability to inspect the parameter list is restricted: "network" connections (i.e. upstream pattern graph inputs) cannot be evaluated at the time CreateInstanceData is invoked.

Note that CreateInstanceData() is only called once, when the plugin instance is created. As a consequence, edits happening during an interactive session can't be captured by this method. The InstanceData::synchronizeHints member allows a plugin to subscribe to a synchronization call, following some edits. In order for SynchronizeInstanceData() to be called, this member needs to be set to a non-zero value by CreateInstanceData().

Note that some quantities are not accessible anymore through the RixContext object in CreateInstanceData(), for reasons related to interactive rendering. In particular:

  • LPE-related quantities
  • Display-related quantities (e.g. resolution)
  • editable options should only be queried in SynchronizeInstanceData().

Additionally, a plugin can create its parameter table dynamically based on the parameters provided to each instance of the plugin. This dynamically created table should be saved in the paramtable member of InstanceData, and should be freed by the InstanceData freefunc. Generally, concrete interfaces should be preferred over dynamic interfaces due to their extra memory expense. If the paramtable member remains null, all instances will share the parameter table returned by GetParamTable. In order to prevent the renderer from filtering out dynamic parameters as bad inputs, a plugin that is using a dynamically created table should have a k_RixSCAnyType entry in its plugin parameter table.

A trivial implementation of the following methods doesn't modify the InstanceData objects provided. Plugins should consider the number of potential instances that may be produced in a worst-case render to assess the memory impact of the instance data. The renderer will free data via freefunc when it understands that the plugin instance will no longer be needed. The handle parameter the value associated with the Ri instance but may not be guaranteed to be globally unique. The instanceid parameter is optionally delivered via the parameterlist (see RI_INSTANCEID docs) and is expected (though not guaranteed) to be unique. This call might be called in multiple threads and should be re-entrant and thread-safe.

Enumerator
k_None 
k_All 

Definition at line 274 of file RixShading.h.

Constructor & Destructor Documentation

◆ RixShadingPlugin()

RixShadingPlugin::RixShadingPlugin ( int  version)
inlineprotected

Definition at line 339 of file RixShading.h.

◆ ~RixShadingPlugin()

virtual RixShadingPlugin::~RixShadingPlugin ( )
inlineprotectedvirtual

Definition at line 341 of file RixShading.h.

Member Function Documentation

◆ CreateInstanceData()

virtual void RixShadingPlugin::CreateInstanceData ( RixContext rixCtx,
RtUString const  handle,
RixParameterList const *  parameterList,
InstanceData instanceData 
)
inlinevirtual

CreateInstanceData() is called once per plugin-instance. It may be called before other renderer options and/or plugins have been set-up. As a consequence, some quantities may not be accessible in CreateInstanceData(). For example:

  • LPE-related quantities
  • Display-related quantities (e.g. resolution)
  • editable options SynchronizeInstanceData() should be used to retrieve the up-to-date related quantities.

Reimplemented in RixIntegratorFactory, and RixProjectionFactory.

Definition at line 303 of file RixShading.h.

◆ Finalize()

virtual void RixShadingPlugin::Finalize ( RixContext ctx)
pure virtual

Finalize() is the companion to Init(), called at the end of rendering with the expectation that any data allocated within the Init() implementation will be released.

◆ GetInterface()

virtual int RixShadingPlugin::GetInterface ( ) const
inlinevirtual

◆ GetParamTable()

virtual RixSCParamInfo const* RixShadingPlugin::GetParamTable ( )
pure virtual

All shading plugins are expected to return a description of their input and output parameters via the GetParamTable() method. This returns a pointer to an array of RixSCParamInfo, containing one entry for each input and output parameter, as well as an extra empty entry to mark the end of the table. This parameter table is used by the renderer to ensure proper type checking and validate the connections of upstream and downstream nodes. As such, each entry in the table should set a name, a type (RixSCType enumeration), detail (varying vs uniform, RixSCDetail enumeration), and access (input vs output, RixSCAccess enumeration). These declarations also need to be kept in sync with the associated .args file.

◆ GetVersion()

virtual int RixShadingPlugin::GetVersion ( ) const
inlinevirtual

Definition at line 171 of file RixShading.h.

◆ Init()

virtual int RixShadingPlugin::Init ( RixContext ctx,
RtUString const  pluginPath 
)
pure virtual

In order to initialize the plugin, the renderer will call Init() once. Even if the plugin is evoked multiple times during the render with different arguments, Init() will still be called only once during the lifetime of the render. The RixContext parameter can be used by the plugin to request any RixInterfaces services provided by the renderer. Any expensive memory allocations or operations that can be reused during the lifetime of the plugin can be performed in this routine. Upon successful initialization, this routine should return a zero status.

◆ Synchronize()

virtual void RixShadingPlugin::Synchronize ( RixContext ctx,
RixSCSyncMsg  syncMsg,
RixParameterList const *  syncParams 
)
pure virtual

This method is used to deliver occasional status information from the renderer. Parameterlist contents depend upon the SyncMsg. A trivial implementation simply does nothing, ignoring all events.

◆ SynchronizeInstanceData()

virtual void RixShadingPlugin::SynchronizeInstanceData ( RixContext rixCtx,
RtUString const  handle,
RixParameterList const *  instanceParams,
uint32_t const  editHints,
InstanceData instanceData 
)
inlinevirtual

SynchronizeInstanceData() will only be called if InstanceData::synchronizeHints was set to a non-zero value during the initial call to CreateInstanceData(). This method is allowed to modify:

  • data (including freeing the previous pointer and allocating new memory)
  • datalen
  • freefunc
  • synchronizeHints

However, it is not currently possible to modify:

  • paramtable

Note that special care should be taken when modifying synchronizeHints, so that the plugin instance doesn't lock itself out of synchronization notifications.

Reimplemented in RixIntegratorFactory, and RixProjectionFactory.

Definition at line 326 of file RixShading.h.

Member Data Documentation

◆ m_version

int RixShadingPlugin::m_version
protected

Definition at line 343 of file RixShading.h.


The documentation for this class was generated from the following file: